Search in sources :

Example 1 with BolloomBalloonItem

use of com.minecraftabnormals.endergetic.common.items.BolloomBalloonItem in project endergetic by team-abnormals.

the class BoatEntityMixin method addBalloonAttachingInteraction.

@Inject(at = @At("HEAD"), method = "interact", cancellable = true)
private void addBalloonAttachingInteraction(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResultType> info) {
    ItemStack stack = player.getItemInHand(hand);
    Entity boat = this.getEntity();
    Item item = stack.getItem();
    if (item instanceof BolloomBalloonItem && BolloomBalloonItem.canAttachBalloonToTarget(boat)) {
        player.swing(hand, true);
        if (!boat.level.isClientSide) {
            BolloomBalloonItem.attachToEntity(((BolloomBalloonItem) item).getBalloonColor(), boat);
        }
        if (!player.isCreative())
            stack.shrink(1);
        info.setReturnValue(ActionResultType.CONSUME);
    }
}
Also used : BoatEntity(net.minecraft.entity.item.BoatEntity) Entity(net.minecraft.entity.Entity) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Item(net.minecraft.item.Item) BolloomBalloonItem(com.minecraftabnormals.endergetic.common.items.BolloomBalloonItem) BolloomBalloonItem(com.minecraftabnormals.endergetic.common.items.BolloomBalloonItem) ItemStack(net.minecraft.item.ItemStack) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

BolloomBalloonEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)1 BolloomBalloonItem (com.minecraftabnormals.endergetic.common.items.BolloomBalloonItem)1 Entity (net.minecraft.entity.Entity)1 BoatEntity (net.minecraft.entity.item.BoatEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1