Skip to content

Instantly share code, notes, and snippets.

@unascribed
Created May 10, 2015 05:00
Show Gist options
  • Save unascribed/f200f64bb169271d07d6 to your computer and use it in GitHub Desktop.
Save unascribed/f200f64bb169271d07d6 to your computer and use it in GitHub Desktop.
/** @author Aesen Vismea **/
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
EnumFacing face = EnumFacing.values()[side];
int xO = x+face.getFrontOffsetX();
int yO = y+face.getFrontOffsetY();
int zO = z+face.getFrontOffsetZ();
world.setBlock(xO, yO, zO, Blocks.mob_spawner);
TileEntityMobSpawner te = new TileEntityMobSpawner();
te.readFromNBT(itemstack.getTagCompound());
world.setTileEntity(xO, yO, zO, te);
return true;
}
// Example code to create an item for a Wither spawner
{
ItemStack stack = new ItemStack(MyMod.MY_ITEM);
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("EntityId", 64);
stack.setTagCompound(tag);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment