/** * 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(); } } }
/** * 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 TileEntityStructure) { TileEntityStructure tileentitystructure = (TileEntityStructure)tileentity; boolean flag = worldIn.isBlockPowered(pos); boolean flag1 = tileentitystructure.isPowered(); if (flag && !flag1) { tileentitystructure.setPowered(true); this.trigger(tileentitystructure); } else if (!flag && flag1) { tileentitystructure.setPowered(false); } } } }
private void trigger(TileEntityStructure p_189874_1_) { switch (p_189874_1_.getMode()) { case SAVE: p_189874_1_.save(false); break; case LOAD: p_189874_1_.load(false); break; case CORNER: p_189874_1_.unloadStructure(); case DATA: } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer()); this.mapSpecialRenderers.put(TileEntityShulkerBox.class, new TileEntityShulkerBoxRenderer(new ModelShulker())); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
/** * 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 TileEntityStructure) { TileEntityStructure tileentitystructure = (TileEntityStructure)tileentity; boolean flag = worldIn.isBlockPowered(pos); boolean flag1 = tileentitystructure.isPowered(); if (flag && !flag1) { tileentitystructure.setPowered(true); this.trigger(tileentitystructure); } else if (!flag && flag1) { tileentitystructure.setPowered(false); } } } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer()); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
@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(); } } } }
/** * 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 TileEntityStructure) { TileEntityStructure tileentitystructure = (TileEntityStructure)tileentity; boolean flag = worldIn.isBlockPowered(pos); boolean flag1 = tileentitystructure.func_189722_G(); if (flag && !flag1) { tileentitystructure.func_189723_d(true); this.func_189874_a(tileentitystructure); } else if (!flag && flag1) { tileentitystructure.func_189723_d(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 { tileentity.onDataPacket(netManager, packetIn); } if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock)this.gameController.currentScreen).updateGui(); } } }
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn) { Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap(); StructureBoundingBox structureboundingbox = placementIn.getBoundingBox(); for (Template.BlockInfo template$blockinfo : this.blocks) { BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos); if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos)) { IBlockState iblockstate = template$blockinfo.blockState; if (iblockstate.getBlock() instanceof BlockStructure && template$blockinfo.tileentityData != null) { TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode")); if (tileentitystructure$mode == TileEntityStructure.Mode.DATA) { map.put(blockpos, template$blockinfo.tileentityData.getString("metadata")); } } } } return map; }
@Override public void openEditStructure(TileEntityStructure structure) { if (m_realPlayer == null) { super.openEditStructure(structure); } else { syncToRealPlayer(); m_realPlayer.openEditStructure(structure); syncPublicFieldsFromReal(); } }
@Override public void openEditStructure(TileEntityStructure structure) { if (m_realPlayer == null) { super.openEditStructure(structure); } else { m_realPlayer.openEditStructure(structure); } }
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn) { Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap(); StructureBoundingBox structureboundingbox = placementIn.getBoundingBox(); for (Template.BlockInfo template$blockinfo : this.blocks) { BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos); if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos)) { IBlockState iblockstate = template$blockinfo.blockState; if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK && template$blockinfo.tileentityData != null) { TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode")); if (tileentitystructure$mode == TileEntityStructure.Mode.DATA) { map.put(blockpos, template$blockinfo.tileentityData.getString("metadata")); } } } } return map; }
/** * 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) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityStructure) { TileEntityStructure tileentitystructure = (TileEntityStructure)tileentity; tileentitystructure.createdBy(placer); } } }
/** * 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(); } } }
/** * 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) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityStructure) { TileEntityStructure tileentitystructure = (TileEntityStructure)tileentity; tileentitystructure.func_189720_a(placer); } } }
private void func_189874_a(TileEntityStructure p_189874_1_) { switch (p_189874_1_.func_189700_k()) { case SAVE: p_189874_1_.func_189712_b(false); break; case LOAD: p_189874_1_.func_189714_c(false); break; case CORNER: p_189874_1_.func_189706_E(); case DATA: } }
public void openEditStructure(TileEntityStructure structure) { }
public void openEditStructure(TileEntityStructure structure) { this.mc.displayGuiScreen(new GuiEditStructure(structure)); }
/** * Returns a new instance of a block's tile entity class. Called on placing the block. */ public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityStructure(); }
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); return tileentity instanceof TileEntityStructure ? ((TileEntityStructure)tileentity).usedBy(playerIn) : false; }
/** * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * IBlockstate */ public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(MODE, TileEntityStructure.Mode.DATA); }
/** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(MODE, TileEntityStructure.Mode.getById(meta)); }
/** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return ((TileEntityStructure.Mode)state.getValue(MODE)).getModeId(); }
private void renderInvisibleBlocks(TileEntityStructure p_190054_1_, double p_190054_2_, double p_190054_4_, double p_190054_6_, BlockPos p_190054_8_, Tessellator p_190054_9_, VertexBuffer p_190054_10_, boolean p_190054_11_) { GlStateManager.glLineWidth(p_190054_11_ ? 3.0F : 1.0F); p_190054_10_.begin(3, DefaultVertexFormats.POSITION_COLOR); World world = p_190054_1_.getWorld(); BlockPos blockpos = p_190054_1_.getPos(); BlockPos blockpos1 = blockpos.add(p_190054_8_); for (BlockPos blockpos2 : BlockPos.getAllInBox(blockpos1, blockpos1.add(p_190054_1_.getStructureSize()).add(-1, -1, -1))) { IBlockState iblockstate = world.getBlockState(blockpos2); boolean flag = iblockstate == Blocks.AIR.getDefaultState(); boolean flag1 = iblockstate == Blocks.STRUCTURE_VOID.getDefaultState(); if (flag || flag1) { float f = flag ? 0.05F : 0.0F; double d0 = (double)((float)(blockpos2.getX() - blockpos.getX()) + 0.45F) + p_190054_2_ - (double)f; double d1 = (double)((float)(blockpos2.getY() - blockpos.getY()) + 0.45F) + p_190054_4_ - (double)f; double d2 = (double)((float)(blockpos2.getZ() - blockpos.getZ()) + 0.45F) + p_190054_6_ - (double)f; double d3 = (double)((float)(blockpos2.getX() - blockpos.getX()) + 0.55F) + p_190054_2_ + (double)f; double d4 = (double)((float)(blockpos2.getY() - blockpos.getY()) + 0.55F) + p_190054_4_ + (double)f; double d5 = (double)((float)(blockpos2.getZ() - blockpos.getZ()) + 0.55F) + p_190054_6_ + (double)f; if (p_190054_11_) { RenderGlobal.drawBoundingBox(p_190054_10_, d0, d1, d2, d3, d4, d5, 0.0F, 0.0F, 0.0F, 1.0F); } else if (flag) { RenderGlobal.drawBoundingBox(p_190054_10_, d0, d1, d2, d3, d4, d5, 0.5F, 0.5F, 1.0F, 1.0F); } else { RenderGlobal.drawBoundingBox(p_190054_10_, d0, d1, d2, d3, d4, d5, 1.0F, 0.25F, 0.25F, 1.0F); } } } p_190054_9_.draw(); }
public boolean isGlobalRenderer(TileEntityStructure te) { return true; }
public GuiEditStructure(TileEntityStructure p_i47142_1_) { this.tileStructure = p_i47142_1_; this.decimalFormat.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); }
/** * Draws the screen and all the components in it. */ public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); TileEntityStructure.Mode tileentitystructure$mode = this.tileStructure.getMode(); this.drawCenteredString(this.fontRendererObj, I18n.format("tile.structureBlock.name", new Object[0]), this.width / 2, 10, 16777215); if (tileentitystructure$mode != TileEntityStructure.Mode.DATA) { this.drawString(this.fontRendererObj, I18n.format("structure_block.structure_name", new Object[0]), this.width / 2 - 153, 30, 10526880); this.nameEdit.drawTextBox(); } if (tileentitystructure$mode == TileEntityStructure.Mode.LOAD || tileentitystructure$mode == TileEntityStructure.Mode.SAVE) { this.drawString(this.fontRendererObj, I18n.format("structure_block.position", new Object[0]), this.width / 2 - 153, 70, 10526880); this.posXEdit.drawTextBox(); this.posYEdit.drawTextBox(); this.posZEdit.drawTextBox(); String s = I18n.format("structure_block.include_entities", new Object[0]); int i = this.fontRendererObj.getStringWidth(s); this.drawString(this.fontRendererObj, s, this.width / 2 + 154 - i, 150, 10526880); } if (tileentitystructure$mode == TileEntityStructure.Mode.SAVE) { this.drawString(this.fontRendererObj, I18n.format("structure_block.size", new Object[0]), this.width / 2 - 153, 110, 10526880); this.sizeXEdit.drawTextBox(); this.sizeYEdit.drawTextBox(); this.sizeZEdit.drawTextBox(); String s2 = I18n.format("structure_block.detect_size", new Object[0]); int k = this.fontRendererObj.getStringWidth(s2); this.drawString(this.fontRendererObj, s2, this.width / 2 + 154 - k, 110, 10526880); String s1 = I18n.format("structure_block.show_air", new Object[0]); int j = this.fontRendererObj.getStringWidth(s1); this.drawString(this.fontRendererObj, s1, this.width / 2 + 154 - j, 70, 10526880); } if (tileentitystructure$mode == TileEntityStructure.Mode.LOAD) { this.drawString(this.fontRendererObj, I18n.format("structure_block.integrity", new Object[0]), this.width / 2 - 153, 110, 10526880); this.integrityEdit.drawTextBox(); this.seedEdit.drawTextBox(); String s3 = I18n.format("structure_block.show_boundingbox", new Object[0]); int l = this.fontRendererObj.getStringWidth(s3); this.drawString(this.fontRendererObj, s3, this.width / 2 + 154 - l, 70, 10526880); } if (tileentitystructure$mode == TileEntityStructure.Mode.DATA) { this.drawString(this.fontRendererObj, I18n.format("structure_block.custom_data", new Object[0]), this.width / 2 - 153, 110, 10526880); this.dataEdit.drawTextBox(); } String s4 = "structure_block.mode_info." + tileentitystructure$mode.getName(); this.drawString(this.fontRendererObj, I18n.format(s4, new Object[0]), this.width / 2 - 153, 174, 10526880); super.drawScreen(mouseX, mouseY, partialTicks); }
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); return tileentity instanceof TileEntityStructure ? ((TileEntityStructure)tileentity).usedBy(playerIn) : false; }