Advertisement
Corosus

Untitled

Aug 12th, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import de.matthiasmann.twl.Button;
  4. import de.matthiasmann.twl.Widget;
  5. import de.matthiasmann.twl.model.SimpleButtonModel;
  6. import java.util.List;
  7. import net.minecraft.src.Block;
  8. import net.minecraft.src.Entity;
  9. import net.minecraft.src.EntityArrow303;
  10. import net.minecraft.src.EntityLiving;
  11. import net.minecraft.src.EntityPlayer;
  12. import net.minecraft.src.EntitySlimeFX;
  13. import net.minecraft.src.GuiModScreen;
  14. import net.minecraft.src.Item;
  15. import net.minecraft.src.ItemStack;
  16. import net.minecraft.src.Material;
  17. import net.minecraft.src.MathHelper;
  18. import net.minecraft.src.ModAction;
  19. import net.minecraft.src.ModSettingScreen;
  20. import net.minecraft.src.ModSettings;
  21. import net.minecraft.src.SettingFloat;
  22. import net.minecraft.src.SettingInt;
  23. import net.minecraft.src.WidgetClassicTwocolumn;
  24. import net.minecraft.src.WidgetFloat;
  25. import net.minecraft.src.WidgetInt;
  26. import net.minecraft.src.WidgetSimplewindow;
  27. import net.minecraft.src.World;
  28. import net.minecraft.src.mod_Arrows303;
  29.  
  30. public class EntityArrow303Ice extends EntityArrow303 {
  31.  
  32. public static ModSettings Settings;
  33. public static ModSettingScreen screen;
  34. public static SettingInt mobFreezeTime;
  35. public static SettingInt playerFreezeTime;
  36. public static SettingFloat playerFreezeFactor;
  37. public static SettingFloat mobFreezeFactor;
  38. public static WidgetSimplewindow subscreenwin;
  39. public EntityLiving victim;
  40. public float freezeFactor;
  41. public int freezeTimer;
  42.  
  43.  
  44. public void subscreen() {
  45. GuiModScreen.show((Widget)subscreenwin);
  46. }
  47.  
  48. public void setupConfig() {
  49. SimpleButtonModel var1 = new SimpleButtonModel();
  50. var1.addActionCallback(new ModAction(this, "subscreen", new Class[0]));
  51. Button var2 = new Button(var1);
  52. var2.setText("Ice Arrow");
  53. mod_Arrows303.screen.append(var2);
  54. WidgetClassicTwocolumn var3 = new WidgetClassicTwocolumn(new Widget[0]);
  55. mod_Arrows303.Settings.append(mobFreezeTime = new SettingInt("icearrow_mob_freeze_time", 10, 1, 30));
  56. var3.add(new WidgetInt(mobFreezeTime, "Mob freeze time"));
  57. mod_Arrows303.Settings.append(mobFreezeFactor = new SettingFloat("icearrow_mob_freeze_factor", 0.1F, 0.0F, 0.1F, 1.0F));
  58. var3.add(new WidgetFloat(mobFreezeFactor, "Mob freeze factor"));
  59. mod_Arrows303.Settings.append(playerFreezeTime = new SettingInt("icearrow_player_freeze_time", 5, 1, 30));
  60. var3.add(new WidgetInt(playerFreezeTime, "Player freeze time"));
  61. mod_Arrows303.Settings.append(playerFreezeFactor = new SettingFloat("icearrow_player_freeze_factor", 0.5F, 0.0F, 0.1F, 1.0F));
  62. var3.add(new WidgetFloat(playerFreezeFactor, "Player freeze factor"));
  63. subscreenwin = new WidgetSimplewindow(var3, "Ice Arrow");
  64. }
  65.  
  66. public void entityInit() {
  67. super.entityInit();
  68. this.name = "IceArrow";
  69. this.craftingResults = 1;
  70. this.itemId = 130 + Block.blocksList.length;
  71. this.tip = Item.snowball;
  72. this.item = new ItemStack(this.itemId, 1, 0);
  73. this.spriteFile = "/arrows/icearrow.png";
  74. }
  75.  
  76. public EntityArrow303Ice(World var1) {
  77. super(var1);
  78. }
  79.  
  80. public EntityArrow303Ice(World var1, double var2, double var4, double var6) {
  81. super(var1, var2, var4, var6);
  82. }
  83.  
  84. public EntityArrow303Ice(World var1, EntityLiving var2) {
  85. super(var1, var2);
  86. }
  87.  
  88. public boolean onHitBlock() {
  89. if(this.victim == null) {
  90. this.setEntityDead();
  91. return true;
  92. } else {
  93. return false;
  94. }
  95. }
  96.  
  97. public boolean onHitTarget(Entity var1) {
  98. if(var1 instanceof EntityLiving && this.victim == null) {
  99. List var2 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, var1.boundingBox.expand(3.0D, 3.0D, 3.0D));
  100.  
  101. for(int var3 = 0; var3 < var2.size(); ++var3) {
  102. Entity var4 = (Entity)var2.get(var3);
  103. if(var4 instanceof EntityArrow303Ice) {
  104. EntityArrow303Ice var5 = (EntityArrow303Ice)var4;
  105. if(var5.victim == var1) {
  106. var5.freezeTimer += this.getFreezeTimer((EntityLiving)var1);
  107. var5.isDead = false;
  108. var1.attackEntityFrom(this.shooter, 4);
  109. this.setEntityDead();
  110. return false;
  111. }
  112. }
  113. }
  114.  
  115. var1.attackEntityFrom(this.shooter, 4);
  116. this.freezeMob((EntityLiving)var1);
  117. return false;
  118. } else {
  119. return false;
  120. }
  121. }
  122.  
  123. public int getFreezeTimer(EntityLiving var1) {
  124. return (var1 instanceof EntityPlayer?(Integer)playerFreezeTime.get():(Integer)mobFreezeTime.get()).intValue() * 20;
  125. }
  126.  
  127. public void freezeMob(EntityLiving var1) {
  128. this.victim = var1;
  129. this.freezeFactor = (var1 instanceof EntityPlayer?(Float)playerFreezeFactor.get():(Float)mobFreezeFactor.get()).floatValue();
  130. this.freezeTimer = this.getFreezeTimer(var1);
  131. this.motionX = this.motionY = this.motionZ = 0.0D;
  132. }
  133.  
  134. public void unfreezeMob() {
  135. this.victim = null;
  136. }
  137.  
  138. public void setEntityDead() {
  139. if(this.victim != null) {
  140. this.unfreezeMob();
  141. }
  142.  
  143. super.setEntityDead();
  144. }
  145.  
  146. public void onUpdate() {
  147. super.onUpdate();
  148. if(this.victim != null) {
  149. if(this.victim.isDead || this.victim.deathTime > 0) {
  150. this.setEntityDead();
  151. return;
  152. }
  153.  
  154. this.isDead = false;
  155. this.inGround = false;
  156. this.posX = this.victim.posX;
  157. this.posY = this.victim.boundingBox.minY + (double)this.victim.height * 0.5D;
  158. this.posZ = this.victim.posZ;
  159. this.setPosition(this.posX, this.posY, this.posZ);
  160. this.victim.motionX *= (double)this.freezeFactor;
  161. this.victim.motionY *= (double)this.freezeFactor;
  162. this.victim.motionZ *= (double)this.freezeFactor;
  163. --this.freezeTimer;
  164. if(this.freezeTimer <= 0) {
  165. this.setEntityDead();
  166. }
  167. }
  168.  
  169. }
  170.  
  171. public boolean onHit() {
  172. if(this.victim != null) {
  173. return false;
  174. } else {
  175. int var1 = MathHelper.floor_double(this.posX);
  176. int var2 = MathHelper.floor_double(this.posY);
  177. int var3 = MathHelper.floor_double(this.posZ);
  178.  
  179. for(int var4 = var1 - 1; var4 <= var1 + 1; ++var4) {
  180. for(int var5 = var2 - 1; var5 <= var2 + 1; ++var5) {
  181. for(int var6 = var3 - 1; var6 <= var3 + 1; ++var6) {
  182. if(this.worldObj.getBlockMaterial(var4, var5, var6) == Material.water && this.worldObj.getBlockMetadata(var4, var5, var6) == 0) {
  183. this.worldObj.setBlockWithNotify(var4, var5, var6, 79);
  184. } else if(this.worldObj.getBlockMaterial(var4, var5, var6) == Material.lava && this.worldObj.getBlockMetadata(var4, var5, var6) == 0) {
  185. this.worldObj.setBlockWithNotify(var4, var5, var6, 49);
  186. } else if(this.worldObj.getBlockId(var4, var5, var6) == 51) {
  187. this.worldObj.setBlockWithNotify(var4, var5, var6, 0);
  188. } else if(this.worldObj.getBlockId(var4, var5, var6) == 50) {
  189. Block.blocksList[50].dropBlockAsItemWithChance(this.worldObj, var4, var5, var6, this.worldObj.getBlockMetadata(var4, var5, var6), 1.0F);
  190. this.worldObj.setBlockWithNotify(var4, var5, var6, 0);
  191. Block.blocksList[50].onBlockDestroyedByExplosion(this.worldObj, var4, var5, var6);
  192. }
  193. }
  194. }
  195. }
  196.  
  197. return true;
  198. }
  199. }
  200.  
  201. public void tickFlying() {
  202. super.tickFlying();
  203. if(((Boolean)mod_Arrows303.particles.get()).booleanValue()) {
  204. EntitySlimeFX var1 = new EntitySlimeFX(this.worldObj, this.posX, this.posY, this.posZ, Item.snowball);
  205. var1.motionX = var1.motionZ = var1.motionY = 0.01D;
  206. var1.renderDistanceWeight = 10.0D;
  207. mod_Arrows303.mc.effectRenderer.addEffect(var1);
  208. }
  209.  
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement