use of me.steven.carrier.api.CarryingData in project Carrier by GabrielOlvH.
the class MixinPlayerRenderer method carrier_renderCarrying.
@Inject(method = "render", at = @At("TAIL"))
private void carrier_renderCarrying(AbstractClientPlayerEntity player, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light, CallbackInfo ci) {
CarrierComponent carrier = Carrier.HOLDER.get(player);
CarryingData carrying = carrier.getCarryingData();
if (carrying == null)
return;
Carriable<?> carriable = CarriableRegistry.INSTANCE.get(carrying.getType());
if (carriable != null) {
carriable.render(player, carrier, matrices, vertexConsumerProvider, tickDelta, light);
}
}
use of me.steven.carrier.api.CarryingData in project Carrier by GabrielOlvH.
the class MixinPlayerEntity method a.
@Inject(method = "updateSwimming", at = @At("HEAD"), cancellable = true)
private void a(CallbackInfo ci) {
CarrierComponent carrier = Carrier.HOLDER.get(this);
CarryingData carrying = carrier.getCarryingData();
if (carrying != null) {
setSwimming(false);
ci.cancel();
}
}
use of me.steven.carrier.api.CarryingData 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.api.CarryingData in project Carrier by GabrielOlvH.
the class ServerWorldTickCallback method onEndTick.
@Override
public void onEndTick(ServerWorld serverWorld) {
for (ServerPlayerEntity player : serverWorld.getPlayers()) {
CarrierComponent carrier = Carrier.HOLDER.get(player);
CarryingData carrying = carrier.getCarryingData();
if (carrying != null) {
Config config = Carrier.CONFIG;
if (config.getSlownessLevel() > 0)
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 20, config.getSlownessLevel() - 1));
if (config.getHungerExhaustion() > 0)
player.getHungerManager().addExhaustion(config.getHungerExhaustion());
}
}
}
use of me.steven.carrier.api.CarryingData 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;
}
Aggregations