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;
}
}
}
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;
}
Aggregations