This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private MarketItem buy(MarketItem item) { | |
if (!walletSystem.isValidTransaction(-1 * item.cost)) { | |
logger.warn("Insufficient funds"); | |
return item; | |
} else { | |
if (!createItemOrBlock(item.name)) { | |
logger.warn("Failed to create entity"); | |
return item; | |
} | |
Iterable<EntityRef> storageBuildings = entityManager.getEntitiesWith(MultiInvStorageComponent.class, SettlementRefComponent.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isValidSpawnPosition(Vector3i pos) { | |
if (!settlementEntityManager.checkOutsideAllSettlements(new Vector2i(pos.x, pos.z))) { | |
return false; | |
} | |
Vector3i below = new Vector3i(pos.x, pos.y - 1, pos.z); | |
Block blockBelow = worldProvider.getBlock(below); | |
if (!blockBelow.equals(sand)) { | |
return false; | |
} | |
Block blockAtPosition = worldProvider.getBlock(pos); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Block getClosestMatch(byte connections, Side topSide) { | |
EnumSet<Side> sides = SideBitFlag.getSides(connections); | |
// Indices represent priorities, 0 being the highest and 6 being the lowest | |
String[] keys = new String[baseSideBitMap.size()]; | |
keys[0] = FOUR_CONNECTIONS_CROSS; | |
keys[1] = THREE_CONNECTIONS_T; | |
keys[2] = ONE_CONNECTIONS_SLOPE; | |
keys[3] = TWO_CONNECTIONS_CORNER; | |
keys[4] = TWO_CONNECTIONS_LINE; | |
keys[5] = ONE_CONNECTION; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Vector2i clamp(Vector2f point, Rect2f box) { | |
float x; | |
float y; | |
Rect2f iconRegion = Rect2f.createFromMinAndSize(point, iconSize); | |
if (box.contains(iconRegion)) { | |
return new Vector2i(point.x, point.y); | |
} else { | |
if (iconRegion.maxX() >= box.maxX()) { | |
x = (int) box.maxX() - iconSize.x; | |
} else if (iconRegion.minX() <= box.minX()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void mount(EntityRef cart, EntityRef rider){ | |
CartRidableComponent cartRidableComponent = cart.getComponent(CartRidableComponent.class); | |
RigidBodyComponent railVehicleRigidBody = cart.getComponent(RigidBodyComponent.class); | |
if(rider.getComponent(RidingCartComponent.class) != null){ | |
return; | |
} | |
if(cartRidableComponent.rider != null){ | |
return; | |
} | |
rider.send(new SetMovementModeEvent(MovementMode.NONE)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* credit to http://99webtools.com/blog/php-simple-captcha-script/ | |
*/ | |
session_start(); | |
$code=sprintf('%04d',rand(0,9999)); | |
$_SESSION["code"]=$code; | |
$im = imagecreatetruecolor(50, 24); | |
$bg = imagecolorallocate($im, 22, 192, 212); // background color cyan | |
$fg = imagecolorallocate($im, 55, 55, 55); // text color gray |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Node { | |
public: | |
int data; | |
Node* parent = NULL; | |
Node* left = NULL; | |
Node* right = NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
class Node { | |
public: | |
int key; | |
Node* next; | |
Node(int k, Node* n) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Node { | |
public: | |
int key; | |
Node* next; | |
Node(int k, Node* n) { | |
key = k; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set exrc | |
set secure | |
set nocompatible | |
filetype off | |
"set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path were Vundle should install plugins |