Jump to content

Item needs to spawn an entity but it only gives the animation for using the item.


witherlord00

Recommended Posts

Alright guys one more problem don't get tired of me just yet. I have a problem with an item and I am wanting to spawn a Mob or Entity from said Item, but it ain't quite working.

I used the Egg item's class as a base but I am sure I am missing a detail or two...

 

 FUiiP9U.gif

 

The code as presented-

package mod.teamfusion.fuziongearz.items;

import mod.teamfusion.fuziongearz.entities.models.EntityAirPaladin; 
import mod.teamfusion.fuziongearz.entities.models.EntityEarthPaladin;
import mod.teamfusion.fuziongearz.entities.models.EntityFirePaladin;
import mod.teamfusion.fuziongearz.entities.models.EntityWaterPaladin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

public class ItemElementsCall extends BasicItem { 

	public ItemElementsCall() {
		super("element_caller");	
	}
	@Override
	 public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
	    {
	        ItemStack itemstack = playerIn.getHeldItem(handIn);
	        
	        
	        if (!worldIn.isRemote)
	        {
	           
	            EntityEarthPaladin entity = new EntityEarthPaladin(worldIn);
	            
	        			    worldIn.spawnEntity(entity); 
	     
	        			    
	
}
	        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);}
    
	    
	

}

 

 

Edited by witherlord00
Link to comment
Share on other sites

6 minutes ago, witherlord00 said:

The code as presented

You never set the entities position.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

4 minutes ago, witherlord00 said:

What is the class for an Armor Stand maybe I can pull an entity position from it?

EntityArmorStand, but you are not gonna be able to pull an entity position from it. Just call setPostion on your instance of EntityEarthPaladin and pass in the appropriate x, y, z postion.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

This still not be working

package mod.teamfusion.fuziongearz.items;

import mod.teamfusion.fuziongearz.entities.models.EntityAirPaladin; 
import mod.teamfusion.fuziongearz.entities.models.EntityEarthPaladin;
import mod.teamfusion.fuziongearz.entities.models.EntityFirePaladin;
import mod.teamfusion.fuziongearz.entities.models.EntityWaterPaladin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

public class ItemElementsCall extends BasicItem { 

	
	public ItemElementsCall() {
		super("element_caller");	
		  
	}
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn, int x, int y, int z)
	    {
	        ItemStack itemstack = playerIn.getHeldItem(handIn);
	        
	        
	        if (!worldIn.isRemote)
	        {
	           
	            EntityEarthPaladin entity = new EntityEarthPaladin (worldIn);
	            
	            
	        			    worldIn.spawnEntity(entity); 
	        			    entity.setPosition(x, y, z);
	        			    
	
}
	        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);}
    
	
	

}

I think it's missing something.

Link to comment
Share on other sites

3 minutes ago, witherlord00 said:

I think it's missing something.

Do you know Java?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, witherlord00 said:

Basic Java

Then you should know what @Override means and why you should have it on your methods.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

Saying "not to be rude" does not make your post polite. No, I will not just "get off your back" if you post copyrighted code on this forum. Please do not do it again and try to understand why it is a bad thing.

 

Post updated code.

package mod.teamfusion.fuziongearz.items;

import mod.teamfusion.fuziongearz.entities.models.EntityAirPaladin; 
import mod.teamfusion.fuziongearz.entities.models.EntityEarthPaladin;
import mod.teamfusion.fuziongearz.entities.models.EntityFirePaladin;
import mod.teamfusion.fuziongearz.entities.models.EntityWaterPaladin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

public class ItemElementsCall extends BasicItem { 

	
	public ItemElementsCall() {
		super("element_caller");	
		  
	}
	@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn, int x, int y, int z)
	    {
	        ItemStack itemstack = playerIn.getHeldItem(handIn);
	        
	        
	        if (!worldIn.isRemote)
	        {
	           
	            EntityEarthPaladin entity = new EntityEarthPaladin (worldIn);
	            
	          entity.setPosition(x, y, z);
	            
	        			   worldIn.spawnEntity(entity); 
	          
	        			    
	
}
	        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);}
    
	
	

}

 

Link to comment
Share on other sites

@witherlord00 You did not fix the override error. Item#onItemRightClick doesn't have x, y, z parameters.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

package mod.teamfusion.fuziongearz.entities.models;

import javax.annotation.Nullable;

import mod.teamfusion.fuziongearz.init.FusionBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAIMoveTowardsTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWanderAvoidWater;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.EntityAIZombieAttack;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.monster.EntityGuardian;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSourceIndirect;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.BossInfo;
import net.minecraft.world.BossInfoServer;
import net.minecraft.world.World;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class EntityEarthPaladin extends EntityMob {  

	
	
	public EntityEarthPaladin(World p_i1738_1_) {
		super(p_i1738_1_);
		//width  //height
		this.setSize(0.9F, 1.9F);
		
	}
	  @Override
	    protected void initEntityAI() {
		  this.tasks.addTask(6, new EntityAIWanderAvoidWater(this, 1.0D));
	        this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false));
	        this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	        this.tasks.addTask(8, new EntityAILookIdle(this));
	        this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
	        this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F));
	        this.applyEntityAI();}
	        
	  public static final ResourceLocation LOOT_TABLE = new ResourceLocation("fusiongears" + ":" + "earth_paladin");
	        
	        private void applyEntityAI(){
	            this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
	           
	         
}   
	        
	        
	  @Override
	    protected void applyEntityAttributes() {
    super.applyEntityAttributes();
    this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(200.0D);
    this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
    this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);
    this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(2.0D);

	 
		}
		 public boolean attackEntityAsMob(Entity entityIn)
		    {
		      
		        this.world.setEntityState(this, (byte)4);
		        boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)(7 + this.rand.nextInt(15)));

		       

		        this.playSound(SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, 1.0F, 1.0F);
		        return flag;
}
		
	    
	    
	     protected SoundEvent getHurtSound()
	        {
	            return SoundEvents.ITEM_SHIELD_BLOCK;
	        }
	    
	       
	        protected SoundEvent getDeathSound()
	        {
	            return SoundEvents.ITEM_SHIELD_BREAK;
	        }

	        protected void playStepSound(BlockPos pos, Block blockIn)
	        {
	            this.playSound(SoundEvents.ENTITY_IRONGOLEM_STEP, 1.0F, 1.0F);
	            
	        } 
	        @Override
	    	public boolean attackEntityFrom(DamageSource source, float damage) {
	    		if (source instanceof EntityDamageSourceIndirect)
	    			return false;
	    		return super.attackEntityFrom(source, damage);
	    	}
	    	@Override
	        public int getTotalArmorValue() {
	            return 10;}  
	    	
	    	@Override
	        protected ResourceLocation getLootTable()
	        {
	               return LOOT_TABLE;
	           }
	    	 
	    	    
}

EntityEarthPaladin Class^^^

 

 

package mod.teamfusion.fuziongearz.entities.models;

import mod.teamfusion.fuziongearz.Main;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Biomes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ModEntities {

    public static void init() { 
        
        int id = 1;//primary secondary
        EntityRegistry.registerModEntity(new ResourceLocation("fusiongears" + ":" + "earth_paladin"),EntityEarthPaladin.class, "earth_paladin", id++, Main.instance, 64, 3, true, 0x3CFF00, 0x33CC00);//real egg colors- 0x3CFF00 by 0x33CC00 
        EntityRegistry.registerModEntity(new ResourceLocation("fusiongears" + ":" + "fire_paladin"),EntityFirePaladin.class, "fire_paladin", id++, Main.instance, 64, 3, true, 0xEF7C38, 0xBC6E2F);//real egg colors- 0xEF7C38, 0xBC6E2F 
        EntityRegistry.registerModEntity(new ResourceLocation("fusiongears" + ":" + "water_paladin"),EntityWaterPaladin.class, "water_paladin", id++, Main.instance, 64, 3, true, 0x388DEF, 0x2F65BC);//real egg colors-0x388DEF, 0x2F65BC
        EntityRegistry.registerModEntity(new ResourceLocation("fusiongears" + ":" + "air_paladin"),EntityAirPaladin.class, "air_paladin", id++, Main.instance, 64, 3, true, 0xA4A4A4, 0x838383);//real egg colors- 0xA4A4A4, 0x838383

        
        
        
        

    }

    @SideOnly(Side.CLIENT)
    public static void initModels() {
       RenderingRegistry.registerEntityRenderingHandler(EntityEarthPaladin.class, RenderEarthPaladin.FACTORY);
       RenderingRegistry.registerEntityRenderingHandler(EntityFirePaladin.class, RenderFirePaladin.FACTORY);
       RenderingRegistry.registerEntityRenderingHandler(EntityWaterPaladin.class, RenderWaterPaladin.FACTORY);
       RenderingRegistry.registerEntityRenderingHandler(EntityAirPaladin.class, RenderAirPaladin.FACTORY);
       
    }
}

ModEntities(registry class)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.