Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.woodmagic.entity;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
- import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
- import net.minecraftforge.fml.client.registry.RenderingRegistry;
- import net.minecraft.world.biome.Biome;
- import net.minecraft.world.World;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.DamageSource;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.Item;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.ai.EntityAIWatchClosest;
- import net.minecraft.entity.ai.EntityAIWander;
- import net.minecraft.entity.ai.EntityAITempt;
- import net.minecraft.entity.ai.EntityAISwimming;
- import net.minecraft.entity.ai.EntityAIOpenDoor;
- import net.minecraft.entity.ai.EntityAILookIdle;
- import net.minecraft.entity.ai.EntityAILeapAtTarget;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.EnumCreatureAttribute;
- import net.minecraft.entity.EntityCreature;
- import net.minecraft.entity.Entity;
- import net.minecraft.client.renderer.entity.RenderLiving;
- import net.minecraft.client.model.ModelRenderer;
- import net.minecraft.client.model.ModelBase;
- import net.mcreator.woodmagic.item.ItemWoodwand;
- import net.mcreator.woodmagic.ElementsWoodMagic;
- import java.util.Iterator;
- import java.util.ArrayList;
- @ElementsWoodMagic.ModElement.Tag
- public class EntityOakminion extends ElementsWoodMagic.ModElement {
- public static final int ENTITYID = 1;
- public static final int ENTITYID_RANGED = 2;
- public EntityOakminion(ElementsWoodMagic instance) {
- super(instance, 3);
- }
- @Override
- public void initElements() {
- elements.entities.add(() -> EntityEntryBuilder.create().entity(EntityCustom.class)
- .id(new ResourceLocation("woodmagic", "oakminion"), ENTITYID).name("oakminion").tracker(64, 3, true).egg(-19622, -8893165).build());
- }
- private Biome[] allbiomes(net.minecraft.util.registry.RegistryNamespaced<ResourceLocation, Biome> in) {
- Iterator<Biome> itr = in.iterator();
- ArrayList<Biome> ls = new ArrayList<Biome>();
- while (itr.hasNext())
- ls.add(itr.next());
- return ls.toArray(new Biome[ls.size()]);
- }
- @SideOnly(Side.CLIENT)
- @Override
- public void preInit(FMLPreInitializationEvent event) {
- RenderingRegistry.registerEntityRenderingHandler(EntityCustom.class, renderManager -> {
- return new RenderLiving(renderManager, new ModelOakMinionV2(), 0.5f) {
- protected ResourceLocation getEntityTexture(Entity entity) {
- return new ResourceLocation("woodmagic:textures/ak_inion-texturemap.png");
- }
- };
- });
- }
- public static class EntityCustom extends EntityCreature {
- public EntityCustom(World world) {
- super(world);
- setSize(0.6f, 1.8f);
- experienceValue = 5;
- this.isImmuneToFire = false;
- setNoAI(!true);
- enablePersistence();
- }
- @Override
- protected void initEntityAI() {
- super.initEntityAI();
- this.tasks.addTask(1, new EntityAITempt(this, 1, new ItemStack(ItemWoodwand.block, (int) (1)).getItem(), false));
- this.tasks.addTask(2, new EntityAIWander(this, 1));
- this.tasks.addTask(3, new EntityAILookIdle(this));
- this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, (float) 6));
- this.tasks.addTask(5, new EntityAISwimming(this));
- this.tasks.addTask(6, new EntityAILeapAtTarget(this, (float) 0.8));
- this.tasks.addTask(7, new EntityAIOpenDoor(this, true));
- this.tasks.addTask(8, new EntityAIOpenDoor(this, false));
- }
- @Override
- public EnumCreatureAttribute getCreatureAttribute() {
- return EnumCreatureAttribute.UNDEFINED;
- }
- @Override
- protected boolean canDespawn() {
- return false;
- }
- @Override
- protected Item getDropItem() {
- return null;
- }
- @Override
- public net.minecraft.util.SoundEvent getAmbientSound() {
- return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
- }
- @Override
- public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
- return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.generic.hurt"));
- }
- @Override
- public net.minecraft.util.SoundEvent getDeathSound() {
- return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.generic.death"));
- }
- @Override
- protected float getSoundVolume() {
- return 1.0F;
- }
- @Override
- public boolean attackEntityFrom(DamageSource source, float amount) {
- if (source == DamageSource.FALL)
- return false;
- if (source == DamageSource.CACTUS)
- return false;
- if (source == DamageSource.DROWN)
- return false;
- return super.attackEntityFrom(source, amount);
- }
- @Override
- protected void applyEntityAttributes() {
- super.applyEntityAttributes();
- if (this.getEntityAttribute(SharedMonsterAttributes.ARMOR) != null)
- this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0D);
- if (this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
- this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
- if (this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10D);
- if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
- this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3D);
- }
- }
- public static class ModelOakMinionV2 extends ModelBase {
- public ModelRenderer Head;
- public ModelRenderer Branch;
- public ModelRenderer torso;
- public ModelRenderer Branch2;
- public ModelRenderer Branch3;
- public ModelRenderer leaf;
- public ModelRenderer leg1;
- public ModelRenderer leg2;
- public ModelRenderer Arm1;
- public ModelRenderer Arm2;
- public ModelOakMinionV2() {
- this.textureWidth = 64;
- this.textureHeight = 64;
- this.Arm1 = new ModelRenderer(this, 0, 0);
- this.Arm1.setRotationPoint(6.5F, -1.4F, 0.0F);
- this.Arm1.addBox(0.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
- this.Branch3 = new ModelRenderer(this, 0, 0);
- this.Branch3.setRotationPoint(3.1F, 0.0F, 0.0F);
- this.Branch3.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1, 0.0F);
- this.setRotateAngle(Branch3, -0.045553093477052F, 0.6829473363053812F, 0.5009094953223726F);
- this.leg1 = new ModelRenderer(this, 0, 0);
- this.leg1.setRotationPoint(3.0F, 1.0F, 0.0F);
- this.leg1.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
- this.torso = new ModelRenderer(this, 0, 0);
- this.torso.setRotationPoint(0.0F, -0.8F, 0.0F);
- this.torso.addBox(-5.5F, -1.5F, -1.6F, 12, 3, 3, 0.0F);
- this.setRotateAngle(torso, 0.0F, 0.0153588974175501F, 0.0F);
- this.leaf = new ModelRenderer(this, 50, 50);
- this.leaf.setRotationPoint(3.5F, 0.5F, 0.3F);
- this.leaf.addBox(-0.8F, -1.4F, 0.0F, 4, 4, 0, 0.0F);
- this.setRotateAngle(leaf, -0.5462880558742251F, -0.27314402793711257F, -1.5481070465189704F);
- this.Arm2 = new ModelRenderer(this, 52, 0);
- this.Arm2.setRotationPoint(-6.0F, -1.5F, 0.0F);
- this.Arm2.addBox(-1.3F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
- this.leg2 = new ModelRenderer(this, 0, 0);
- this.leg2.setRotationPoint(0.0F, 1.0F, 0.0F);
- this.leg2.addBox(-3.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F);
- this.Branch = new ModelRenderer(this, 0, 0);
- this.Branch.setRotationPoint(6.0F, -7.3F, 0.0F);
- this.Branch.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1, 0.0F);
- this.setRotateAngle(Branch, 0.27314402793711257F, 0.091106186954104F, -0.5462880558742251F);
- this.Branch2 = new ModelRenderer(this, 0, 0);
- this.Branch2.setRotationPoint(3.1F, 0.0F, 0.0F);
- this.Branch2.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F);
- this.setRotateAngle(Branch2, -0.091106186954104F, -0.8651597102135892F, 0.0F);
- this.Head = new ModelRenderer(this, 0, 0);
- this.Head.setRotationPoint(0.0F, 16.8F, 0.0F);
- this.Head.addBox(-5.5F, -10.0F, -6.0F, 12, 12, 12, 0.0F);
- this.torso.addChild(this.Arm1);
- this.Branch.addChild(this.Branch3);
- this.torso.addChild(this.leg1);
- this.Head.addChild(this.torso);
- this.Branch2.addChild(this.leaf);
- this.torso.addChild(this.Arm2);
- this.torso.addChild(this.leg2);
- this.Head.addChild(this.Branch);
- this.Branch.addChild(this.Branch2);
- }
- @Override
- public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
- this.Head.render(f5);
- }
- public void setRotateAngle(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);
- this.leg1.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
- this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
- this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
- this.leg2.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
- this.Arm2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
- this.Arm1.rotateAngleX = MathHelper.cos(f * 0.6662F) * f1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement