Guest User

error in code

a guest
Apr 27th, 2020
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.43 KB | None | 0 0
  1.  
  2. package net.mcreator.weamod.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.Items;
  21. import net.minecraft.item.ItemStack;
  22. import net.minecraft.item.ItemGroup;
  23. import net.minecraft.item.Item;
  24. import net.minecraft.entity.passive.AnimalEntity;
  25. import net.minecraft.entity.ai.goal.SwimGoal;
  26. import net.minecraft.entity.ai.goal.RandomWalkingGoal;
  27. import net.minecraft.entity.ai.goal.LookRandomlyGoal;
  28. import net.minecraft.entity.ai.goal.LeapAtTargetGoal;
  29. import net.minecraft.entity.ai.goal.HurtByTargetGoal;
  30. import net.minecraft.entity.SharedMonsterAttributes;
  31. import net.minecraft.entity.Pose;
  32. import net.minecraft.entity.EntityType;
  33. import net.minecraft.entity.EntitySpawnPlacementRegistry;
  34. import net.minecraft.entity.EntitySize;
  35. import net.minecraft.entity.EntityClassification;
  36. import net.minecraft.entity.Entity;
  37. import net.minecraft.entity.CreatureAttribute;
  38. import net.minecraft.entity.AgeableEntity;
  39. import net.minecraft.client.renderer.entity.model.EntityModel;
  40. import net.minecraft.client.renderer.entity.MobRenderer;
  41.  
  42. import net.mcreator.weamod.WeamodElements;
  43.  
  44. import java.util.ArrayList;
  45.  
  46. @WeamodElements.ModElement.Tag
  47. public class BonzibuddyEntity extends WeamodElements.ModElement {
  48. public static EntityType entity = null;
  49. public BonzibuddyEntity(WeamodElements instance) {
  50. super(instance, 1);
  51. FMLJavaModLoadingContext.get().getModEventBus().register(this);
  52. }
  53.  
  54. @Override
  55. public void initElements() {
  56. entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.CREATURE).setShouldReceiveVelocityUpdates(true)
  57. .setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(0.6f, 1.7f)).build("bonzibuddy")
  58. .setRegistryName("bonzibuddy");
  59. elements.entities.add(() -> entity);
  60. elements.items
  61. .add(() -> new SpawnEggItem(entity, -10079233, -6750055, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("bonzibuddy"));
  62. }
  63.  
  64. @Override
  65. public void init(FMLCommonSetupEvent event) {
  66. for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
  67. boolean biomeCriteria = false;
  68. if (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("jungle")))
  69. biomeCriteria = true;
  70. if (!biomeCriteria)
  71. continue;
  72. biome.getSpawns(EntityClassification.CREATURE).add(new Biome.SpawnListEntry(entity, 16, 3, 3));
  73. }
  74. EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
  75. AnimalEntity::func_223315_a);
  76. }
  77.  
  78. @SubscribeEvent
  79. @OnlyIn(Dist.CLIENT)
  80. public void registerModels(ModelRegistryEvent event) {
  81. RenderingRegistry.registerEntityRenderingHandler(CustomEntity.class, renderManager -> {
  82. return new MobRenderer(renderManager, new ModelGolira(), 0.5f) {
  83. protected ResourceLocation getEntityTexture(Entity entity) {
  84. return new ResourceLocation("weamod:textures/golira.png");
  85. }
  86. };
  87. });
  88. }
  89. public static class CustomEntity extends AnimalEntity {
  90. public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
  91. this(entity, world);
  92. }
  93.  
  94. public CustomEntity(EntityType<CustomEntity> type, World world) {
  95. super(type, world);
  96. experienceValue = 15;
  97. setNoAI(false);
  98. }
  99.  
  100. @Override
  101. protected void registerGoals() {
  102. super.registerGoals();
  103. this.goalSelector.addGoal(1, new RandomWalkingGoal(this, 1));
  104. this.goalSelector.addGoal(2, new LookRandomlyGoal(this));
  105. this.goalSelector.addGoal(3, new SwimGoal(this));
  106. this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, (float) 0.8));
  107. this.targetSelector.addGoal(5, new HurtByTargetGoal(this));
  108. }
  109.  
  110. @Override
  111. public CreatureAttribute getCreatureAttribute() {
  112. return CreatureAttribute.UNDEFINED;
  113. }
  114.  
  115. protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
  116. super.dropSpecialItems(source, looting, recentlyHitIn);
  117. }
  118.  
  119. @Override
  120. public net.minecraft.util.SoundEvent getAmbientSound() {
  121. return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("weamod:goliraugabuga"));
  122. }
  123.  
  124. @Override
  125. public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
  126. return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("weamod:goliralastimatum"));
  127. }
  128.  
  129. @Override
  130. public net.minecraft.util.SoundEvent getDeathSound() {
  131. return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("weamod:goliramuerte"));
  132. }
  133.  
  134. @Override
  135. protected float getSoundVolume() {
  136. return 1.0F;
  137. }
  138.  
  139. @Override
  140. protected void registerAttributes() {
  141. super.registerAttributes();
  142. if (this.getAttribute(SharedMonsterAttributes.ARMOR) != null)
  143. this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0.5);
  144. if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
  145. this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3);
  146. if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
  147. this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50);
  148. if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
  149. this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(12);
  150. }
  151.  
  152. @Override
  153. public AgeableEntity createChild(AgeableEntity ageable) {
  154. return (CustomEntity) entity.create(this.world);
  155. }
  156.  
  157. @Override
  158. public float getStandingEyeHeight(Pose pose, EntitySize size) {
  159. return this.isChild() ? size.height : 1.3F;
  160. }
  161.  
  162. @Override
  163. public boolean isBreedingItem(ItemStack stack) {
  164. if (stack == null)
  165. return false;
  166. if (new ItemStack(Items.ENCHANTED_GOLDEN_APPLE, (int) (1)).getItem() == stack.getItem())
  167. return true;
  168. return false;
  169. }
  170. }
  171.  
  172. public static class ModelGolira extends EntityModel<Entity> {
  173. Geometry.irongolem Geometry.irongolemObject;
  174. // Getter Methods
  175. public Geometry.irongolem getGeometry.irongolem() {
  176. return Geometry.irongolemObject;
  177. }
  178. // Setter Methods
  179. public void setGeometry.irongolem(
  180. Geometry.irongolem geometry.irongolemObject)
  181. {
  182. this.Geometry.irongolemObject = geometry.irongolemObject;
  183. }
  184. }
  185.  
  186. public static class Geometry.irongolem
  187. {
  188. private float textureheight;
  189. private float texturewidth;
  190. ArrayList<Object> bones = new ArrayList<Object>();
  191. // Getter Methods
  192. public float getTextureheight() {
  193. return textureheight;
  194. }
  195.  
  196. public float getTexturewidth() {
  197. return texturewidth;
  198. }
  199.  
  200. // Setter Methods
  201. public void setTextureheight(float textureheight) {
  202. this.textureheight = textureheight;
  203. }
  204.  
  205. public void setTexturewidth(float texturewidth) {
  206. this.texturewidth = texturewidth;
  207. }
  208. }
  209. }
Advertisement
Add Comment
Please, Sign In to add comment