Skip to content

Commit

Permalink
Improvements to Maralith model
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackJar72 committed Jun 22, 2021
1 parent 2fa748c commit dfa1604
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 69 deletions.
Binary file added libs/forge-1.12.2-geckolib-3.0.0-beta.7.jar
Binary file not shown.
139 changes: 124 additions & 15 deletions src/main/java/com/gw/dm/entity/EntityHissingDemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,59 @@

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;
import net.minecraft.world.WorldServer;

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<ItemStack> hands = NonNullList.<ItemStack>withSize(6, ItemStack.EMPTY);
private final List<Integer> handshuffler = new ArrayList<>();
private int shuffle = 0;

private static final DataParameter<Boolean> SWINGING_ARMS
= EntityDataManager.<Boolean>createKey(EntityFallenAngel.class, DataSerializers.BOOLEAN);
= EntityDataManager.<Boolean>createKey(EntityHissingDemon.class, DataSerializers.BOOLEAN);
private static final DataParameter<Integer> SWINGING_ARM
= EntityDataManager.<Integer>createKey(EntityFallenAngel.class, DataSerializers.VARINT);
= EntityDataManager.<Integer>createKey(EntityHissingDemon.class, DataSerializers.VARINT);
private int armInUse = 0;

public EntityHissingDemon(World worldIn) {
Expand All @@ -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);
}


Expand All @@ -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));
}
}


Expand Down Expand Up @@ -155,7 +205,18 @@ private ItemStack getHandWeapon(DifficultyInstance difficulty) {
}


public NonNullList<ItemStack> getHands() {
return hands;
}


public int getHandToSwing() {
return armInUse;
}


public void nextHand() {
shuffle++;
if(shuffle > handshuffler.size() || shuffle < 0) {
shuffle = 0;
Collections.shuffle(handshuffler, rand);
Expand Down Expand Up @@ -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);
}

}
93 changes: 44 additions & 49 deletions src/main/java/com/gw/dm/model/ModelHissingDemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,103 +58,97 @@ 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);
ab3.setRotationPoint(-9.0F, 15.0F, 0.0F);


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);
ab6.setRotationPoint(-9.0F, 15.0F, 0.0F);


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;
Expand Down Expand Up @@ -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);
}


Expand Down
Loading

0 comments on commit dfa1604

Please sign in to comment.