use of ValkyrienWarfareControl.GraphTheory.INodeProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsObject method loadClaimedChunks.
public void loadClaimedChunks() {
ArrayList<TileEntity> nodeTileEntitiesToUpdate = new ArrayList<TileEntity>();
claimedChunks = new Chunk[(ownedChunks.radius * 2) + 1][(ownedChunks.radius * 2) + 1];
claimedChunksEntries = new PlayerChunkMapEntry[(ownedChunks.radius * 2) + 1][(ownedChunks.radius * 2) + 1];
for (int x = ownedChunks.minX; x <= ownedChunks.maxX; x++) {
for (int z = ownedChunks.minZ; z <= ownedChunks.maxZ; z++) {
Chunk chunk = worldObj.getChunkFromChunkCoords(x, z);
if (chunk == null) {
System.out.println("Just a loaded a null chunk");
chunk = new Chunk(worldObj, x, z);
}
// Do this to get it re-integrated into the world
if (!worldObj.isRemote) {
injectChunkIntoWorld(chunk, x, z, false);
}
for (Entry<BlockPos, TileEntity> entry : chunk.chunkTileEntityMap.entrySet()) {
TileEntity tile = entry.getValue();
if (tile instanceof INodeProvider) {
nodeTileEntitiesToUpdate.add(tile);
}
}
claimedChunks[x - ownedChunks.minX][z - ownedChunks.minZ] = chunk;
}
}
VKChunkCache = new VWChunkCache(worldObj, claimedChunks);
refrenceBlockPos = getRegionCenter();
coordTransform = new CoordTransformObject(this);
if (!worldObj.isRemote) {
createPhysicsCalculations();
}
detectBlockPositions();
for (TileEntity tile : nodeTileEntitiesToUpdate) {
Node node = ((INodeProvider) tile).getNode();
if (node != null) {
node.updateBuildState();
} else {
System.err.println("How the fuck did we get a null node?");
}
}
coordTransform.updateAllTransforms();
}
use of ValkyrienWarfareControl.GraphTheory.INodeProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ItemRelayWire method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState clickedState = worldIn.getBlockState(pos);
Block block = clickedState.getBlock();
TileEntity currentTile = worldIn.getTileEntity(pos);
if (currentTile instanceof INodeProvider && !worldIn.isRemote) {
ICapabilityLastRelay inst = stack.getCapability(ValkyrienWarfareControlMod.lastRelayCapability, null);
if (inst != null) {
if (!inst.hasLastRelay()) {
inst.setLastRelay(pos);
//Draw a wire in the player's hand after this
} else {
BlockPos lastPos = inst.getLastRelay();
double distance = lastPos.distanceSq(pos);
TileEntity lastPosTile = worldIn.getTileEntity(lastPos);
if (!lastPos.equals(pos) && lastPosTile != null && currentTile != null) {
if (distance < range * range) {
Node lastPosNode = ((INodeProvider) lastPosTile).getNode();
Node currentPosNode = ((INodeProvider) currentTile).getNode();
//Connect the two bastards
// inst.setLastRelay(pos);
inst.setLastRelay(null);
if (lastPosNode != null && currentPosNode != null) {
currentPosNode.linkNode(lastPosNode);
}
// System.out.println("Success");
stack.damageItem(1, playerIn);
} else {
playerIn.addChatComponentMessage(new TextComponentString("Nodes are too far away, try better wire"));
inst.setLastRelay(null);
}
} else {
inst.setLastRelay(pos);
}
}
}
}
return EnumActionResult.FAIL;
}
Aggregations