Java Code Examples for net.minecraft.world.World#removeBlockEntity()

The following examples show how to use net.minecraft.world.World#removeBlockEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PistonBlock_movableTEMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
        target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD)
private void onMove(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
                    CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1,
                    List<BlockPos> list_1, List<BlockState> list_2, List list_3, int int_2, BlockState[] blockStates_1,
                    Direction direction_2)
{
    //Get the blockEntities and remove them from the world before any magic starts to happen
    if (CarpetSettings.movableBlockEntities)
    {
        list1_BlockEntities.set(Lists.newArrayList());
        for (int i = 0; i < list_1.size(); ++i)
        {
            BlockPos blockpos = list_1.get(i);
            BlockEntity blockEntity = (list_2.get(i).getBlock().hasBlockEntity()) ? world_1.getBlockEntity(blockpos) : null;
            list1_BlockEntities.get().add(blockEntity);
            if (blockEntity != null)
            {
                //hopefully this call won't have any side effects in the future, such as dropping all the BlockEntity's items
                //we want to place this same(!) BlockEntity object into the world later when the movement stops again
                world_1.removeBlockEntity(blockpos);
                blockEntity.markDirty();
            }
        }
    }
}
 
Example 2
Source File: MixinWorldChunk.java    From multiconnect with MIT License 4 votes vote down vote up
@Redirect(method = "setBlockState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;removeBlockEntity(Lnet/minecraft/util/math/BlockPos;)V"))
private void redirectRemoveBlockEntity(World world, BlockPos pos) {
    if (shouldReplaceBlockEntity)
        world.removeBlockEntity(pos);
}