use of me.steven.carrier.mixin.AccessorBlockEntity in project Carrier by GabrielOlvH.
the class CarriableSpawner method render.
@Override
@Environment(EnvType.CLIENT)
public void render(@NotNull PlayerEntity player, @NotNull CarrierComponent carrier, @NotNull MatrixStack matrices, @NotNull VertexConsumerProvider vcp, float tickDelta, int light) {
BlockState blockState = Blocks.SPAWNER.getDefaultState();
getEntity().readNbt(carrier.getCarryingData().getBlockEntityTag());
((AccessorBlockEntity) getEntity()).setWorld(player.world);
matrices.push();
matrices.scale(0.6f, 0.6f, 0.6f);
float yaw = MathHelper.lerpAngleDegrees(tickDelta, player.prevBodyYaw, player.bodyYaw);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-yaw));
matrices.translate(-0.5, 0.8, 0.2);
MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(blockState, matrices, vcp, light, OverlayTexture.DEFAULT_UV);
if (MinecraftClient.isFancyGraphicsOrBetter())
getEntityRenderer().render(getEntity(), tickDelta, matrices, vcp, light, OverlayTexture.DEFAULT_UV);
matrices.pop();
}
use of me.steven.carrier.mixin.AccessorBlockEntity 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 me.steven.carrier.mixin.AccessorBlockEntity 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 me.steven.carrier.mixin.AccessorBlockEntity in project Carrier by GabrielOlvH.
the class CarriableEnchantingTable method render.
@Override
@Environment(EnvType.CLIENT)
public void render(@NotNull PlayerEntity player, @NotNull CarrierComponent carrier, @NotNull MatrixStack matrices, @NotNull VertexConsumerProvider vcp, float tickDelta, int light) {
BlockState blockState = getParent().getDefaultState();
getEntity().readNbt(carrier.getCarryingData().getBlockEntityTag());
((AccessorBlockEntity) getEntity()).setWorld(player.world);
matrices.push();
matrices.scale(0.6f, 0.6f, 0.6f);
float yaw = MathHelper.lerpAngleDegrees(tickDelta, player.prevBodyYaw, player.bodyYaw);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-yaw));
matrices.translate(-0.5, 0.8, 0.2);
MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(blockState, matrices, vcp, light, OverlayTexture.DEFAULT_UV);
if (MinecraftClient.isFancyGraphicsOrBetter())
getEntityRenderer().render(getEntity(), tickDelta, matrices, vcp, light, OverlayTexture.DEFAULT_UV);
matrices.pop();
}
Aggregations