Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.28 KB | None | 0 0
  1.  
  2. package net.mcreator.woodmagic.entity;
  3.  
  4. import net.minecraftforge.fml.relauncher.SideOnly;
  5. import net.minecraftforge.fml.relauncher.Side;
  6. import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
  7. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  8. import net.minecraftforge.fml.client.registry.RenderingRegistry;
  9.  
  10. import net.minecraft.world.biome.Biome;
  11. import net.minecraft.world.World;
  12. import net.minecraft.util.math.MathHelper;
  13. import net.minecraft.util.ResourceLocation;
  14. import net.minecraft.util.DamageSource;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.item.Item;
  17. import net.minecraft.entity.player.EntityPlayer;
  18. import net.minecraft.entity.ai.EntityAIWatchClosest;
  19. import net.minecraft.entity.ai.EntityAIWander;
  20. import net.minecraft.entity.ai.EntityAITempt;
  21. import net.minecraft.entity.ai.EntityAISwimming;
  22. import net.minecraft.entity.ai.EntityAIOpenDoor;
  23. import net.minecraft.entity.ai.EntityAILookIdle;
  24. import net.minecraft.entity.ai.EntityAILeapAtTarget;
  25. import net.minecraft.entity.SharedMonsterAttributes;
  26. import net.minecraft.entity.EnumCreatureAttribute;
  27. import net.minecraft.entity.EntityCreature;
  28. import net.minecraft.entity.Entity;
  29. import net.minecraft.client.renderer.entity.RenderLiving;
  30. import net.minecraft.client.model.ModelRenderer;
  31. import net.minecraft.client.model.ModelBase;
  32.  
  33.  
  34. import net.mcreator.woodmagic.item.ItemWoodwand;
  35. import net.mcreator.woodmagic.ElementsWoodMagic;
  36.  
  37. import java.util.Iterator;
  38. import java.util.ArrayList;
  39.  
  40. @ElementsWoodMagic.ModElement.Tag
  41. public class EntityOakminion extends ElementsWoodMagic.ModElement {
  42. public static final int ENTITYID = 1;
  43. public static final int ENTITYID_RANGED = 2;
  44. public EntityOakminion(ElementsWoodMagic instance) {
  45. super(instance, 3);
  46. }
  47.  
  48. @Override
  49. public void initElements() {
  50. elements.entities.add(() -> EntityEntryBuilder.create().entity(EntityCustom.class)
  51. .id(new ResourceLocation("woodmagic", "oakminion"), ENTITYID).name("oakminion").tracker(64, 3, true).egg(-19622, -8893165).build());
  52. }
  53.  
  54. private Biome[] allbiomes(net.minecraft.util.registry.RegistryNamespaced<ResourceLocation, Biome> in) {
  55. Iterator<Biome> itr = in.iterator();
  56. ArrayList<Biome> ls = new ArrayList<Biome>();
  57. while (itr.hasNext())
  58. ls.add(itr.next());
  59. return ls.toArray(new Biome[ls.size()]);
  60. }
  61.  
  62. @SideOnly(Side.CLIENT)
  63. @Override
  64. public void preInit(FMLPreInitializationEvent event) {
  65. RenderingRegistry.registerEntityRenderingHandler(EntityCustom.class, renderManager -> {
  66. return new RenderLiving(renderManager, new ModelOakMinionV2(), 0.5f) {
  67. protected ResourceLocation getEntityTexture(Entity entity) {
  68. return new ResourceLocation("woodmagic:textures/ak_inion-texturemap.png");
  69. }
  70. };
  71. });
  72. }
  73. public static class EntityCustom extends EntityCreature {
  74. public EntityCustom(World world) {
  75. super(world);
  76. setSize(0.6f, 1.8f);
  77. experienceValue = 5;
  78. this.isImmuneToFire = false;
  79. setNoAI(!true);
  80. enablePersistence();
  81. }
  82.  
  83. @Override
  84. protected void initEntityAI() {
  85. super.initEntityAI();
  86. this.tasks.addTask(1, new EntityAITempt(this, 1, new ItemStack(ItemWoodwand.block, (int) (1)).getItem(), false));
  87. this.tasks.addTask(2, new EntityAIWander(this, 1));
  88. this.tasks.addTask(3, new EntityAILookIdle(this));
  89. this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, (float) 6));
  90. this.tasks.addTask(5, new EntityAISwimming(this));
  91. this.tasks.addTask(6, new EntityAILeapAtTarget(this, (float) 0.8));
  92. this.tasks.addTask(7, new EntityAIOpenDoor(this, true));
  93. this.tasks.addTask(8, new EntityAIOpenDoor(this, false));
  94. }
  95.  
  96. @Override
  97. public EnumCreatureAttribute getCreatureAttribute() {
  98. return EnumCreatureAttribute.UNDEFINED;
  99. }
  100.  
  101. @Override
  102. protected boolean canDespawn() {
  103. return false;
  104. }
  105.  
  106. @Override
  107. protected Item getDropItem() {
  108. return null;
  109. }
  110.  
  111. @Override
  112. public net.minecraft.util.SoundEvent getAmbientSound() {
  113. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
  114. }
  115.  
  116. @Override
  117. public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
  118. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.generic.hurt"));
  119. }
  120.  
  121. @Override
  122. public net.minecraft.util.SoundEvent getDeathSound() {
  123. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.generic.death"));
  124. }
  125.  
  126. @Override
  127. protected float getSoundVolume() {
  128. return 1.0F;
  129. }
  130.  
  131. @Override
  132. public boolean attackEntityFrom(DamageSource source, float amount) {
  133. if (source == DamageSource.FALL)
  134. return false;
  135. if (source == DamageSource.CACTUS)
  136. return false;
  137. if (source == DamageSource.DROWN)
  138. return false;
  139. return super.attackEntityFrom(source, amount);
  140. }
  141.  
  142. @Override
  143. protected void applyEntityAttributes() {
  144. super.applyEntityAttributes();
  145. if (this.getEntityAttribute(SharedMonsterAttributes.ARMOR) != null)
  146. this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0D);
  147. if (this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
  148. this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
  149. if (this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
  150. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10D);
  151. if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
  152. this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3D);
  153. }
  154. }
  155.  
  156.  
  157. public static class ModelOakMinionV2 extends ModelBase {
  158. public ModelRenderer Head;
  159. public ModelRenderer Branch;
  160. public ModelRenderer torso;
  161. public ModelRenderer Branch2;
  162. public ModelRenderer Branch3;
  163. public ModelRenderer leaf;
  164. public ModelRenderer leg1;
  165. public ModelRenderer leg2;
  166. public ModelRenderer Arm1;
  167. public ModelRenderer Arm2;
  168. public ModelOakMinionV2() {
  169. this.textureWidth = 64;
  170. this.textureHeight = 64;
  171. this.Arm1 = new ModelRenderer(this, 0, 0);
  172. this.Arm1.setRotationPoint(6.5F, -1.4F, 0.0F);
  173. this.Arm1.addBox(0.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
  174. this.Branch3 = new ModelRenderer(this, 0, 0);
  175. this.Branch3.setRotationPoint(3.1F, 0.0F, 0.0F);
  176. this.Branch3.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1, 0.0F);
  177. this.setRotateAngle(Branch3, -0.045553093477052F, 0.6829473363053812F, 0.5009094953223726F);
  178. this.leg1 = new ModelRenderer(this, 0, 0);
  179. this.leg1.setRotationPoint(3.0F, 1.0F, 0.0F);
  180. this.leg1.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
  181. this.torso = new ModelRenderer(this, 0, 0);
  182. this.torso.setRotationPoint(0.0F, -0.8F, 0.0F);
  183. this.torso.addBox(-5.5F, -1.5F, -1.6F, 12, 3, 3, 0.0F);
  184. this.setRotateAngle(torso, 0.0F, 0.0153588974175501F, 0.0F);
  185. this.leaf = new ModelRenderer(this, 50, 50);
  186. this.leaf.setRotationPoint(3.5F, 0.5F, 0.3F);
  187. this.leaf.addBox(-0.8F, -1.4F, 0.0F, 4, 4, 0, 0.0F);
  188. this.setRotateAngle(leaf, -0.5462880558742251F, -0.27314402793711257F, -1.5481070465189704F);
  189. this.Arm2 = new ModelRenderer(this, 52, 0);
  190. this.Arm2.setRotationPoint(-6.0F, -1.5F, 0.0F);
  191. this.Arm2.addBox(-1.3F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
  192. this.leg2 = new ModelRenderer(this, 0, 0);
  193. this.leg2.setRotationPoint(0.0F, 1.0F, 0.0F);
  194. this.leg2.addBox(-3.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
  195. this.Branch = new ModelRenderer(this, 0, 0);
  196. this.Branch.setRotationPoint(6.0F, -7.3F, 0.0F);
  197. this.Branch.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1, 0.0F);
  198. this.setRotateAngle(Branch, 0.27314402793711257F, 0.091106186954104F, -0.5462880558742251F);
  199. this.Branch2 = new ModelRenderer(this, 0, 0);
  200. this.Branch2.setRotationPoint(3.1F, 0.0F, 0.0F);
  201. this.Branch2.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F);
  202. this.setRotateAngle(Branch2, -0.091106186954104F, -0.8651597102135892F, 0.0F);
  203. this.Head = new ModelRenderer(this, 0, 0);
  204. this.Head.setRotationPoint(0.0F, 16.8F, 0.0F);
  205. this.Head.addBox(-5.5F, -10.0F, -6.0F, 12, 12, 12, 0.0F);
  206. this.torso.addChild(this.Arm1);
  207. this.Branch.addChild(this.Branch3);
  208. this.torso.addChild(this.leg1);
  209. this.Head.addChild(this.torso);
  210. this.Branch2.addChild(this.leaf);
  211. this.torso.addChild(this.Arm2);
  212. this.torso.addChild(this.leg2);
  213. this.Head.addChild(this.Branch);
  214. this.Branch.addChild(this.Branch2);
  215. }
  216.  
  217. @Override
  218. public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
  219. this.Head.render(f5);
  220. }
  221.  
  222.  
  223. public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
  224. modelRenderer.rotateAngleX = x;
  225. modelRenderer.rotateAngleY = y;
  226. modelRenderer.rotateAngleZ = z;
  227. }
  228.  
  229. public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e) {
  230. super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  231. this.leg1.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
  232. this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
  233. this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
  234. this.leg2.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
  235. this.Arm2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
  236. this.Arm1.rotateAngleX = MathHelper.cos(f * 0.6662F) * f1;
  237. }
  238. }
  239. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement