Search in sources :

Example 1 with PoppetItem

use of moriyashiine.bewitchment.api.item.PoppetItem in project bewitchment by MoriyaShiine.

the class ItemEntityMixin method bewitchment$stopPoppetsFromFloating.

@Inject(method = "applyWaterBuoyancy", at = @At("HEAD"), cancellable = true)
private void bewitchment$stopPoppetsFromFloating(CallbackInfo ci) {
    if (getStack().getItem() instanceof PoppetItem) {
        Vec3d velocity = getVelocity();
        setVelocity(velocity.x * 0.99, velocity.y * 0.9, velocity.z * 0.99);
        ci.cancel();
    }
}
Also used : PoppetItem(moriyashiine.bewitchment.api.item.PoppetItem) Vec3d(net.minecraft.util.math.Vec3d) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with PoppetItem

use of moriyashiine.bewitchment.api.item.PoppetItem in project bewitchment by MoriyaShiine.

the class PoppetShelfBlockEntity method onUse.

public void onUse(World world, BlockPos pos, PlayerEntity player, Hand hand) {
    BWWorldState worldState = BWWorldState.get(world);
    ItemStack stack = player.getStackInHand(hand);
    if (stack.getItem() instanceof PoppetItem) {
        int firstEmpty = getFirstEmptySlot();
        if (firstEmpty != -1) {
            DefaultedList<ItemStack> inventory = worldState.poppetShelves.get(pos.asLong());
            inventory.set(firstEmpty, stack.split(1));
            sync();
            worldState.markDirty();
        }
    } else {
        DefaultedList<ItemStack> inventory = worldState.poppetShelves.get(pos.asLong());
        if (inventory != null) {
            ItemScatterer.spawn(world, pos, inventory);
            worldState.poppetShelves.remove(pos.asLong());
            sync();
            worldState.markDirty();
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) PoppetItem(moriyashiine.bewitchment.api.item.PoppetItem) BWWorldState(moriyashiine.bewitchment.common.world.BWWorldState)

Aggregations

PoppetItem (moriyashiine.bewitchment.api.item.PoppetItem)2 BWWorldState (moriyashiine.bewitchment.common.world.BWWorldState)1 ItemStack (net.minecraft.item.ItemStack)1 Vec3d (net.minecraft.util.math.Vec3d)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1