Jump to content

Custom projectile not being launched and only falls down through ground 1.10.2


hhggtg3279

Recommended Posts

I have registered the entity and the item, everything is rendered and the damage is working however when I throw my projectile, it just drops though the ground and is not shot out like a snowball, I have no errors i'm aware of if anyone could double check and help please.

 

ModKnife class

 

package top.mod.item;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.SoundEvents;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.stats.StatList;

import net.minecraft.util.ActionResult;

import net.minecraft.util.EnumActionResult;

import net.minecraft.util.EnumHand;

import net.minecraft.util.SoundCategory;

import net.minecraft.world.World;

import net.minecraft.world.storage.WorldInfo;

public class ModKnife extends Item{

public ModKnife()

{

this.maxStackSize = 16;

}

public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)

{

if(!playerIn.capabilities.isCreativeMode)

{

--itemStackIn.stackSize;

}

 

worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.F));

 

if(!worldIn.isRemote)

{

EntityModKnife enitymodknife = new EntityModKnife(worldIn, playerIn);

worldIn.spawnEntityInWorld(enitymodknife);

 

}

return new ActionResult<ItemStack> (EnumActionResult.SUCCESS, itemStackIn);

}

}

 

 

 

EntityModKnife

 

package top.mod.item;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.projectile.EntityThrowable;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.util.DamageSource;

import net.minecraft.util.EnumParticleTypes;

import net.minecraft.util.math.RayTraceResult;

import net.minecraft.world.World;

public class EntityModKnife extends EntityThrowable{

public EntityModKnife(World worldIn) {

super(worldIn);

 

}

public EntityModKnife(World worldIn, EntityLivingBase throwerIn) {

super(worldIn, throwerIn);

 

}

public EntityModKnife(World worldIn, double x, double y, double z) {

super(worldIn, x, y, z);

 

}

@Override

protected void onImpact(RayTraceResult result)

{

if(result.entityHit != null)

{

result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 6.0F);

}

if(!this.worldObj.isRemote && this.rand.nextInt(8) == 0)

{

int i = 1;

if(this.rand.nextInt(32) == 0)

{

i =4;

}

 

double d0 = 0.08D;

 

for (int k = 0; k < 8; ++k)

{

this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double) this.rand.nextFloat() - 0.5D) * 0.08D, ((double) this.rand.nextFloat() - 0.5D) * 0.08D, ((double) this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Item.getIdFromItem(Items.EGG)});

}

}

if (!this.worldObj.isRemote)

{

this.setDead();

}

}

}

 

 

Link to comment
Share on other sites

Why don't you go back and look at what you may have copied this from.

ItemSnowball to be more precise.

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

It worked thankyou, I just needed to add the function public static void func_189662_a(DataFixer p_189662_0_)

{

    EntityThrowable.func_189661_a(p_189662_0_, "copperknife");

}

 

in my EntityModKnife

 

The

EntityThrowable.func_189661_a

method (a.k.a

registerFixesThrowable

in newer mappings) does absolutely nothing. Adding a static method will also do absolutely nothing unless you call it from somewhere.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

It worked thankyou, I just needed to add the function public static void func_189662_a(DataFixer p_189662_0_)

{

    EntityThrowable.func_189661_a(p_189662_0_, "copperknife");

}

 

in my EntityModKnife

 

The

EntityThrowable.func_189661_a

method (a.k.a

registerFixesThrowable

in newer mappings) does absolutely nothing. Adding a static method will also do absolutely nothing unless you call it from somewhere.

Im pretty sure what he actually forgot was to call setHeading (not sure if that is the name, but i am close).

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

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



×
×
  • Create New...

Important Information

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