use of powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable in project MineFactoryReloaded by powercrystals.
the class ItemRedNetMeter method onItemUse.
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
if (world.isRemote) {
return true;
}
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te instanceof TileEntityRedNetCable) {
int value;
boolean foundNonZero = false;
for (int i = 0; i < 16; i++) {
value = ((TileEntityRedNetCable) te).getNetwork().getPowerLevelOutput(i);
if (value != 0) {
player.sendChatToPlayer(_colorNames[i] + ": " + value);
foundNonZero = true;
}
}
if (!foundNonZero) {
player.sendChatToPlayer("All RedNet subnets are 0");
} else {
player.sendChatToPlayer("All other RedNet subnets are 0");
}
return true;
} else if (te instanceof TileEntityRedNetLogic) {
int value;
boolean foundNonZero = false;
for (int i = 0; i < ((TileEntityRedNetLogic) te).getBufferLength(13); i++) {
value = ((TileEntityRedNetLogic) te).getVariableValue(i);
if (value != 0) {
player.sendChatToPlayer("Variable " + i + ": " + value);
foundNonZero = true;
}
}
if (!foundNonZero) {
player.sendChatToPlayer("All variables are 0");
} else {
player.sendChatToPlayer("All other variables are 0");
}
return true;
} else if (world.getBlockId(x, y, z) == Block.redstoneWire.blockID) {
player.sendChatToPlayer("Dust: " + world.getBlockMetadata(x, y, z));
}
return false;
}
use of powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable in project MineFactoryReloaded by powercrystals.
the class BlockRedNetCable method onNeighborBlockChange.
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) {
super.onNeighborBlockChange(world, x, y, z, blockId);
if (blockId == blockID || world.isRemote) {
return;
}
RedstoneNetwork.log("Cable block at %d, %d, %d got update from ID %d", x, y, z, blockId);
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te instanceof TileEntityRedNetCable) {
((TileEntityRedNetCable) te).onNeighboorChanged();
}
}
use of powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable in project MineFactoryReloaded by powercrystals.
the class BlockRedNetCable method addCollisionBoxesToList.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB collisionTest, List collisionBoxList, Entity entity) {
TileEntity cable = world.getBlockTileEntity(x, y, z);
if (cable instanceof TileEntityRedNetCable) {
for (AxisAlignedBB aabb : getParts((TileEntityRedNetCable) cable)) {
if (aabb == null) {
continue;
}
aabb = AxisAlignedBB.getBoundingBox(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ);
aabb.minX += x;
aabb.maxX += x;
aabb.minY += y;
aabb.maxY += y;
aabb.minZ += z;
aabb.maxZ += z;
if (collisionTest.intersectsWith(aabb)) {
collisionBoxList.add(aabb);
}
}
} else {
super.addCollisionBoxesToList(world, x, y, z, collisionTest, collisionBoxList, entity);
}
}
use of powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable in project MineFactoryReloaded by powercrystals.
the class BlockRedNetCable method setBlockBoundsBasedOnState.
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float xMin = 1;
float yMin = 1;
float zMin = 1;
float xMax = 0;
float yMax = 0;
float zMax = 0;
TileEntity cable = world.getBlockTileEntity(x, y, z);
if (cable instanceof TileEntityRedNetCable) {
for (AxisAlignedBB aabb : getParts((TileEntityRedNetCable) cable)) {
if (aabb == null) {
continue;
}
xMin = Math.min(xMin, (float) aabb.minX);
yMin = Math.min(yMin, (float) aabb.minY);
zMin = Math.min(zMin, (float) aabb.minZ);
xMax = Math.max(xMax, (float) aabb.maxX);
yMax = Math.max(yMax, (float) aabb.maxY);
zMax = Math.max(zMax, (float) aabb.maxZ);
}
setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
} else {
super.setBlockBoundsBasedOnState(world, x, y, z);
}
}
use of powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable in project MineFactoryReloaded by powercrystals.
the class BlockRedNetCable method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) {
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, x, y, z, side);
if (MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.useBlock == Result.DENY) {
return false;
}
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te instanceof TileEntityRedNetCable) {
TileEntityRedNetCable cable = (TileEntityRedNetCable) te;
int subHit = getPartClicked(player, 3.0F, cable);
if (subHit < 0) {
return false;
}
side = _partSideMappings[subHit];
ItemStack s = player.inventory.getCurrentItem();
if (side >= 0) {
if (MFRUtil.isHoldingHammer(player)) {
if (!world.isRemote) {
int nextColor;
if (!player.isSneaking()) {
nextColor = cable.getSideColor(ForgeDirection.getOrientation(side)) + 1;
if (nextColor > 15)
nextColor = 0;
} else {
nextColor = cable.getSideColor(ForgeDirection.getOrientation(side)) - 1;
if (nextColor < 0)
nextColor = 15;
}
cable.setSideColor(ForgeDirection.getOrientation(side), nextColor);
world.markBlockForUpdate(x, y, z);
return true;
}
} else if (s != null && s.itemID == Item.dyePowder.itemID) {
if (!world.isRemote) {
cable.setSideColor(ForgeDirection.getOrientation(side), 15 - s.getItemDamage());
world.markBlockForUpdate(x, y, z);
return true;
}
}
} else if (MFRUtil.isHoldingHammer(player)) {
byte mode = cable.getMode();
mode++;
if (mode > 2) {
mode = 0;
}
cable.setMode(mode);
if (!world.isRemote) {
PacketDispatcher.sendPacketToAllAround(x, y, z, 50, world.provider.dimensionId, cable.getDescriptionPacket());
if (mode == 0) {
player.sendChatToPlayer("Set cable to standard connection mode");
} else if (mode == 1) {
player.sendChatToPlayer("Set cable to forced-connection mode");
} else if (mode == 2) {
player.sendChatToPlayer("Set cable to cable-only connection mode");
}
}
}
}
return false;
}
Aggregations