Search in sources :

Example 1 with CarrierComponent

use of me.steven.carrier.api.CarrierComponent 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);
    }
}
Also used : CarryingData(me.steven.carrier.api.CarryingData) CarrierComponent(me.steven.carrier.api.CarrierComponent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with CarrierComponent

use of me.steven.carrier.api.CarrierComponent 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();
    }
}
Also used : CarryingData(me.steven.carrier.api.CarryingData) CarrierComponent(me.steven.carrier.api.CarrierComponent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with CarrierComponent

use of me.steven.carrier.api.CarrierComponent in project Carrier by GabrielOlvH.

the class MixinPlayerModel method carrier_setAngles.

@Inject(method = "setAngles", at = @At("RETURN"))
private void carrier_setAngles(LivingEntity livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
    if (livingEntity instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) livingEntity;
        CarrierComponent carrier = Carrier.HOLDER.get(player);
        if (carrier.getCarryingData() == null)
            return;
        float pitch = 0.4f;
        if (player.isSneaking())
            pitch = 0.8f;
        rightArm.pitch = -pitch;
        leftArm.pitch = -pitch;
        rightSleeve.pitch = -pitch;
        leftSleeve.pitch = -pitch;
    }
}
Also used : CarrierComponent(me.steven.carrier.api.CarrierComponent) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with CarrierComponent

use of me.steven.carrier.api.CarrierComponent 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());
        }
    }
}
Also used : CarryingData(me.steven.carrier.api.CarryingData) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CarrierComponent(me.steven.carrier.api.CarrierComponent)

Example 5 with CarrierComponent

use of me.steven.carrier.api.CarrierComponent in project Carrier by GabrielOlvH.

the class MixinGameRenderer method carrier_renderCarrying.

@Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;renderHand(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/Camera;F)V"), cancellable = true)
private void carrier_renderCarrying(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) {
    ClientPlayerEntity player = MinecraftClient.getInstance().player;
    CarrierComponent carrier = Carrier.HOLDER.get(player);
    CarryingData carrying = carrier.getCarryingData();
    if (carrying == null)
        return;
    Carriable<?> carriable = CarriableRegistry.INSTANCE.get(carrying.getType());
    if (carriable != null) {
        ci.cancel();
    }
}
Also used : CarryingData(me.steven.carrier.api.CarryingData) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) CarrierComponent(me.steven.carrier.api.CarrierComponent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

CarrierComponent (me.steven.carrier.api.CarrierComponent)6 CarryingData (me.steven.carrier.api.CarryingData)5 Inject (org.spongepowered.asm.mixin.injection.Inject)5 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1