Search in sources :

Example 1 with NectarItem

use of nomble.beebuddy.item.NectarItem in project beebuddy by queenofthebees.

the class BeeEntityMixin method tame.

@Override
protected void tame(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cbir) {
    ItemStack stack = player.getStackInHand(hand);
    boolean friend = beebuddy$getFriend().map(player.getUuid()::equals).orElse(false);
    if (!this.world.isClient) {
        if (stack.getItem() == Items.HONEY_BOTTLE) {
            if (friend && this.getHealth() < this.getMaxHealth()) {
                if (!player.abilities.creativeMode) {
                    stack.decrement(1);
                }
                this.heal(this.getMaxHealth());
                cbir.setReturnValue(ActionResult.SUCCESS);
            } else if (!friend && !beebuddy$hasFriend()) {
                if (!player.abilities.creativeMode) {
                    stack.decrement(1);
                    ItemStack g = new ItemStack(Items.GLASS_BOTTLE);
                    if (stack.isEmpty()) {
                        player.setStackInHand(hand, g);
                    } else if (!player.inventory.insertStack(g)) {
                        player.dropItem(g, false);
                    }
                }
                if (this.random.nextInt(4) == 0) {
                    beebuddy$setFriend(Optional.of(player.getUuid()));
                    if (player instanceof ServerPlayerEntity) {
                        ServerPlayerEntity p = (ServerPlayerEntity) player;
                        Criteria.TAME_ANIMAL.trigger(p, (BeeEntity) (Object) this);
                    }
                    beebuddy$friendify();
                    this.world.sendEntityStatus(this, (byte) 7);
                } else {
                    this.world.sendEntityStatus(this, (byte) 6);
                }
                cbir.setReturnValue(ActionResult.SUCCESS);
            }
        } else if (stack.getItem() instanceof NectarItem) {
            NectarItem n = (NectarItem) stack.getItem();
            if (friend || !beebuddy$hasFriend()) {
                if (!player.abilities.creativeMode) {
                    stack.decrement(1);
                }
                beebuddy$setNectarType(n.getType());
                cbir.setReturnValue(ActionResult.SUCCESS);
            }
        } else {
            beebuddy$setSitting(!beebuddy$isSitting());
            cbir.setReturnValue(ActionResult.SUCCESS);
        }
    } else if (friend || stack.getItem() == Items.HONEY_BOTTLE) {
        cbir.setReturnValue(ActionResult.CONSUME);
    } else if (stack.getItem() instanceof NectarItem) {
        cbir.setReturnValue(ActionResult.CONSUME);
    }
}
Also used : BeeEntity(net.minecraft.entity.passive.BeeEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) NectarItem(nomble.beebuddy.item.NectarItem) ItemStack(net.minecraft.item.ItemStack)

Example 2 with NectarItem

use of nomble.beebuddy.item.NectarItem in project beebuddy by queenofthebees.

the class BeeBuddy method onInitialize.

@Override
public void onInitialize() {
    for (String s : new String[] { "ace", "agender", "aro", "bi", "demiboy", "demigirl", "gay", "genderfluid", "genderqueer", "honeyed", "lesbian", "mlm", "nonbinary", "omni", "pan", "poly", "trans", "xenogender" }) {
        Item it = new NectarItem(s, new Item.Settings().group(ItemGroup.MISC));
        Identifier id = new Identifier("beebuddy", s + "_nectar");
        // eh, we aren't really using item references to need to save em
        Registry.register(Registry.ITEM, id, it);
    }
    LOGGER.info("bzzzz!");
}
Also used : Item(net.minecraft.item.Item) NectarItem(nomble.beebuddy.item.NectarItem) Identifier(net.minecraft.util.Identifier) NectarItem(nomble.beebuddy.item.NectarItem)

Aggregations

NectarItem (nomble.beebuddy.item.NectarItem)2 BeeEntity (net.minecraft.entity.passive.BeeEntity)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1 Identifier (net.minecraft.util.Identifier)1