Jump to content

Recommended Posts

Posted

Hello, I have made a custom grenade and it harms all but the player! How do I make it damage the player and display a custom death message, please could you tell me how or give me a link to a video tutorial?

Posted

Grenade Class:

 

package palmerjj01.YoshiCraft.Grenades;

 

import palmerjj01.YoshiCraft.Entity.EntityYoshiGrenade;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class ItemYoshiGrenade extends Item {

 

public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){

if(!player.capabilities.isCreativeMode){

--itemstack.stackSize;

}

world.playSoundAtEntity(player, "random.fizz", 0.7F, 0.8F);

 

if(!world.isRemote){

world.spawnEntityInWorld(new EntityYoshiGrenade(world, player));

}

 

return itemstack;

}

}

 

EntityGrenadeClass:

 

package palmerjj01.YoshiCraft.Entity;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.projectile.EntityThrowable;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.world.World;

 

public class EntityYoshiGrenade extends EntityThrowable {

 

 

public EntityYoshiGrenade(World p_i1776_1_) {

super(p_i1776_1_);

}

 

public EntityYoshiGrenade(World world, EntityLivingBase entity){

super(world, entity);

}

 

@Override

public void onImpact(MovingObjectPosition p_70184_1_) {

for(int i = 0; i < 10; i++){

this.worldObj.spawnParticle("flame", this.posX, this.posY, this.posZ, 0,9F, 0.9F);

}

 

if(!this.worldObj.isRemote){

this.setDead();

if(!this.worldObj.isRemote){

this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 4.5F, true);

}

}

}

 

}

Posted

Where is the player argument? What do you mean by "When I spawn Entity"?

 

 world.spawnEntityInWorld(new EntityYoshiGrenade(world, player));

I'll need help, and I'll give help. Just ask, you know I will!

Posted

That, specifically, I can't really say from experience. I was trying to answer this question:

 

Where is the player argument? What do you mean by "When I spawn Entity"?

I'll need help, and I'll give help. Just ask, you know I will!

Posted

     
if(!this.worldObj.isRemote){
         this.setDead();
         if(!this.worldObj.isRemote){
            this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 4.5F, true);
         }
      }

 

I ran that code and it produced perfectly valid explosions that damaged the player. So I think something else is preventing your character from taking damage. This may sound silly but I must ask. Are you testing this in creative mode? If not I would start looking at things like blast resistance or other parts of your mod.

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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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