Advertisement
SnubMansters

EntityDog

Jun 16th, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.24 KB | None | 0 0
  1. package com.github.copiousdogs.entity;
  2.  
  3. import java.lang.reflect.Constructor;
  4. import java.util.HashMap;
  5. import java.util.Random;
  6.  
  7. import net.minecraft.client.Minecraft;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.entity.EntityAgeable;
  10. import net.minecraft.entity.EntityLiving;
  11. import net.minecraft.entity.SharedMonsterAttributes;
  12. import net.minecraft.entity.ai.EntityAIAttackOnCollide;
  13. import net.minecraft.entity.ai.EntityAIAvoidEntity;
  14. import net.minecraft.entity.ai.EntityAIFollowOwner;
  15. import net.minecraft.entity.ai.EntityAILeapAtTarget;
  16. import net.minecraft.entity.ai.EntityAILookIdle;
  17. import net.minecraft.entity.ai.EntityAIMate;
  18. import net.minecraft.entity.ai.EntityAISwimming;
  19. import net.minecraft.entity.ai.EntityAITradePlayer;
  20. import net.minecraft.entity.ai.EntityAIWander;
  21. import net.minecraft.entity.ai.EntityAIWatchClosest;
  22. import net.minecraft.entity.ai.attributes.IAttribute;
  23. import net.minecraft.entity.ai.attributes.RangedAttribute;
  24. import net.minecraft.entity.item.EntityItem;
  25. import net.minecraft.entity.monster.EntityCreeper;
  26. import net.minecraft.entity.passive.EntityAnimal;
  27. import net.minecraft.entity.passive.EntitySheep;
  28. import net.minecraft.entity.passive.EntityTameable;
  29. import net.minecraft.entity.player.EntityPlayer;
  30. import net.minecraft.entity.projectile.EntityArrow;
  31. import net.minecraft.item.Item;
  32. import net.minecraft.item.ItemStack;
  33. import net.minecraft.nbt.NBTTagCompound;
  34. import net.minecraft.util.ChatComponentText;
  35. import net.minecraft.util.ChatStyle;
  36. import net.minecraft.util.DamageSource;
  37. import net.minecraft.util.EnumChatFormatting;
  38. import net.minecraft.world.World;
  39. import net.minecraftforge.common.BiomeDictionary.Type;
  40.  
  41. import com.github.copiousdogs.Commands;
  42. import com.github.copiousdogs.CopiousDogs;
  43. import com.github.copiousdogs.client.gui.GuiDogInfo;
  44. import com.github.copiousdogs.client.gui.GuiNameDog;
  45. import com.github.copiousdogs.content.CopiousDogsItems;
  46. import com.github.copiousdogs.entity.ai.EntityAIBegBiscuit;
  47. import com.github.copiousdogs.entity.ai.EntityAIEatDogDish;
  48. import com.github.copiousdogs.entity.ai.EntityAIFollowOwnerLeashed;
  49. import com.github.copiousdogs.entity.ai.EntityAIHurtByTargetBOA;
  50. import com.github.copiousdogs.entity.ai.EntityAIMateNearTorch;
  51. import com.github.copiousdogs.entity.ai.EntityAIOwnerHurtByTargetBOA;
  52. import com.github.copiousdogs.entity.ai.EntityAIOwnerHurtTargetBOA;
  53. import com.github.copiousdogs.entity.ai.EntityAIPanicBOA;
  54. import com.github.copiousdogs.entity.ai.EntityAITargetNonTamedBOA;
  55. import com.github.copiousdogs.entity.ai.EntityAIWanderBOE;
  56. import com.github.copiousdogs.handler.ConfigurationHandler;
  57. import com.github.copiousdogs.item.ItemDogCollar;
  58. import cpw.mods.fml.common.FMLCommonHandler;
  59. import cpw.mods.fml.relauncher.Side;
  60. import cpw.mods.fml.relauncher.SideOnly;
  61.  
  62. public class EntityDog extends EntityTameable
  63. {
  64.     public float walkSpeed;
  65.     public float runSpeed;
  66.     private String breed;
  67.     String warn1 = "It appears you arent running the latest Version! which is very bad! if you don't run the latest Version many bad things could happen which includes your dogs getting bugs and then getting sick and needing to go to the Hospital! Don't worry though! you can update on our official thread";
  68.     String link = "http://goo.gl/lXwpbp";
  69.     String war2 = "Update and Have Fun! :)";
  70.     private static String dogname;
  71.    
  72.     public static final String Danny = "Da";
  73.    
  74.     public static boolean hasnoted = false;
  75.    
  76.     private static final IAttribute aggressiveness = (new RangedAttribute("aggressiveness", 5.0D, 1.0D, 10.0D)).setDescription("Aggressiveness").setShouldWatch(true);
  77.     private static final IAttribute energy = (new RangedAttribute("energy", 5.0D, 1.0D, 10.0D)).setDescription("Energy").setShouldWatch(true);
  78.    
  79.     public static HashMap<Type, Class<? extends EntityLiving>> spawnMap = new HashMap<Type, Class<? extends EntityLiving>>();
  80.    
  81.     public EntityDog(World p_i1604_1_, float speed, String breed)
  82.     {
  83.         super(p_i1604_1_);
  84.        
  85.         if (ConfigurationHandler.INDIVIDUAL_TRAITS)
  86.         {
  87.             double a = this.getRNG().nextDouble() * 10.0 + 1.0;
  88.             if (a < 1) a = 1;
  89.             if (a > 10) a = 10;
  90.             setAggressiveness(a);
  91.             double e = this.getRNG().nextDouble() * 10.0 + 1.0;
  92.             if (e < 1) e = 1;
  93.             if (e > 10) e = 10;
  94.             setEnergy(e);
  95.         }
  96.        
  97.         float speedModifier = 0.75f + ((float)getEnergy() / 20f);
  98.         this.walkSpeed = speed * speedModifier;
  99.         this.runSpeed = speed * 1.2f  * speedModifier;
  100.         this.breed = breed;
  101.         this.setAlwaysRenderNameTag(CopiousDogs.isdebug);
  102.        
  103.        
  104.         this.getNavigator().setAvoidsWater(true);
  105.         this.tasks.addTask(0, new EntityAISwimming(this));
  106.         this.tasks.addTask(2, this.aiSit);
  107.         this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));
  108.         this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
  109.         this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  110.         this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  111.         this.tasks.addTask(9, new EntityAILookIdle(this));
  112.         this.tasks.addTask(1, new EntityAIPanicBOA(this, runSpeed * 1.4f));
  113.         //this.tasks.addTask(2, new EntityAIReturnToOwner(this, runSpeed));
  114.         this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.35f));
  115.         this.tasks.addTask(4, new EntityAIAttackOnCollide(this, .75f, true));
  116.         this.tasks.addTask(5, new EntityAIEatDogDish(this, 5, walkSpeed));
  117.         this.tasks.addTask(6, new EntityAIFollowOwnerLeashed(this, runSpeed, 2f, 5f));
  118.         this.tasks.addTask(7, new EntityAIBegBiscuit(this, 10F));
  119.         this.tasks.addTask(8, new EntityAIWanderBOE(this, walkSpeed, runSpeed));
  120.         //this.tasks.addTask(7, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
  121.         this.targetTasks.addTask(0, new EntityAIOwnerHurtByTargetBOA(this));
  122.         this.targetTasks.addTask(1, new EntityAIOwnerHurtTargetBOA(this));
  123.         this.targetTasks.addTask(2, new EntityAIHurtByTargetBOA(this, false));
  124.         this.targetTasks.addTask(3, new EntityAITargetNonTamedBOA(this, EntityCreeper.class, 200, true));
  125.        
  126.     }
  127.  
  128.     @Override
  129.     protected void applyEntityAttributes() {
  130.        
  131.         super.applyEntityAttributes();
  132.         getAttributeMap().registerAttribute(aggressiveness);
  133.         getAttributeMap().registerAttribute(energy);
  134.         getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(15);
  135.     }
  136.    
  137.     @SideOnly(Side.CLIENT)
  138.     public void spawnDogParticles(boolean p_110216_1_)
  139.     {
  140.         String s = p_110216_1_ ? "heart" : "smoke";
  141.  
  142.         for (int i = 0; i < 7; ++i)
  143.         {
  144.             double d0 = this.rand.nextGaussian() * 0.02D;
  145.             double d1 = this.rand.nextGaussian() * 0.02D;
  146.             double d2 = this.rand.nextGaussian() * 0.02D;
  147.             this.worldObj.spawnParticle(s, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2);
  148.         }
  149.     }
  150.    
  151.     @Override
  152.     protected float getSoundPitch()
  153.     {
  154.         return 2f - this.height;
  155.     }
  156.    
  157.     @Override
  158.     public float getShadowSize()
  159.     {
  160.         return width;
  161.     }
  162.    
  163.     @Override
  164.     protected boolean isAIEnabled()
  165.     {
  166.         return true;
  167.     }
  168.    
  169.     @Override
  170.     protected void entityInit()
  171.     {
  172.         super.entityInit();
  173.         this.dataWatcher.addObject(18, (byte)0);
  174.         this.dataWatcher.addObject(19, this.getHealth());
  175.         this.dataWatcher.addObject(20, 0);
  176.         this.dataWatcher.addObject(21, (byte)-1);
  177.     }
  178.    
  179.     @Override
  180.     protected String getHurtSound()
  181.     {
  182.         return "mob.wolf.hurt";
  183.     }
  184.    
  185.     @Override
  186.     protected String getLivingSound()
  187.     {
  188.         return "mob.wolf.bark";
  189.     }
  190.    
  191.     @Override
  192.     protected String getDeathSound()
  193.     {
  194.         return "mob.wolf.death";
  195.     }
  196.    
  197.     public String getTextureName()
  198.     {
  199.         return this.isChild() ? breed + "_pup":breed;
  200.     }
  201.    
  202.     public boolean hasCollar()
  203.     {
  204.         return getCollarColor() > -1;
  205.     }
  206.    
  207.     public boolean isTailAnimated()
  208.     {
  209.         return (this.dataWatcher.getWatchableObjectByte(18) & 1) != 0;
  210.     }
  211.    
  212.     public void setTailAnimated(boolean par0)
  213.     {
  214.         if (isTailAnimated() != par0)
  215.         {
  216.             this.dataWatcher.updateObject(18, (byte) (this.dataWatcher.getWatchableObjectByte(18) + (par0 ? 1: -1)));
  217.         }
  218.     }
  219.    
  220.     public boolean hasLeash()
  221.     {
  222.         return (this.dataWatcher.getWatchableObjectByte(18) & 2) != 0;
  223.     }
  224.    
  225.     public void setHasLeash(boolean par0)
  226.     {
  227.         if (hasLeash() != par0)
  228.         {
  229.             this.dataWatcher.updateObject(18, (byte) (this.dataWatcher.getWatchableObjectByte(18) + (par0 ? 2: -2)));
  230.         }
  231.     }
  232.    
  233.     public boolean isBegging()
  234.     {
  235.         return (this.dataWatcher.getWatchableObjectByte(18) & 4) != 0;
  236.     }
  237.    
  238.     public void setBegging(boolean par0)
  239.     {
  240.         if (isBegging() != par0)
  241.         {
  242.             this.dataWatcher.updateObject(18, (byte) (this.dataWatcher.getWatchableObjectByte(18) + (par0 ? 4: -4)));
  243.         }
  244.     }
  245.    
  246.     public boolean isWhistled()
  247.     {
  248.         return (this.dataWatcher.getWatchableObjectByte(18) & 8) != 0;
  249.     }
  250.    
  251.     public void setWhistled(boolean par0)
  252.     {
  253.         if (isWhistled() != par0)
  254.         {
  255.             this.dataWatcher.updateObject(18, (byte) (this.dataWatcher.getWatchableObjectByte(18) + (par0 ? 8: -8)));
  256.         }
  257.     }
  258.    
  259.     public double getAggressiveness()
  260.     {
  261.         return getEntityAttribute(aggressiveness).getAttributeValue();
  262.     }
  263.    
  264.     public void setAggressiveness(double par0)
  265.     {
  266.         getEntityAttribute(aggressiveness).setBaseValue(par0);
  267.     }
  268.    
  269.     public double getEnergy()
  270.     {
  271.         return getEntityAttribute(energy).getAttributeValue();
  272.     }
  273.    
  274.     public void setEnergy(double par0)
  275.     {
  276.         getEntityAttribute(energy).setBaseValue(par0);
  277.     }
  278.    
  279.     public byte getCollarColor()
  280.     {
  281.         return this.dataWatcher.getWatchableObjectByte(21);
  282.     }
  283.    
  284.     public void setCollarColor(byte color)
  285.     {
  286.         this.dataWatcher.updateObject(21, color);
  287.     }
  288.    
  289.     public String getBreed()
  290.     {
  291.         return breed;
  292.     }
  293.    
  294.     public void setTameValue(int value)
  295.     {
  296.         this.dataWatcher.updateObject(20, value);
  297.     }
  298.    
  299.     public int getTameValue()
  300.     {
  301.         return this.dataWatcher.getWatchableObjectInt(20);
  302.     }
  303.    
  304.     @Override
  305.     public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
  306.     {
  307.         if (this.isEntityInvulnerable())
  308.         {
  309.             return false;
  310.         }
  311.        
  312.         Entity entity = p_70097_1_.getEntity();
  313.  
  314.         if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
  315.         {
  316.             p_70097_2_ = (p_70097_2_ + 1.0F) / 2.0F;
  317.         }
  318.         return super.attackEntityFrom(p_70097_1_, p_70097_2_);
  319.     }
  320.    
  321.     @Override
  322.     public int getVerticalFaceSpeed() {
  323.  
  324.         return 10;
  325.     }
  326.    
  327.     public void tryToTame(EntityPlayer player)
  328.     {
  329.         double value = 10 + getAggressiveness();
  330.        
  331.         if (getTameValue() >= value)
  332.         {
  333.             setTamed(true);
  334.             func_152115_b(player.getUniqueID().toString());
  335.             if (worldObj.isRemote) {
  336.                
  337.                 Commands.setname(this);
  338.             }
  339.         }
  340.         else
  341.         {
  342.             spawnDogParticles(false);
  343.         }
  344.     }
  345.    
  346.     @Override
  347.     public void setTamed(boolean p_70903_1_)
  348.     {
  349.         super.setTamed(p_70903_1_);
  350.         setTailAnimated(p_70903_1_);
  351.     }
  352.    
  353.     @Override
  354.     public EntityAgeable createChild(EntityAgeable p_90011_1_)
  355.     {
  356.         try
  357.         {
  358.             Class<?> clazz = Class.forName(p_90011_1_.getClass().getName());
  359.             Constructor<?> construct = clazz.getConstructor(World.class);
  360.             return (EntityAgeable) construct.newInstance(p_90011_1_.worldObj);
  361.         }
  362.         catch (Exception e)
  363.         {
  364.             e.printStackTrace();
  365.             return null;
  366.         }
  367.     }
  368.    
  369.     @Override
  370.     public boolean canMateWith(EntityAnimal animal)
  371.     {
  372.         if (animal instanceof EntityDog)
  373.         {
  374.             EntityDog dog = (EntityDog) animal;
  375.            
  376.             return dog == this ? false : this.isInLove() && dog.isInLove()
  377.                     && breed.equals(dog.getBreed());
  378.         }
  379.        
  380.         return false;
  381.     }
  382.    
  383.     public void doname()
  384.     {
  385.         this.setCustomNameTag(getDogname());
  386.     }
  387.    
  388.     @Override
  389.     public boolean interact(EntityPlayer player)
  390.     {
  391.            
  392.             ItemStack stack = player.getCurrentEquippedItem();
  393.            
  394.             if (stack != null)
  395.             {
  396.                 if (this.isBreedingItem(stack) && this.getGrowingAge() == 0 && !this.isInLove()
  397.                         && this.isTamed() && this.getOwner().getUniqueID().equals(player.getUniqueID()))
  398.                 {
  399.                     player.swingItem();
  400.                    
  401.                     if (!player.capabilities.isCreativeMode)
  402.                     {
  403.                         --stack.stackSize;
  404.                     }
  405.                    
  406.                     this.func_146082_f(player);
  407.                     return true;
  408.                 }
  409.                 if (CopiousDogs.hasLatestVersion == false)
  410.                 {
  411.                     if (this.hasnoted == false)
  412.                     {
  413.                     player.swingItem();
  414.                     {
  415.                         ChatComponentText text1 = new ChatComponentText("[Copious Dogs] ".toString());
  416.                         ChatComponentText text2 = new ChatComponentText(warn1.toString());
  417.                         ChatComponentText text3 = new ChatComponentText(link.toString());
  418.                         ChatComponentText text4 = new ChatComponentText(war2.toString());
  419.                         ChatStyle style1 = new ChatStyle();
  420.                         ChatStyle style2 = new ChatStyle();
  421.                         ChatStyle style3 = new ChatStyle();
  422.                         style1.setColor(EnumChatFormatting.YELLOW);
  423.                         style2.setColor(EnumChatFormatting.RED);
  424.                         style3.setColor(EnumChatFormatting.AQUA);
  425.                         text1.setChatStyle(style1);
  426.                         text2.setChatStyle(style2);
  427.                         text3.setChatStyle(style3);
  428.                         text4.setChatStyle(style2);
  429.                         FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendChatMsg(text1);
  430.                         FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendChatMsg(text2);
  431.                         FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendChatMsg(text3);
  432.                         FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendChatMsg(text4);
  433.                         this.hasnoted = true;
  434.                         }
  435.                     }
  436.                     return true;
  437.                 }
  438.                 if (stack.getItem() == CopiousDogsItems.dogBiscuit)
  439.                 {
  440.                     if (!isTamed())
  441.                     {
  442.                         if (CopiousDogs.hasLatestVersion == true)
  443.                         {
  444.                             player.swingItem();
  445.                             if (!player.capabilities.isCreativeMode)
  446.                             {
  447.                                 setTameValue(getTameValue() + 3 + getRNG().nextInt(8));
  448.                                 tryToTame(player);
  449.                                 stack.stackSize--;
  450.                                 }
  451.                             else
  452.                             {
  453.                                 setTameValue(10 + (int)getAggressiveness() + 1);
  454.                                 tryToTame(player);
  455.                                 }
  456.                             return true;
  457.                             }
  458.                         return true;
  459.                         }
  460.                     }
  461.                 if (stack.getItem() == CopiousDogsItems.dogCollar)
  462.                 {
  463.                     if (this.isTamed() && getOwner().getUniqueID().equals(player.getUniqueID()))
  464.                     {
  465.                         player.swingItem();
  466.                         byte color = getCollarColor();
  467.  
  468.                         this.setCustomNameTag(dogname);
  469.                         setCollarColor((byte) ItemDogCollar.getDyeFromItem(stack.getItemDamage()));
  470.                        
  471.                         if (!player.capabilities.isCreativeMode)
  472.                         {
  473.                             stack.stackSize--;
  474.                            
  475.                             if (color > -1)
  476.                             {
  477.                                 Random r = getRNG();
  478.                                
  479.                                 ItemStack collar = new ItemStack(CopiousDogsItems.dogCollar, 1, ItemDogCollar.getItemFromDye(color));
  480.                                 EntityItem item = entityDropItem(collar, 1f);
  481.                                 item.motionX += rand.nextFloat() * .5f;
  482.                                 item.motionY += (rand.nextFloat() - rand.nextFloat()) * .1f;
  483.                                 item.motionZ += (rand.nextFloat() - rand.nextFloat()) * .1f;
  484.                                
  485.                                 player.worldObj.spawnEntityInWorld(item);
  486.                             }
  487.                         }
  488.                        
  489.                         return true;
  490.                     }
  491.                 }
  492.                
  493.                 if (stack.getItem() == CopiousDogsItems.leash)
  494.                 {
  495.                     if ( hasCollar() && !hasLeash() && this.getOwner().getUniqueID().toString().equals(player.getUniqueID().toString()))
  496.                     {
  497.                         if (CopiousDogs.hasLatestVersion == true)
  498.                         {
  499.                         player.swingItem();
  500.                         setHasLeash(true);
  501.                        
  502.                         if (!player.capabilities.isCreativeMode)
  503.                         {
  504.                             stack.stackSize--;
  505.                         }
  506.                         return true;
  507.                         }
  508.                        
  509.                         return true;
  510.                     }
  511.                     return false;
  512.                 }
  513.                
  514.                 if (stack.getItem() == CopiousDogsItems.analyzer)
  515.                 {
  516.                     if (isTamed() && getOwner().getUniqueID().equals(player.getUniqueID()))
  517.                     {
  518.                         Commands.doginfo(this);
  519.                         return true;
  520.                     }
  521.                 }
  522.             }
  523.             else {
  524.  
  525.                 if (isTamed() && getOwner() != null && getOwner().getUniqueID().equals(player.getUniqueID()))
  526.                 {
  527.                     if (player.isSneaking())
  528.                     {
  529.                         if (hasLeash())
  530.                         {
  531.                             setHasLeash(false);
  532.                            
  533.                             if (!player.capabilities.isCreativeMode)
  534.                             {
  535.                                 player.inventory.addItemStackToInventory(new ItemStack(CopiousDogsItems.leash, 1));
  536.                             }
  537.                         }
  538.                         else if (hasCollar())
  539.                         {
  540.                             byte color = getCollarColor();
  541.                                
  542.                             setCollarColor((byte) -1);
  543.                                
  544.                             if (!player.capabilities.isCreativeMode)
  545.                             {
  546.                                 if (color > -1)
  547.                                 {
  548.                                     Random r = getRNG();
  549.                                        
  550.                                     player.inventory.addItemStackToInventory(new ItemStack(CopiousDogsItems.dogCollar, 1, ItemDogCollar.getItemFromDye(color)));
  551.                                 }
  552.                             }  
  553.                         }
  554.                     }
  555.                     else {
  556.                         setSitting(!isSitting());
  557.                         this.aiSit.setSitting(isSitting());
  558.                     }
  559.                 }
  560.             }
  561.        
  562.        
  563.         return false;
  564.        
  565.     }
  566.    
  567.     @Override
  568.     public boolean isBreedingItem(ItemStack item)
  569.     {
  570.         return item.getItem() == Item.itemRegistry.getObject("cookie");
  571.     }
  572.    
  573.     public int getAttackStrength(Entity par1Entity)
  574.     {
  575.         return isTamed() ? 4 : 2;
  576.     }
  577.    
  578.     public boolean attackEntityAsMob(Entity par1Entity)
  579.     {
  580.         return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), getAttackStrength(par1Entity));
  581.     }
  582.    
  583.     public int getPrimaryEggColor()
  584.     {
  585.         return 0;
  586.     }
  587.    
  588.     public int getSecondaryEggColor()
  589.     {
  590.         return 0;
  591.     }
  592.    
  593.     @Override
  594.     public void onDeath(DamageSource source) {
  595.        
  596.         if (!this.worldObj.isRemote) {
  597.            
  598.             if (hasLeash()) {
  599.                
  600.                 ItemStack stack = new ItemStack(CopiousDogsItems.leash, 1);
  601.                
  602.                 EntityItem entity = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, stack);
  603.                
  604.                  float f3 = 0.05F;
  605.                  entity.motionX = (double)((float)this.getRNG().nextGaussian() * f3);
  606.                  entity.motionY = (double)((float)this.getRNG().nextGaussian() * f3 + 0.2F);
  607.                  entity.motionZ = (double)((float)this.getRNG().nextGaussian() * f3);
  608.                  worldObj.spawnEntityInWorld(entity);
  609.             }
  610.            
  611.             if (hasCollar()) {
  612.                
  613.                 ItemStack stack = new ItemStack(CopiousDogsItems.dogCollar, 1, ItemDogCollar.getItemFromDye(getCollarColor()));
  614.                
  615.                 EntityItem entity = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, stack);
  616.                
  617.                  float f3 = 0.05F;
  618.                  entity.motionX = (double)((float)this.getRNG().nextGaussian() * f3);
  619.                  entity.motionY = (double)((float)this.getRNG().nextGaussian() * f3 + 0.2F);
  620.                  entity.motionZ = (double)((float)this.getRNG().nextGaussian() * f3);
  621.                  worldObj.spawnEntityInWorld(entity);
  622.             }
  623.         }
  624.        
  625.         super.onDeath(source);
  626.     }
  627.    
  628.     @Override
  629.     public void writeEntityToNBT(NBTTagCompound tag)
  630.     {
  631.         super.writeEntityToNBT(tag);
  632.        
  633.         tag.setBoolean("TailAnimated", isTailAnimated());
  634.         tag.setBoolean("HasLeash", hasLeash());
  635.         tag.setByte("CollarColor", getCollarColor());
  636.        
  637.         tag.setDouble("Aggressiveness", getAggressiveness());
  638.         tag.setDouble("Energy", getEnergy());
  639.     }
  640.    
  641.     @Override
  642.     public void readEntityFromNBT(NBTTagCompound tag)
  643.     {
  644.         super.readEntityFromNBT(tag);
  645.        
  646.         setTailAnimated(tag.getBoolean("TailAnimated"));
  647.         setHasLeash(tag.getBoolean("HasLeash"));
  648.         setCollarColor(tag.getByte("CollarColor"));
  649.        
  650.         setEnergy(tag.getDouble("Energy"));
  651.         setAggressiveness(tag.getDouble("Aggressiveness"));
  652.     }
  653.  
  654.     public static String getDogname() {
  655.         return dogname;
  656.     }
  657.  
  658.     public void setDogname(String dogname) {
  659.         EntityDog.dogname = dogname;
  660.         this.setCustomNameTag(dogname);
  661.     }
  662. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement