diff --git a/libs/forge-1.12.2-geckolib-3.0.0-beta.7.jar b/libs/forge-1.12.2-geckolib-3.0.0-beta.7.jar new file mode 100644 index 0000000..8e9bae4 Binary files /dev/null and b/libs/forge-1.12.2-geckolib-3.0.0-beta.7.jar differ diff --git a/src/main/java/com/gw/dm/entity/EntityHissingDemon.java b/src/main/java/com/gw/dm/entity/EntityHissingDemon.java index 2623e7b..8909348 100644 --- a/src/main/java/com/gw/dm/entity/EntityHissingDemon.java +++ b/src/main/java/com/gw/dm/entity/EntityHissingDemon.java @@ -6,22 +6,44 @@ import com.gw.dm.DungeonMobs; import com.gw.dm.EntityDungeonMob; +import com.gw.dm.ai.AIAngelAttack; +import com.gw.dm.ai.AIAngelWander; +import com.gw.dm.ai.TaskAngelAgroOnPlayer; import com.gw.dm.util.AudioHandler; import com.gw.dm.util.ConfigHandler; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAttackMelee; +import net.minecraft.entity.ai.EntityAIFindEntityNearestPlayer; +import net.minecraft.entity.ai.EntityAIFleeSun; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILeapAtTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAIRestrictSun; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWanderAvoidWater; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.EntityAIZombieAttack; import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.network.play.server.SPacketAnimation; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.SoundEvent; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.World; @@ -29,14 +51,14 @@ public class EntityHissingDemon extends EntityDungeonMob implements IMob, IRangedAttackMob, IBeMagicMob { private static String mobName = DungeonMobs.MODID + ":dmmaralith"; - private final ItemStack[] hands = new ItemStack[6]; + private final NonNullList hands = NonNullList.withSize(6, ItemStack.EMPTY); private final List handshuffler = new ArrayList<>(); private int shuffle = 0; private static final DataParameter SWINGING_ARMS - = EntityDataManager.createKey(EntityFallenAngel.class, DataSerializers.BOOLEAN); + = EntityDataManager.createKey(EntityHissingDemon.class, DataSerializers.BOOLEAN); private static final DataParameter SWINGING_ARM - = EntityDataManager.createKey(EntityFallenAngel.class, DataSerializers.VARINT); + = EntityDataManager.createKey(EntityHissingDemon.class, DataSerializers.VARINT); private int armInUse = 0; public EntityHissingDemon(World worldIn) { @@ -49,20 +71,41 @@ public EntityHissingDemon(World worldIn) { } // TODO Auto-generated constructor stub } + + + @Override + public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { + setHandWeapons(difficulty); + return super.onInitialSpawn(difficulty, livingdata); + } + + + @Override + protected void initEntityAI() { + //TODO: Stand-in code here, replace with specific + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false)); + this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWanderAvoidWater(this, 1.0D)); + this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); + targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0])); + targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); + } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(60.0d + getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(66.0d * ConfigHandler.healthx); getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.8d);; - getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5d); + getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4d); getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(12.0d); - getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(8.0d); - getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(20.0d + getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(4.0d); + getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(9.0d * ConfigHandler.damagex + ConfigHandler.damageplus); - getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(6.0d); + getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(32.0d); } @@ -88,16 +131,23 @@ protected SoundEvent getDeathSound() { } - private void equipHands(DifficultyInstance difficulty) { - for(int i = 0; i < hands.length; i++) { - hands[i] = getHandWeapon(difficulty); - } + @Override + public ItemStack getHeldItemMainhand() { + return hands.get(armInUse); } - @Override - public ItemStack getHeldItemMainhand() { - return hands[armInUse]; + public ItemStack getHeldItem(final int hand) { + //System.err.println("Item #" + hand + " requested, returning " + hands.get(hand)); + return hands.get(hand); + } + + + private void setHandWeapons(DifficultyInstance difficulty) { + for(int i = 0; i < hands.size(); i++) { + hands.set(i, getHandWeapon(difficulty)); + //System.err.println(hands.get(i)); + } } @@ -155,7 +205,18 @@ private ItemStack getHandWeapon(DifficultyInstance difficulty) { } + public NonNullList getHands() { + return hands; + } + + + public int getHandToSwing() { + return armInUse; + } + + public void nextHand() { + shuffle++; if(shuffle > handshuffler.size() || shuffle < 0) { shuffle = 0; Collections.shuffle(handshuffler, rand); @@ -186,9 +247,57 @@ public int getArmSwinging() { } + @Override + public boolean canBreatheUnderwater() { + return true; + } + + @Override public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { // TODO Auto-generated method stub } + + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + super.writeEntityToNBT(compound); + NBTTagList nbttaglist1 = new NBTTagList(); + for (ItemStack itemstack1 : hands) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + if (!itemstack1.isEmpty()) { + itemstack1.writeToNBT(nbttagcompound1); + } + nbttaglist1.appendTag(nbttagcompound1); + } + compound.setTag("SixHandItems", nbttaglist1); + } + + + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + super.readEntityFromNBT(compound); + if (compound.hasKey("SixItems", 9)) { + NBTTagList nbttaglist1 = compound.getTagList("HandItems", 10); + for (int i = 0; i < hands.size(); i++) { + hands.set(i, new ItemStack(nbttaglist1.getCompoundTagAt(i))); + } + } + } + + @Override + protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier) { + for(int i = 0; i < hands.size(); i++) { + ItemStack itemstack = hands.get(i); + if (!itemstack.isEmpty() && !EnchantmentHelper.hasVanishingCurse(itemstack) && wasRecentlyHit + && (double)(this.rand.nextFloat() - (float)lootingModifier * 0.01f) < 0.5f) { + if (itemstack.isItemStackDamageable()) { + itemstack.setItemDamage(itemstack.getMaxDamage() - this.rand.nextInt(1 + this.rand.nextInt(Math.max(itemstack.getMaxDamage() - 3, 1)))); + } + + this.entityDropItem(itemstack, 0.0f); + } + } + super.dropEquipment(wasRecentlyHit, lootingModifier); + } } diff --git a/src/main/java/com/gw/dm/model/ModelHissingDemon.java b/src/main/java/com/gw/dm/model/ModelHissingDemon.java index feb6d99..852455e 100644 --- a/src/main/java/com/gw/dm/model/ModelHissingDemon.java +++ b/src/main/java/com/gw/dm/model/ModelHissingDemon.java @@ -58,27 +58,25 @@ public ModelHissingDemon() { textureHeight = 96; head = hbone = new ModelRenderer(this); - hbone.setRotationPoint(8.0F, -2.0F, 0.0F); - hbone.cubeList.add(new ModelBox(hbone, 0, 0, -14.0F, -7.0F, -3.0F, 12, 12, 12, 0.0F, false)); + hbone.setRotationPoint(0.0F, 1.0F, 0.0F); + hbone.cubeList.add(new ModelBox(hbone, 0, 0, -6.0F, -22.0F, -3.0F, 12, 12, 12, 0.0F, false)); ab1 = new ModelRenderer(this); - ab1.setRotationPoint(-8.0F, 12.0F, 0.0F); + ab1.setRotationPoint(-6.0F, 2.0F, 0.0F); arm1_r1 = new ModelRenderer(this); - arm1_r1.setRotationPoint(2.0F, -9.0F, 0.0F); + arm1_r1.setRotationPoint(0.0F, -9.0F, 0.0F); ab1.addChild(arm1_r1); - //setRotationAngle(arm1_r1, 0.0F, 0.0F, 2.3562F); - arm1_r1.cubeList.add(new ModelBox(arm1_r1, 0, 61, -2.5F, 0.15F, 0.75F, 4, 18, 4, 0.0F, false)); + arm1_r1.cubeList.add(new ModelBox(arm1_r1, 0, 61, -2.4289F, -1.9211F, 0.75F, 4, 18, 4, 0.0F, false)); ab2 = new ModelRenderer(this); - ab2.setRotationPoint(-8.0F, -4.0F, 0.0F); + ab2.setRotationPoint(-6.0F, 5.0F, 0.0F); arm2_r1 = new ModelRenderer(this); - arm2_r1.setRotationPoint(2.0F, 8.5F, 0.0F); + arm2_r1.setRotationPoint(0.0F, -9.5F, 0.0F); ab2.addChild(arm2_r1); - //setRotationAngle(arm2_r1, 0.0F, 0.0F, 1.5708F); arm2_r1.cubeList.add(new ModelBox(arm2_r1, 21, 61, -1.75F, 0.15F, 0.825F, 4, 18, 4, 0.0F, false)); ab3 = new ModelRenderer(this); @@ -86,29 +84,26 @@ public ModelHissingDemon() { arm3_r1 = new ModelRenderer(this); - arm3_r1.setRotationPoint(3.0F, -9.0F, 0.0F); + arm3_r1.setRotationPoint(3.0F, -17.0F, 0.0F); ab3.addChild(arm3_r1); - //setRotationAngle(arm3_r1, 0.0F, 0.0F, 0.7854F); - arm3_r1.cubeList.add(new ModelBox(arm3_r1, 0, 61, -1.0F, 0.15F, 0.675F, 4, 18, 5, 0.0F, false)); + arm3_r1.cubeList.add(new ModelBox(arm3_r1, 0, 61, -2.3431F, -1.1931F, 0.675F, 4, 18, 5, 0.0F, false)); ab4 = new ModelRenderer(this); ab4.setRotationPoint(-8.0F, 12.0F, 0.0F); arm4_r1 = new ModelRenderer(this); - arm4_r1.setRotationPoint(14.0F, -9.0F, 0.0F); + arm4_r1.setRotationPoint(14.0F, -19.0F, 0.0F); ab4.addChild(arm4_r1); - //setRotationAngle(arm4_r1, 0.0F, 0.0F, -2.3562F); - arm4_r1.cubeList.add(new ModelBox(arm4_r1, 0, 61, -1.0F, 0.15F, 0.75F, 4, 18, 5, 0.0F, false)); + arm4_r1.cubeList.add(new ModelBox(arm4_r1, 0, 61, -2.0711F, -1.9211F, 0.75F, 4, 18, 5, 0.0F, false)); ab5 = new ModelRenderer(this); ab5.setRotationPoint(-8.0F, -4.0F, 0.0F); arm5_r1 = new ModelRenderer(this); - arm5_r1.setRotationPoint(14.0F, 8.5F, 0.0F); + arm5_r1.setRotationPoint(14.0F, -0.5F, 0.0F); ab5.addChild(arm5_r1); - //setRotationAngle(arm5_r1, 0.0F, 0.0F, -1.5708F); arm5_r1.cubeList.add(new ModelBox(arm5_r1, 21, 61, -1.75F, 0.15F, 0.825F, 4, 18, 4, 0.0F, false)); ab6 = new ModelRenderer(this); @@ -116,45 +111,44 @@ public ModelHissingDemon() { arm6_r1 = new ModelRenderer(this); - arm6_r1.setRotationPoint(15.0F, -9.0F, 0.0F); + arm6_r1.setRotationPoint(15.0F, -17.0F, 0.0F); ab6.addChild(arm6_r1); - //setRotationAngle(arm6_r1, 0.0F, 0.0F, -0.7854F); - arm6_r1.cubeList.add(new ModelBox(arm6_r1, 0, 61, -2.5F, 0.15F, 0.675F, 4, 18, 5, 0.0F, false)); + arm6_r1.cubeList.add(new ModelBox(arm6_r1, 0, 61, -2.1569F, -2.1931F, 0.675F, 4, 18, 5, 0.0F, false)); t1 = new ModelRenderer(this); - t1.setRotationPoint(-9.0F, 15.0F, 0.0F); - t1.cubeList.add(new ModelBox(t1, 43, 17, 4.0F, 1.0F, 12.0F, 10, 8, 8, 0.0F, false)); + t1.setRotationPoint(0.0F, 15.0F, 0.0F); + t1.cubeList.add(new ModelBox(t1, 43, 17, -5.0F, -4.0F, 4.0F, 10, 8, 8, 0.0F, false)); t2 = new ModelRenderer(this); - t2.setRotationPoint(-9.0F, 15.0F, 0.0F); - t2.cubeList.add(new ModelBox(t2, 0, 44, 5.0F, 1.0F, 19.0F, 8, 8, 8, 0.0F, false)); + t2.setRotationPoint(0.0F, 15.0F, 0.0F); + t2.cubeList.add(new ModelBox(t2, 0, 44, -4.0F, 1.0F, 6.0F, 8, 8, 8, 0.0F, false)); t3 = new ModelRenderer(this); - t3.setRotationPoint(-9.0F, 15.0F, 0.0F); - t3.cubeList.add(new ModelBox(t3, 51, 0, 5.0F, 1.0F, 27.0F, 8, 8, 8, 0.0F, false)); + t3.setRotationPoint(0.0F, 15.0F, 0.0F); + t3.cubeList.add(new ModelBox(t3, 51, 0, -4.0F, 1.0F, 14.0F, 8, 8, 8, 0.0F, false)); t4 = new ModelRenderer(this); - t4.setRotationPoint(-9.0F, 15.0F, 0.0F); - t4.cubeList.add(new ModelBox(t4, 40, 63, 6.0F, 3.0F, 34.0F, 6, 6, 6, 0.0F, false)); + t4.setRotationPoint(0.0F, 15.0F, 0.0F); + t4.cubeList.add(new ModelBox(t4, 40, 63, -3.0F, 3.0F, 22.0F, 6, 6, 6, 0.0F, false)); t5 = new ModelRenderer(this); t5.setRotationPoint(0.0F, 24.0F, 0.0F); - t5.cubeList.add(new ModelBox(t5, 65, 63, -2.0F, -4.0F, 40.0F, 4, 4, 4, 0.0F, false)); + t5.cubeList.add(new ModelBox(t5, 65, 63, -2.0F, -4.0F, 28.0F, 4, 4, 4, 0.0F, false)); t6 = new ModelRenderer(this); t6.setRotationPoint(0.0F, 24.0F, 0.0F); - t6.cubeList.add(new ModelBox(t6, 39, 0, -1.5F, -3.0F, 44.0F, 3, 3, 3, 0.0F, false)); + t6.cubeList.add(new ModelBox(t6, 39, 0, -1.5F, -3.0F, 32.0F, 3, 3, 3, 0.0F, false)); t7 = new ModelRenderer(this); t7.setRotationPoint(0.0F, 24.0F, 0.0F); - t7.cubeList.add(new ModelBox(t7, 0, 0, -1.0F, -2.0F, 47.0F, 2, 2, 2, 0.0F, false)); + t7.cubeList.add(new ModelBox(t7, 0, 0, -1.0F, -2.0F, 35.0F, 2, 2, 2, 0.0F, false)); bb_main = new ModelRenderer(this); bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 25, -7.0F, -9.0F, 3.0F, 14, 9, 9, 0.0F, false)); - bb_main.cubeList.add(new ModelBox(bb_main, 41, 38, -6.0F, -21.0F, 0.0F, 12, 18, 6, 0.0F, false)); - bb_main.cubeList.add(new ModelBox(bb_main, 27, 44, -5.0F, -18.0F, -1.5F, 4, 3, 2, 0.0F, false)); - bb_main.cubeList.add(new ModelBox(bb_main, 27, 44, 1.0F, -18.0F, -1.5F, 4, 3, 2, 0.0F, true)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 25, -7.0F, -19.0F, 1.0F, 14, 9, 9, 0.0F, false)); + bb_main.cubeList.add(new ModelBox(bb_main, 41, 38, -6.0F, -33.0F, 0.0F, 12, 18, 6, 0.0F, false)); + bb_main.cubeList.add(new ModelBox(bb_main, 27, 44, -5.0F, -31.0F, -1.5F, 4, 3, 2, 0.0F, false)); + bb_main.cubeList.add(new ModelBox(bb_main, 27, 44, 1.0F, -31.0F, -1.5F, 4, 3, 2, 0.0F, true)); arms = new ModelRenderer[6]; arms[0] = arm1_r1; @@ -202,28 +196,29 @@ public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageI head.rotateAngleY = netHeadYaw * 0.017453292F; head.rotateAngleX = headPitch * 0.017453292F; - //Temporary hack to see if it works - limbSwing = ageInTicks; - limbSwingAmount = 0.025f; - arms[0].rotateAngleZ = ARM1Z; arms[1].rotateAngleZ = ARM2Z; arms[2].rotateAngleZ = ARM3Z; arms[0].rotateAngleY = arms[1].rotateAngleY = arms[2].rotateAngleY = 0f; - arms[0].rotateAngleX = arms[1].rotateAngleX = arms[2].rotateAngleX = 0f; + arms[0].rotateAngleX = arms[1].rotateAngleX = arms[2].rotateAngleX = -ARM3Z; arms[3].rotateAngleZ = -ARM1Z; arms[4].rotateAngleZ = -ARM2Z; arms[5].rotateAngleZ = -ARM3Z; arms[3].rotateAngleY = arms[4].rotateAngleY = arms[5].rotateAngleY = 0f; - arms[3].rotateAngleX = arms[4].rotateAngleX = arms[5].rotateAngleX = 0f; - - tail[0].offsetX = MathHelper.cos(limbSwing * 0.6662F + tailAng[0]) * tailMov[0] * limbSwingAmount * 16f; - tail[1].offsetX = MathHelper.cos(limbSwing * 0.6662F + tailAng[1]) * tailMov[1] * limbSwingAmount * 16f; - tail[2].offsetX = MathHelper.cos(limbSwing * 0.6662F + tailAng[2]) * tailMov[2] * limbSwingAmount * 16f; - tail[3].offsetX = MathHelper.cos(limbSwing * 0.6662F + tailAng[3]) * tailMov[3] * limbSwingAmount * 16f; - tail[4].offsetX = MathHelper.cos(limbSwing * 0.6662F + tailAng[4]) * tailMov[4] * limbSwingAmount * 16f; - tail[5].offsetX = MathHelper.cos(limbSwing * 0.6662F + tailAng[5]) * tailMov[5] * limbSwingAmount * 16f; - tail[6].offsetX = MathHelper.cos(limbSwing * 0.6662F + tailAng[6]) * tailMov[6] * limbSwingAmount * 16f; + arms[3].rotateAngleX = arms[4].rotateAngleX = arms[5].rotateAngleX = -ARM3Z; + + tail[0].offsetX = MathHelper.cos(limbSwing * 0.2666f + tailAng[0]) * tailMov[0] * limbSwingAmount / 2f; + tail[1].offsetX = MathHelper.cos(limbSwing * 0.2666f + tailAng[1]) * tailMov[1] * limbSwingAmount / 2f; + tail[2].offsetX = MathHelper.cos(limbSwing * 0.2666f + tailAng[2]) * tailMov[2] * limbSwingAmount / 2f; + tail[3].offsetX = MathHelper.cos(limbSwing * 0.2666f + tailAng[3]) * tailMov[3] * limbSwingAmount / 2f; + tail[4].offsetX = MathHelper.cos(limbSwing * 0.2666f + tailAng[4]) * tailMov[4] * limbSwingAmount / 2f; + tail[5].offsetX = MathHelper.cos(limbSwing * 0.2666f + tailAng[5]) * tailMov[5] * limbSwingAmount / 2f; + tail[6].offsetX = MathHelper.cos(limbSwing * 0.2666f + tailAng[6]) * tailMov[6] * limbSwingAmount / 2f; + } + + + public void postRenderArm(float scale, int hand) { + arms[hand].postRender(scale); } diff --git a/src/main/java/com/gw/dm/render/LayerSixHeldItems.java b/src/main/java/com/gw/dm/render/LayerSixHeldItems.java index f175c6e..6d4733d 100644 --- a/src/main/java/com/gw/dm/render/LayerSixHeldItems.java +++ b/src/main/java/com/gw/dm/render/LayerSixHeldItems.java @@ -1,23 +1,72 @@ package com.gw.dm.render; +import com.gw.dm.entity.EntityHissingDemon; +import com.gw.dm.model.ModelHissingDemon; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHandSide; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class LayerSixHeldItems implements LayerRenderer { +public class LayerSixHeldItems implements LayerRenderer { + private RenderHissingDemon demonRenderer; + + public LayerSixHeldItems(RenderHissingDemon livingEntityRendererIn) { + demonRenderer = livingEntityRendererIn; + } + @Override - public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, + public void doRenderLayer(EntityHissingDemon demon, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - // TODO Auto-generated method stub + //int armInUse = demon.getHandToSwing(); + GlStateManager.pushMatrix(); { + this.renderHeldItem(demon, demon.getHeldItem(0), ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, 0); + this.renderHeldItem(demon, demon.getHeldItem(1), ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, 1); + this.renderHeldItem(demon, demon.getHeldItem(2), ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, 2); + this.renderHeldItem(demon, demon.getHeldItem(3), ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, 3); + this.renderHeldItem(demon, demon.getHeldItem(4), ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, 4); + this.renderHeldItem(demon, demon.getHeldItem(5), ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, 5); + } GlStateManager.popMatrix(); } + + + private void renderHeldItem(EntityHissingDemon demon, ItemStack item, ItemCameraTransforms.TransformType transType, int arm) { + //System.err.println("Rendering ... " + item); + if ((item != null) && !item.isEmpty()) { + boolean flagl = arm > 2; + EnumHandSide side; + if(flagl) { + side = EnumHandSide.LEFT; + } else { + side = EnumHandSide.RIGHT; + } + GlStateManager.pushMatrix(); { + // Forge: moved this call down, fixes incorrect offset while sneaking. + this.translateToHand(arm); + GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); + GlStateManager.translate((float)(flagl ? -1 : 1) / 16.0F, 0.125F, -0.625F); + Minecraft.getMinecraft().getItemRenderer().renderItemSide(demon, item, transType, flagl); + } GlStateManager.popMatrix(); + } + } + + + protected void translateToHand(int hand) { + ((ModelHissingDemon)this.demonRenderer.getMainModel()).postRenderArm(0.0625F, hand); + } + @Override public boolean shouldCombineTextures() { - // TODO Auto-generated method stub return false; } diff --git a/src/main/java/com/gw/dm/render/RenderHissingDemon.java b/src/main/java/com/gw/dm/render/RenderHissingDemon.java index faac42f..e9c153c 100644 --- a/src/main/java/com/gw/dm/render/RenderHissingDemon.java +++ b/src/main/java/com/gw/dm/render/RenderHissingDemon.java @@ -6,6 +6,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -16,12 +17,18 @@ public class RenderHissingDemon extends RenderLiving { public RenderHissingDemon(RenderManager rendermanagerIn, ModelBase modelbaseIn, float shadowsizeIn) { super(rendermanagerIn, modelbaseIn, shadowsizeIn); - // TODO Auto-generated constructor stub + this.addLayer(new LayerSixHeldItems(this)); } @Override protected ResourceLocation getEntityTexture(EntityHissingDemon entity) { return new ResourceLocation(DungeonMobs.MODID, "textures/entity/hissing_demon.png"); } + + @Override + public void doRender(EntityHissingDemon entity, double x, double y, double z, float entityYaw, float partialTicks) { + super.doRender(entity, x, y, z, entityYaw, partialTicks); + + } } diff --git a/src/main/resources/assets/dungeonmobs/textures/entity/hissing_demon.png b/src/main/resources/assets/dungeonmobs/textures/entity/hissing_demon.png index 1e7e1bb..f47d847 100644 Binary files a/src/main/resources/assets/dungeonmobs/textures/entity/hissing_demon.png and b/src/main/resources/assets/dungeonmobs/textures/entity/hissing_demon.png differ