Search in sources :

Example 1 with TileEntityStructure

use of net.minecraft.tileentity.TileEntityStructure in project tweakeroo by maruohon.

the class MixinTileEntityStructure method overrideCornerBlockScan.

@Inject(method = "getNearbyCornerBlocks", at = @At("HEAD"), cancellable = true)
private void overrideCornerBlockScan(BlockPos start, BlockPos end, CallbackInfoReturnable<List<TileEntityStructure>> cir) {
    if (FeatureToggle.TWEAK_STRUCTURE_BLOCK_LIMIT.getBooleanValue()) {
        List<TileEntityStructure> structureBlocks = new ArrayList<>();
        BlockPos pos = this.getPos();
        World world = this.getWorld();
        String name = ((TileEntityStructure) (Object) this).getName();
        int maxSize = Configs.Generic.STRUCTURE_BLOCK_MAX_SIZE.getIntegerValue();
        // Expand by the maximum position/offset and a bit of margin
        final int minX = pos.getX() - maxSize - 32 - 2;
        final int minZ = pos.getZ() - maxSize - 32 - 2;
        final int maxX = pos.getX() + maxSize + 32 + 2;
        final int maxZ = pos.getZ() + maxSize + 32 + 2;
        final int minY = Math.max(0, pos.getY() - maxSize - 32 - 2);
        final int maxY = Math.min(255, pos.getY() + maxSize + 32 + 2);
        for (int cz = minZ >> 4; cz <= (maxZ >> 4); ++cz) {
            for (int cx = minX >> 4; cx <= (maxX >> 4); ++cx) {
                Collection<TileEntity> list = world.getChunk(cx, cz).getTileEntityMap().values();
                for (TileEntity te : list) {
                    if (te instanceof TileEntityStructure) {
                        TileEntityStructure tes = (TileEntityStructure) te;
                        BlockPos p = te.getPos();
                        if (tes.getMode() == TileEntityStructure.Mode.CORNER && tes.getName().equals(name) && p.getX() >= minX && p.getX() <= maxX && p.getY() >= minY && p.getY() <= maxY && p.getZ() >= minZ && p.getZ() <= maxZ) {
                            structureBlocks.add((TileEntityStructure) te);
                        }
                    }
                }
            }
        }
        cir.setReturnValue(structureBlocks);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityStructure(net.minecraft.tileentity.TileEntityStructure) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with TileEntityStructure

use of net.minecraft.tileentity.TileEntityStructure in project Lands-of-Icaria by Axanthic-Game-Studios.

the class TemplatePublic method getDataBlocks.

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;
}
Also used : StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) IBlockState(net.minecraft.block.state.IBlockState) TileEntityStructure(net.minecraft.tileentity.TileEntityStructure) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with TileEntityStructure

use of net.minecraft.tileentity.TileEntityStructure in project CumServerPro by MCUmbrella.

the class NetHandlerPlayClient method handleUpdateTileEntity.

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 || i == 11 && tileentity instanceof TileEntityBed) {
            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();
        }
    }
}
Also used : TileEntityBeacon(net.minecraft.tileentity.TileEntityBeacon) GuiCommandBlock(net.minecraft.client.gui.GuiCommandBlock) TileEntityStructure(net.minecraft.tileentity.TileEntityStructure) TileEntityCommandBlock(net.minecraft.tileentity.TileEntityCommandBlock) TileEntityShulkerBox(net.minecraft.tileentity.TileEntityShulkerBox) TileEntityBed(net.minecraft.tileentity.TileEntityBed) TileEntityEndGateway(net.minecraft.tileentity.TileEntityEndGateway) SPacketUpdateTileEntity(net.minecraft.network.play.server.SPacketUpdateTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySign(net.minecraft.tileentity.TileEntitySign) TileEntitySkull(net.minecraft.tileentity.TileEntitySkull) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner) TileEntityFlowerPot(net.minecraft.tileentity.TileEntityFlowerPot) TileEntityBanner(net.minecraft.tileentity.TileEntityBanner)

Example 4 with TileEntityStructure

use of net.minecraft.tileentity.TileEntityStructure in project CumServerPro by MCUmbrella.

the class NetHandlerPlayServer method processCustomPayload.

public void processCustomPayload(CPacketCustomPayload packetIn) {
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.player.getServerWorld());
    String s = packetIn.getChannelName();
    if ("MC|BEdit".equals(s)) {
        if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
            this.disconnect("Book edited too quickly!");
            return;
        }
        this.lastBookTick = MinecraftServer.currentTick;
        PacketBuffer packetbuffer = packetIn.getBufferData();
        try {
            ItemStack itemstack = packetbuffer.readItemStack();
            if (itemstack.isEmpty()) {
                return;
            }
            if (!ItemWritableBook.isNBTValid(itemstack.getTagCompound())) {
                throw new IOException("Invalid book tag!");
            }
            ItemStack itemstack1 = this.player.getHeldItemMainhand();
            if (itemstack1.isEmpty()) {
                return;
            }
            if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
                itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
                CraftEventFactory.handleEditBookEvent(player, itemstack1);
            }
        } catch (Exception exception6) {
            LOGGER.error("Couldn't handle book info", exception6);
            this.disconnect("Invalid book data!");
        }
    } else if ("MC|BSign".equals(s)) {
        if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
            this.disconnect("Book edited too quickly!");
            return;
        }
        this.lastBookTick = MinecraftServer.currentTick;
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        try {
            ItemStack itemstack3 = packetbuffer1.readItemStack();
            if (itemstack3.isEmpty()) {
                return;
            }
            if (!ItemWrittenBook.validBookTagContents(itemstack3.getTagCompound())) {
                throw new IOException("Invalid book tag!");
            }
            ItemStack itemstack4 = this.player.getHeldItemMainhand();
            if (itemstack4.isEmpty()) {
                return;
            }
            if (itemstack3.getItem() == Items.WRITABLE_BOOK && itemstack4.getItem() == Items.WRITABLE_BOOK) {
                ItemStack itemstack2 = new ItemStack(Items.WRITTEN_BOOK);
                itemstack2.setTagInfo("author", new NBTTagString(this.player.getName()));
                itemstack2.setTagInfo("title", new NBTTagString(itemstack3.getTagCompound().getString("title")));
                NBTTagList nbttaglist = itemstack3.getTagCompound().getTagList("pages", 8);
                for (int i = 0; i < nbttaglist.tagCount(); ++i) {
                    String s1 = nbttaglist.getStringTagAt(i);
                    ITextComponent itextcomponent = new TextComponentString(s1);
                    s1 = ITextComponent.Serializer.componentToJson(itextcomponent);
                    nbttaglist.set(i, new NBTTagString(s1));
                }
                itemstack2.setTagInfo("pages", nbttaglist);
                // this.player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, itemstack2);
                CraftEventFactory.handleEditBookEvent(player, itemstack2);
            }
        } catch (Exception exception7) {
            LOGGER.error("Couldn't sign book", exception7);
            this.disconnect("Invalid book data!");
        }
    } else if ("MC|TrSel".equals(s)) {
        try {
            int k = packetIn.getBufferData().readInt();
            Container container = this.player.openContainer;
            if (container instanceof ContainerMerchant) {
                ((ContainerMerchant) container).setCurrentRecipeIndex(k);
            }
        } catch (Exception exception5) {
            LOGGER.error("Couldn't select trade", exception5);
            this.disconnect("Invalid trade data!");
        }
    } else if ("MC|AdvCmd".equals(s)) {
        if (!this.serverController.isCommandBlockEnabled()) {
            this.player.sendMessage(new TextComponentTranslation("advMode.notEnabled"));
            return;
        }
        if (!this.player.canUseCommandBlock()) {
            this.player.sendMessage(new TextComponentTranslation("advMode.notAllowed"));
            return;
        }
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        try {
            int l = packetbuffer2.readByte();
            CommandBlockBaseLogic commandblockbaselogic1 = null;
            if (l == 0) {
                TileEntity tileentity = this.player.world.getTileEntity(new BlockPos(packetbuffer2.readInt(), packetbuffer2.readInt(), packetbuffer2.readInt()));
                if (tileentity instanceof TileEntityCommandBlock) {
                    commandblockbaselogic1 = ((TileEntityCommandBlock) tileentity).getCommandBlockLogic();
                }
            } else if (l == 1) {
                Entity entity = this.player.world.getEntityByID(packetbuffer2.readInt());
                if (entity instanceof EntityMinecartCommandBlock) {
                    commandblockbaselogic1 = ((EntityMinecartCommandBlock) entity).getCommandBlockLogic();
                }
            }
            String s6 = packetbuffer2.readString(packetbuffer2.readableBytes());
            boolean flag2 = packetbuffer2.readBoolean();
            if (commandblockbaselogic1 != null) {
                commandblockbaselogic1.setCommand(s6);
                commandblockbaselogic1.setTrackOutput(flag2);
                if (!flag2) {
                    commandblockbaselogic1.setLastOutput(null);
                }
                commandblockbaselogic1.updateCommand();
                this.player.sendMessage(new TextComponentTranslation("advMode.setCommand.success", s6));
            }
        } catch (Exception exception4) {
            LOGGER.error("Couldn't set command block", exception4);
            this.disconnect("Invalid command data!");
        }
    } else if ("MC|AutoCmd".equals(s)) {
        if (!this.serverController.isCommandBlockEnabled()) {
            this.player.sendMessage(new TextComponentTranslation("advMode.notEnabled"));
            return;
        }
        if (!this.player.canUseCommandBlock()) {
            this.player.sendMessage(new TextComponentTranslation("advMode.notAllowed"));
            return;
        }
        PacketBuffer packetbuffer3 = packetIn.getBufferData();
        try {
            CommandBlockBaseLogic commandblockbaselogic = null;
            TileEntityCommandBlock tileentitycommandblock = null;
            BlockPos blockpos1 = new BlockPos(packetbuffer3.readInt(), packetbuffer3.readInt(), packetbuffer3.readInt());
            TileEntity tileentity2 = this.player.world.getTileEntity(blockpos1);
            if (tileentity2 instanceof TileEntityCommandBlock) {
                tileentitycommandblock = (TileEntityCommandBlock) tileentity2;
                commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic();
            }
            String s7 = packetbuffer3.readString(packetbuffer3.readableBytes());
            boolean flag3 = packetbuffer3.readBoolean();
            TileEntityCommandBlock.Mode tileentitycommandblock$mode = TileEntityCommandBlock.Mode.valueOf(packetbuffer3.readString(16));
            boolean flag = packetbuffer3.readBoolean();
            boolean flag1 = packetbuffer3.readBoolean();
            if (commandblockbaselogic != null) {
                EnumFacing enumfacing = this.player.world.getBlockState(blockpos1).getValue(BlockCommandBlock.FACING);
                switch(tileentitycommandblock$mode) {
                    case SEQUENCE:
                        IBlockState iblockstate3 = Blocks.CHAIN_COMMAND_BLOCK.getDefaultState();
                        this.player.world.setBlockState(blockpos1, iblockstate3.withProperty(BlockCommandBlock.FACING, enumfacing).withProperty(BlockCommandBlock.CONDITIONAL, Boolean.valueOf(flag)), 2);
                        break;
                    case AUTO:
                        IBlockState iblockstate2 = Blocks.REPEATING_COMMAND_BLOCK.getDefaultState();
                        this.player.world.setBlockState(blockpos1, iblockstate2.withProperty(BlockCommandBlock.FACING, enumfacing).withProperty(BlockCommandBlock.CONDITIONAL, Boolean.valueOf(flag)), 2);
                        break;
                    case REDSTONE:
                        IBlockState iblockstate = Blocks.COMMAND_BLOCK.getDefaultState();
                        this.player.world.setBlockState(blockpos1, iblockstate.withProperty(BlockCommandBlock.FACING, enumfacing).withProperty(BlockCommandBlock.CONDITIONAL, Boolean.valueOf(flag)), 2);
                }
                tileentity2.validate();
                this.player.world.setTileEntity(blockpos1, tileentity2);
                commandblockbaselogic.setCommand(s7);
                commandblockbaselogic.setTrackOutput(flag3);
                if (!flag3) {
                    commandblockbaselogic.setLastOutput(null);
                }
                tileentitycommandblock.setAuto(flag1);
                commandblockbaselogic.updateCommand();
                if (!net.minecraft.util.StringUtils.isNullOrEmpty(s7)) {
                    this.player.sendMessage(new TextComponentTranslation("advMode.setCommand.success", s7));
                }
            }
        } catch (Exception exception3) {
            LOGGER.error("Couldn't set command block", exception3);
            this.disconnect("Invalid command data!");
        }
    } else if ("MC|Beacon".equals(s)) {
        if (this.player.openContainer instanceof ContainerBeacon) {
            try {
                PacketBuffer packetbuffer4 = packetIn.getBufferData();
                int i1 = packetbuffer4.readInt();
                int k1 = packetbuffer4.readInt();
                ContainerBeacon containerbeacon = (ContainerBeacon) this.player.openContainer;
                Slot slot = containerbeacon.getSlot(0);
                if (slot.getHasStack()) {
                    slot.decrStackSize(1);
                    IInventory iinventory = containerbeacon.getTileEntity();
                    iinventory.setField(1, i1);
                    iinventory.setField(2, k1);
                    iinventory.markDirty();
                }
            } catch (Exception exception2) {
                LOGGER.error("Couldn't set beacon", exception2);
                this.disconnect("Invalid beacon data!");
            }
        }
    } else if ("MC|ItemName".equals(s)) {
        if (this.player.openContainer instanceof ContainerRepair) {
            ContainerRepair containerrepair = (ContainerRepair) this.player.openContainer;
            if (packetIn.getBufferData() != null && packetIn.getBufferData().readableBytes() >= 1) {
                String s5 = ChatAllowedCharacters.filterAllowedCharacters(packetIn.getBufferData().readString(32767));
                if (s5.length() <= 35) {
                    containerrepair.updateItemName(s5);
                }
            } else {
                containerrepair.updateItemName("");
            }
        }
    } else if ("MC|Struct".equals(s)) {
        if (!this.player.canUseCommandBlock()) {
            return;
        }
        PacketBuffer packetbuffer5 = packetIn.getBufferData();
        try {
            BlockPos blockpos = new BlockPos(packetbuffer5.readInt(), packetbuffer5.readInt(), packetbuffer5.readInt());
            IBlockState iblockstate1 = this.player.world.getBlockState(blockpos);
            TileEntity tileentity1 = this.player.world.getTileEntity(blockpos);
            if (tileentity1 instanceof TileEntityStructure) {
                TileEntityStructure tileentitystructure = (TileEntityStructure) tileentity1;
                int l1 = packetbuffer5.readByte();
                String s8 = packetbuffer5.readString(32);
                tileentitystructure.setMode(TileEntityStructure.Mode.valueOf(s8));
                tileentitystructure.setName(packetbuffer5.readString(64));
                int i2 = MathHelper.clamp(packetbuffer5.readInt(), -32, 32);
                int j2 = MathHelper.clamp(packetbuffer5.readInt(), -32, 32);
                int k2 = MathHelper.clamp(packetbuffer5.readInt(), -32, 32);
                tileentitystructure.setPosition(new BlockPos(i2, j2, k2));
                int l2 = MathHelper.clamp(packetbuffer5.readInt(), 0, 32);
                int i3 = MathHelper.clamp(packetbuffer5.readInt(), 0, 32);
                int j = MathHelper.clamp(packetbuffer5.readInt(), 0, 32);
                tileentitystructure.setSize(new BlockPos(l2, i3, j));
                String s2 = packetbuffer5.readString(32);
                tileentitystructure.setMirror(Mirror.valueOf(s2));
                String s3 = packetbuffer5.readString(32);
                tileentitystructure.setRotation(Rotation.valueOf(s3));
                tileentitystructure.setMetadata(packetbuffer5.readString(128));
                tileentitystructure.setIgnoresEntities(packetbuffer5.readBoolean());
                tileentitystructure.setShowAir(packetbuffer5.readBoolean());
                tileentitystructure.setShowBoundingBox(packetbuffer5.readBoolean());
                tileentitystructure.setIntegrity(MathHelper.clamp(packetbuffer5.readFloat(), 0.0F, 1.0F));
                tileentitystructure.setSeed(packetbuffer5.readVarLong());
                String s4 = tileentitystructure.getName();
                if (l1 == 2) {
                    if (tileentitystructure.save()) {
                        this.player.sendStatusMessage(new TextComponentTranslation("structure_block.save_success", s4), false);
                    } else {
                        this.player.sendStatusMessage(new TextComponentTranslation("structure_block.save_failure", s4), false);
                    }
                } else if (l1 == 3) {
                    if (!tileentitystructure.isStructureLoadable()) {
                        this.player.sendStatusMessage(new TextComponentTranslation("structure_block.load_not_found", s4), false);
                    } else if (tileentitystructure.load()) {
                        this.player.sendStatusMessage(new TextComponentTranslation("structure_block.load_success", s4), false);
                    } else {
                        this.player.sendStatusMessage(new TextComponentTranslation("structure_block.load_prepare", s4), false);
                    }
                } else if (l1 == 4) {
                    if (tileentitystructure.detectSize()) {
                        this.player.sendStatusMessage(new TextComponentTranslation("structure_block.size_success", s4), false);
                    } else {
                        this.player.sendStatusMessage(new TextComponentTranslation("structure_block.size_failure"), false);
                    }
                }
                tileentitystructure.markDirty();
                this.player.world.notifyBlockUpdate(blockpos, iblockstate1, iblockstate1, 3);
            }
        } catch (Exception exception1) {
            LOGGER.error("Couldn't set structure block", exception1);
            this.disconnect("Invalid structure data!");
        }
    } else if ("MC|PickItem".equals(s)) {
        PacketBuffer packetbuffer6 = packetIn.getBufferData();
        try {
            int j1 = packetbuffer6.readVarInt();
            this.player.inventory.pickItem(j1);
            this.player.connection.sendPacket(new SPacketSetSlot(-2, this.player.inventory.currentItem, this.player.inventory.getStackInSlot(this.player.inventory.currentItem)));
            this.player.connection.sendPacket(new SPacketSetSlot(-2, j1, this.player.inventory.getStackInSlot(j1)));
            this.player.connection.sendPacket(new SPacketHeldItemChange(this.player.inventory.currentItem));
        } catch (Exception exception) {
            LOGGER.error("Couldn't pick item", exception);
            this.disconnect("Invalid pick item!");
        }
    } else // CraftBukkit start
    if (packetIn.getChannelName().equals("REGISTER")) {
        try {
            String channels = packetIn.getBufferData().toString(com.google.common.base.Charsets.UTF_8);
            for (String channel : channels.split("\0")) {
                getPlayer().addChannel(channel);
            }
        } catch (Exception ex) {
            NetHandlerPlayServer.LOGGER.error("Couldn\'t register custom payload", ex);
            this.disconnect("Invalid payload REGISTER!");
        }
    } else if (packetIn.getChannelName().equals("UNREGISTER")) {
        try {
            String channels = packetIn.getBufferData().toString(com.google.common.base.Charsets.UTF_8);
            for (String channel : channels.split("\0")) {
                getPlayer().removeChannel(channel);
            }
        } catch (Exception ex) {
            NetHandlerPlayServer.LOGGER.error("Couldn\'t unregister custom payload", ex);
            this.disconnect("Invalid payload UNREGISTER!");
        }
    } else {
        try {
            byte[] data = new byte[packetIn.getBufferData().readableBytes()];
            packetIn.getBufferData().readBytes(data);
            server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetIn.getChannelName(), data);
        } catch (Exception ex) {
            NetHandlerPlayServer.LOGGER.error("Couldn\'t dispatch custom payload", ex);
            this.disconnect("Invalid custom payload!");
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CPacketUseEntity(net.minecraft.network.play.client.CPacketUseEntity) Entity(net.minecraft.entity.Entity) EnumFacing(net.minecraft.util.EnumFacing) ITextComponent(net.minecraft.util.text.ITextComponent) TileEntityCommandBlock(net.minecraft.tileentity.TileEntityCommandBlock) NBTTagString(net.minecraft.nbt.NBTTagString) TextComponentString(net.minecraft.util.text.TextComponentString) ContainerBeacon(net.minecraft.inventory.ContainerBeacon) NBTTagList(net.minecraft.nbt.NBTTagList) CommandBlockBaseLogic(net.minecraft.tileentity.CommandBlockBaseLogic) TileEntity(net.minecraft.tileentity.TileEntity) SPacketHeldItemChange(net.minecraft.network.play.server.SPacketHeldItemChange) ContainerRepair(net.minecraft.inventory.ContainerRepair) Container(net.minecraft.inventory.Container) NBTTagString(net.minecraft.nbt.NBTTagString) BlockPos(net.minecraft.util.math.BlockPos) SPacketSetSlot(net.minecraft.network.play.server.SPacketSetSlot) IInventory(net.minecraft.inventory.IInventory) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBlockState(net.minecraft.block.state.IBlockState) TileEntityStructure(net.minecraft.tileentity.TileEntityStructure) IOException(java.io.IOException) ReportedException(net.minecraft.util.ReportedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TextComponentString(net.minecraft.util.text.TextComponentString) ContainerMerchant(net.minecraft.inventory.ContainerMerchant) EntityMinecartCommandBlock(net.minecraft.entity.item.EntityMinecartCommandBlock) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) SPacketSetSlot(net.minecraft.network.play.server.SPacketSetSlot) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.inventory.CraftItemStack)

Example 5 with TileEntityStructure

use of net.minecraft.tileentity.TileEntityStructure in project CumServerPro by MCUmbrella.

the class Template method getDataBlocks.

public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn) {
    Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap();
    StructureBoundingBox structureboundingbox = placementIn.getBoundingBox();
    for (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;
}
Also used : StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) IBlockState(net.minecraft.block.state.IBlockState) TileEntityStructure(net.minecraft.tileentity.TileEntityStructure) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

TileEntityStructure (net.minecraft.tileentity.TileEntityStructure)13 TileEntity (net.minecraft.tileentity.TileEntity)10 BlockPos (net.minecraft.util.math.BlockPos)7 IBlockState (net.minecraft.block.state.IBlockState)6 TileEntityCommandBlock (net.minecraft.tileentity.TileEntityCommandBlock)4 IInventory (net.minecraft.inventory.IInventory)3 StructureBoundingBox (net.minecraft.world.gen.structure.StructureBoundingBox)3 IOException (java.io.IOException)2 GuiCommandBlock (net.minecraft.client.gui.GuiCommandBlock)2 Entity (net.minecraft.entity.Entity)2 EntityMinecartCommandBlock (net.minecraft.entity.item.EntityMinecartCommandBlock)2 Container (net.minecraft.inventory.Container)2 ContainerBeacon (net.minecraft.inventory.ContainerBeacon)2 ContainerMerchant (net.minecraft.inventory.ContainerMerchant)2 ContainerRepair (net.minecraft.inventory.ContainerRepair)2 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)2 Slot (net.minecraft.inventory.Slot)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 NBTTagString (net.minecraft.nbt.NBTTagString)2