Search in sources :

Example 1 with RenderPlayer

use of net.minecraft.client.renderer.entity.RenderPlayer in project Wizardry by TeamWizardry.

the class ClientProxy method init.

@Override
public void init(FMLInitializationEvent event) {
    super.init(event);
    MinecraftForge.EVENT_BUS.register(CapeHandler.instance());
    Minecraft.getMinecraft().getRenderManager().getSkinMap().values().forEach(render -> render.addLayer(new BloodRenderLayer(render)));
    Map<String, RenderPlayer> skinMap = Minecraft.getMinecraft().getRenderManager().getSkinMap();
    RenderPlayer render = skinMap.get("default");
    render.addLayer(new RenderHaloPlayer(render.getMainModel().bipedHead));
    render = skinMap.get("slim");
    render.addLayer(new RenderHaloPlayer(render.getMainModel().bipedHead));
    Map<Class<? extends Entity>, Render<? extends Entity>> map = Minecraft.getMinecraft().getRenderManager().entityRenderMap;
    for (ResourceLocation entity : EntityList.getEntityNameList()) {
        Class<? extends Entity> clazz = EntityList.getClass(entity);
        Render<? extends Entity> entityRenderer = map.get(clazz);
        if (entityRenderer instanceof RenderLiving<?>) {
            ModelBase main = ((RenderLiving<?>) entityRenderer).getMainModel();
            ModelRenderer renderer = null;
            if (main instanceof ModelBiped)
                renderer = ((ModelBiped) main).bipedHead;
            ((RenderLiving<?>) entityRenderer).addLayer(new RenderHaloEntity(renderer));
        }
    }
}
Also used : RenderHaloEntity(com.teamwizardry.wizardry.client.render.item.RenderHaloEntity) Entity(net.minecraft.entity.Entity) Render(net.minecraft.client.renderer.entity.Render) RenderLiving(net.minecraft.client.renderer.entity.RenderLiving) ModelBase(net.minecraft.client.model.ModelBase) RenderHaloEntity(com.teamwizardry.wizardry.client.render.item.RenderHaloEntity) RenderHaloPlayer(com.teamwizardry.wizardry.client.render.item.RenderHaloPlayer) ModelBiped(net.minecraft.client.model.ModelBiped) ModelRenderer(net.minecraft.client.model.ModelRenderer) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) BloodRenderLayer(com.teamwizardry.wizardry.client.render.BloodRenderLayer)

Example 2 with RenderPlayer

use of net.minecraft.client.renderer.entity.RenderPlayer in project Hyperium by HyperiumClient.

the class MemoryHelper method worldEvent.

@InvokeEvent
public void worldEvent(WorldUnloadEvent event) {
    try {
        TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
        Map<ResourceLocation, ITextureObject> mapTextureObjects = ((IMixinTextureManager) textureManager).getMapTextureObjects();
        List<ResourceLocation> removes = new ArrayList<>();
        mapTextureObjects.forEach((key, iTextureObject) -> {
            if (iTextureObject instanceof ThreadDownloadImageData) {
                IImageBuffer imageBuffer = ((IMixinThreadDownloadImageData) iTextureObject).getImageBuffer();
                if (imageBuffer == null)
                    return;
                Class<? extends IImageBuffer> aClass = imageBuffer.getClass();
                // Optifine
                if (aClass.getName().equalsIgnoreCase("CapeImageBuffer")) {
                    removes.add(key);
                }
            }
        });
        removes.forEach(this::deleteSkin);
        // locations.forEach(this::deleteSkin);
        int size = locations.size();
        locations.clear();
        int del = 0;
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        try {
            Method getSkinMap = renderManager.getClass().getMethod("getSkinMap");
            Object invoke = getSkinMap.invoke(renderManager);
            Map<String, RenderPlayer> skinMap = (Map<String, RenderPlayer>) invoke;
            for (RenderPlayer value : skinMap.values()) {
                ModelPlayer mainModel = value.getMainModel();
                Class<?> superClass = mainModel.getClass().getSuperclass();
                for (Field field : superClass.getDeclaredFields()) {
                    field.setAccessible(true);
                    try {
                        Object o = field.get(mainModel);
                        if (o != null) {
                            try {
                                Field entityIn = o.getClass().getSuperclass().getDeclaredField("entityIn");
                                entityIn.setAccessible(true);
                                Object o1 = entityIn.get(o);
                                if (o1 != null) {
                                    entityIn.set(o, null);
                                    del++;
                                }
                            } catch (IllegalAccessException | NoSuchFieldException ignored) {
                            }
                            try {
                                Field clientPlayer = o.getClass().getSuperclass().getDeclaredField("clientPlayer");
                                clientPlayer.setAccessible(true);
                                Object o1 = clientPlayer.get(o);
                                if (o1 != null) {
                                    clientPlayer.set(o, null);
                                    del++;
                                }
                            } catch (IllegalAccessException | NoSuchFieldException ignored) {
                            }
                        }
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
        Hyperium.LOGGER.info("Deleted " + (removes.size() + size + del) + " cosmetic items / skins");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : IMixinThreadDownloadImageData(cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData) ArrayList(java.util.ArrayList) IMixinThreadDownloadImageData(cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData) Field(java.lang.reflect.Field) ResourceLocation(net.minecraft.util.ResourceLocation) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) IMixinTextureManager(cc.hyperium.mixins.client.renderer.texture.IMixinTextureManager) RenderManager(net.minecraft.client.renderer.entity.RenderManager) ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TextureManager(net.minecraft.client.renderer.texture.TextureManager) IMixinTextureManager(cc.hyperium.mixins.client.renderer.texture.IMixinTextureManager) ModelPlayer(net.minecraft.client.model.ModelPlayer) IImageBuffer(net.minecraft.client.renderer.IImageBuffer) ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) Map(java.util.Map) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 3 with RenderPlayer

use of net.minecraft.client.renderer.entity.RenderPlayer in project EnderIO by SleepyTrousers.

the class UpgradeRenderManager method onPlayerRenderPre.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onPlayerRenderPre(RenderPlayerEvent.Pre event) {
    final RenderPlayer renderer = event.getRenderer();
    if (renderer != null && !injected.containsKey(renderer)) {
        UpgradeRenderManager.replaceCapeLayer(renderer);
        renderer.addLayer(new UpgradeRenderDispatcher(renderer));
        injected.put(renderer, null);
    }
}
Also used : RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with RenderPlayer

use of net.minecraft.client.renderer.entity.RenderPlayer in project BloodMagic by WayofTime.

the class ClientProxy method addElytraLayer.

private void addElytraLayer() {
    RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
    try {
        Map<String, RenderPlayer> skinMap = ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, renderManager, "skinMap", "field_178636_l");
        skinMap.get("default").addLayer(new LayerBloodElytra(skinMap.get("default")));
        skinMap.get("slim").addLayer(new LayerBloodElytra(skinMap.get("slim")));
        BMLog.DEBUG.info("Elytra layer added");
    } catch (Exception e) {
        BMLog.DEBUG.error("Failed to set custom Elytra Layer for Elytra Living Armour Upgrade: {}", e.getMessage());
    }
}
Also used : LayerBloodElytra(WayofTime.bloodmagic.client.render.LayerBloodElytra) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Example 5 with RenderPlayer

use of net.minecraft.client.renderer.entity.RenderPlayer in project Galacticraft by micdoodle8.

the class ClientProxyCore method postInit.

@Override
public void postInit(FMLPostInitializationEvent event) {
    ClientProxyCore.registerInventoryTabs();
    ClientProxyCore.addVariants();
    ItemSchematic.registerTextures();
    MinecraftForge.EVENT_BUS.register(new TabRegistry());
    if (!CompatibilityManager.RenderPlayerAPILoaded) {
        try {
            Field field = RenderManager.class.getDeclaredField(GCCoreUtil.isDeobfuscated() ? "playerRenderer" : "field_178637_m");
            field.setAccessible(true);
            field.set(FMLClientHandler.instance().getClient().getRenderManager(), new RenderPlayerGC());
            field = RenderManager.class.getDeclaredField(GCCoreUtil.isDeobfuscated() ? "skinMap" : "field_178636_l");
            field.setAccessible(true);
            Map<String, RenderPlayer> skinMap = (Map<String, RenderPlayer>) field.get(FMLClientHandler.instance().getClient().getRenderManager());
            skinMap.put("default", new RenderPlayerGC(skinMap.get("default"), false));
            skinMap.put("slim", new RenderPlayerGC(skinMap.get("slim"), true));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    try {
        Field ftc = Minecraft.getMinecraft().getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "mcMusicTicker" : "field_147126_aw");
        ftc.setAccessible(true);
        ftc.set(Minecraft.getMinecraft(), new MusicTickerGC(Minecraft.getMinecraft()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) TabRegistry(micdoodle8.mods.galacticraft.api.client.tabs.TabRegistry) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) MusicTickerGC(micdoodle8.mods.galacticraft.core.client.sounds.MusicTickerGC) RenderManager(net.minecraft.client.renderer.entity.RenderManager) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) IOException(java.io.IOException)

Aggregations

RenderPlayer (net.minecraft.client.renderer.entity.RenderPlayer)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 RenderManager (net.minecraft.client.renderer.entity.RenderManager)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)3 Field (java.lang.reflect.Field)2 ModelBiped (net.minecraft.client.model.ModelBiped)2 Render (net.minecraft.client.renderer.entity.Render)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 FakePlayer (net.minecraftforge.common.util.FakePlayer)2 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)2 EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)2 LayerBloodElytra (WayofTime.bloodmagic.client.render.LayerBloodElytra)1 InvokeEvent (cc.hyperium.event.InvokeEvent)1 IMixinThreadDownloadImageData (cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData)1 IMixinTextureManager (cc.hyperium.mixins.client.renderer.texture.IMixinTextureManager)1 BloodRenderLayer (com.teamwizardry.wizardry.client.render.BloodRenderLayer)1 RenderHaloEntity (com.teamwizardry.wizardry.client.render.item.RenderHaloEntity)1 RenderHaloPlayer (com.teamwizardry.wizardry.client.render.item.RenderHaloPlayer)1