Search in sources :

Example 6 with SpongeBlockSnapshotBuilder

use of org.spongepowered.common.block.SpongeBlockSnapshotBuilder in project SpongeForge by SpongePowered.

the class MixinBlockSnapshot method createSpongeBlockSnapshot.

@Override
public BlockSnapshot createSpongeBlockSnapshot() {
    Location<World> location = new Location<>((World) this.getWorld(), VecHelper.toVector3i(this.pos));
    SpongeBlockSnapshotBuilder builder = new SpongeBlockSnapshotBuilder();
    builder.blockState((BlockState) this.replacedBlock).worldId(location.getExtent().getUniqueId()).position(location.getBlockPosition());
    if (this.nbt != null) {
        builder.unsafeNbt(this.nbt);
    }
    TileEntity te = getTileEntity();
    if (te != null) {
        if (!te.hasWorld()) {
            te.setWorld(this.getWorld());
        }
        for (DataManipulator<?, ?> manipulator : ((IMixinCustomDataHolder) te).getCustomManipulators()) {
            builder.add(manipulator);
        }
    }
    return builder.build();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) SpongeBlockSnapshotBuilder(org.spongepowered.common.block.SpongeBlockSnapshotBuilder) World(org.spongepowered.api.world.World) IMixinCustomDataHolder(org.spongepowered.common.interfaces.data.IMixinCustomDataHolder) Location(org.spongepowered.api.world.Location)

Aggregations

SpongeBlockSnapshotBuilder (org.spongepowered.common.block.SpongeBlockSnapshotBuilder)6 Vector3i (com.flowpowered.math.vector.Vector3i)3 World (org.spongepowered.api.world.World)3 IMixinCustomDataHolder (org.spongepowered.common.interfaces.data.IMixinCustomDataHolder)3 IBlockState (net.minecraft.block.state.IBlockState)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)2 BlockState (org.spongepowered.api.block.BlockState)2 TileEntity (org.spongepowered.api.block.tileentity.TileEntity)2 Location (org.spongepowered.api.world.Location)2 UUID (java.util.UUID)1 TileEntity (net.minecraft.tileentity.TileEntity)1 Transaction (org.spongepowered.api.data.Transaction)1 PropertyRegistry (org.spongepowered.api.data.property.PropertyRegistry)1 BookViewDataBuilder (org.spongepowered.api.text.serializer.BookViewDataBuilder)1 TextConfigSerializer (org.spongepowered.api.text.serializer.TextConfigSerializer)1 VariableAmount (org.spongepowered.api.util.weighted.VariableAmount)1 SpongeBlockStateBuilder (org.spongepowered.common.block.SpongeBlockStateBuilder)1 SpongeGameProfileBuilder (org.spongepowered.common.data.builder.authlib.SpongeGameProfileBuilder)1 SpongeBlockStateMetaContentUpdater (org.spongepowered.common.data.builder.block.state.SpongeBlockStateMetaContentUpdater)1