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.

Featured Replies

Posted

Hey there!

I was wondering whether it's possible to detect when an item is dropped into the water and let the item explode upon impact or not?

Messed a bit around with the onDroppedByPlayer Event, but didn't manage to get it done!  :o

Thanks for the help,

Eixix

I think you can accomplish this with the onEntityUpdate method available in the item class. You'd have to proactively check for water, though.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Once an item is dropped it become an EntityItem. An EntityItem extends Entity so has access to the isInWater() method to tell you it is in water. If you also want it to explode in rain, use the isWet() method instead. So like diesieben07 says, you should make your item drop your own custom EntityItem that explodes if isInWater() is true (check in the onUpdate() method). For explosions, look at TNT or EntityCreeper.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

Thanks for your help! :) I got a custom EntityItem now, but the thing is, that it will not render, neither i can pick it up once i threw it on the ground.

 

This is my Item Class (ItemSodium.java)

package tv.Tunfisch.HardcoreSilicon.Items;

import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import tv.Tunfisch.HardcoreSilicon.Entity.EntitySodium;

public class ItemSodium extends Item{
ItemStack itemSodium;
public ItemSodium(){

}

@Override
public boolean hasCustomEntity(ItemStack stack)
    {
        return true;
    }

@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack)
    {
        return new EntitySodium(world);
    }
}

 

This is my Custom Entity (EntitySodium.java) - side note: I did not yet implement the explosion

package tv.Tunfisch.HardcoreSilicon.Entity;

import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import tv.Tunfisch.HardcoreSilicon.Register.ItemRegister;


public class EntitySodium extends EntityItem{

public EntitySodium(World worldIn) {
	super(worldIn);
	setEntityItemStack(new ItemStack(ItemRegister.itemSodium));
}

@Override
public void onEntityUpdate(){
	if (this.inWater){

	}
}

}

 

Thanks for being patient with me im not a native speaker and just began to develop Minecraft Mods :)

Greetings,

 

Edit: Removed pastebin links

  • 5 weeks later...
  • Author

Sorry for answering so late, had to do a lot at university...

Can you describe how to copy them to the new entity?

Thank you!

 

Yep, I'm a total noob, merry christas ;)

 

  • Author

You're the real MVP ;)

Ok last question on a very basic thing:

How do I spawn already existing entities? In this case a primed TNT at the location of the Item?

 

Sorry for all the questions, but I'm not really into entities... Is there some kind of documentation for 1.8 modding?

 

Thanks,

Eixix

  • Author

So how do I get the coordinates from the EntitySodium transferred to the EntityPrimedTNT?

  • Author

But this is an ItemEntity there are no such fields ._. Or I am too dumb to find them...

  • Author

Oh for gods sake there was a typo ... How dumb actually... I know basic Java, but I'm struggeling with the weird structure Minecraft has from time to time...

First term computer science...

 

Thanks anyway

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.