Search in sources :

Example 1 with TileEntityCommandBlock

use of net.minecraft.tileentity.TileEntityCommandBlock in project SpongeCommon by SpongePowered.

the class SpongeCommandBlockBuilder method buildContent.

@Override
protected Optional<CommandBlock> buildContent(DataView container) throws InvalidDataException {
    return super.buildContent(container).flatMap(commandBlock -> {
        if (!container.contains(DataQueries.STORED_COMMAND, DataQueries.SUCCESS_COUNT, DataQueries.DOES_TRACK_OUTPUT)) {
            ((TileEntity) commandBlock).invalidate();
            return Optional.empty();
        }
        CommandBlockBaseLogic cmdBlockLogic = ((TileEntityCommandBlock) commandBlock).getCommandBlockLogic();
        cmdBlockLogic.setCommand(container.getString(DataQueries.STORED_COMMAND).get());
        cmdBlockLogic.successCount = container.getInt(DataQueries.SUCCESS_COUNT).get();
        cmdBlockLogic.setTrackOutput(container.getBoolean(DataQueries.DOES_TRACK_OUTPUT).get());
        if (cmdBlockLogic.shouldTrackOutput()) {
            cmdBlockLogic.setLastOutput(SpongeTexts.toComponent(SpongeTexts.fromLegacy(container.getString(DataQueries.TRACKED_OUTPUT).get())));
        }
        ((TileEntityCommandBlock) commandBlock).validate();
        return Optional.of(commandBlock);
    });
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CommandBlockBaseLogic(net.minecraft.tileentity.CommandBlockBaseLogic) TileEntityCommandBlock(net.minecraft.tileentity.TileEntityCommandBlock)

Example 2 with TileEntityCommandBlock

use of net.minecraft.tileentity.TileEntityCommandBlock in project Charset by CharsetMC.

the class CarryTransformerEntityMinecart method getExtractedPair.

protected Pair<IBlockState, TileEntity> getExtractedPair(@Nonnull Entity object, boolean simulate) {
    if (object instanceof EntityMinecartTNT) {
        return Pair.of(Blocks.TNT.getDefaultState(), null);
    } else if (object instanceof EntityMinecartCommandBlock) {
        TileEntityCommandBlock tile = new TileEntityCommandBlock();
        NBTTagCompound compound = ((EntityMinecartCommandBlock) object).getCommandBlockLogic().writeToNBT(new NBTTagCompound());
        tile.readFromNBT(compound);
        return Pair.of(Blocks.COMMAND_BLOCK.getDefaultState(), tile);
    } else if (object instanceof EntityMinecartChest) {
        TileEntityChest tile = new TileEntityChest();
        copyEntityToTile(tile, object, "Items");
        return Pair.of(Blocks.CHEST.getDefaultState(), tile);
    } else if (object instanceof EntityMinecartHopper) {
        TileEntityHopper tile = new TileEntityHopper();
        copyEntityToTile(tile, object, "Items");
        return Pair.of(Blocks.HOPPER.getDefaultState(), tile);
    } else /* else if (object instanceof EntityMinecartFurnace) {
			TileEntityFurnace tile = new TileEntityFurnace();
			copyEntityToTile(tile, object, "Fuel");
			return Pair.of(Blocks.FURNACE.getDefaultState(), tile);
		}*/
    {
        return null;
    }
}
Also used : TileEntityHopper(net.minecraft.tileentity.TileEntityHopper) TileEntityChest(net.minecraft.tileentity.TileEntityChest) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityCommandBlock(net.minecraft.tileentity.TileEntityCommandBlock)

Aggregations

TileEntityCommandBlock (net.minecraft.tileentity.TileEntityCommandBlock)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 CommandBlockBaseLogic (net.minecraft.tileentity.CommandBlockBaseLogic)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityChest (net.minecraft.tileentity.TileEntityChest)1 TileEntityHopper (net.minecraft.tileentity.TileEntityHopper)1