Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. package com.harry.customgems.gems;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6.  
  7. import com.harry.customgems.init.ModItems;
  8.  
  9. import mod.akrivus.kagic.entity.EntityGem;
  10. import mod.akrivus.kagic.entity.ai.EntityAICommandGems;
  11. import mod.akrivus.kagic.entity.ai.EntityAIFollowDiamond;
  12. import mod.akrivus.kagic.entity.ai.EntityAIStandGuard;
  13. import mod.akrivus.kagic.entity.ai.EntityAIStay;
  14. import mod.akrivus.kagic.entity.gem.EntityAgate;
  15. import mod.akrivus.kagic.entity.gem.EntityQuartzSoldier;
  16. import mod.akrivus.kagic.entity.gem.GemCuts;
  17. import mod.akrivus.kagic.entity.gem.GemPlacements;
  18. import mod.heimrarnadalr.kagic.util.Colors;
  19. import net.minecraft.block.state.IBlockState;
  20. import net.minecraft.entity.EntityLivingBase;
  21. import net.minecraft.entity.SharedMonsterAttributes;
  22. import net.minecraft.entity.ai.EntityAILookIdle;
  23. import net.minecraft.entity.ai.EntityAIWatchClosest;
  24. import net.minecraft.entity.passive.IAnimals;
  25. import net.minecraft.entity.player.EntityPlayer;
  26. import net.minecraft.init.MobEffects;
  27. import net.minecraft.potion.PotionEffect;
  28. import net.minecraft.util.DamageSource;
  29. import net.minecraft.util.EnumHand;
  30. import net.minecraft.util.ResourceLocation;
  31. import net.minecraft.util.math.AxisAlignedBB;
  32. import net.minecraft.world.World;
  33.  
  34. public class EntityFort extends EntityAgate implements IAnimals
  35. {
  36.  
  37. public static final HashMap<IBlockState, Double> FORT_YIELDS = new HashMap<IBlockState, Double>();
  38. public static final double AGATE_DEFECTIVITY_MULTIPLIER = 1;
  39. public static final double AGATE_DEPTH_THRESHOLD = 42;
  40. public static final HashMap<Integer, ResourceLocation> AGATE_HAIR_STYLES = new HashMap<Integer, ResourceLocation>();
  41. private int waterTicks = 0;
  42. public boolean atWater = false;
  43. //public static final float[][] BANDCOLORS = {{0xF9 / 255f, 0xFF / 255f, 0xFE / 255f}}; // #F9FFFE
  44.  
  45. public static final int SKIN_COLOR_BEGIN = 0xDF5400;
  46. public static final int SKIN_COLOR_END = 0xFF5B42;
  47.  
  48. private static final int NUM_HAIRSTYLES = 1;
  49.  
  50. public static final int HAIR_COLOR_BEGIN = 0xDBAA65;
  51. public static final int HAIR_COLOR_END = 0xDBAA42;
  52.  
  53. public EntityFort(World worldIn) {
  54. super(worldIn);
  55. this.isSoldier = true;
  56. this.setSize(0.6F, 2.0F);
  57. this.nativeColor = 11;
  58. this.setInsigniaColor(0);
  59. this.droppedGemItem = ModItems.FORT_GEM;
  60. this.droppedCrackedGemItem = ModItems.CRACKED_FORT_GEM;
  61.  
  62. //Define valid gem cuts and placements
  63. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.BACK_OF_HEAD);
  64. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.LEFT_EYE);
  65. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.RIGHT_EYE);
  66. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.FOREHEAD);
  67. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.NOSE);
  68. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.LEFT_CHEEK);
  69. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.RIGHT_CHEEK);
  70. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.BACK);
  71. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.CHEST);
  72. this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.BELLY);
  73.  
  74. this.stayAI = new EntityAIStay(this);
  75. this.tasks.addTask(1, new EntityAIFollowDiamond(this, 1.0D));
  76. this.tasks.addTask(1, new EntityAICommandGems(this, 0.6D));
  77. this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 16.0F));
  78. //this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityMob.class, 16.0F));
  79. this.tasks.addTask(7, new EntityAIStandGuard(this, 0.6D));
  80. this.tasks.addTask(8, new EntityAILookIdle(this));
  81.  
  82. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50.0D);
  83. this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(15.0D);
  84. this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4D);
  85. }
  86.  
  87. public boolean processInteract(EntityPlayer player, EnumHand hand) {
  88. return super.processInteract(player, hand);
  89. }
  90.  
  91. public void onDeath(DamageSource cause) {
  92. super.onDeath(cause);
  93. }
  94.  
  95. public void whenDefective() {
  96. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
  97. this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(10.0D);
  98. }
  99.  
  100. public void whenPrimary() {
  101. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(80.D);
  102. this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(50.0D);
  103. }
  104. private void startScreamingAtTheWater() {
  105. if (!this.world.isRemote) {
  106. AxisAlignedBB axisalignedbb = new AxisAlignedBB(this.posX, this.posY, this.posZ, this.posX + 1, this.posY + 1, this.posZ + 1).grow(16.0, this.world.getHeight(), 16.0);
  107. List<EntityLivingBase> list = this.world.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
  108. for (EntityLivingBase entity : list) {
  109. if (!entity.isDead || entity.getHealth() > 0.0F) {
  110. if (entity instanceof EntityGem) {
  111. EntityGem gem = (EntityGem) entity;
  112. if (this.getServitude() == gem.getServitude()) {
  113. if (this.getServitude() == EntityGem.SERVE_HUMAN) {
  114. if (this.isOwnerId(gem.getOwnerId())) {
  115. entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 300));
  116. }
  117. } else {
  118. entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 300));
  119. }
  120. }
  121. }
  122. if (this.isOwner(entity)) {
  123. entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 100));
  124. }
  125. }
  126. }
  127. }
  128. }
  129.  
  130. @Override
  131. public void onLivingUpdate() {
  132. if (this.waterTicks > 80 && !this.isDefective() && !(this.isDead || this.getHealth() <= 0.0F)) {
  133. this.startScreamingAtTheWater();
  134. this.waterTicks = 0;
  135. }
  136. this.waterTicks += 1;
  137. super.onLivingUpdate();
  138. }
  139.  
  140. protected int generateGemColor() {
  141. return 0x003BE0;
  142. }
  143.  
  144. @Override
  145. protected int generateSkinColor() {
  146. ArrayList<Integer> skinColors = new ArrayList<Integer>();
  147. skinColors.add(EntityFort.SKIN_COLOR_BEGIN);
  148. skinColors.add(EntityFort.SKIN_COLOR_END);
  149. return Colors.arbiLerp(skinColors);
  150. }
  151.  
  152. @Override
  153. protected int generateHairColor() {
  154. ArrayList<Integer> hairColors = new ArrayList<Integer>();
  155. hairColors.add(EntityFort.HAIR_COLOR_BEGIN);
  156. hairColors.add(EntityFort.HAIR_COLOR_END);
  157. return Colors.arbiLerp(hairColors);
  158. }
  159.  
  160. @Override
  161. protected int generateHairStyle() {
  162. return this.rand.nextInt(EntityFort.NUM_HAIRSTYLES);
  163. }
  164.  
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement