Search in sources :

Example 1 with IPartialSafeNBT

use of com.simibubi.create.foundation.utility.IPartialSafeNBT in project Create by Creators-of-Create.

the class SchematicannonTileEntity method launchBlockOrBelt.

protected void launchBlockOrBelt(BlockPos target, ItemStack icon, BlockState blockState, BlockEntity tile) {
    if (AllBlocks.BELT.has(blockState)) {
        blockState = stripBeltIfNotLast(blockState);
        if (tile instanceof BeltTileEntity && AllBlocks.BELT.has(blockState))
            launchBelt(target, blockState, ((BeltTileEntity) tile).beltLength);
        else if (blockState != Blocks.AIR.defaultBlockState())
            launchBlock(target, icon, blockState, null);
    } else {
        CompoundTag data = null;
        if (tile != null) {
            if (AllBlockTags.SAFE_NBT.matches(blockState)) {
                data = tile.saveWithFullMetadata();
                data = NBTProcessors.process(tile, data, true);
            } else if (tile instanceof IPartialSafeNBT) {
                data = new CompoundTag();
                ((IPartialSafeNBT) tile).writeSafe(data, false);
                data = NBTProcessors.process(tile, data, true);
            }
        }
        launchBlock(target, icon, blockState, data);
    }
}
Also used : BeltTileEntity(com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity) IPartialSafeNBT(com.simibubi.create.foundation.utility.IPartialSafeNBT) CompoundTag(net.minecraft.nbt.CompoundTag)

Aggregations

BeltTileEntity (com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity)1 IPartialSafeNBT (com.simibubi.create.foundation.utility.IPartialSafeNBT)1 CompoundTag (net.minecraft.nbt.CompoundTag)1