Search in sources :

Example 1 with AbstractClientPlayerEntity

use of net.minecraft.client.entity.player.AbstractClientPlayerEntity 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)

Aggregations

AbstractClientPlayerEntity (net.minecraft.client.entity.player.AbstractClientPlayerEntity)1 PlayerRenderer (net.minecraft.client.renderer.entity.PlayerRenderer)1 Hand (net.minecraft.util.Hand)1 HandSide (net.minecraft.util.HandSide)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1