Search in sources :

Example 1 with TileEntityRedNetCable

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRedNetCable(powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable) TileEntityRedNetLogic(powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetLogic)

Example 2 with TileEntityRedNetCable

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();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRedNetCable(powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable)

Example 3 with TileEntityRedNetCable

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);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) TileEntityRedNetCable(powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable)

Example 4 with TileEntityRedNetCable

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);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) TileEntityRedNetCable(powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable)

Example 5 with TileEntityRedNetCable

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PlayerInteractEvent(net.minecraftforge.event.entity.player.PlayerInteractEvent) TileEntityRedNetCable(powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileEntityRedNetCable (powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable)10 TileEntity (net.minecraft.tileentity.TileEntity)9 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)2 BlockPosition (powercrystals.core.position.BlockPosition)2 TileEntityRedNetLogic (powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetLogic)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 ForgeDirection (net.minecraftforge.common.ForgeDirection)1 PlayerInteractEvent (net.minecraftforge.event.entity.player.PlayerInteractEvent)1 TileEntityFactory (powercrystals.minefactoryreloaded.tile.base.TileEntityFactory)1 TileEntityConveyor (powercrystals.minefactoryreloaded.tile.conveyor.TileEntityConveyor)1 TileEntityAutoJukebox (powercrystals.minefactoryreloaded.tile.machine.TileEntityAutoJukebox)1 TileEntityRedNetHistorian (powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetHistorian)1