mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-20 12:19:37 +00:00
Added pollen collection kit
This commit is contained in:
1 parent
76c3f85b2b
commit
5bcf0d1bf0
7 files changed
+69
-2
No files matched your search
@@ -1,6 +1,4 @@
|
||||
recipes { // TOOLS
|
||||
// === Tools ===
|
||||
|
||||
D = I:diamond
|
||||
P = I:gendustry:PowerModule
|
||||
|
||||
@@ -16,6 +14,14 @@ recipes { // TOOLS
|
||||
P__
|
||||
}
|
||||
|
||||
recipes {
|
||||
L = I:gendustry:Labware
|
||||
S = I:string
|
||||
P = I:paper
|
||||
|
||||
shapeless: LSP => I:gendustry:PollenKit
|
||||
}
|
||||
|
||||
recipes { // CRAFTING ITEMS
|
||||
P = B:glass_pane
|
||||
S = B:piston
|
||||
|
||||
@@ -29,6 +29,7 @@ item.gendustry.grafter.name=Industrial Grafter
|
||||
item.gendustry.scoop.name=Scooporator MX200 Turbo
|
||||
item.gendustry.ImportCover.name=Item Import Cover
|
||||
item.gendustry.EjectCover.name=Item Eject Cover
|
||||
item.gendustry.PollenKit.name=Pollen Collection Kit
|
||||
|
||||
# ==== FLUIDS ====
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 961 B |
Binary file not shown.
@@ -10,6 +10,7 @@
|
||||
package net.bdew.gendustry.config
|
||||
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.compat.ForestryHelper
|
||||
import net.bdew.gendustry.custom.{CustomHoneyComb, CustomHoneyDrop}
|
||||
import net.bdew.gendustry.items._
|
||||
import net.bdew.gendustry.machines.apiary.upgrades.ItemApiaryUpgrade
|
||||
@@ -40,6 +41,10 @@ object Items extends ItemManager(GendustryCreativeTabs.main) {
|
||||
regSimpleItem("UpgradeFrame")
|
||||
regSimpleItem("ClimateModule")
|
||||
|
||||
if (ForestryHelper.haveRoot("Trees")) {
|
||||
regItem(PollenKit)
|
||||
}
|
||||
|
||||
val coverEject = regItem(EjectCover)
|
||||
val coverImport = regItem(ImportCover)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package net.bdew.gendustry.forestry
|
||||
import java.util.Random
|
||||
|
||||
import com.mojang.authlib.GameProfile
|
||||
import cpw.mods.fml.common.registry.GameRegistry
|
||||
import forestry.api.apiculture.{EnumBeeType, IBee, IBeeRoot}
|
||||
import forestry.api.arboriculture.{EnumGermlingType, ITree, ITreeRoot}
|
||||
import forestry.api.genetics._
|
||||
@@ -19,6 +20,7 @@ import forestry.api.lepidopterology.{EnumFlutterType, IButterflyRoot}
|
||||
import net.bdew.gendustry.config.Items
|
||||
import net.bdew.gendustry.items.GeneTemplate
|
||||
import net.bdew.gendustry.machines.mutatron.MachineMutatron
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
|
||||
@@ -211,4 +213,14 @@ object GeneticsHelper {
|
||||
filter { x => root.getDefaultTemplate()(x.ordinal()) != null }
|
||||
map { x => x.ordinal() -> x }
|
||||
).toMap
|
||||
|
||||
lazy val leafBlocks = Set(GameRegistry.findBlock("minecraft", "leaves"), GameRegistry.findBlock("minecraft", "leaves2"))
|
||||
|
||||
def getErsatzPollen(bl: Block, meta: Int): Option[IIndividual] = {
|
||||
if (leafBlocks.contains(bl)) {
|
||||
val fixedMeta = bl.damageDropped(meta)
|
||||
import scala.collection.JavaConversions._
|
||||
AlleleManager.ersatzSaplings.find({ case (stack, _) => stack.getItemDamage == fixedMeta }) map (_._2)
|
||||
} else None
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2015
|
||||
* 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
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.items
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType
|
||||
import forestry.api.genetics.IPollinatable
|
||||
import net.bdew.gendustry.compat.ForestryHelper
|
||||
import net.bdew.gendustry.forestry.GeneticsHelper
|
||||
import net.bdew.lib.block.BlockRef
|
||||
import net.bdew.lib.items.{ItemUtils, SimpleItem}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
|
||||
object PollenKit extends SimpleItem("PollenKit") {
|
||||
override def onItemUse(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, xOff: Float, yOff: Float, zOff: Float): Boolean = {
|
||||
if (player.isSneaking) return false
|
||||
if (!world.isRemote) {
|
||||
if (player.inventory.getCurrentItem.getItem != this) return false
|
||||
val blockRef = BlockRef(x, y, z)
|
||||
(blockRef.getTile[IPollinatable](world) map { te => te.getPollen }
|
||||
// If block is not IPollinatable, check for vanilla leafs conversion
|
||||
orElse (blockRef.block(world) flatMap { bl => GeneticsHelper.getErsatzPollen(bl, blockRef.meta(world)) })
|
||||
) map { individual =>
|
||||
// Generate pollen item and consume kit
|
||||
val newStack = ForestryHelper.getRoot("Trees").getMemberStack(individual, EnumGermlingType.POLLEN.ordinal())
|
||||
if (newStack != null) {
|
||||
ItemUtils.dropItemToPlayer(world, player, newStack)
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user