Advertisement
Corosus

Untitled

Oct 31st, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.55 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.io.File;
  4.  
  5. public class mod_MinerZombie extends BaseMod implements Runnable {
  6.  
  7.  
  8. public static World worldRef;
  9. public static Minecraft mc;
  10. public static EntityPlayer theplayer;
  11.  
  12. @MLProp2 public static STBoolean NaziB;
  13. @MLProp2 public static STBoolean KnightB;
  14. @MLProp2 public static STBoolean hostilesBreakWallsB;
  15. @MLProp2 public static STFloat MiningZombieDigPower;
  16.  
  17. public static long lastTickRun = 0;
  18. public static boolean inMenu = false;
  19.  
  20.  
  21.  
  22. public ModSettings settings;
  23. public ModSettingScreen screen;
  24.  
  25. public mod_MinerZombie() {
  26. ModLoader.RegisterEntityID(EntityZombieKnight.class, "ZombieKnight", ModLoader.getUniqueEntityId());
  27. ModLoader.RegisterEntityID(EntityZombieNazi.class, "ZombieNazi", ModLoader.getUniqueEntityId());
  28. ModLoader.RegisterEntityID(EntityZombieMiner.class, "ZombieMiner", ModLoader.getUniqueEntityId());
  29. /*ModLoader.RegisterEntityID(EntityPetArrow.class, "PetArrow", ModLoader.getUniqueEntityId());*/
  30. ModLoader.AddSpawn(EntityZombieKnight.class, 10, 0, 1000, EnumCreatureType.monster);
  31. ModLoader.AddSpawn(EntityZombieNazi.class, 10, 0, 1000, EnumCreatureType.monster);
  32. ModLoader.AddSpawn(EntityZombieMiner.class, 10, 0, 1000, EnumCreatureType.monster);
  33. }
  34.  
  35. public void ModsLoaded() {
  36. try {
  37. mod_PathingActivated.hasMinerZombie = true;
  38. } catch (Exception ex) {
  39. }
  40.  
  41. loadConfig();
  42. }
  43.  
  44. public void loadConfig() {
  45. NaziB = new STBoolean("NaziB", true);
  46. KnightB = new STBoolean("KnightB", true);
  47. hostilesBreakWallsB = new STBoolean("hostilesBreakWalls", true);
  48. MiningZombieDigPower = new STFloat("MiningZombieDigPower", 2.8F, 0.0F, 0.1F, 50F);
  49. settings = new ModSettings("Miner Zombie Settings");
  50. screen = new ModSettingScreen("Miner Zombie");
  51. settings.append(NaziB);
  52. screen.append(new WidgetBoolean(NaziB, "Enable Zombie Nazi"));
  53. settings.append(KnightB);
  54. screen.append(new WidgetBoolean(KnightB, "Enable Zombie Knight"));
  55. settings.append(hostilesBreakWallsB);
  56. screen.append(new WidgetBoolean(hostilesBreakWallsB, "Enable Zombie Miner"));
  57. settings.append(MiningZombieDigPower);
  58. screen.append(new WidgetFloat(MiningZombieDigPower, "Zombie dig power"));
  59. SimpleButtonModel simplebuttonmodel = new SimpleButtonModel();
  60. simplebuttonmodel.addActionCallback(new ModAction(settings, "resetAll", new Class[0]));
  61. Button button = new Button(simplebuttonmodel);
  62. button.setText("Reset all to defaults");
  63. screen.append(button);
  64. settings.load();
  65. //run();
  66. (new Thread(this)).start();
  67. inMenu = true;
  68.  
  69. try {
  70. //enable for non guiapi
  71. //mod_AITools.setupProperties(this.getClass());
  72. } catch (Exception ex) {
  73. ex.printStackTrace();
  74. }
  75. }
  76.  
  77. public void run() {
  78. try {
  79. while(true) {
  80. if(mc == null) {
  81. mc = ModLoader.getMinecraftInstance();
  82. }
  83.  
  84. if(mc == null) {
  85. Thread.sleep(500L);
  86. } else if(mc.thePlayer == null) {
  87. Thread.sleep(500L);
  88. } else {
  89. worldRef = mc.theWorld;
  90. theplayer = mc.thePlayer;
  91. Thread.sleep(5000L);
  92. }
  93. }
  94. } catch (Throwable var6) {
  95. var6.printStackTrace();
  96. }
  97. }
  98.  
  99.  
  100.  
  101.  
  102. public void AddRenderer(Map var1) {
  103. var1.put(EntityZombieKnight.class, new RenderBiped(new ModelBiped(), 0.5F));
  104. var1.put(EntityZombieNazi.class, new RenderBiped(new ModelBiped(), 0.5F));
  105. var1.put(EntityZombieMiner.class, new RenderBiped(new ModelBiped(), 0.5F));
  106. }
  107.  
  108. public String Version() {
  109. return "v1.0 for MC b1.7.3";
  110. }
  111.  
  112.  
  113. public static void mineComplete(EntityCreature entityliving) {
  114. entityliving.mining = false;
  115. entityliving.noMoveTicks = 0;
  116. entityliving.curBlockDmg = 0.0F;
  117.  
  118. if(entityliving instanceof EntityZombieMiner) {
  119. ((EntityZombieMiner)entityliving).swingArm = false;
  120. entityliving.forcejump = true;
  121. }
  122. }
  123.  
  124. public static void tryDig(EntityCreature entityliving, EntityLiving entityliving1) {
  125. if(entityliving1 == null) {
  126. return;
  127. }
  128.  
  129. float f = 2.0F;
  130. float f1 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  131. float f2 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  132. f1 = 0.0F;
  133. float f3 = entityliving.prevRotationYaw + (entityliving.rotationYaw - entityliving.prevRotationYaw) * f;
  134. int i = (int)Math.floor((double)(f3 / 90F) + 0.5D);
  135. f3 = (float)i * 90F;
  136. double d = entityliving.prevPosX + (entityliving.posX - entityliving.prevPosX) * (double)f;
  137. double d1 = (entityliving.prevPosY + (entityliving.posY - entityliving.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityliving.yOffset;
  138. double d2 = entityliving.prevPosZ + (entityliving.posZ - entityliving.prevPosZ) * (double)f;
  139. Vec3D vec3d = Vec3D.createVector(d, d1, d2);
  140. float f4 = MathHelper.cos(-f3 * 0.01745329F - 3.141593F);
  141. float f5 = MathHelper.sin(-f3 * 0.01745329F - 3.141593F);
  142. float f6 = -MathHelper.cos(-f1 * 0.01745329F - 0.7853982F);
  143. float f7 = MathHelper.sin(-f1 * 0.01745329F - 0.7853982F);
  144. float f8 = f5 * f6;
  145. float f9 = f7;
  146. float f10 = f4 * f6;
  147. entityliving.info = f3;
  148. double d3 = 1.0D;
  149. double d4 = 1.8D;
  150. double d5 = 0.050000000000000003D;
  151. Vec3D vec3d1 = vec3d.addVector((double)f8 * d3, (double)f9 * d3, (double)f10 * d3);
  152. MovingObjectPosition movingobjectposition = entityliving.worldObj.rayTraceBlocks_do(vec3d, vec3d1, true);
  153.  
  154. if(movingobjectposition == null) {
  155. return;
  156. }
  157.  
  158. int j = MathHelper.floor_float((float)(entityliving.posX - entityliving1.posX));
  159. int k = (int)(entityliving.posY - entityliving1.posY);
  160. int l = MathHelper.floor_float((float)(entityliving.posZ - entityliving1.posZ));
  161. boolean flag = false;
  162.  
  163. if(j + l > 0) {
  164. if((float)(k / (j + l)) > 1.0F) {
  165. flag = true;
  166. }
  167. } else if(k > 2) {
  168. flag = true;
  169. }
  170.  
  171. if(movingobjectposition.typeOfHit == EnumMovingObjectType.TILE || flag) {
  172. int i2 = f2 >= -20F ? 0 : 1;
  173. int i1;
  174. int j1;
  175. int k1;
  176.  
  177. if(flag) {
  178. i1 = (int)entityliving.posX;
  179. j1 = (int)entityliving.posZ - 1;
  180. k1 = (int)entityliving.posZ;
  181. } else {
  182. i1 = movingobjectposition.blockX;
  183. j1 = movingobjectposition.blockY + i2;
  184. k1 = movingobjectposition.blockZ;
  185. }
  186.  
  187. int l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  188.  
  189. if(l1 == 0 && (i2 == 1 || flag)) {
  190. j1--;
  191. l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  192.  
  193. if(l1 == 0 && i2 == 1) {
  194. j1--;
  195. l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  196. }
  197. }
  198.  
  199. if(i1 != entityliving.curBlockX || j1 != entityliving.curBlockZ) {
  200. entityliving.curBlockDmg = 0.0F;
  201. entityliving.curBlockX = i1;
  202. entityliving.curBlockZ = j1;
  203. }
  204.  
  205. Block block = Block.blocksList[l1];
  206. float f11 = MiningZombieDigPower.get() * (float)(entityliving.nearbyMinerCount + 1);
  207.  
  208. if(block != null) {
  209. if(entityliving instanceof EntityZombieMiner) {
  210. ((EntityZombieMiner)entityliving).swingArm = true;
  211. }
  212.  
  213. double d6 = (double)f8 * d5;
  214. double d7 = (double)f9 * d5;
  215. double d8 = (double)f10 * d5;
  216.  
  217. for(int j2 = 0; j2 <= (int)entityliving.curBlockDmg; j2++) {
  218. entityliving.worldObj.spawnParticle("explode", d + ((double)f8 * d4 + (double)(entityliving.worldObj.rand.nextFloat() * (entityliving.curBlockDmg / 10F))), d1 + (double)f9 * d4 + 0.0D + (double)((entityliving.worldObj.rand.nextFloat() * entityliving.curBlockDmg) / 10F), d2 + ((double)f10 * d4 + (double)((entityliving.worldObj.rand.nextFloat() * entityliving.curBlockDmg) / 10F)), 0.0D, 0.0D, 0.0D);
  219. }
  220.  
  221. mc.effectRenderer.addBlockHitEffects((int)i1, (int)j1, (int)k1, 0);
  222. entityliving.worldObj.playSoundAtEntity(entityliving, "step.stone", 1.0F, 1.0F / (entityliving.worldObj.rand.nextFloat() * 0.4F + 0.8F));
  223. entityliving.curBlockDmg += f11 / (float)block.blockHardness;
  224.  
  225. if(entityliving.getDistanceToEntity(theplayer) >= 17F);
  226.  
  227. if(entityliving.curBlockDmg > 10F) {
  228. entityliving.curBlockDmg = 0.0F;
  229. mc.effectRenderer.addBlockDestroyEffects((int)i1, (int)j1, (int)k1, 1, 0);
  230. entityliving.worldObj.spawnParticle("flame", d + (double)f8 * d4, d1 + (double)f9 * d4, d2 + (double)f10 * d4, d6 / 2D, d7 / 2D, d8 / 2D);
  231. entityliving.worldObj.setBlockWithNotify(i1, j1, k1, 0);
  232. mineComplete(entityliving);
  233. entityliving.nearbyMinerCount = 0;
  234. Object obj = null;
  235. List list = entityliving.worldObj.getEntitiesWithinAABBExcludingEntity(entityliving, entityliving.boundingBox.expand(2D, 2D, 2D));
  236.  
  237. if(list != null) {
  238. for(int k2 = 0; k2 < list.size(); k2++) {
  239. Entity entity = (Entity)list.get(k2);
  240.  
  241. if(entity instanceof EntityCreature) {
  242. entityliving.nearbyMinerCount++;
  243. mineComplete((EntityCreature)entity);
  244. }
  245. }
  246. }
  247. }
  248.  
  249. if(entityliving.worldObj.getBlockMaterial(i1, j1, k1) != Material.ground) {
  250. if(entityliving.worldObj.getBlockMaterial(i1, j1, k1) != Material.rock);
  251. }
  252. }
  253. }
  254. }
  255. }
  256.  
  257.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement