Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.rpg_neon.entity;
- import net.minecraftforge.registries.ForgeRegistries;
- import net.minecraftforge.fml.network.FMLPlayMessages;
- import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
- import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
- import net.minecraftforge.fml.client.registry.RenderingRegistry;
- import net.minecraftforge.eventbus.api.SubscribeEvent;
- import net.minecraftforge.client.event.ModelRegistryEvent;
- import net.minecraftforge.api.distmarker.OnlyIn;
- import net.minecraftforge.api.distmarker.Dist;
- import net.minecraft.world.gen.Heightmap;
- import net.minecraft.world.biome.Biome;
- import net.minecraft.world.World;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.DamageSource;
- import net.minecraft.item.SpawnEggItem;
- import net.minecraft.item.ItemGroup;
- import net.minecraft.item.Item;
- import net.minecraft.entity.monster.MonsterEntity;
- import net.minecraft.entity.ai.goal.SwimGoal;
- import net.minecraft.entity.ai.goal.RandomWalkingGoal;
- import net.minecraft.entity.ai.goal.PanicGoal;
- import net.minecraft.entity.ai.goal.LookRandomlyGoal;
- import net.minecraft.entity.ai.goal.LeapAtTargetGoal;
- import net.minecraft.entity.ai.goal.HurtByTargetGoal;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.EntityType;
- import net.minecraft.entity.EntitySpawnPlacementRegistry;
- import net.minecraft.entity.EntityClassification;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.CreatureAttribute;
- import net.minecraft.client.renderer.entity.model.RendererModel;
- import net.minecraft.client.renderer.entity.model.EntityModel;
- import net.minecraft.client.renderer.entity.MobRenderer;
- import net.mcreator.rpg_neon.RPGneonElements;
- @RPGneonElements.ModElement.Tag
- public class AeEntity extends RPGneonElements.ModElement {
- public static EntityType entity = null;
- public AeEntity(RPGneonElements instance) {
- super(instance, 50);
- FMLJavaModLoadingContext.get().getModEventBus().register(this);
- }
- @Override
- public void initElements() {
- entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.MONSTER).setShouldReceiveVelocityUpdates(true)
- .setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(0.6f, 1.8f)).build("ae")
- .setRegistryName("ae");
- elements.entities.add(() -> entity);
- elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("ae"));
- }
- @Override
- public void init(FMLCommonSetupEvent event) {
- for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
- biome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(entity, 20, 3, 30));
- }
- EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
- MonsterEntity::func_223315_a);
- }
- @SubscribeEvent
- @OnlyIn(Dist.CLIENT)
- public void registerModels(ModelRegistryEvent event) {
- RenderingRegistry.registerEntityRenderingHandler(CustomEntity.class, renderManager -> {
- return new MobRenderer(renderManager, new Modelwanderlantern(), 0.5f) {
- protected ResourceLocation getEntityTexture(Entity entity) {
- return new ResourceLocation("rpg_neon:textures/ir_antern.png");
- }
- };
- });
- }
- public static class CustomEntity extends MonsterEntity {
- public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
- this(entity, world);
- }
- public CustomEntity(EntityType<CustomEntity> type, World world) {
- super(type, world);
- experienceValue = 5;
- setNoAI(false);
- }
- @Override
- protected void registerGoals() {
- super.registerGoals();
- this.goalSelector.addGoal(1, new RandomWalkingGoal(this, 1));
- this.goalSelector.addGoal(2, new LookRandomlyGoal(this));
- this.goalSelector.addGoal(3, new SwimGoal(this));
- this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, (float) 0.8));
- this.goalSelector.addGoal(5, new PanicGoal(this, 1.2));
- this.targetSelector.addGoal(6, new HurtByTargetGoal(this));
- }
- @Override
- public CreatureAttribute getCreatureAttribute() {
- return CreatureAttribute.UNDEFINED;
- }
- protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
- super.dropSpecialItems(source, looting, recentlyHitIn);
- }
- @Override
- public net.minecraft.util.SoundEvent getAmbientSound() {
- return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(""));
- }
- @Override
- public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
- return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
- }
- @Override
- public net.minecraft.util.SoundEvent getDeathSound() {
- return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
- }
- @Override
- protected float getSoundVolume() {
- return 1.0F;
- }
- @Override
- protected void registerAttributes() {
- super.registerAttributes();
- if (this.getAttribute(SharedMonsterAttributes.ARMOR) != null)
- this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0);
- if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
- this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3);
- if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
- this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10);
- if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
- this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3);
- }
- }
- public static class wonderlanturn extends ModelBase {
- private final ModelRenderer bb_main;
- public wonderlanturn() {
- textureWidth = 16;
- textureHeight = 16;
- bb_main = new ModelRenderer(this);
- bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.014F, -10.0F, -1.014F, 2, 2, 2, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -3.0157F, -10.993F, -1.0087F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.0157F, -8.993F, -3.0087F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, 1.9825F, -11.0F, -2.0174F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.0087F, -5.9947F, -2.0035F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.007F, -9.0017F, 1.9913F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -1.0157F, -11.9982F, -0.014F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -0.0053F, -7.0017F, 0.993F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, 1.9912F, -9.0052F, 0.986F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -3.0105F, -9.9965F, 0.993F, 1, 1, 1, 0.0F, false));
- bb_main.cubeList.add(new ModelBox(bb_main, 2, 4, -3.014F, -8.9912F, -2.0052F, 1, 1, 1, 0.0F, false));
- }
- @Override
- public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
- bb_main.render(f5);
- }
- public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
- modelRenderer.rotateAngleX = x;
- modelRenderer.rotateAngleY = y;
- modelRenderer.rotateAngleZ = z;
- }
- public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e) {
- super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement