Search in sources :

Example 1 with AdvancedAbstractClientPlayerEntity

use of de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity in project BudschieMorphMod by Budschie.

the class RenderHandler method onMorphInit.

@SubscribeEvent
public static void onMorphInit(InitializeMorphEntityEvent event) {
    if (event.getPlayer() == Minecraft.getInstance().player)
        event.getMorphEntity().setCustomNameVisible(false);
    if (event.getMorphEntity() instanceof AbstractClientPlayerEntity) {
        AbstractClientPlayerEntity entity = (AbstractClientPlayerEntity) event.getMorphEntity();
        // WTF?!?
        entity.setPrimaryHand(event.getPlayer().getPrimaryHand() == HandSide.LEFT ? HandSide.RIGHT : HandSide.LEFT);
    }
    if (event.getMorphEntity() instanceof AdvancedAbstractClientPlayerEntity) {
        AdvancedAbstractClientPlayerEntity advanced = (AdvancedAbstractClientPlayerEntity) event.getMorphEntity();
        // I LOVE lambdas!
        advanced.setIsWearing(part -> event.getPlayer().isWearing(part));
    }
    if (event.getMorphEntity() instanceof MobEntity) {
        if (event.getMorphEntity() instanceof AbstractSkeletonEntity)
            ((MobEntity) event.getMorphEntity()).setLeftHanded(event.getPlayer().getPrimaryHand() == HandSide.RIGHT);
        else
            ((MobEntity) event.getMorphEntity()).setLeftHanded(event.getPlayer().getPrimaryHand() == HandSide.LEFT);
    }
}
Also used : AdvancedAbstractClientPlayerEntity(de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) AdvancedAbstractClientPlayerEntity(de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity) AbstractSkeletonEntity(net.minecraft.entity.monster.AbstractSkeletonEntity) MobEntity(net.minecraft.entity.MobEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with AdvancedAbstractClientPlayerEntity

use of de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity in project BudschieMorphMod by Budschie.

the class ClientSetup method onClientSetup.

@SubscribeEvent
public static void onClientSetup(final FMLClientSetupEvent event) {
    RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.MORPH_ENTITY.get(), manager -> new MorphEntityRenderer(manager));
    ClientRegistry.registerKeyBinding(USE_ABILITY_KEY);
    ClientRegistry.registerKeyBinding(SCROLL_DOWN_MORPH_UI);
    ClientRegistry.registerKeyBinding(SCROLL_UP_MORPH_UI);
    ClientRegistry.registerKeyBinding(SCROLL_LEFT_MORPH_UI);
    ClientRegistry.registerKeyBinding(SCROLL_RIGHT_MORPH_UI);
    ClientRegistry.registerKeyBinding(TOGGLE_MORPH_UI);
    ClientRegistry.registerKeyBinding(TOGGLE_MORPH_FAVOURITE);
    ClientRegistry.registerKeyBinding(NEXT_MORPH_UI);
    ClientRegistry.registerKeyBinding(PREVIOUS_MORPH_UI);
    ClientRegistry.registerKeyBinding(MORPH_UI);
    UglyHackThatDoesntWork.thisisstupid = (gameProfile, world) -> {
        AdvancedAbstractClientPlayerEntity entity = new AdvancedAbstractClientPlayerEntity((ClientWorld) world, gameProfile);
        Minecraft.getInstance().getSkinManager().loadProfileTextures(gameProfile, (type, resourceLocation, texture) -> {
            if (type == Type.CAPE) {
                entity.capeResourceLocation = Minecraft.getInstance().getSkinManager().loadSkin(texture, type);
                ;
            } else if (type == Type.SKIN) {
                entity.skinResourceLocation = Minecraft.getInstance().getSkinManager().loadSkin(texture, type);
            } else if (type == Type.ELYTRA) {
                entity.elytraResourceLocation = Minecraft.getInstance().getSkinManager().loadSkin(texture, type);
            }
        }, true);
        return entity;
    };
}
Also used : AdvancedAbstractClientPlayerEntity(de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity) MorphEntityRenderer(de.budschie.bmorph.entity.rendering.MorphEntityRenderer) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

AdvancedAbstractClientPlayerEntity (de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 MorphEntityRenderer (de.budschie.bmorph.entity.rendering.MorphEntityRenderer)1 AbstractClientPlayerEntity (net.minecraft.client.entity.player.AbstractClientPlayerEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 AbstractSkeletonEntity (net.minecraft.entity.monster.AbstractSkeletonEntity)1