From 4fa2fb1ac9a4e545ba278cbc06b2515e131051de Mon Sep 17 00:00:00 2001 From: bdew Date: Wed, 19 Mar 2014 15:56:31 +0200 Subject: [PATCH] Added industrial scoop tool --- .../assets/gendustry/gendustry-tuning.cfg | 12 ++- resources/assets/gendustry/lang/en_US.lang | 1 + .../bdew/gendustry/CommandGiveTemplate.scala | 6 +- src/net/bdew/gendustry/config/Items.scala | 5 +- .../gendustry/items/IndustrialScoop.scala | 85 +++++++++++++++++++ 5 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 src/net/bdew/gendustry/items/IndustrialScoop.scala diff --git a/resources/assets/gendustry/gendustry-tuning.cfg b/resources/assets/gendustry/gendustry-tuning.cfg index 3fa863b..f192f89 100644 --- a/resources/assets/gendustry/gendustry-tuning.cfg +++ b/resources/assets/gendustry/gendustry-tuning.cfg @@ -168,9 +168,15 @@ cfg Machines { cfg Items { cfg IndustrialGrafter { Enabled = Yes - Charges = 200 // Number of blocks that a fully charged grafter can break - MjPerCharge = 500 // Cost of a single broken block in MJ - AOE = 2 // Radius from the central block, 1 = 3x3x3, 2 = 5x5x5 and so on + Charges = 200 // Number of blocks that a fully charged grafter can break + MjPerCharge = 500 // Cost of a single broken block in MJ + AOE = 2 // Radius from the central block, 1 = 3x3x3, 2 = 5x5x5 and so on + SaplingModifier = 100 // Modifier for chance to get sapling, 100 is equal to a vanila grafter + } + cfg IndustrialScoop { + Enabled = Yes + Charges = 500 // Number of blocks that a fully charged grafter can break + MjPerCharge = 10 // Cost of a single broken block in MJ } } diff --git a/resources/assets/gendustry/lang/en_US.lang b/resources/assets/gendustry/lang/en_US.lang index 94dff74..cd378e0 100644 --- a/resources/assets/gendustry/lang/en_US.lang +++ b/resources/assets/gendustry/lang/en_US.lang @@ -26,6 +26,7 @@ item.gendustry.GeneTemplate.name=Genetic Template item.gendustry.GeneSampleBlank.name=Blank Gene Sample item.gendustry.Waste.name=Genetic Waste item.gendustry.grafter.name=Industrial Grafter +item.gendustry.scoop.name=Scooporator MX200 Turbo # ==== FLUIDS ==== diff --git a/src/net/bdew/gendustry/CommandGiveTemplate.scala b/src/net/bdew/gendustry/CommandGiveTemplate.scala index 74f13ab..75462f1 100644 --- a/src/net/bdew/gendustry/CommandGiveTemplate.scala +++ b/src/net/bdew/gendustry/CommandGiveTemplate.scala @@ -1,10 +1,10 @@ /* - * Copyright (c) bdew, 2013 - * https://github.com/bdew/teleporter + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry * * This mod is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in - * https://raw.github.com/bdew/teleporter/master/MMPL-1.0.txt + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt */ package net.bdew.gendustry diff --git a/src/net/bdew/gendustry/config/Items.scala b/src/net/bdew/gendustry/config/Items.scala index c4d1688..8ebe2ab 100644 --- a/src/net/bdew/gendustry/config/Items.scala +++ b/src/net/bdew/gendustry/config/Items.scala @@ -10,7 +10,7 @@ package net.bdew.gendustry.config import cpw.mods.fml.common.registry.GameRegistry -import net.bdew.gendustry.items.{IndustrialGrafter, GeneTemplate, GeneSample} +import net.bdew.gendustry.items.{IndustrialScoop, IndustrialGrafter, GeneTemplate, GeneSample} import net.bdew.gendustry.machines.apiary.upgrades.ItemApiaryUpgrade import net.bdew.lib.config.ItemManager import net.bdew.gendustry.Gendustry @@ -28,6 +28,9 @@ object Items extends ItemManager(Config.IDs) { val grafter = regItemCls(classOf[IndustrialGrafter], "IndustrialGrafter", false) GameRegistry.registerCustomItemStack("IndustrialGrafter", grafter.stackWithCharge(0)) + val scoop = regItemCls(classOf[IndustrialScoop], "IndustrialScoop", false) + GameRegistry.registerCustomItemStack("IndustrialScoop", scoop.stackWithCharge(0)) + regSimpleItem("MutagenTank") regSimpleItem("BeeReceptacle") regSimpleItem("PowerModule") diff --git a/src/net/bdew/gendustry/items/IndustrialScoop.scala b/src/net/bdew/gendustry/items/IndustrialScoop.scala new file mode 100644 index 0000000..c51c54a --- /dev/null +++ b/src/net/bdew/gendustry/items/IndustrialScoop.scala @@ -0,0 +1,85 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.items + +import net.minecraft.item.{ItemStack, EnumToolMaterial, ItemTool} +import net.minecraft.world.World +import net.minecraft.entity.player.EntityPlayer +import net.bdew.gendustry.Gendustry +import net.bdew.gendustry.config.Tuning +import net.bdew.lib.Misc +import net.minecraft.block.Block +import net.minecraft.entity.EntityLivingBase +import java.util +import net.minecraft.creativetab.CreativeTabs +import cpw.mods.fml.relauncher.{Side, SideOnly} +import net.minecraft.client.renderer.texture.IconRegister +import cpw.mods.fml.common.Optional +import net.bdew.gendustry.compat.PowerProxy +import net.bdew.gendustry.power.ItemPowered +import forestry.api.core.IToolScoop +import net.minecraftforge.common.{ForgeHooks, MinecraftForge} + +@Optional.Interface(modid = PowerProxy.IC2_MOD_ID, iface = "ic2.api.item.ISpecialElectricItem") +class IndustrialScoop(id: Int) extends ItemTool(id, 0, EnumToolMaterial.IRON, Array.empty[Block]) with ItemPowered with IToolScoop { + lazy val cfg = Tuning.getSection("Items").getSection("IndustrialScoop") + lazy val mjPerCharge = cfg.getInt("MjPerCharge") + lazy val maxCharge = cfg.getInt("Charges") * mjPerCharge + + setUnlocalizedName(Gendustry.modId + ".scoop") + setMaxStackSize(1) + setMaxDamage(101) + + MinecraftForge.setToolClass(this, "scoop", 3) + + efficiencyOnProperMaterial = 32 + + override def getStrVsBlock(stack: ItemStack, block: Block) = getStrVsBlock(stack, block, 1) + override def getStrVsBlock(stack: ItemStack, block: Block, meta: Int) = + if (!hasCharges(stack)) + 0.1F + else if (ForgeHooks.isToolEffective(stack, block, meta)) + efficiencyOnProperMaterial + else + 0.1F + + override def onBlockDestroyed(stack: ItemStack, world: World, blockId: Int, x: Int, y: Int, z: Int, player: EntityLivingBase): Boolean = { + if (ForgeHooks.isToolEffective(stack, Block.blocksList(world.getBlockId(x, y, z)), world.getBlockMetadata(x, y, z))) { + useCharge(stack, 1, player) + return true + } + return false + } + + override def hitEntity(stack: ItemStack, target: EntityLivingBase, player: EntityLivingBase): Boolean = false + + override def addInformation(stack: ItemStack, player: EntityPlayer, l: util.List[_], par4: Boolean) = { + import scala.collection.JavaConverters._ + val tip = l.asInstanceOf[util.List[String]].asScala + + tip += Misc.toLocalF("gendustry.label.charges", getCharge(stack) / mjPerCharge) + } + + override def getSubItems(par1: Int, tabs: CreativeTabs, l: util.List[_]) { + import scala.collection.JavaConverters._ + val items = l.asInstanceOf[util.List[ItemStack]].asScala + items += new ItemStack(this) + items += stackWithCharge(maxCharge) + } + + override def getItemEnchantability: Int = 0 + override def getIsRepairable(par1ItemStack: ItemStack, par2ItemStack: ItemStack): Boolean = false + override def isBookEnchantable(itemstack1: ItemStack, itemstack2: ItemStack): Boolean = false + + @SideOnly(Side.CLIENT) + override def registerIcons(reg: IconRegister) { + itemIcon = reg.registerIcon(Gendustry.modId + ":scoop") + } +}