Search in sources :

Example 1 with ModelPlayer

use of net.minecraft.client.model.ModelPlayer 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 2 with ModelPlayer

use of net.minecraft.client.model.ModelPlayer in project Galacticraft by micdoodle8.

the class ModelBipedGC method setRotationAngles.

public static void setRotationAngles(ModelBiped biped, float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
    if (!(par7Entity instanceof EntityPlayer))
        return;
    final EntityPlayer player = (EntityPlayer) par7Entity;
    final ItemStack currentItemStack = player.inventory.getCurrentItem();
    final float floatPI = 3.1415927F;
    if (!par7Entity.onGround && par7Entity.worldObj.provider instanceof IGalacticraftWorldProvider && par7Entity.ridingEntity == null && !(currentItemStack != null && currentItemStack.getItem() instanceof IHoldableItem)) {
        float speedModifier = 0.1162F * 2;
        float angularSwingArm = MathHelper.cos(par1 * (speedModifier / 2));
        float rightMod = biped.heldItemRight != 0 ? 1 : 2;
        biped.bipedRightArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * rightMod * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
        biped.bipedRightArm.rotateAngleX += -angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX += angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * 1.4F * par2;
        biped.bipedLeftLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2 + floatPI) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2) * 1.4F * par2;
    }
    PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
    if (gearData != null) {
        if (gearData.getParachute() != null) {
            // Parachute is equipped
            biped.bipedLeftArm.rotateAngleX += floatPI;
            biped.bipedLeftArm.rotateAngleZ += floatPI / 10;
            biped.bipedRightArm.rotateAngleX += floatPI;
            biped.bipedRightArm.rotateAngleZ -= floatPI / 10;
        }
    }
    if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof IHoldableItem && !(player.ridingEntity instanceof ICameraZoomEntity)) {
        Item heldItem = player.inventory.getCurrentItem().getItem();
        IHoldableItem holdableItem = (IHoldableItem) heldItem;
        IHoldableItemCustom holdableItemCustom = heldItem instanceof IHoldableItemCustom ? (IHoldableItemCustom) heldItem : null;
        if (holdableItem.shouldHoldLeftHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getLeftHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, floatPI / 10.0F);
            }
            biped.bipedLeftArm.rotateAngleX = angle.floatX();
            biped.bipedLeftArm.rotateAngleY = angle.floatY();
            biped.bipedLeftArm.rotateAngleZ = angle.floatZ();
        }
        if (holdableItem.shouldHoldRightHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getRightHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, (float) -Math.PI / 10.0F);
            }
            biped.bipedRightArm.rotateAngleX = angle.floatX();
            biped.bipedRightArm.rotateAngleY = angle.floatY();
            biped.bipedRightArm.rotateAngleZ = angle.floatZ();
        }
    }
    final List<?> l = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.fromBounds(player.posX - 20, 0, player.posZ - 20, player.posX + 20, 200, player.posZ + 20));
    for (int i = 0; i < l.size(); i++) {
        final Entity e = (Entity) l.get(i);
        if (e instanceof EntityTieredRocket) {
            final EntityTieredRocket ship = (EntityTieredRocket) e;
            if (ship.riddenByEntity != null && !(ship.riddenByEntity).equals(player) && (ship.getLaunched() || ship.timeUntilLaunch < 390)) {
                biped.bipedRightArm.rotateAngleZ -= floatPI / 8F + MathHelper.sin(par3 * 0.9F) * 0.2F;
                biped.bipedRightArm.rotateAngleX = floatPI;
                break;
            }
        }
    }
    if (player.isPlayerSleeping() && GalacticraftCore.isPlanetsLoaded) {
        RenderPlayerGC.RotatePlayerEvent event = new RenderPlayerGC.RotatePlayerEvent((AbstractClientPlayer) player);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.vanillaOverride && (event.shouldRotate == null || event.shouldRotate)) {
            biped.bipedHead.rotateAngleX = (float) (20.0F - Math.sin(player.ticksExisted / 10.0F) / 7.0F);
            biped.bipedHead.rotateAngleY = 0.0F;
            biped.bipedHead.rotateAngleZ = 0.0F;
            biped.bipedLeftArm.rotateAngleX = 0.0F;
            biped.bipedLeftArm.rotateAngleY = 0.0F;
            biped.bipedLeftArm.rotateAngleZ = 0.0F;
            biped.bipedRightArm.rotateAngleX = 0.0F;
            biped.bipedRightArm.rotateAngleY = 0.0F;
            biped.bipedRightArm.rotateAngleZ = 0.0F;
        }
    }
    if (biped instanceof ModelPlayer) {
        ModelBiped.copyModelAngles(biped.bipedHead, ((ModelPlayer) biped).bipedHeadwear);
    }
}
Also used : Entity(net.minecraft.entity.Entity) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) RenderPlayerGC(micdoodle8.mods.galacticraft.core.client.render.entities.RenderPlayerGC) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IHoldableItemCustom(micdoodle8.mods.galacticraft.api.item.IHoldableItemCustom) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Item(net.minecraft.item.Item) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) ModelPlayer(net.minecraft.client.model.ModelPlayer) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 3 with ModelPlayer

use of net.minecraft.client.model.ModelPlayer in project Wizardry by TeamWizardry.

the class BloodRenderLayer method setModelVisibilities.

private void setModelVisibilities(AbstractClientPlayer clientPlayer) {
    ModelPlayer modelplayer = render.getMainModel();
    if (clientPlayer.isSpectator()) {
        modelplayer.setVisible(true);
        modelplayer.bipedHead.showModel = true;
        modelplayer.bipedHeadwear.showModel = true;
    } else {
        ItemStack stackMain = clientPlayer.getHeldItemMainhand();
        ItemStack stackOff = clientPlayer.getHeldItemOffhand();
        modelplayer.setVisible(false);
        modelplayer.bipedHeadwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.HAT);
        modelplayer.bipedBodyWear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.JACKET);
        modelplayer.bipedLeftLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_PANTS_LEG);
        modelplayer.bipedRightLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_PANTS_LEG);
        modelplayer.bipedLeftArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_SLEEVE);
        modelplayer.bipedRightArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE);
        modelplayer.isSneak = clientPlayer.isSneaking();
        ArmPose poseMain = ArmPose.EMPTY;
        if (!stackMain.isEmpty()) {
            poseMain = ArmPose.ITEM;
            if (clientPlayer.getItemInUseCount() > 0) {
                EnumAction enumaction = stackMain.getItemUseAction();
                if (enumaction == EnumAction.BLOCK) {
                    poseMain = ArmPose.BLOCK;
                } else if (enumaction == EnumAction.BOW) {
                    poseMain = ArmPose.BOW_AND_ARROW;
                }
            }
        }
        ArmPose poseOff = ArmPose.EMPTY;
        if (!stackOff.isEmpty()) {
            poseOff = ArmPose.ITEM;
            if (clientPlayer.getItemInUseCount() > 0) {
                EnumAction enumaction1 = stackOff.getItemUseAction();
                if (enumaction1 == EnumAction.BLOCK) {
                    poseOff = ArmPose.BLOCK;
                }
            }
        }
        if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) {
            modelplayer.rightArmPose = poseMain;
            modelplayer.leftArmPose = poseOff;
        } else {
            modelplayer.rightArmPose = poseOff;
            modelplayer.leftArmPose = poseMain;
        }
    }
}
Also used : ModelPlayer(net.minecraft.client.model.ModelPlayer) ItemStack(net.minecraft.item.ItemStack) ArmPose(net.minecraft.client.model.ModelBiped.ArmPose) EnumAction(net.minecraft.item.EnumAction)

Example 4 with ModelPlayer

use of net.minecraft.client.model.ModelPlayer in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class LayerRendererDrive method doRenderLayer.

@Override
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/armour/Valor.png");
    String drive = entitylivingbaseIn.getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName();
    switch(drive) {
        case Strings.Form_Valor:
            texture = new ResourceLocation(Reference.MODID, "textures/armour/Valor.png");
            break;
        case Strings.Form_Wisdom:
            texture = new ResourceLocation(Reference.MODID, "textures/armour/Wisdom.png");
            break;
        case Strings.Form_Limit:
            texture = new ResourceLocation(Reference.MODID, "textures/armour/Limit.png");
            break;
        case Strings.Form_Master:
            texture = new ResourceLocation(Reference.MODID, "textures/armour/Master.png");
            break;
        case Strings.Form_Final:
            texture = new ResourceLocation(Reference.MODID, "textures/armour/Final.png");
            break;
        case Strings.Form_Anti:
            texture = new ResourceLocation(Reference.MODID, "textures/armour/Anti.png");
            break;
    }
    if (entitylivingbaseIn.getCapability(ModCapabilities.DRIVE_STATE, null).getInDrive()) {
        ModelPlayer model = renderPlayer.getMainModel();
        model.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entitylivingbaseIn);
        if (model.isSneak) {
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }
        renderPlayer.bindTexture(texture);
        if (drive.equals(Strings.Form_Anti)) {
            GlStateManager.color(1, 1, 1, 0.95f);
            GlStateManager.enableBlend();
            model.bipedHeadwear.render(scale);
        }
        model.bipedBodyWear.render(scale);
        model.bipedLeftArmwear.render(scale);
        model.bipedRightArmwear.render(scale);
        model.bipedLeftLegwear.render(scale);
        model.bipedRightLegwear.render(scale);
    }
}
Also used : ModelPlayer(net.minecraft.client.model.ModelPlayer) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 5 with ModelPlayer

use of net.minecraft.client.model.ModelPlayer in project Hyperium by HyperiumClient.

the class HyperiumRenderPlayer method onUpdateTimer.

public void onUpdateTimer() {
    ModelPlayer modelplayer = parent.getMainModel();
    modelplayer.isRiding = modelplayer.isSneak = false;
}
Also used : ModelPlayer(net.minecraft.client.model.ModelPlayer)

Aggregations

ModelPlayer (net.minecraft.client.model.ModelPlayer)5 ItemStack (net.minecraft.item.ItemStack)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 InvokeEvent (cc.hyperium.event.InvokeEvent)1 IMixinThreadDownloadImageData (cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData)1 IMixinTextureManager (cc.hyperium.mixins.client.renderer.texture.IMixinTextureManager)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ICameraZoomEntity (micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity)1 IHoldableItem (micdoodle8.mods.galacticraft.api.item.IHoldableItem)1 IHoldableItemCustom (micdoodle8.mods.galacticraft.api.item.IHoldableItemCustom)1 EntityTieredRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket)1 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 RenderPlayerGC (micdoodle8.mods.galacticraft.core.client.render.entities.RenderPlayerGC)1 PlayerGearData (micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)1 ArmPose (net.minecraft.client.model.ModelBiped.ArmPose)1