/** * Called by ItemBlocks after a block is set in the world, to allow post-place logic */ public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCommandBlock) { CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock)tileentity).getCommandBlockLogic(); if (stack.hasDisplayName()) { commandblocklogic.setName(stack.getDisplayName()); } if (!worldIn.isRemote) { commandblocklogic.setTrackOutput(worldIn.getGameRules().getBoolean("sendCommandFeedback")); } } }
/** * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks, * beacons, skulls, flowerpot */ public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); if (i == 1 && tileentity instanceof TileEntityMobSpawner || i == 2 && tileentity instanceof TileEntityCommandBlock || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner) { tileentity.readFromNBT(packetIn.getNbtCompound()); } } }
/** * Updates the NBTTagCompound metadata of instances of the following * entitytypes: Mob spawners, command blocks, beacons, skulls, flowerpot */ public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); if (i == 1 && tileentity instanceof TileEntityMobSpawner || i == 2 && tileentity instanceof TileEntityCommandBlock || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner) { tileentity.readFromNBT(packetIn.getNbtCompound()); } } }
/** * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks, * beacons, skulls, flowerpot */ public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (this.gameController.world.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock; if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign || i == 10 && tileentity instanceof TileEntityShulkerBox) { tileentity.readFromNBT(packetIn.getNbtCompound()); } if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock)this.gameController.currentScreen).updateGui(); } } }
private void nextMode() { switch (this.commandBlockMode) { case SEQUENCE: this.commandBlockMode = TileEntityCommandBlock.Mode.AUTO; break; case AUTO: this.commandBlockMode = TileEntityCommandBlock.Mode.REDSTONE; break; case REDSTONE: this.commandBlockMode = TileEntityCommandBlock.Mode.SEQUENCE; } }
@Override public void onReceiveClient(Minecraft client, WorldClient world, EntityPlayerSP player, MessageContext context) { BlockSystem blockSystem = BlockSystems.PROXY.getBlockSystemHandler(world).getBlockSystem(this.blockSystem); if (blockSystem != null) { if (blockSystem.isBlockLoaded(this.pos)) { TileEntity blockEntity = blockSystem.getTileEntity(this.pos); boolean commandBlock = this.type == 2 && blockEntity instanceof TileEntityCommandBlock; if (this.type == 1 && blockEntity instanceof TileEntityMobSpawner || commandBlock || this.type == 3 && blockEntity instanceof TileEntityBeacon || this.type == 4 && blockEntity instanceof TileEntitySkull || this.type == 5 && blockEntity instanceof TileEntityFlowerPot || this.type == 6 && blockEntity instanceof TileEntityBanner || this.type == 7 && blockEntity instanceof TileEntityStructure || this.type == 8 && blockEntity instanceof TileEntityEndGateway || this.type == 9 && blockEntity instanceof TileEntitySign) { blockEntity.readFromNBT(this.data); } else { blockEntity.onDataPacket(client.getConnection().getNetworkManager(), new SPacketUpdateTileEntity(this.pos, this.type, this.data)); } if (commandBlock && client.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock) client.currentScreen).updateGui(); } } } }
private void setup(ICommandSender sender) { this.sender = sender; if (sender instanceof EntityPlayerMP) { player = (EntityPlayerMP) sender; } if (sender instanceof TileEntity) { user = new Coord((TileEntity) sender); } selected = currentSelection.get(); if (sender.canCommandSenderUseCommand(4, "stop")) { op = true; } if (sender instanceof TileEntityCommandBlock) { op = true; } if (op) { creative = true; } }
ColossalBuilder doGen(Coord at, int randSeed) { Coord signAt = at.copy(); ColossalBuilder builder = new ColossalBuilder(randSeed, at); builder.construct(); if (signAt.getTE(TileEntityCommandBlock.class) != null) { signAt.set(BlockStandingSign.ROTATION, 12, true); TileEntitySign sign = signAt.getTE(TileEntitySign.class); if (sign != null) { sign.signText[0] = new ChatComponentText("Colossus Seed"); sign.signText[1] = new ChatComponentText("" + randSeed); signAt.markBlockForUpdate(); } } return builder; }
/** * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks, * beacons, skulls, flowerpot */ public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock; if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign) { tileentity.readFromNBT(packetIn.getNbtCompound()); } else { tileentity.onDataPacket(netManager, packetIn); } if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock)this.gameController.currentScreen).updateGui(); } } }
public void func_72468_a(Packet132TileEntityData p_72468_1_) { if(this.field_72563_h.field_71441_e.func_72899_e(p_72468_1_.field_73334_a, p_72468_1_.field_73332_b, p_72468_1_.field_73333_c)) { TileEntity var2 = this.field_72563_h.field_71441_e.func_72796_p(p_72468_1_.field_73334_a, p_72468_1_.field_73332_b, p_72468_1_.field_73333_c); if(var2 != null) { if(p_72468_1_.field_73330_d == 1 && var2 instanceof TileEntityMobSpawner) { var2.func_70307_a(p_72468_1_.field_73331_e); } else if(p_72468_1_.field_73330_d == 2 && var2 instanceof TileEntityCommandBlock) { var2.func_70307_a(p_72468_1_.field_73331_e); } else if(p_72468_1_.field_73330_d == 3 && var2 instanceof TileEntityBeacon) { var2.func_70307_a(p_72468_1_.field_73331_e); } else if(p_72468_1_.field_73330_d == 4 && var2 instanceof TileEntitySkull) { var2.func_70307_a(p_72468_1_.field_73331_e); } } } }
@Override public void processCommand(ICommandSender icommandsender, String[] astring) { if(icommandsender instanceof EntityPlayer) // If the sender is a player { ProcessPlayer((EntityPlayer) icommandsender, astring); // Cast the sender into an EntityPlayer then call the ProcessPlayer method } else if(icommandsender instanceof TileEntityCommandBlock) // If the sender is a commandblock { ProcessCommandBlock((TileEntityCommandBlock) icommandsender, astring); } else // If it's the Server console { ProcessServerConsole(icommandsender, astring); } }
public CraftCommandBlock(Block block) { super(block); CraftWorld world = (CraftWorld) block.getWorld(); commandBlock = (TileEntityCommandBlock) world.getTileEntityAt(getX(), getY(), getZ()); command = commandBlock.func_145993_a().field_145763_e; name = commandBlock.func_145993_a().getCommandSenderName(); }
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCommandBlock) { ((TileEntityCommandBlock)tileentity).getCommandBlockLogic().trigger(worldIn); worldIn.updateComparatorOutputLevel(pos, this); } }
@Override public void displayGuiCommandBlock(TileEntityCommandBlock commandBlock) { if (m_realPlayer == null) { super.displayGuiCommandBlock(commandBlock); } else { syncToRealPlayer(); m_realPlayer.displayGuiCommandBlock(commandBlock); syncPublicFieldsFromReal(); } }
@Override public void displayGuiCommandBlock(TileEntityCommandBlock commandBlock) { if (m_realPlayer == null) { super.displayGuiCommandBlock(commandBlock); } else { m_realPlayer.displayGuiCommandBlock(commandBlock); } }
public GetCommandBlock() { branches.add(new CommandBranch(ctx -> { if (mc.objectMouseOver.getBlockPos() != null) { TileEntity tileEntity = mc.theWorld.getTileEntity(mc.objectMouseOver.getBlockPos()); if (tileEntity != null && tileEntity instanceof TileEntityCommandBlock) { out(((TileEntityCommandBlock) tileEntity).getCommandBlockLogic().getCommand()); } } })); }
/** * Returns a new instance of a block's tile entity class. Called on placing the block. */ public TileEntity createNewTileEntity(World worldIn, int meta) { TileEntityCommandBlock tileentitycommandblock = new TileEntityCommandBlock(); tileentitycommandblock.setAuto(this == Blocks.CHAIN_COMMAND_BLOCK); return tileentitycommandblock; }
/** * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid * block, etc. */ public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCommandBlock) { TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity; boolean flag = worldIn.isBlockPowered(pos); boolean flag1 = tileentitycommandblock.isPowered(); boolean flag2 = tileentitycommandblock.isAuto(); if (flag && !flag1) { tileentitycommandblock.setPowered(true); if (tileentitycommandblock.getMode() != TileEntityCommandBlock.Mode.SEQUENCE && !flag2) { boolean flag3 = !tileentitycommandblock.isConditional() || this.isNextToSuccessfulCommandBlock(worldIn, pos, state); tileentitycommandblock.setConditionMet(flag3); worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); if (flag3) { this.propagateUpdate(worldIn, pos); } } } else if (!flag && flag1) { tileentitycommandblock.setPowered(false); } } } }
/** * Checks whether the command block at a given position is adjacent to another one that executed successfully. */ public boolean isNextToSuccessfulCommandBlock(World worldIn, BlockPos pos, IBlockState state) { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); TileEntity tileentity = worldIn.getTileEntity(pos.offset(enumfacing.getOpposite())); return tileentity instanceof TileEntityCommandBlock && ((TileEntityCommandBlock)tileentity).getCommandBlockLogic().getSuccessCount() > 0; }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCommandBlock && playerIn.canUseCommandBlock()) { playerIn.displayGuiCommandBlock((TileEntityCommandBlock)tileentity); return true; } else { return false; } }
/** * Called by ItemBlocks after a block is set in the world, to allow post-place logic */ public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCommandBlock) { TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity; CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic(); if (stack.hasDisplayName()) { commandblockbaselogic.setName(stack.getDisplayName()); } if (!worldIn.isRemote) { NBTTagCompound nbttagcompound = stack.getTagCompound(); if (nbttagcompound == null || !nbttagcompound.hasKey("BlockEntityTag", 10)) { commandblockbaselogic.setTrackOutput(worldIn.getGameRules().getBoolean("sendCommandFeedback")); tileentitycommandblock.setAuto(this == Blocks.CHAIN_COMMAND_BLOCK); } if (tileentitycommandblock.getMode() == TileEntityCommandBlock.Mode.SEQUENCE) { boolean flag = worldIn.isBlockPowered(pos); tileentitycommandblock.setPowered(flag); } } } }
public void propagateUpdate(World worldIn, BlockPos pos) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == Blocks.COMMAND_BLOCK || iblockstate.getBlock() == Blocks.REPEATING_COMMAND_BLOCK) { BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(pos); blockpos$mutableblockpos.move((EnumFacing)iblockstate.getValue(FACING)); for (TileEntity tileentity = worldIn.getTileEntity(blockpos$mutableblockpos); tileentity instanceof TileEntityCommandBlock; tileentity = worldIn.getTileEntity(blockpos$mutableblockpos)) { TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity; if (tileentitycommandblock.getMode() != TileEntityCommandBlock.Mode.SEQUENCE) { break; } IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos); Block block = iblockstate1.getBlock(); if (block != Blocks.CHAIN_COMMAND_BLOCK || worldIn.isUpdateScheduled(blockpos$mutableblockpos, block)) { break; } worldIn.scheduleUpdate(new BlockPos(blockpos$mutableblockpos), block, this.tickRate(worldIn)); blockpos$mutableblockpos.move((EnumFacing)iblockstate1.getValue(FACING)); } } }
/** * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid * block, etc. */ public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCommandBlock) { TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity; boolean flag = worldIn.isBlockPowered(pos); boolean flag1 = tileentitycommandblock.isPowered(); boolean flag2 = tileentitycommandblock.isAuto(); if (flag && !flag1) { tileentitycommandblock.setPowered(true); if (tileentitycommandblock.getMode() != TileEntityCommandBlock.Mode.SEQUENCE && !flag2) { boolean flag3 = !tileentitycommandblock.isConditional() || this.isNextToSuccessfulCommandBlock(worldIn, pos, state); tileentitycommandblock.setConditionMet(flag3); worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); if (flag3) { this.propagateUpdate(worldIn, pos); } } } else if (!flag && flag1) { tileentitycommandblock.setPowered(false); } } } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCommandBlock && playerIn.canUseCommandBlock()) { playerIn.displayGuiCommandBlock((TileEntityCommandBlock)tileentity); return true; } else { return false; } }
/** * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks, * beacons, skulls, flowerpot */ public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock; if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign) { tileentity.readFromNBT(packetIn.getNbtCompound()); } else { if(tileentity == null) { LOGGER.error("Received invalid update packet for null tile entity at {} with data: {}", packetIn.getPos(), packetIn.getNbtCompound()); return; } tileentity.onDataPacket(netManager, packetIn); } if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock)this.gameController.currentScreen).updateGui(); } } }