Search in sources :

Example 6 with Hand

use of net.minecraft.util.Hand in project AgriCraft by AgriCraft.

the class MagnifyingGlassViewHandler method onPlayerRender.

@SuppressWarnings("unused")
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerRender(RenderPlayerEvent.Pre event) {
    if (this.isActive()) {
        PlayerRenderer renderer = event.getRenderer();
        PlayerModel<AbstractClientPlayerEntity> model = renderer.getEntityModel();
        Hand hand = this.getActiveHand();
        HandSide side = Minecraft.getInstance().gameSettings.mainHand;
        if ((hand == Hand.MAIN_HAND && side == HandSide.RIGHT) || (hand == Hand.OFF_HAND && side == HandSide.LEFT)) {
            model.rightArmPose = BipedModel.ArmPose.BLOCK;
            model.leftArmPose = BipedModel.ArmPose.EMPTY;
        } else if ((hand == Hand.MAIN_HAND && side == HandSide.LEFT) || (hand == Hand.OFF_HAND && side == HandSide.RIGHT)) {
            model.leftArmPose = BipedModel.ArmPose.BLOCK;
            model.rightArmPose = BipedModel.ArmPose.EMPTY;
        }
    }
}
Also used : PlayerRenderer(net.minecraft.client.renderer.entity.PlayerRenderer) HandSide(net.minecraft.util.HandSide) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) Hand(net.minecraft.util.Hand) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 7 with Hand

use of net.minecraft.util.Hand in project AgriCraft by AgriCraft.

the class ItemSeedBag method onItemUse.

@Nonnull
@Override
public ActionResultType onItemUse(@Nonnull ItemUseContext context) {
    Contents contents = this.getContents(context.getItem());
    if (this.isActivated(context.getItem())) {
        Hand hand = context.getHand();
        PlayerEntity player = context.getPlayer();
        if (hand == Hand.OFF_HAND) {
            // From off hand: interact with main to insert / extract seeds
            if (player != null && this.attemptExtractOrInsertSeed(player, contents)) {
                return ActionResultType.SUCCESS;
            }
        } else {
            // From main hand: interact with the world to plant the seed
            if (this.attemptPlantSeed(context.getWorld(), context.getPos(), contents, player)) {
                return ActionResultType.SUCCESS;
            }
        }
    }
    return ActionResultType.PASS;
}
Also used : CapabilitySeedBagContents(com.infinityraider.agricraft.capability.CapabilitySeedBagContents) Hand(net.minecraft.util.Hand) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Nonnull(javax.annotation.Nonnull)

Aggregations

Hand (net.minecraft.util.Hand)7 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 ItemStack (net.minecraft.item.ItemStack)4 BlockPos (net.minecraft.util.math.BlockPos)4 World (net.minecraft.world.World)4 BlockState (net.minecraft.block.BlockState)2 Direction (net.minecraft.util.Direction)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 Sets (com.google.common.collect.Sets)1 AgriCraft (com.infinityraider.agricraft.AgriCraft)1 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)1 IAgriSeedItem (com.infinityraider.agricraft.api.v1.content.items.IAgriSeedItem)1 CapabilitySeedBagContents (com.infinityraider.agricraft.capability.CapabilitySeedBagContents)1 TileEntitySeedAnalyzer (com.infinityraider.agricraft.content.core.TileEntitySeedAnalyzer)1 Set (java.util.Set)1 Nonnull (javax.annotation.Nonnull)1 Block (net.minecraft.block.Block)1 Blocks (net.minecraft.block.Blocks)1 FarmlandBlock (net.minecraft.block.FarmlandBlock)1 AbstractClientPlayerEntity (net.minecraft.client.entity.player.AbstractClientPlayerEntity)1