Files
TinkersConstruct/src/main/java/tconstruct/items/blocks/ItemBlockLandmine.java
T

90 lines
2.4 KiB
Java
Raw Normal View History

package tconstruct.items.blocks;
2013-07-27 17:03:16 +10:00
import java.util.List;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.util.StatCollector;
import tconstruct.blocks.logic.TileEntityLandmine;
2013-11-29 23:16:32 -05:00
import tconstruct.common.TRepo;
2013-07-27 17:03:16 +10:00
/**
*
* @author fuj1n
*
*/
2013-08-31 05:13:31 -07:00
public class ItemBlockLandmine extends ItemBlock
{
public ItemBlockLandmine(int par1)
{
super(par1);
this.setHasSubtypes(true);
}
@Override
public void addInformation (ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
String interaction = null;
switch (par1ItemStack.getItemDamage())
{
case 0:
interaction = StatCollector.translateToLocal("landmine1.tooltip");
2013-08-31 05:13:31 -07:00
break;
case 1:
interaction = StatCollector.translateToLocal("landmine2.tooltip");
2013-08-31 05:13:31 -07:00
break;
case 2:
interaction = StatCollector.translateToLocal("landmine3.tooltip");
2013-08-31 05:13:31 -07:00
break;
default:
interaction = StatCollector.translateToLocal("landmine4.tooltip");
2013-08-31 05:13:31 -07:00
break;
}
2013-11-26 07:08:06 -05:00
par3List.add(StatCollector.translateToLocal("landmine5.tooltip") + interaction);
2013-08-31 05:13:31 -07:00
}
@Override
public int getMetadata (int par1)
{
return 0;
}
@Override
public boolean placeBlockAt (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
2013-11-29 23:16:32 -05:00
if (!world.setBlock(x, y, z, TRepo.landmine.blockID, metadata, 3))
2013-08-31 05:13:31 -07:00
{
return false;
}
2013-11-29 23:16:32 -05:00
if (world.getBlockId(x, y, z) == TRepo.landmine.blockID)
2013-08-31 05:13:31 -07:00
{
2013-11-29 23:16:32 -05:00
TRepo.landmine.onBlockPlacedBy(world, x, y, z, player, stack);
2013-08-31 05:13:31 -07:00
TileEntityLandmine te = (TileEntityLandmine) world.getBlockTileEntity(x, y, z);
if (te == null)
{
2013-11-29 23:16:32 -05:00
te = (TileEntityLandmine) TRepo.landmine.createTileEntity(world, metadata);
2013-08-31 05:13:31 -07:00
}
te.triggerType = stack.getItemDamage();
world.setBlockTileEntity(x, y, z, te);
2013-11-29 23:16:32 -05:00
TRepo.landmine.onPostBlockPlaced(world, x, y, z, metadata);
2013-08-31 05:13:31 -07:00
}
return true;
}
public static Random getRandom ()
{
return itemRand;
}
2013-07-27 17:03:16 +10:00
}