| public class ItemMonture extends Item |
| { |
| public static String[] type = new String[]{"ItemMonture1", "ItemMonture2", "ItemMonture3", "ItemMonture4", "ItemMonture5", "ItemMonture6", "ItemMonture7", "ItemMonture8", "ItemMonture9", "ItemMonture10", "ItemMonture11", "ItemMonture12", "ItemMonture13", "ItemMonture14", "Recycleur"}; |
| public IIcon[] iconArray = new IIcon[type.length]; |
| |
| public ItemMonture() |
| { |
| super(); |
| this.setHasSubtypes(true); |
| } |
| |
| public int getMaxItemUseDuration(ItemStack stack) |
| { |
| return 1; |
| } |
| |
| @Override |
| public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) |
| { |
| int metadata = stack.getItemDamage(); |
| if(metadata == 0) |
| { |
| EntityMoto e = new EntityMoto(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize–; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Moto"); |
| } |
| return true; |
| } |
| else if(metadata == 1) |
| { |
| EntityMoto e = new EntityMoto(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Moto1"); |
| } |
| return true; |
| } |
| else if(metadata == 2) |
| { |
| EntityMoto e = new EntityMoto(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Moto2"); |
| } |
| return true; |
| } |
| else if (metadata == 3) |
| { |
| EntityBMX e = new EntityBMX(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "BMX"); |
| } |
| return true; |
| } |
| else if (metadata == 4) |
| { |
| EntityBMX e = new EntityBMX(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "BMX1"); |
| } |
| return true; |
| } |
| else if (metadata == 5) |
| { |
| EntityBMX e = new EntityBMX(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "BMX2"); |
| } |
| return true; |
| } |
| else if (metadata == 6) |
| { |
| EntityBuggy e = new EntityBuggy(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Buggy"); |
| } |
| return true; |
| } |
| else if (metadata == 7) |
| { |
| EntityBuggy e = new EntityBuggy(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Buggy1"); |
| } |
| return true; |
| } |
| else if (metadata == 8) |
| { |
| EntityBuggy e = new EntityBuggy(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Buggy2"); |
| } |
| return true; |
| } |
| else if (metadata == 9) |
| { |
| EntityBaignoire e = new EntityBaignoire(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Baignoire"); |
| } |
| return true; |
| } |
| else if (metadata == 10) |
| { |
| EntityKart e = new EntityKart(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Kart"); |
| } |
| return true; |
| } |
| else if (metadata == 11) |
| { |
| EntityKart e = new EntityKart(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Kart1"); |
| } |
| return true; |
| } |
| else if (metadata == 12) |
| { |
| EntityKart e = new EntityKart(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Kart2"); |
| } |
| return true; |
| } |
| else if (metadata == 13) |
| { |
| EntityBolide e = new EntityBolide(world); |
| if(!world.isRemote) |
| { |
| e.setPosition(x, y + 1.0F, z); |
| world.spawnEntityInWorld(e); |
| stack.stackSize--; |
| DataWatcher dw = e.getDataWatcher(); |
| dw.updateObject(30, "Bolide"); |
| } |
| return true; |
| } |
| else if (metadata == 14) |
| { |
| |
| } |
| return false; |
| } |
| |
| public int getMetadata(int metadata) |
| { |
| return metadata; |
| } |
| |
| public String getUnlocalizedName(ItemStack stack) |
| { |
| int metadata = stack.getItemDamage(); |
| |
| if(metadata > type.length || metadata < 0) |
| { |
| metadata = 0; |
| } |
| |
| return super.getUnlocalizedName() + "." + type[metadata]; |
| } |
| |
| @SuppressWarnings({ "rawtypes", "unchecked" }) |
| public void getSubItems(Item item, CreativeTabs tabs, List list) |
| { |
| for(int i = 0; i < type.length; i++) |
| { |
| list.add(new ItemStack(item, 1, i)); |
| } |
| } |
| |
| public void registerIcons(IIconRegister iconRegister) |
| { |
| for(int i = 0; i < type.length; i++) |
| this.iconArray* = iconRegister.registerIcon(Modpg.MODID + ":" + type*); |
| } |
| |
| public IIcon getIcon(int side, int metadata) |
| { |
| if(metadata >= 0 && metadata < type.length) |
| { |
| return this.iconArray[metadata]; |
| } |
| return this.iconArray[0]; |
| } |
| |
| public IIcon getIconFromDamage(int metadata) |
| { |
| return metadata < type.length && metadata >= 0 ? iconArray[metadata] : iconArray[0]; |
| } |
| } |