Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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();

}

}

}

 

 

  • Author

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

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.

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.

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

 

Yes, I pointed this out in the OP's thread on Minecraft Forum.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.