Guest User

Untitled

a guest
May 20th, 2020
28
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package net.mcreator.void_craft.entity;
  3.  
  4. import net.minecraftforge.fml.relauncher.SideOnly;
  5. import net.minecraftforge.fml.relauncher.Side;
  6. import net.minecraftforge.fml.common.registry.EntityRegistry;
  7. import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
  8. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  9. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  10. import net.minecraftforge.fml.client.registry.RenderingRegistry;
  11.  
  12. import net.minecraft.world.biome.Biome;
  13. import net.minecraft.world.World;
  14. import net.minecraft.util.math.MathHelper;
  15. import net.minecraft.util.math.BlockPos;
  16. import net.minecraft.util.ResourceLocation;
  17. import net.minecraft.util.EnumParticleTypes;
  18. import net.minecraft.util.DamageSource;
  19. import net.minecraft.pathfinding.PathNavigateFlying;
  20. import net.minecraft.item.ItemStack;
  21. import net.minecraft.item.Item;
  22. import net.minecraft.entity.projectile.EntityPotion;
  23. import net.minecraft.entity.monster.EntityZombie;
  24. import net.minecraft.entity.ai.EntityFlyHelper;
  25. import net.minecraft.entity.ai.EntityAIWander;
  26. import net.minecraft.entity.ai.EntityAILookIdle;
  27. import net.minecraft.entity.ai.EntityAIHurtByTarget;
  28. import net.minecraft.entity.ai.EntityAIAttackMelee;
  29. import net.minecraft.entity.SharedMonsterAttributes;
  30. import net.minecraft.entity.EnumCreatureType;
  31. import net.minecraft.entity.EnumCreatureAttribute;
  32. import net.minecraft.entity.Entity;
  33. import net.minecraft.client.renderer.entity.RenderLiving;
  34. import net.minecraft.client.model.ModelRenderer;
  35. import net.minecraft.client.model.ModelBox;
  36. import net.minecraft.client.model.ModelBase;
  37. import net.minecraft.block.state.IBlockState;
  38.  
  39. import net.mcreator.void_craft.item.ItemLostSoul;
  40. import net.mcreator.void_craft.ElementsVoidCraft;
  41.  
  42. import java.util.Random;
  43.  
  44. @ElementsVoidCraft.ModElement.Tag
  45. public class EntityWraith extends ElementsVoidCraft.ModElement {
  46. public static final int ENTITYID = 7;
  47. public static final int ENTITYID_RANGED = 8;
  48. public EntityWraith(ElementsVoidCraft instance) {
  49. super(instance, 116);
  50. }
  51.  
  52. @Override
  53. public void initElements() {
  54. elements.entities.add(() -> EntityEntryBuilder.create().entity(EntityCustom.class).id(new ResourceLocation("void_craft", "wraith"), ENTITYID)
  55. .name("wraith").tracker(64, 3, true).egg(-13816531, -15331303).build());
  56. }
  57.  
  58. @Override
  59. public void init(FMLInitializationEvent event) {
  60. Biome[] spawnBiomes = {Biome.REGISTRY.getObject(new ResourceLocation("void_craft:voidspace")),};
  61. EntityRegistry.addSpawn(EntityCustom.class, 2, 1, 1, EnumCreatureType.MONSTER, spawnBiomes);
  62. }
  63.  
  64. @SideOnly(Side.CLIENT)
  65. @Override
  66. public void preInit(FMLPreInitializationEvent event) {
  67. RenderingRegistry.registerEntityRenderingHandler(EntityCustom.class, renderManager -> {
  68. return new RenderLiving(renderManager, new Modelcustom_WaithOUOmodel(), 0.5f) {
  69. protected ResourceLocation getEntityTexture(Entity entity) {
  70. return new ResourceLocation("void_craft:textures/raith3.png");
  71. }
  72. };
  73. });
  74. }
  75. public static class EntityCustom extends EntityZombie {
  76. public EntityCustom(World world) {
  77. super(world);
  78. setSize(0.6f, 1.8f);
  79. experienceValue = 20;
  80. this.isImmuneToFire = true;
  81. setNoAI(!true);
  82. this.navigator = new PathNavigateFlying(this, this.world);
  83. this.moveHelper = new EntityFlyHelper(this);
  84. }
  85.  
  86. @Override
  87. protected void initEntityAI() {
  88. super.initEntityAI();
  89. this.tasks.addTask(1, new EntityAIWander(this, 1));
  90. this.tasks.addTask(2, new EntityAILookIdle(this));
  91. this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, false));
  92. this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.2, false));
  93. }
  94.  
  95. @Override
  96. public EnumCreatureAttribute getCreatureAttribute() {
  97. return EnumCreatureAttribute.UNDEFINED;
  98. }
  99.  
  100. @Override
  101. protected Item getDropItem() {
  102. return new ItemStack(ItemLostSoul.block, (int) (1)).getItem();
  103. }
  104.  
  105. @Override
  106. public net.minecraft.util.SoundEvent getAmbientSound() {
  107. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.wither.ambient"));
  108. }
  109.  
  110. @Override
  111. public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
  112. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.wither.hurt"));
  113. }
  114.  
  115. @Override
  116. public net.minecraft.util.SoundEvent getDeathSound() {
  117. return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.wither.death"));
  118. }
  119.  
  120. @Override
  121. protected float getSoundVolume() {
  122. return 1.0F;
  123. }
  124.  
  125. @Override
  126. public void fall(float l, float d) {
  127. }
  128.  
  129. @Override
  130. public boolean attackEntityFrom(DamageSource source, float amount) {
  131. if (source.getImmediateSource() instanceof EntityPotion)
  132. return false;
  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. if (source == DamageSource.LIGHTNING_BOLT)
  140. return false;
  141. return super.attackEntityFrom(source, amount);
  142. }
  143.  
  144. @Override
  145. protected void applyEntityAttributes() {
  146. super.applyEntityAttributes();
  147. if (this.getEntityAttribute(SharedMonsterAttributes.ARMOR) != null)
  148. this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0D);
  149. if (this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
  150. this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
  151. if (this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
  152. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(60D);
  153. if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
  154. this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(14D);
  155. this.getAttributeMap().registerAttribute(SharedMonsterAttributes.FLYING_SPEED);
  156. this.getEntityAttribute(SharedMonsterAttributes.FLYING_SPEED).setBaseValue(0.3);
  157. }
  158.  
  159. @Override
  160. public void onUpdate() {
  161. super.onUpdate();
  162. this.setNoGravity(true);
  163. }
  164.  
  165. @Override
  166. protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos) {
  167. }
  168.  
  169. @Override
  170. public void setNoGravity(boolean ignored) {
  171. super.setNoGravity(true);
  172. }
  173.  
  174. public void onLivingUpdate() {
  175. super.onLivingUpdate();
  176. int i = (int) this.posX;
  177. int j = (int) this.posY;
  178. int k = (int) this.posZ;
  179. Random random = this.rand;
  180. if (true)
  181. for (int l = 0; l < 2; ++l) {
  182. double d0 = (i + random.nextFloat());
  183. double d1 = (j + random.nextFloat());
  184. double d2 = (k + random.nextFloat());
  185. int i1 = random.nextInt(2) * 2 - 1;
  186. double d3 = (random.nextFloat() - 0.5D) * 0.5D;
  187. double d4 = (random.nextFloat() - 0.5D) * 0.5D;
  188. double d5 = (random.nextFloat() - 0.5D) * 0.5D;
  189. world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, d3, d4, d5);
  190. }
  191. }
  192. }
  193.  
  194. // Made with Blockbench
  195. // Paste this code into your mod.
  196. public static class Modelcustom_WaithOUOmodel extends ModelBase {
  197. private final ModelRenderer Body;
  198. private final ModelRenderer Head;
  199. private final ModelRenderer Right_Arm;
  200. private final ModelRenderer Left_arm;
  201. public custom_Wraithmodel() {
  202. textureWidth = 128;
  203. textureHeight = 128;
  204. Body = new ModelRenderer(this);
  205. Body.setRotationPoint(0.0F, 24.0F, 0.0F);
  206. Body.cubeList.add(new ModelBox(Body, 0, 9, -4.0F, -8.0F, -4.0F, 8, 1, 8, 0.0F, false));
  207. Body.cubeList.add(new ModelBox(Body, 0, 28, -3.0F, -10.0F, -4.0F, 6, 3, 8, 0.0F, false));
  208. Body.cubeList.add(new ModelBox(Body, 43, 18, -2.0F, -13.0F, -3.0F, 4, 5, 7, 0.0F, false));
  209. Body.cubeList.add(new ModelBox(Body, 24, 0, -2.0F, -14.0F, 2.0F, 4, 6, 1, 0.0F, false));
  210. Body.cubeList.add(new ModelBox(Body, 40, 0, -2.0F, -22.0F, -2.0F, 4, 14, 4, 0.0F, false));
  211. Body.cubeList.add(new ModelBox(Body, 19, 31, -2.0F, -10.0F, -4.0F, 4, 3, 9, 0.0F, false));
  212. Body.cubeList.add(new ModelBox(Body, 21, 21, -3.0F, -8.0F, -5.0F, 6, 1, 9, 0.0F, false));
  213. Body.cubeList.add(new ModelBox(Body, 0, 18, -3.0F, -8.0F, -4.0F, 6, 1, 9, 0.0F, false));
  214. Body.cubeList.add(new ModelBox(Body, 22, 8, -2.0F, -8.0F, -4.0F, 4, 1, 10, 0.0F, false));
  215. Body.cubeList.add(new ModelBox(Body, 21, 19, -3.0F, -7.0F, -6.0F, 6, 1, 1, 0.0F, false));
  216. Body.cubeList.add(new ModelBox(Body, 20, 28, -2.0F, -7.0F, 6.0F, 4, 1, 1, 0.0F, false));
  217. Body.cubeList.add(new ModelBox(Body, 61, 49, -5.0F, -7.0F, -4.0F, 1, 1, 8, 0.0F, false));
  218. Body.cubeList.add(new ModelBox(Body, 53, 60, 4.0F, -7.0F, -4.0F, 1, 1, 8, 0.0F, false));
  219. Body.cubeList.add(new ModelBox(Body, 4, 15, 2.0F, -7.0F, 5.0F, 1, 1, 1, 0.0F, false));
  220. Body.cubeList.add(new ModelBox(Body, 0, 15, 3.0F, -7.0F, 4.0F, 1, 1, 1, 0.0F, false));
  221. Body.cubeList.add(new ModelBox(Body, 4, 12, 3.0F, -7.0F, -5.0F, 1, 1, 1, 0.0F, false));
  222. Body.cubeList.add(new ModelBox(Body, 4, 9, -4.0F, -7.0F, 4.0F, 1, 1, 1, 0.0F, false));
  223. Body.cubeList.add(new ModelBox(Body, 4, 3, -4.0F, -7.0F, -5.0F, 1, 1, 1, 0.0F, false));
  224. Body.cubeList.add(new ModelBox(Body, 4, 0, -3.0F, -7.0F, 5.0F, 1, 1, 1, 0.0F, false));
  225. Head = new ModelRenderer(this);
  226. Head.setRotationPoint(0.0F, 24.0F, 0.0F);
  227. Head.cubeList.add(new ModelBox(Head, 0, 39, -4.0F, -31.0F, -4.0F, 1, 8, 8, 0.0F, false));
  228. Head.cubeList.add(new ModelBox(Head, 37, 37, 3.0F, -31.0F, -4.0F, 1, 8, 8, 0.0F, false));
  229. Head.cubeList.add(new ModelBox(Head, 0, 0, -4.0F, -23.0F, -4.0F, 8, 1, 8, 0.0F, false));
  230. Head.cubeList.add(new ModelBox(Head, 65, 31, -3.0F, -31.0F, -3.0F, 6, 8, 1, 0.0F, false));
  231. Head.cubeList.add(new ModelBox(Head, 0, 64, -2.0F, -32.0F, -3.0F, 4, 9, 1, 0.0F, false));
  232. Head.cubeList.add(new ModelBox(Head, 67, 18, -1.0F, -33.0F, -3.0F, 2, 10, 1, 0.0F, false));
  233. Head.cubeList.add(new ModelBox(Head, 10, 60, -3.0F, -32.0F, -4.0F, 1, 1, 8, 0.0F, false));
  234. Head.cubeList.add(new ModelBox(Head, 57, 22, -2.0F, -33.0F, -5.0F, 1, 1, 8, 0.0F, false));
  235. Head.cubeList.add(new ModelBox(Head, 56, 9, 2.0F, -32.0F, -4.0F, 1, 1, 8, 0.0F, false));
  236. Head.cubeList.add(new ModelBox(Head, 56, 0, 1.0F, -33.0F, -5.0F, 1, 1, 8, 0.0F, false));
  237. Head.cubeList.add(new ModelBox(Head, 55, 40, 0.0F, -34.0F, -6.0F, 1, 1, 8, 0.0F, false));
  238. Head.cubeList.add(new ModelBox(Head, 0, 55, -1.0F, -34.0F, -6.0F, 1, 1, 8, 0.0F, false));
  239. Head.cubeList.add(new ModelBox(Head, 0, 6, -1.0F, -33.0F, 2.0F, 2, 1, 1, 0.0F, false));
  240. Head.cubeList.add(new ModelBox(Head, 47, 31, -3.0F, -31.0F, 4.0F, 6, 8, 1, 0.0F, false));
  241. Head.cubeList.add(new ModelBox(Head, 63, 58, -3.0F, -32.0F, 3.0F, 6, 9, 1, 0.0F, false));
  242. Right_Arm = new ModelRenderer(this);
  243. Right_Arm.setRotationPoint(0.0F, 24.0F, 0.0F);
  244. setRotationAngle(Right_Arm, 3.1416F, 0.0F, 0.0F);
  245. Right_Arm.cubeList.add(new ModelBox(Right_Arm, 38, 53, -3.0F, 9.0F, -2.0F, 1, 13, 4, 0.0F, false));
  246. Right_Arm.cubeList.add(new ModelBox(Right_Arm, 51, 51, -5.0F, 9.0F, -2.0F, 1, 13, 4, 0.0F, false));
  247. Right_Arm.cubeList.add(new ModelBox(Right_Arm, 10, 69, -4.0F, 9.0F, 1.0F, 1, 13, 1, 0.0F, false));
  248. Right_Arm.cubeList.add(new ModelBox(Right_Arm, 0, 12, -4.0F, 10.0F, -1.0F, 1, 1, 2, 0.0F, false));
  249. Right_Arm.cubeList.add(new ModelBox(Right_Arm, 0, 9, -4.0F, 21.0F, -1.0F, 1, 1, 2, 0.0F, false));
  250. Right_Arm.cubeList.add(new ModelBox(Right_Arm, 48, 67, -4.0F, 9.0F, -2.0F, 1, 13, 1, 0.0F, false));
  251. Left_arm = new ModelRenderer(this);
  252. Left_arm.setRotationPoint(0.0F, 24.0F, 0.0F);
  253. setRotationAngle(Left_arm, 3.1416F, 0.0F, 0.0F);
  254. Left_arm.cubeList.add(new ModelBox(Left_arm, 28, 49, 4.0F, 9.0F, -2.0F, 1, 13, 4, 0.0F, false));
  255. Left_arm.cubeList.add(new ModelBox(Left_arm, 18, 43, 2.0F, 9.0F, -2.0F, 1, 13, 4, 0.0F, false));
  256. Left_arm.cubeList.add(new ModelBox(Left_arm, 32, 66, 3.0F, 9.0F, 1.0F, 1, 13, 1, 0.0F, false));
  257. Left_arm.cubeList.add(new ModelBox(Left_arm, 0, 3, 3.0F, 10.0F, -1.0F, 1, 1, 2, 0.0F, false));
  258. Left_arm.cubeList.add(new ModelBox(Left_arm, 0, 0, 3.0F, 21.0F, -1.0F, 1, 1, 2, 0.0F, false));
  259. Left_arm.cubeList.add(new ModelBox(Left_arm, 28, 66, 3.0F, 9.0F, -2.0F, 1, 13, 1, 0.0F, false));
  260. }
  261.  
  262. @Override
  263. public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
  264. Body.render(f5);
  265. Head.render(f5);
  266. Right_Arm.render(f5);
  267. Left_arm.render(f5);
  268. }
  269.  
  270. public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
  271. modelRenderer.rotateAngleX = x;
  272. modelRenderer.rotateAngleY = y;
  273. modelRenderer.rotateAngleZ = z;
  274. }
  275.  
  276. public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e) {
  277. super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  278. this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
  279. this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
  280. this.Right_Arm.rotateAngleX = MathHelper.cos(f * 0.6662F) * f1;
  281. this.Left_arm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
  282. }
  283. }
  284. }
RAW Paste Data