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);
});
}
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;
}
}
Aggregations