use of net.minecraft.block.entity.BlockEntity in project friends-and-foes by Faboslav.
the class BeeEntityMixin method isHiveValid.
@Inject(method = "isHiveValid", at = @At(value = "RETURN", ordinal = 1), cancellable = true)
private void isHiveValid(CallbackInfoReturnable<Boolean> cir) {
var isHiveValid = cir.getReturnValue();
if (isHiveValid) {
cir.setReturnValue(isHiveValid);
}
BlockEntity blockEntity = this.world.getBlockEntity(this.hivePos);
isHiveValid = blockEntity != null && blockEntity.getType() == ModBlockEntityTypes.FRIENDS_AND_FOES_BEEHIVES;
if (!info.getReturnValueZ() && be instanceof ApiaryBlockEntity)
info.setReturnValue(true);
}
use of net.minecraft.block.entity.BlockEntity in project Fabric-Course-118 by Kaupenjoe.
the class HoneyFluid method beforeBreakingBlock.
protected void beforeBreakingBlock(WorldAccess world, BlockPos pos, BlockState state) {
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
Block.dropStacks(state, world, pos, blockEntity);
}
use of net.minecraft.block.entity.BlockEntity in project isometric-renders by gliscowo.
the class IsoRenderCommand method executeBlockTarget.
private static int executeBlockTarget(FabricClientCommandSource source) {
final MinecraftClient client = MinecraftClient.getInstance();
IsometricRenderScreen screen = new IsometricRenderScreen();
if (client.crosshairTarget.getType() != HitResult.Type.BLOCK) {
source.sendError(Text.of("You're not looking at a block"));
return 0;
}
final BlockPos hitPos = ((BlockHitResult) client.crosshairTarget).getBlockPos();
BlockState state = client.world.getBlockState(hitPos);
BlockEntity be = null;
if (state.getBlock() instanceof BlockWithEntity) {
CompoundTag tag = client.world.getBlockEntity(hitPos).toTag(new CompoundTag());
be = ((BlockWithEntity) state.getBlock()).createBlockEntity(client.world);
((BlockEntityAccessor) be).setCachedState(state);
be.setLocation(client.world, MinecraftClient.getInstance().player.getBlockPos());
CompoundTag copyTag = tag.copy();
copyTag.putInt("x", 0);
copyTag.putInt("y", 0);
copyTag.putInt("z", 0);
be.fromTag(be.getCachedState(), copyTag);
be.setLocation(client.world, MinecraftClient.getInstance().player.getBlockPos());
}
if (be != null) {
IsometricRenderPresets.setupBlockEntityRender(screen, be);
} else {
IsometricRenderPresets.setupBlockStateRender(screen, state);
}
IsometricRenderHelper.scheduleScreen(screen);
return 0;
}
use of net.minecraft.block.entity.BlockEntity in project Client by MatHax.
the class GhostHand method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (!mc.options.useKey.isPressed() || mc.player.isSneaking())
return;
for (BlockEntity blockEntity : Utils.blockEntities()) {
if (new BlockPos(mc.player.raycast(mc.interactionManager.getReachDistance(), mc.getTickDelta(), false).getPos()).equals(blockEntity.getPos()))
return;
}
Vec3d nextPos = new Vec3d(0, 0, 0.1).rotateX(-(float) Math.toRadians(mc.player.getPitch())).rotateY(-(float) Math.toRadians(mc.player.getYaw()));
for (int i = 1; i < mc.interactionManager.getReachDistance() * 10; i++) {
BlockPos curPos = new BlockPos(mc.player.getCameraPosVec(mc.getTickDelta()).add(nextPos.multiply(i)));
if (posList.contains(curPos))
continue;
posList.add(curPos);
for (BlockEntity blockEntity : Utils.blockEntities()) {
if (blockEntity.getPos().equals(curPos)) {
mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(mc.player.getPos(), Direction.UP, curPos, true));
return;
}
}
}
posList.clear();
}
use of net.minecraft.block.entity.BlockEntity in project AurorasDecorations by LambdAurora.
the class BlockEntityHelper method sync.
default void sync() {
World world = ((BlockEntity) this).getWorld();
// Maintain distinct failure case from below
Preconditions.checkNotNull(world);
if (!(world instanceof ServerWorld))
throw new IllegalStateException("Cannot call sync() on the logical client! Did you check world.isClient first?");
((ServerWorld) world).getChunkManager().markForUpdate(((BlockEntity) this).getPos());
}
Aggregations