From 59263e1ad9faa56271c5a3b1712260c25046bc92 Mon Sep 17 00:00:00 2001 From: KAMKEEL Date: Fri, 30 Apr 2021 02:43:35 -0400 Subject: [PATCH] Fixed Entity Modeling! --- src/main/java/noppes/npcs/CustomNpcs.java | 1 - .../java/noppes/npcs/client/ClientProxy.java | 3 - .../client/gui/model/GuiCreationScreen.java | 2 - .../noppes/npcs/client/model/ModelMPM.java | 69 ++++++++++++++---- .../npcs/client/model/ModelNPCMale.java | 73 +++++++++++++------ .../renderer/ImageBufferDownloadAlt.java | 20 +---- .../npcs/client/renderer/RenderCustomNpc.java | 9 +-- .../client/renderer/RenderNPCHumanMale.java | 50 ++----------- .../client/renderer/RenderNPCInterface.java | 1 - .../noppes/npcs/entity/EntityCustomNpc64.java | 19 ----- 10 files changed, 110 insertions(+), 137 deletions(-) delete mode 100644 src/main/java/noppes/npcs/entity/EntityCustomNpc64.java diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index ba3fbfe13..3d843ffe4 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -201,7 +201,6 @@ public class CustomNpcs { registerNpc(EntityNpcDragon.class, "NpcDragon"); registerNpc(EntityNPCEnderman.class, "npcEnderman"); registerNpc(EntityNPCGolem.class, "npcGolem"); - registerNpc(EntityCustomNpc64.class, "CustomNpc64"); registerNpc(EntityCustomNpc.class, "CustomNpc"); diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index d1cdc4543..150e6e342 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -181,10 +181,7 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerEntityRenderingHandler(EntityNpcSlime.class, new RenderNpcSlime(new ModelNpcSlime(16), new ModelNpcSlime(0), 0.25F)); RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile()); - // Changes Made Here: RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc()); - RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc64.class, new RenderCustomNpc(false)); // False for Steve - // RenderingRegistry.registerEntityRenderingHandler(EntityNPCAlex.class, new RenderCustomNpc(true)); // False for Steve RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale( diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 5a9db8824..a4ef5c218 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -32,7 +32,6 @@ import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.PixelmonHelper; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityFakeLiving; -import noppes.npcs.entity.EntityCustomNpc64; import noppes.npcs.entity.EntityNPCInterface; public class GuiCreationScreen extends GuiModelInterface implements ICustomScrollListener{ @@ -63,7 +62,6 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol } catch (NoSuchMethodException e) { } } - data.put("CustomNPC64", EntityCustomNpc64.class); list = new ArrayList(data.keySet()); Collections.sort(list,String.CASE_INSENSITIVE_ORDER); } diff --git a/src/main/java/noppes/npcs/client/model/ModelMPM.java b/src/main/java/noppes/npcs/client/model/ModelMPM.java index 70b8a721f..613e7b7e5 100644 --- a/src/main/java/noppes/npcs/client/model/ModelMPM.java +++ b/src/main/java/noppes/npcs/client/model/ModelMPM.java @@ -118,10 +118,11 @@ public class ModelMPM extends ModelNPCMale{ } } + // Updated False = 64x32 Skin // Steve 64x64 and Alex 64x64 - public ModelMPM(float par1, boolean arms) { + public ModelMPM(float par1, boolean updated, boolean arms) { - super(par1, true); + super(par1, updated, arms); isArmor = par1 > 0; float par2 = 0; @@ -143,23 +144,58 @@ public class ModelMPM extends ModelNPCMale{ this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); - this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); + if(updated){ + if (arms){ + // Alex Version + this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); + this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.5F + par2, 0.0F); - // Changed for 64x64 Texture - this.bipedLeftArm = new ModelScaleRenderer(this, 32, 48); - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); + this.bipedLeftArm = new ModelScaleRenderer(this, 32, 48); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); + } + else{ + // Steve Version + this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); + + this.bipedLeftArm = new ModelScaleRenderer(this, 32, 48); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); + } + + this.bipedRightLeg = (new ModelScaleRenderer(this, 0, 16)); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); + + // Changed for 64x64 Texture + this.bipedLeftLeg = new ModelScaleRenderer(this, 16, 48); + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); + } + else{ + + this.bipedRightArm = new ModelScaleRenderer(this, 40, 16); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); + this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); + + this.bipedRightLeg = new ModelScaleRenderer(this, 0, 16); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); + this.bipedLeftLeg = new ModelScaleRenderer(this, 0, 16); + this.bipedLeftLeg.mirror = true; + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); + + } - this.bipedRightLeg = (new ModelScaleRenderer(this, 0, 16)); - this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); - this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); - // Changed for 64x64 Texture - this.bipedLeftLeg = new ModelScaleRenderer(this, 16, 48); - this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); headwear = new ModelHeadwear(this, arms); legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg); @@ -179,6 +215,7 @@ public class ModelMPM extends ModelNPCMale{ this.bipedBody.addChild(skirt = new ModelSkirt(this)); this.bipedBody.addChild(fin = new ModelFin(this)); + // NEED TO FIX this.bipedLeftArm.addChild(clawsL = new ModelClaws(this, false)); this.bipedRightArm.addChild(clawsR = new ModelClaws(this, true)); } diff --git a/src/main/java/noppes/npcs/client/model/ModelNPCMale.java b/src/main/java/noppes/npcs/client/model/ModelNPCMale.java index 43a5af7e3..73fd61442 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNPCMale.java +++ b/src/main/java/noppes/npcs/client/model/ModelNPCMale.java @@ -8,6 +8,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.MathHelper; import noppes.npcs.CustomNpcs; +import noppes.npcs.client.model.util.ModelScaleRenderer; import noppes.npcs.constants.EnumAnimation; import noppes.npcs.entity.EntityNPCInterface; @@ -21,19 +22,16 @@ public class ModelNPCMale extends ModelBiped public float animationTick; public float dancingTicks; - public float randomFloat; public ModelNPCMale(float f) { init(f, 0.0F); - randomFloat = f; } - public ModelNPCMale(float f, boolean newSteve) + public ModelNPCMale(float f, boolean updated, boolean arms) { super(f, 0.0F, 64, 64); - init(f, 0.0F, true); - randomFloat = f; + init(f, 0.0F, updated, arms); } @Override @@ -44,7 +42,7 @@ public class ModelNPCMale extends ModelBiped // 64x64 Skin - public void init(float f, float f1, boolean NewSteve) + public void init(float f, float f1, boolean updated, boolean arms) { heldItemLeft = 0; @@ -74,29 +72,56 @@ public class ModelNPCMale extends ModelBiped bipedBody.addBox(-4F, 0.0F, -2F, 8, 12, 4, f); bipedBody.setRotationPoint(0.0F, 0.0F + f1, 0.0F); + if(updated){ + if (arms){ + // Alex Version + bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); + bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, f); + bipedRightArm.setRotationPoint(-5.0F, 2.5F + f1, 0.0F); - bipedRightArm = new ModelRenderer(this, 40, 16); - bipedRightArm.addBox(-3F, -2F, -2F, 4, 12, 4, f); - bipedRightArm.setRotationPoint(-5F, 2.0F + f1, 0.0F); + bipedLeftArm = new ModelScaleRenderer(this, 32, 48); + bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, f); + bipedLeftArm.setRotationPoint(5.0F, 2.5F + f1, 0.0F); + } + else{ + // Steve Version + bipedRightArm = new ModelRenderer(this, 40, 16); + bipedRightArm.addBox(-3F, -2F, -2F, 4, 12, 4, f); + bipedRightArm.setRotationPoint(-5F, 2.0F + f1, 0.0F); - // Changed - bipedLeftArm = new ModelRenderer(this, 32, 48); - bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, f); - bipedLeftArm.setRotationPoint(5.0F, 2.0F + f1, 0.0F); + bipedLeftArm = new ModelRenderer(this, 32, 48); + bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, f); + bipedLeftArm.setRotationPoint(5.0F, 2.0F + f1, 0.0F); + } - bipedRightLeg = new ModelRenderer(this, 0, 16); - bipedRightLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f); - bipedRightLeg.setRotationPoint(-2F, 12F + f1, 0.0F); + bipedRightLeg = new ModelRenderer(this, 0, 16); + bipedRightLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f); + bipedRightLeg.setRotationPoint(-2F, 12F + f1, 0.0F); - // Changed - bipedLeftLeg = new ModelRenderer(this, 16, 48); - bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, f); - bipedLeftLeg.setRotationPoint(1.9F, 12.0F + f1, 0.0F); + // 64x64 Leg Version + bipedLeftLeg = new ModelRenderer(this, 16, 48); + bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, f); + bipedLeftLeg.setRotationPoint(1.9F, 12.0F + f1, 0.0F); + } + else{ + bipedRightArm = new ModelRenderer(this, 40, 16); + bipedRightArm.addBox(-3F, -2F, -2F, 4, 12, 4, f); + bipedRightArm.setRotationPoint(-5F, 2.0F + f1, 0.0F); - bipedLeftLeg = new ModelRenderer(this, 0, 16); - bipedLeftLeg.mirror = true; - bipedLeftLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f); - bipedLeftLeg.setRotationPoint(2.0F, 12F + f1, 0.0F); + bipedLeftArm = new ModelRenderer(this, 40, 16); + bipedLeftArm.mirror = true; + bipedLeftArm.addBox(-1F, -2F, -2F, 4, 12, 4, f); + bipedLeftArm.setRotationPoint(5F, 2.0F + f1, 0.0F); + + bipedRightLeg = new ModelRenderer(this, 0, 16); + bipedRightLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f); + bipedRightLeg.setRotationPoint(-2F, 12F + f1, 0.0F); + + bipedLeftLeg = new ModelRenderer(this, 0, 16); + bipedLeftLeg.mirror = true; + bipedLeftLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f); + bipedLeftLeg.setRotationPoint(2.0F, 12F + f1, 0.0F); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java index bb2ed839c..4551a0c59 100644 --- a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java +++ b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java @@ -11,36 +11,20 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { private int imageData[]; private int imageWidth; private int imageHeight; - private boolean NPC64; - - public ImageBufferDownloadAlt() { - NPC64 = false; - } - - public ImageBufferDownloadAlt(boolean value) { - NPC64 = value; - } - @Override public BufferedImage parseUserSkin(BufferedImage bufferedimage) { imageWidth = bufferedimage.getWidth(null); imageHeight = bufferedimage.getHeight(null); -// } else { -// imageHeight = imageWidth / 2; -// } - BufferedImage bufferedimage1 = new BufferedImage(imageWidth, imageHeight, 2); + BufferedImage bufferedimage1 = new BufferedImage(imageWidth, imageWidth, 2); Graphics g = bufferedimage1.getGraphics(); g.drawImage(bufferedimage, 0, 0, null); g.dispose(); imageData = ((DataBufferInt) bufferedimage1.getRaster().getDataBuffer()).getData(); - setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 4); -// } else { -// setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 2); -// } + setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 4); return bufferedimage1; } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java index 84e304aa4..e962de122 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java @@ -29,14 +29,7 @@ public class RenderCustomNpc extends RenderNPCHumanMale{ // Default Renderer public RenderCustomNpc() { - super(new ModelMPM(0), new ModelMPM(1), new ModelMPM(0.5f)); - } - - // 64x64 Version - // True = Alex Arms - // False = Steve Arms - public RenderCustomNpc(boolean arms) { - super(new ModelMPM(0, arms), new ModelMPM(1, arms), new ModelMPM(0.5f, arms)); + super(new ModelMPM(0, false, false), new ModelMPM(1,false, false), new ModelMPM(0.5f, false, false)); } @Override diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java index 0f88dc91b..07c8f8698 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java @@ -55,6 +55,9 @@ public class RenderNPCHumanMale extends RenderNPCInterface protected ModelNPCMale modelArmorChestplate; protected ModelNPCMale modelArmor; + protected final ModelMPM steve = new ModelMPM(0, true, false); + protected final ModelMPM alex = new ModelMPM(0, true, true); + public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor) { super(mainmodel, 0.5F); @@ -138,10 +141,10 @@ public class RenderNPCHumanMale extends RenderNPCInterface this.mainModel = originalModel; } else if(modelVal == 1){ - this.mainModel = new ModelMPM(0, false); + this.mainModel = steve; } else{ - this.mainModel = new ModelMPM(0, true); + this.mainModel = alex; } } } @@ -432,49 +435,6 @@ public class RenderNPCHumanMale extends RenderNPCInterface } } - @Override - public ResourceLocation getEntityTexture(Entity entity) { - EntityNPCInterface npc = (EntityNPCInterface) entity; - - if (npc.textureLocation == null) { - if (npc.display.skinType == 0) - npc.textureLocation = new ResourceLocation(npc.display.texture); - else if (LastTextureTick < 5) { //fixes request flood somewhat - return AbstractClientPlayer.locationStevePng; - } else if (npc.display.skinType == 1 && npc.display.playerProfile != null) { - Minecraft minecraft = Minecraft.getMinecraft(); - Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile); - if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { - npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture) map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN); - } - LastTextureTick = 0; - } else if (npc.display.skinType == 2) { - try { - MessageDigest digest = MessageDigest.getInstance("MD5"); - byte[] hash = digest.digest(npc.display.url.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(2 * hash.length); - for (byte b : hash) { - sb.append(String.format("%02x", b & 0xff)); - } - npc.textureLocation = new ResourceLocation("skins/" + sb.toString()); - loadSkin(null, npc.textureLocation, npc.display.url, false); - LastTextureTick = 0; - } catch (Exception ex) { - - } - } - } - if(npc.textureLocation == null) - return AbstractClientPlayer.locationStevePng; - return npc.textureLocation; - } - - private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean value){ - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - ITextureObject object = new ImageDownloadAlt(file, par1Str, SkinManager.field_152793_a, new ImageBufferDownloadAlt(value)); - texturemanager.loadTexture(resource, object); - } - @Override protected void renderEquippedItems(EntityLivingBase entityliving, float f){ renderSpecials((EntityNPCInterface)entityliving, f); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 52f76ccaa..459a78951 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -24,7 +24,6 @@ import noppes.npcs.client.model.ModelMPM; import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumStandingType; import noppes.npcs.entity.EntityCustomNpc; -import noppes.npcs.entity.EntityCustomNpc64; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/entity/EntityCustomNpc64.java b/src/main/java/noppes/npcs/entity/EntityCustomNpc64.java deleted file mode 100644 index a4253a9fd..000000000 --- a/src/main/java/noppes/npcs/entity/EntityCustomNpc64.java +++ /dev/null @@ -1,19 +0,0 @@ -package noppes.npcs.entity; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import noppes.npcs.CustomNpcs; -import noppes.npcs.ModelData; -import noppes.npcs.ModelPartData; -import noppes.npcs.client.EntityUtil; - -public class EntityCustomNpc64 extends EntityCustomNpc{ - - public EntityCustomNpc64(World world) { - super(world); - display.texture = "customnpcs:textures/entity/humanmale/Steve64.png"; - } - -}