From 4bf1d4fff185fad01be251f0976a56b55ade7a40 Mon Sep 17 00:00:00 2001 From: Robert S Date: Sat, 27 Sep 2014 21:19:15 -0400 Subject: [PATCH] Converted ItemCell and its sub classes to scala --- .../atomic/items/ItemAntimatter.java | 66 ---------- .../atomic/items/ItemAntimatter.scala | 56 +++++++++ .../atomic/items/ItemBreederFuel.java | 36 ------ .../atomic/items/ItemBreederFuel.scala | 29 +++++ .../atomic/items/ItemCell.java | 40 ------ .../atomic/items/ItemCell.scala | 32 +++++ .../atomic/items/ItemFissileFuel.java | 117 ------------------ .../atomic/items/ItemFissileFuel.scala | 95 ++++++++++++++ .../atomic/items/ItemHazmat.java | 78 ------------ .../atomic/items/ItemHazmat.scala | 73 +++++++++++ .../atomic/items/ItemRadioactive.java | 25 ---- .../atomic/items/ItemRadioactive.scala | 23 ++++ .../atomic/items/ItemUranium.java | 55 -------- .../atomic/items/ItemUranium.scala | 48 +++++++ 14 files changed, 356 insertions(+), 417 deletions(-) delete mode 100644 src/main/scala/resonantinduction/atomic/items/ItemAntimatter.java create mode 100644 src/main/scala/resonantinduction/atomic/items/ItemAntimatter.scala delete mode 100644 src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.java create mode 100644 src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.scala delete mode 100644 src/main/scala/resonantinduction/atomic/items/ItemCell.java create mode 100644 src/main/scala/resonantinduction/atomic/items/ItemCell.scala delete mode 100644 src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.java create mode 100644 src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.scala delete mode 100644 src/main/scala/resonantinduction/atomic/items/ItemHazmat.java create mode 100644 src/main/scala/resonantinduction/atomic/items/ItemHazmat.scala delete mode 100644 src/main/scala/resonantinduction/atomic/items/ItemRadioactive.java create mode 100644 src/main/scala/resonantinduction/atomic/items/ItemRadioactive.scala delete mode 100644 src/main/scala/resonantinduction/atomic/items/ItemUranium.java create mode 100644 src/main/scala/resonantinduction/atomic/items/ItemUranium.scala diff --git a/src/main/scala/resonantinduction/atomic/items/ItemAntimatter.java b/src/main/scala/resonantinduction/atomic/items/ItemAntimatter.java deleted file mode 100644 index 9e0545503..000000000 --- a/src/main/scala/resonantinduction/atomic/items/ItemAntimatter.java +++ /dev/null @@ -1,66 +0,0 @@ -package resonantinduction.atomic.items; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import resonantinduction.core.Reference; -import resonantinduction.core.ResonantTab; - -import java.util.List; - -/* Antimatter Cell */ -public class ItemAntimatter extends ItemCell -{ - private IIcon iconGram; - - public ItemAntimatter() - { - super(); - this.setMaxDamage(0); - this.setHasSubtypes(true); - this.setUnlocalizedName(Reference.prefix() + "antimatter"); - this.setTextureName(Reference.prefix() + "antimatter"); - setCreativeTab(ResonantTab.tab()); - } - - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) - { - // Animated Icons - //ResonantInduction.LOGGER.info(this.getUnlocalizedName().replace("item.", "") + "_milligram"); - this.itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", "") + "_milligram"); - this.iconGram = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", "") + "_gram"); - } - - @Override - public IIcon getIconFromDamage(int metadata) - { - if (metadata >= 1) - { - return this.iconGram; - } - else - { - return this.itemIcon; - } - } - - @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) - { - par3List.add(new ItemStack(item, 1, 0)); - par3List.add(new ItemStack(item, 1, 1)); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) - { - return 160; - } -} diff --git a/src/main/scala/resonantinduction/atomic/items/ItemAntimatter.scala b/src/main/scala/resonantinduction/atomic/items/ItemAntimatter.scala new file mode 100644 index 000000000..58d45a84a --- /dev/null +++ b/src/main/scala/resonantinduction/atomic/items/ItemAntimatter.scala @@ -0,0 +1,56 @@ +package resonantinduction.atomic.items + +import cpw.mods.fml.relauncher.Side +import cpw.mods.fml.relauncher.SideOnly +import net.minecraft.client.renderer.texture.IIconRegister +import net.minecraft.creativetab.CreativeTabs +import net.minecraft.item.Item +import net.minecraft.item.ItemStack +import net.minecraft.util.IIcon +import net.minecraft.world.World +import resonantinduction.core.Reference +import resonantinduction.core.ResonantTab +import java.util.List +import resonant.lib.wrapper.WrapList._ + +class ItemAntimatter extends ItemCell +{ + + private var iconGram: IIcon = null + + //Constructor + this.setMaxDamage(0) + this.setHasSubtypes(true) + this.setUnlocalizedName(Reference.prefix + "antimatter") + this.setTextureName(Reference.prefix + "antimatter") + setCreativeTab(ResonantTab.tab) + + @SideOnly(Side.CLIENT) override def registerIcons(iconRegister: IIconRegister) + { + this.itemIcon = iconRegister.registerIcon(this.getUnlocalizedName.replace("item.", "") + "_milligram") + this.iconGram = iconRegister.registerIcon(this.getUnlocalizedName.replace("item.", "") + "_gram") + } + + override def getIconFromDamage(metadata: Int): IIcon = + { + if (metadata >= 1) + { + return this.iconGram + } + else + { + return this.itemIcon + } + } + + override def getSubItems(item: Item, par2CreativeTabs: CreativeTabs, par3List: List[_]) + { + par3List.add(new ItemStack(item, 1, 0)) + par3List.add(new ItemStack(item, 1, 1)) + } + + override def getEntityLifespan(itemStack: ItemStack, world: World): Int = + { + return 160 + } +} \ No newline at end of file diff --git a/src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.java b/src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.java deleted file mode 100644 index 1360a4b16..000000000 --- a/src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.java +++ /dev/null @@ -1,36 +0,0 @@ -package resonantinduction.atomic.items; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import resonant.api.IReactor; -import resonant.api.IReactorComponent; - -/** - * Breeder rods - */ -public class ItemBreederFuel extends ItemRadioactive implements IReactorComponent -{ - public ItemBreederFuel() - { - super(); - this.setMaxDamage(ItemFissileFuel.DECAY); - this.setMaxStackSize(1); - this.setNoRepair(); - } - - @Override - public void onReact(ItemStack itemStack, IReactor reactor) - { - TileEntity tileEntity = (TileEntity) reactor; - World worldObj = tileEntity.getWorldObj(); - - // Breeder fuel rods have half the normal energy potential of pure uranium. - reactor.heat(ItemFissileFuel.ENERGY_PER_TICK / 2); - - if (reactor.world().getWorldTime() % 20 == 0) - { - itemStack.setItemDamage(Math.min(itemStack.getItemDamage() + 1, itemStack.getMaxDamage())); - } - } -} diff --git a/src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.scala b/src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.scala new file mode 100644 index 000000000..693bdce0e --- /dev/null +++ b/src/main/scala/resonantinduction/atomic/items/ItemBreederFuel.scala @@ -0,0 +1,29 @@ +package resonantinduction.atomic.items + +import net.minecraft.item.ItemStack +import net.minecraft.tileentity.TileEntity +import net.minecraft.world.World +import resonant.api.IReactor +import resonant.api.IReactorComponent + +/** + * Breeder rods + */ +class ItemBreederFuel extends ItemRadioactive with IReactorComponent +{ + //Constructor + this.setMaxDamage(ItemFissileFuel.DECAY) + this.setMaxStackSize(1) + this.setNoRepair + + override def onReact(itemStack: ItemStack, reactor: IReactor) + { + val tileEntity: TileEntity = reactor.asInstanceOf[TileEntity] + val worldObj: World = tileEntity.getWorldObj + reactor.heat(ItemFissileFuel.ENERGY_PER_TICK / 2) + if (reactor.world.getWorldTime % 20 == 0) + { + itemStack.setItemDamage(Math.min(itemStack.getItemDamage + 1, itemStack.getMaxDamage)) + } + } +} \ No newline at end of file diff --git a/src/main/scala/resonantinduction/atomic/items/ItemCell.java b/src/main/scala/resonantinduction/atomic/items/ItemCell.java deleted file mode 100644 index 0fd293986..000000000 --- a/src/main/scala/resonantinduction/atomic/items/ItemCell.java +++ /dev/null @@ -1,40 +0,0 @@ -package resonantinduction.atomic.items; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import resonant.content.prefab.itemblock.ItemTooltip; -import resonant.lib.utility.LanguageUtility; -import resonantinduction.atomic.AtomicContent; -import resonantinduction.core.Reference; -import resonantinduction.core.ResonantTab; - -public class ItemCell extends ItemTooltip -{ - public ItemCell() - { - setContainerItem(AtomicContent.itemCell()); - } - - public ItemCell(String name) - { - if(!name.equalsIgnoreCase("cellEmpty")) - this.setContainerItem(AtomicContent.itemCell()); - this.setUnlocalizedName(Reference.prefix() + name); - this.setTextureName(Reference.prefix() + name); - setCreativeTab(ResonantTab.tab()); - } - - @Override - public String getUnlocalizedName(ItemStack itemstack) - { - String localized = LanguageUtility.getLocal(getUnlocalizedName() + "." + itemstack.getItemDamage() + ".name"); - if (localized != null && !localized.isEmpty()) - { - return getUnlocalizedName() + "." + itemstack.getItemDamage(); - } - - return getUnlocalizedName(); - } -} diff --git a/src/main/scala/resonantinduction/atomic/items/ItemCell.scala b/src/main/scala/resonantinduction/atomic/items/ItemCell.scala new file mode 100644 index 000000000..627eb3d1c --- /dev/null +++ b/src/main/scala/resonantinduction/atomic/items/ItemCell.scala @@ -0,0 +1,32 @@ +package resonantinduction.atomic.items + +import net.minecraft.item.ItemStack +import resonant.content.prefab.itemblock.ItemTooltip +import resonant.lib.utility.LanguageUtility +import resonantinduction.atomic.AtomicContent +import resonantinduction.core.{Reference, ResonantTab} + +class ItemCell extends ItemTooltip +{ + //Constructor + setContainerItem(AtomicContent.itemCell) + + def this(name: String) + { + this() + if (!name.equalsIgnoreCase("cellEmpty")) this.setContainerItem(AtomicContent.itemCell) + this.setUnlocalizedName(Reference.prefix + name) + this.setTextureName(Reference.prefix + name) + setCreativeTab(ResonantTab.tab) + } + + override def getUnlocalizedName(itemstack: ItemStack): String = + { + val localized: String = LanguageUtility.getLocal(getUnlocalizedName + "." + itemstack.getItemDamage + ".name") + if (localized != null && !localized.isEmpty) + { + return getUnlocalizedName + "." + itemstack.getItemDamage + } + return getUnlocalizedName + } +} \ No newline at end of file diff --git a/src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.java b/src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.java deleted file mode 100644 index 720ca9b75..000000000 --- a/src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.java +++ /dev/null @@ -1,117 +0,0 @@ -package resonantinduction.atomic.items; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import resonant.api.IReactor; -import resonant.api.IReactorComponent; -import resonantinduction.atomic.AtomicContent; -import resonantinduction.atomic.machine.reactor.TileReactorCell; -import resonantinduction.core.Reference; -import resonantinduction.core.ResonantTab; -import resonantinduction.core.Settings; -import universalelectricity.core.transform.vector.Vector3; - -import java.util.List; - -/** - * Fissile fuel rod - */ -public class ItemFissileFuel extends ItemRadioactive implements IReactorComponent -{ - public static final int DECAY = 2500; - - /** - * Temperature at which the fuel rod will begin to re-enrich itself. - */ - public static final int BREEDING_TEMP = 1100; - - /** - * The energy in one KG of uranium is: 72PJ, 100TJ in one cell of uranium. - */ - public static final long ENERGY = 100000000000L; - - /** - * Approximately 20,000,000J per tick. 400 MW. - */ - public static final long ENERGY_PER_TICK = ENERGY / 50000; - - public ItemFissileFuel() - { - super(); - this.setMaxStackSize(1); - this.setMaxDamage(DECAY); - this.setNoRepair(); - this.setUnlocalizedName(Reference.prefix() + "rodBreederFuel"); - this.setTextureName(Reference.prefix() + "rodBreederFuel"); - setCreativeTab(ResonantTab.tab()); - } - - @Override - public void onReact(ItemStack itemStack, IReactor reactor) - { - TileEntity tileEntity = (TileEntity) reactor; - World worldObj = tileEntity.getWorldObj(); - int reactors = 0; - - for (int i = 0; i < 6; i++) - { - Vector3 checkPos = new Vector3(tileEntity).add(ForgeDirection.getOrientation(i)); - TileEntity tile = checkPos.getTileEntity(worldObj); - - // Check that the other reactors not only exist but also are running. - if (tile instanceof TileReactorCell && ((TileReactorCell) tile).getTemperature() > BREEDING_TEMP) - { - reactors++; - } - } - - // Only two reactor cells are required to begin the uranium breeding process. - if (reactors >= 2) - { - // Begin the process of re-enriching the uranium rod but not consistently. - // Note: The center reactor cell only needs to be half of breeding temperature for this to work. - if (worldObj.rand.nextInt(1000) <= 100 && reactor.getTemperature() > (BREEDING_TEMP / 2)) - { - // Cells can regain a random amount of health per tick. - int healAmt = worldObj.rand.nextInt(5); - - // Determine if this is a completely dead cell (creative menu fission rod is like this). - //System.out.println("[Atomic Science] [Reactor Cell] Breeding " + String.valueOf(healAmt) + " back into fissle rod. " + String.valueOf(itemStack.getItemDamage()) + " / " + String.valueOf(itemStack.getMaxDamage())); - itemStack.setItemDamage(Math.max(itemStack.getItemDamage() - healAmt, 0)); - } - } - else - { - reactor.heat(ENERGY_PER_TICK); - - if (reactor.world().getWorldTime() % 20 == 0) - { - itemStack.setItemDamage(Math.min(itemStack.getItemDamage() + 1, itemStack.getMaxDamage())); - } - - // Create toxic waste. - if (Settings.allowToxicWaste() && worldObj.rand.nextFloat() > 0.5) - { - FluidStack fluid = AtomicContent.FLUIDSTACK_TOXIC_WASTE().copy(); - fluid.amount = 1; - reactor.fill(ForgeDirection.UNKNOWN, fluid, true); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) - { - par3List.add(new ItemStack(item, 1, 0)); - par3List.add(new ItemStack(item, 1, getMaxDamage() - 1)); - } - -} diff --git a/src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.scala b/src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.scala new file mode 100644 index 000000000..eeefb9d01 --- /dev/null +++ b/src/main/scala/resonantinduction/atomic/items/ItemFissileFuel.scala @@ -0,0 +1,95 @@ +package resonantinduction.atomic.items + +import java.util.List + +import cpw.mods.fml.relauncher.{Side, SideOnly} +import net.minecraft.creativetab.CreativeTabs +import net.minecraft.item.{Item, ItemStack} +import net.minecraft.tileentity.TileEntity +import net.minecraft.world.World +import net.minecraftforge.common.util.ForgeDirection +import net.minecraftforge.fluids.FluidStack +import resonant.api.{IReactor, IReactorComponent} +import resonant.lib.wrapper.WrapList._ +import resonantinduction.atomic.AtomicContent +import resonantinduction.atomic.machine.reactor.TileReactorCell +import resonantinduction.core.{Reference, ResonantTab, Settings} +import universalelectricity.core.transform.vector.Vector3 + +/** + * Fissile fuel rod + */ +object ItemFissileFuel +{ + final val DECAY: Int = 2500 + /** + * Temperature at which the fuel rod will begin to re-enrich itself. + */ + final val BREEDING_TEMP: Int = 1100 + /** + * The energy in one KG of uranium is: 72PJ, 100TJ in one cell of uranium. + */ + final val ENERGY: Long = 100000000000L + /** + * Approximately 20,000,000J per tick. 400 MW. + */ + final val ENERGY_PER_TICK: Long = ENERGY / 50000 +} + +class ItemFissileFuel extends ItemRadioactive with IReactorComponent +{ + + //Constructor + this.setMaxStackSize(1) + this.setMaxDamage(ItemFissileFuel.DECAY) + this.setNoRepair + this.setUnlocalizedName(Reference.prefix + "rodBreederFuel") + this.setTextureName(Reference.prefix + "rodBreederFuel") + setCreativeTab(ResonantTab.tab) + + def onReact(itemStack: ItemStack, reactor: IReactor) + { + val tileEntity: TileEntity = reactor.asInstanceOf[TileEntity] + val worldObj: World = tileEntity.getWorldObj + var reactors: Int = 0 + + for (i <- 0 to 6) + { + val checkPos: Vector3 = new Vector3(tileEntity).add(ForgeDirection.getOrientation(i)) + val tile: TileEntity = checkPos.getTileEntity(worldObj) + if (tile.isInstanceOf[TileReactorCell] && (tile.asInstanceOf[TileReactorCell]).getTemperature > ItemFissileFuel.BREEDING_TEMP) + { + reactors += 1 + } + } + + if (reactors >= 2) + { + if (worldObj.rand.nextInt(1000) <= 100 && reactor.getTemperature > (ItemFissileFuel.BREEDING_TEMP / 2)) + { + val healAmt: Int = worldObj.rand.nextInt(5) + itemStack.setItemDamage(Math.max(itemStack.getItemDamage - healAmt, 0)) + } + } + else + { + reactor.heat(ItemFissileFuel.ENERGY_PER_TICK) + if (reactor.world.getWorldTime % 20 == 0) + { + itemStack.setItemDamage(Math.min(itemStack.getItemDamage + 1, itemStack.getMaxDamage)) + } + if (Settings.allowToxicWaste && worldObj.rand.nextFloat > 0.5) + { + val fluid: FluidStack = AtomicContent.FLUIDSTACK_TOXIC_WASTE.copy + fluid.amount = 1 + reactor.fill(ForgeDirection.UNKNOWN, fluid, true) + } + } + } + + @SideOnly(Side.CLIENT) override def getSubItems(item: Item, par2CreativeTabs: CreativeTabs, par3List: List[_]) + { + par3List.add(new ItemStack(item, 1, 0)) + par3List.add(new ItemStack(item, 1, getMaxDamage - 1)) + } +} \ No newline at end of file diff --git a/src/main/scala/resonantinduction/atomic/items/ItemHazmat.java b/src/main/scala/resonantinduction/atomic/items/ItemHazmat.java deleted file mode 100644 index 2a47dd070..000000000 --- a/src/main/scala/resonantinduction/atomic/items/ItemHazmat.java +++ /dev/null @@ -1,78 +0,0 @@ -package resonantinduction.atomic.items; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.DamageSource; -import net.minecraftforge.common.util.EnumHelper; -import resonant.api.armor.IAntiPoisonArmor; -import resonantinduction.atomic.Atomic; -import resonantinduction.core.Reference; -import resonantinduction.core.ResonantTab; - -/** - * Hazmat - */ -public class ItemHazmat extends ItemArmor implements IAntiPoisonArmor -{ - - public static final ItemArmor.ArmorMaterial hazmatArmorMaterial = EnumHelper.addArmorMaterial("HAZMAT", 0, new int[] { 0, 0, 0, 0 }, 0); - - public ItemHazmat(String name, int slot) - { - super(hazmatArmorMaterial, Atomic.proxy().getArmorIndex("hazmat"), slot); - this.setUnlocalizedName(Reference.prefix() + name); - this.setCreativeTab(ResonantTab.tab()); - this.setMaxDamage(200000); - } - - @Override - public Item setUnlocalizedName(String par1Str) - { - super.setUnlocalizedName(par1Str); - this.setTextureName(par1Str); - return this; - } - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - return Reference.prefix() + Reference.modelPath() + "hazmat.png"; - } - - @Override - public boolean isProtectedFromPoison(ItemStack itemStack, EntityLivingBase entityLiving, String type) - { - return type.equalsIgnoreCase("radiation") || type.equalsIgnoreCase("chemical") || type.equalsIgnoreCase("contagious"); - } - - @Override - public void onProtectFromPoison(ItemStack itemStack, EntityLivingBase entityLiving, String type) - { - itemStack.damageItem(1, entityLiving); - } - - @Override - public int getArmorType() - { - return this.armorType; - } - - @Override - public boolean isPartOfSet(ItemStack armorStack, ItemStack compareStack) - { - if (armorStack != null && compareStack != null) - { - return armorStack.getItem().equals(compareStack.getItem()); - } - return false; - } - - @Override - public boolean areAllPartsNeeded(ItemStack armorStack, EntityLivingBase entity, DamageSource source, Object... data) - { - return true; - } -} diff --git a/src/main/scala/resonantinduction/atomic/items/ItemHazmat.scala b/src/main/scala/resonantinduction/atomic/items/ItemHazmat.scala new file mode 100644 index 000000000..5338b7744 --- /dev/null +++ b/src/main/scala/resonantinduction/atomic/items/ItemHazmat.scala @@ -0,0 +1,73 @@ +package resonantinduction.atomic.items + +import net.minecraft.entity.Entity +import net.minecraft.entity.EntityLivingBase +import net.minecraft.item.Item +import net.minecraft.item.ItemArmor +import net.minecraft.item.ItemStack +import net.minecraft.util.DamageSource +import net.minecraftforge.common.util.EnumHelper +import resonant.api.armor.IAntiPoisonArmor +import resonantinduction.atomic.Atomic +import resonantinduction.core.Reference +import resonantinduction.core.ResonantTab + +/** + * Hazmat + */ +object ItemHazmat +{ + final val hazmatArmorMaterial: ItemArmor.ArmorMaterial = EnumHelper.addArmorMaterial("HAZMAT", 0, Array[Int](0, 0, 0, 0), 0) +} + +class ItemHazmat(slot: Int) extends ItemArmor(ItemHazmat.hazmatArmorMaterial, Atomic.proxy.getArmorIndex("hazmat"), slot) with IAntiPoisonArmor +{ + def this(name: String, slot: Int) + { + this(ItemHazmat.hazmatArmorMaterial, Atomic.proxy.getArmorIndex("hazmat"), slot) + this.setUnlocalizedName(Reference.prefix + name) + this.setCreativeTab(ResonantTab.tab) + this.setMaxDamage(200000) + } + + override def setUnlocalizedName(par1Str: String): Item = + { + super.setUnlocalizedName(par1Str) + this.setTextureName(par1Str) + return this + } + + override def getArmorTexture(stack: ItemStack, entity: Entity, slot: Int, `type`: String): String = + { + return Reference.prefix + Reference.modelPath + "hazmat.png" + } + + def isProtectedFromPoison(itemStack: ItemStack, entityLiving: EntityLivingBase, `type`: String): Boolean = + { + return `type`.equalsIgnoreCase("radiation") || `type`.equalsIgnoreCase("chemical") || `type`.equalsIgnoreCase("contagious") + } + + def onProtectFromPoison(itemStack: ItemStack, entityLiving: EntityLivingBase, `type`: String) + { + itemStack.damageItem(1, entityLiving) + } + + def getArmorType: Int = + { + return this.armorType + } + + def isPartOfSet(armorStack: ItemStack, compareStack: ItemStack): Boolean = + { + if (armorStack != null && compareStack != null) + { + return armorStack.getItem == compareStack.getItem + } + return false + } + + def areAllPartsNeeded(armorStack: ItemStack, entity: EntityLivingBase, source: DamageSource, data: AnyRef*): Boolean = + { + return true + } +} \ No newline at end of file diff --git a/src/main/scala/resonantinduction/atomic/items/ItemRadioactive.java b/src/main/scala/resonantinduction/atomic/items/ItemRadioactive.java deleted file mode 100644 index 4b9d3b6fb..000000000 --- a/src/main/scala/resonantinduction/atomic/items/ItemRadioactive.java +++ /dev/null @@ -1,25 +0,0 @@ -package resonantinduction.atomic.items; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import resonant.lib.prefab.poison.PoisonRadiation; -import universalelectricity.core.transform.vector.Vector3; - -/** - * Radioactive Items - */ -public class ItemRadioactive extends Item -{ - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity entity, int par4, boolean par5) - { - if (entity instanceof EntityLivingBase) - { - PoisonRadiation.INSTANCE.poisonEntity(new Vector3(entity), (EntityLivingBase) entity, 1); - } - } - -} diff --git a/src/main/scala/resonantinduction/atomic/items/ItemRadioactive.scala b/src/main/scala/resonantinduction/atomic/items/ItemRadioactive.scala new file mode 100644 index 000000000..0f7a41922 --- /dev/null +++ b/src/main/scala/resonantinduction/atomic/items/ItemRadioactive.scala @@ -0,0 +1,23 @@ +package resonantinduction.atomic.items + +import net.minecraft.entity.Entity +import net.minecraft.entity.EntityLivingBase +import net.minecraft.item.Item +import net.minecraft.item.ItemStack +import net.minecraft.world.World +import resonant.lib.prefab.poison.PoisonRadiation +import universalelectricity.core.transform.vector.Vector3 + +/** + * Radioactive Items + */ +class ItemRadioactive extends Item +{ + override def onUpdate(par1ItemStack: ItemStack, par2World: World, entity: Entity, par4: Int, par5: Boolean) + { + if (entity.isInstanceOf[EntityLivingBase]) + { + PoisonRadiation.INSTANCE.poisonEntity(new Vector3(entity), entity.asInstanceOf[EntityLivingBase], 1) + } + } +} \ No newline at end of file diff --git a/src/main/scala/resonantinduction/atomic/items/ItemUranium.java b/src/main/scala/resonantinduction/atomic/items/ItemUranium.java deleted file mode 100644 index 4953c6750..000000000 --- a/src/main/scala/resonantinduction/atomic/items/ItemUranium.java +++ /dev/null @@ -1,55 +0,0 @@ -package resonantinduction.atomic.items; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import org.lwjgl.input.Keyboard; -import resonant.lib.render.EnumColor; -import resonant.lib.utility.LanguageUtility; - -import java.util.List; - -/** - * Uranium - */ -public class ItemUranium extends ItemRadioactive -{ - public ItemUranium() - { - super(); - this.setHasSubtypes(true); - this.setMaxDamage(0); - } - - @Override - public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) - { - String tooltip = LanguageUtility.getLocal(getUnlocalizedName(itemStack) + ".tooltip"); - - if (tooltip != null && tooltip.length() > 0) - { - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - list.add(LanguageUtility.getLocal("tooltip.noShift").replace("%0", EnumColor.AQUA.toString()).replace("%1", EnumColor.GREY.toString())); - } - else - { - list.addAll(LanguageUtility.splitStringPerWord(tooltip, 5)); - } - } - } - - @Override - public String getUnlocalizedName(ItemStack itemStack) - { - return this.getUnlocalizedName() + "." + itemStack.getItemDamage(); - } - - @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) - { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - } -} diff --git a/src/main/scala/resonantinduction/atomic/items/ItemUranium.scala b/src/main/scala/resonantinduction/atomic/items/ItemUranium.scala new file mode 100644 index 000000000..3b6f36d7f --- /dev/null +++ b/src/main/scala/resonantinduction/atomic/items/ItemUranium.scala @@ -0,0 +1,48 @@ +package resonantinduction.atomic.items + +import net.minecraft.creativetab.CreativeTabs +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.Item +import net.minecraft.item.ItemStack +import org.lwjgl.input.Keyboard +import resonant.lib.render.EnumColor +import resonant.lib.utility.LanguageUtility +import java.util.List +import resonant.lib.wrapper.WrapList._ + +/** + * Uranium + */ +class ItemUranium extends ItemRadioactive +{ + //Constructor + this.setHasSubtypes(true) + this.setMaxDamage(0) + + override def addInformation(itemStack: ItemStack, par2EntityPlayer: EntityPlayer, list: List[_], par4: Boolean) + { + val tooltip: String = LanguageUtility.getLocal(getUnlocalizedName(itemStack) + ".tooltip") + if (tooltip != null && tooltip.length > 0) + { + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + list.add(LanguageUtility.getLocal("tooltip.noShift").replace("%0", EnumColor.AQUA.toString).replace("%1", EnumColor.GREY.toString)) + } + else + { + list.addAll(LanguageUtility.splitStringPerWord(tooltip, 5)) + } + } + } + + override def getUnlocalizedName(itemStack: ItemStack): String = + { + return this.getUnlocalizedName + "." + itemStack.getItemDamage + } + + override def getSubItems(item: Item, par2CreativeTabs: CreativeTabs, list: List[_]) + { + list.add(new ItemStack(item, 1, 0)) + list.add(new ItemStack(item, 1, 1)) + } +} \ No newline at end of file