Advertisement
Guest User

Untitled

a guest
May 5th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1.  
  2. package net.mcreator.rpg_neon.entity;
  3.  
  4. import net.minecraftforge.registries.ForgeRegistries;
  5. import net.minecraftforge.fml.network.FMLPlayMessages;
  6. import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
  7. import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
  8. import net.minecraftforge.fml.client.registry.RenderingRegistry;
  9. import net.minecraftforge.eventbus.api.SubscribeEvent;
  10. import net.minecraftforge.client.event.ModelRegistryEvent;
  11. import net.minecraftforge.api.distmarker.OnlyIn;
  12. import net.minecraftforge.api.distmarker.Dist;
  13.  
  14. import net.minecraft.world.gen.Heightmap;
  15. import net.minecraft.world.biome.Biome;
  16. import net.minecraft.world.World;
  17. import net.minecraft.util.ResourceLocation;
  18. import net.minecraft.util.DamageSource;
  19. import net.minecraft.item.SpawnEggItem;
  20. import net.minecraft.item.ItemGroup;
  21. import net.minecraft.item.Item;
  22. import net.minecraft.entity.monster.MonsterEntity;
  23. import net.minecraft.entity.ai.goal.SwimGoal;
  24. import net.minecraft.entity.ai.goal.RandomWalkingGoal;
  25. import net.minecraft.entity.ai.goal.PanicGoal;
  26. import net.minecraft.entity.ai.goal.LookRandomlyGoal;
  27. import net.minecraft.entity.ai.goal.LeapAtTargetGoal;
  28. import net.minecraft.entity.ai.goal.HurtByTargetGoal;
  29. import net.minecraft.entity.SharedMonsterAttributes;
  30. import net.minecraft.entity.EntityType;
  31. import net.minecraft.entity.EntitySpawnPlacementRegistry;
  32. import net.minecraft.entity.EntityClassification;
  33. import net.minecraft.entity.Entity;
  34. import net.minecraft.entity.CreatureAttribute;
  35. import net.minecraft.client.renderer.entity.model.RendererModel;
  36. import net.minecraft.client.renderer.entity.model.EntityModel;
  37. import net.minecraft.client.renderer.entity.MobRenderer;
  38.  
  39. import net.mcreator.rpg_neon.RPGneonElements;
  40.  
  41. @RPGneonElements.ModElement.Tag
  42. public class AeEntity extends RPGneonElements.ModElement {
  43. public static EntityType entity = null;
  44. public AeEntity(RPGneonElements instance) {
  45. super(instance, 50);
  46. FMLJavaModLoadingContext.get().getModEventBus().register(this);
  47. }
  48.  
  49. @Override
  50. public void initElements() {
  51. entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.MONSTER).setShouldReceiveVelocityUpdates(true)
  52. .setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(0.6f, 1.8f)).build("ae")
  53. .setRegistryName("ae");
  54. elements.entities.add(() -> entity);
  55. elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("ae"));
  56. }
  57.  
  58. @Override
  59. public void init(FMLCommonSetupEvent event) {
  60. for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
  61. biome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(entity, 20, 3, 30));
  62. }
  63. EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
  64. MonsterEntity::func_223315_a);
  65. }
  66.  
  67. @SubscribeEvent
  68. @OnlyIn(Dist.CLIENT)
  69. public void registerModels(ModelRegistryEvent event) {
  70. RenderingRegistry.registerEntityRenderingHandler(CustomEntity.class, renderManager -> {
  71. return new MobRenderer(renderManager, new Modelwanderlantern(), 0.5f) {
  72. protected ResourceLocation getEntityTexture(Entity entity) {
  73. return new ResourceLocation("rpg_neon:textures/ir_antern.png");
  74. }
  75. };
  76. });
  77. }
  78. public static class CustomEntity extends MonsterEntity {
  79. public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
  80. this(entity, world);
  81. }
  82.  
  83. public CustomEntity(EntityType<CustomEntity> type, World world) {
  84. super(type, world);
  85. experienceValue = 5;
  86. setNoAI(false);
  87. }
  88.  
  89. @Override
  90. protected void registerGoals() {
  91. super.registerGoals();
  92. this.goalSelector.addGoal(1, new RandomWalkingGoal(this, 1));
  93. this.goalSelector.addGoal(2, new LookRandomlyGoal(this));
  94. this.goalSelector.addGoal(3, new SwimGoal(this));
  95. this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, (float) 0.8));
  96. this.goalSelector.addGoal(5, new PanicGoal(this, 1.2));
  97. this.targetSelector.addGoal(6, new HurtByTargetGoal(this));
  98. }
  99.  
  100. @Override
  101. public CreatureAttribute getCreatureAttribute() {
  102. return CreatureAttribute.UNDEFINED;
  103. }
  104.  
  105. protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
  106. super.dropSpecialItems(source, looting, recentlyHitIn);
  107. }
  108.  
  109. @Override
  110. public net.minecraft.util.SoundEvent getAmbientSound() {
  111. return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(""));
  112. }
  113.  
  114. @Override
  115. public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
  116. return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
  117. }
  118.  
  119. @Override
  120. public net.minecraft.util.SoundEvent getDeathSound() {
  121. return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
  122. }
  123.  
  124. @Override
  125. protected float getSoundVolume() {
  126. return 1.0F;
  127. }
  128.  
  129. @Override
  130. protected void registerAttributes() {
  131. super.registerAttributes();
  132. if (this.getAttribute(SharedMonsterAttributes.ARMOR) != null)
  133. this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0);
  134. if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
  135. this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3);
  136. if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
  137. this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10);
  138. if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
  139. this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3);
  140. }
  141. }
  142.  
  143.  
  144. public static class wonderlanturn extends ModelBase {
  145. private final ModelRenderer bb_main;
  146.  
  147. public wonderlanturn() {
  148. textureWidth = 16;
  149. textureHeight = 16;
  150.  
  151. bb_main = new ModelRenderer(this);
  152. bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
  153. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.014F, -10.0F, -1.014F, 2, 2, 2, 0.0F, false));
  154. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -3.0157F, -10.993F, -1.0087F, 1, 1, 1, 0.0F, false));
  155. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.0157F, -8.993F, -3.0087F, 1, 1, 1, 0.0F, false));
  156. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, 1.9825F, -11.0F, -2.0174F, 1, 1, 1, 0.0F, false));
  157. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.0087F, -5.9947F, -2.0035F, 1, 1, 1, 0.0F, false));
  158. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.007F, -9.0017F, 1.9913F, 1, 1, 1, 0.0F, false));
  159. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.0157F, -11.9982F, -0.014F, 1, 1, 1, 0.0F, false));
  160. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -0.0053F, -7.0017F, 0.993F, 1, 1, 1, 0.0F, false));
  161. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, 1.9912F, -9.0052F, 0.986F, 1, 1, 1, 0.0F, false));
  162. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -3.0105F, -9.9965F, 0.993F, 1, 1, 1, 0.0F, false));
  163. bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -3.014F, -8.9912F, -2.0052F, 1, 1, 1, 0.0F, false));
  164. }
  165.  
  166. @Override
  167. public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
  168. bb_main.render(f5);
  169. }
  170. public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
  171. modelRenderer.rotateAngleX = x;
  172. modelRenderer.rotateAngleY = y;
  173. modelRenderer.rotateAngleZ = z;
  174. }
  175.  
  176. public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e) {
  177. super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  178. }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement