Jump to content

[1.8]Item Explosion upon water contact


Eixix

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 5 weeks later...

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

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.