use of net.minecraft.block.entity.BlockEntity in project beyond-earth-fabricated by SomeoneIs404.
the class Fluid method beforeBreakingBlock.
@Override
protected void beforeBreakingBlock(WorldAccess world, BlockPos pos, BlockState state) {
final BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
Block.dropStacks(state, world, pos, blockEntity);
}
use of net.minecraft.block.entity.BlockEntity in project Carrier by GabrielOlvH.
the class CarriableGeneric method tryPlace.
@Override
@NotNull
public ActionResult tryPlace(@NotNull CarrierComponent carrier, @NotNull World world, @NotNull CarriablePlacementContext ctx) {
if (world.isClient)
return ActionResult.PASS;
CarryingData carrying = carrier.getCarryingData();
if (carrying == null)
return ActionResult.PASS;
BlockPos pos = ctx.getBlockPos();
BlockState state = carrying.getBlockState() == null ? parent.getDefaultState() : carrying.getBlockState();
world.setBlockState(pos, state);
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null) {
NbtCompound tag = carrying.getBlockEntityTag();
((AccessorBlockEntity) blockEntity).carrier_writeIdentifyingData(tag);
blockEntity.readNbt(tag);
}
carrier.setCarryingData(null);
world.updateNeighbors(pos, state.getBlock());
return ActionResult.SUCCESS;
}
use of net.minecraft.block.entity.BlockEntity in project Carrier by GabrielOlvH.
the class CarriableChest method tryPlace.
@Override
@NotNull
public ActionResult tryPlace(@NotNull CarrierComponent carrier, @NotNull World world, @NotNull CarriablePlacementContext ctx) {
if (world.isClient)
return ActionResult.PASS;
CarryingData carrying = carrier.getCarryingData();
if (carrying == null)
return ActionResult.PASS;
BlockPos pos = ctx.getBlockPos();
BlockState state = parent.getPlacementState(new ItemPlacementContext(carrier.getOwner(), Hand.MAIN_HAND, ItemStack.EMPTY, new BlockHitResult(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), ctx.getSide(), ctx.getBlockPos(), false)));
world.setBlockState(pos, state);
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null) {
NbtCompound tag = carrying.getBlockEntityTag();
((AccessorBlockEntity) blockEntity).carrier_writeIdentifyingData(tag);
blockEntity.readNbt(tag);
}
carrier.setCarryingData(null);
return ActionResult.SUCCESS;
}
use of net.minecraft.block.entity.BlockEntity in project Carrier by GabrielOlvH.
the class CarriableGeneric method tryPickup.
@Override
@NotNull
public ActionResult tryPickup(@NotNull CarrierComponent carrier, @NotNull World world, @NotNull BlockPos blockPos, @Nullable Entity entity) {
if (world.isClient)
return ActionResult.PASS;
BlockEntity blockEntity = world.getBlockEntity(blockPos);
BlockState blockState = world.getBlockState(blockPos);
CarryingData carrying = new CarryingData(type, blockState, blockEntity);
world.removeBlockEntity(blockPos);
world.removeBlock(blockPos, false);
carrier.setCarryingData(carrying);
return ActionResult.SUCCESS;
}
use of net.minecraft.block.entity.BlockEntity in project FastAsyncWorldEdit by IntellectualSites.
the class FabricWorld method getFullBlock.
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
// Avoid creation by using the CHECK mode -- if it's needed, it'll be re-created anyways
BlockEntity tile = ((WorldChunk) getWorld().getChunk(pos)).getBlockEntity(pos, WorldChunk.CreationType.CHECK);
if (tile != null) {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
tile.toTag(tag);
return getBlock(position).toBaseBlock(NBTConverter.fromNative(tag));
} else {
return getBlock(position).toBaseBlock();
}
}
Aggregations