Search in sources :

Example 6 with CarryingData

use of me.steven.carrier.api.CarryingData 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;
}
Also used : CarryingData(me.steven.carrier.api.CarryingData) BlockState(net.minecraft.block.BlockState) AccessorBlockEntity(me.steven.carrier.mixin.AccessorBlockEntity) BlockEntity(net.minecraft.block.entity.BlockEntity) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with CarryingData

use of me.steven.carrier.api.CarryingData 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)

Example 8 with CarryingData

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

the class MixinPlayerEntity method b.

@Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true)
private void b(CallbackInfoReturnable<Boolean> cir) {
    CarrierComponent carrier = Carrier.HOLDER.get(this);
    CarryingData carrying = carrier.getCarryingData();
    if (carrying != null) {
        cir.setReturnValue(false);
    }
}
Also used : CarryingData(me.steven.carrier.api.CarryingData) CarrierComponent(me.steven.carrier.api.CarrierComponent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

CarryingData (me.steven.carrier.api.CarryingData)8 CarrierComponent (me.steven.carrier.api.CarrierComponent)5 Inject (org.spongepowered.asm.mixin.injection.Inject)4 AccessorBlockEntity (me.steven.carrier.mixin.AccessorBlockEntity)3 BlockState (net.minecraft.block.BlockState)3 BlockEntity (net.minecraft.block.entity.BlockEntity)3 NotNull (org.jetbrains.annotations.NotNull)3 NbtCompound (net.minecraft.nbt.NbtCompound)2 BlockPos (net.minecraft.util.math.BlockPos)2 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1 ItemPlacementContext (net.minecraft.item.ItemPlacementContext)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1 BlockHitResult (net.minecraft.util.hit.BlockHitResult)1 Vec3d (net.minecraft.util.math.Vec3d)1