From 4fd0a7f47340b496ae2c24c0e43e8fead0407f50 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Sat, 28 Nov 2015 20:35:13 +0100 Subject: [PATCH] Fix forestry compatibility and add luber ability to chainsaw --- build.properties | 2 +- .../common/tools/GT_Tool_Chainsaw_LV.java | 39 ++++++++++++++++++- .../loaders/misc/GT_BeeDefinition.java | 15 ++++--- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/build.properties b/build.properties index 60c46a96..d3a86a64 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1517-1.7.10 -gt.version=5.09.13 +gt.version=5.09.14 ae2.version=rv2-beta-33 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/common/tools/GT_Tool_Chainsaw_LV.java b/src/main/java/gregtech/common/tools/GT_Tool_Chainsaw_LV.java index 2e32c5ea..a0d552b4 100644 --- a/src/main/java/gregtech/common/tools/GT_Tool_Chainsaw_LV.java +++ b/src/main/java/gregtech/common/tools/GT_Tool_Chainsaw_LV.java @@ -1,16 +1,25 @@ package gregtech.common.tools; +import java.util.ArrayList; +import java.util.List; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.items.GT_MetaGenerated_Tool; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; +import net.minecraftforge.common.IShearable; +import net.minecraftforge.event.world.BlockEvent; public class GT_Tool_Chainsaw_LV extends GT_Tool_Saw { @@ -77,7 +86,35 @@ public class GT_Tool_Chainsaw_LV } catch (Exception e) { } } - + @Override + public int convertBlockDrops(List aDrops, ItemStack aStack, EntityPlayer aPlayer, Block aBlock, int aX, int aY, int aZ, byte aMetaData, int aFortune, boolean aSilkTouch, BlockEvent.HarvestDropsEvent aEvent) { + int rAmount = 0; + if ((aBlock.getMaterial() == Material.leaves) && ((aBlock instanceof IShearable))) { + aPlayer.worldObj.setBlock(aX, aY, aZ, aBlock, aMetaData, 0); + if (((IShearable) aBlock).isShearable(aStack, aPlayer.worldObj, aX, aY, aZ)) { + ArrayList tDrops = ((IShearable) aBlock).onSheared(aStack, aPlayer.worldObj, aX, aY, aZ, aFortune); + aDrops.clear(); + aDrops.addAll(tDrops); + aEvent.dropChance = 1.0F; + } + aPlayer.worldObj.setBlock(aX, aY, aZ, Blocks.air, 0, 0); + } else if (((aBlock.getMaterial() == Material.ice) || (aBlock.getMaterial() == Material.packedIce)) && (aDrops.isEmpty())) { + aDrops.add(new ItemStack(aBlock, 1, aMetaData)); + aPlayer.worldObj.setBlockToAir(aX, aY, aZ); + aEvent.dropChance = 1.0F; + return 1; + } + if ((GregTech_API.sTimber) && (!aPlayer.isSneaking()) && (OrePrefixes.log.contains(new ItemStack(aBlock, 1, aMetaData)))) { + int tY = aY + 1; + for (int tH = aPlayer.worldObj.getHeight(); tY < tH; tY++) { + if ((aPlayer.worldObj.getBlock(aX, tY, aZ) != aBlock) || (!aPlayer.worldObj.func_147480_a(aX, tY, aZ, true))) { + break; + } + rAmount++; + } + } + return rAmount; + } public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mIconSet.mTextures[gregtech.api.enums.OrePrefixes.toolHeadChainsaw.mTextureIndex] : Textures.ItemIcons.POWER_UNIT_LV; diff --git a/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java b/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java index 690a1ba6..1f186d2e 100644 --- a/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java +++ b/src/main/java/gregtech/loaders/misc/GT_BeeDefinition.java @@ -9,10 +9,13 @@ import forestry.apiculture.genetics.Bee; import forestry.apiculture.genetics.BeeDefinition; import forestry.apiculture.genetics.BeeVariation; import forestry.apiculture.genetics.IBeeDefinition; -import forestry.core.config.ForestryItem; +//import forestry.apiculture.items.EnumHoneyComb; import forestry.core.genetics.alleles.AlleleHelper; +//import forestry.plugins.PluginApiculture; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; import gregtech.common.items.CombType; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -26,7 +29,7 @@ public enum GT_BeeDefinition implements IBeeDefinition { CLAY(GT_BranchDefinition.ORGANIC, "Clay", true, 0x19d0ec, 0xffdc16) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.30f); + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.30f); beeSpecies.addProduct(new ItemStack(Items.clay_ball, 1), 0.15f); beeSpecies.setHumidity(EnumHumidity.DAMP); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -45,7 +48,7 @@ public enum GT_BeeDefinition implements IBeeDefinition { SLIMEBALL(GT_BranchDefinition.ORGANIC, "SlimeBall", true, 0x4E9E55, 0x00FF15) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 15), 0.30f); + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 15), 0.30f); beeSpecies.addSpecialty(GT_Bees.combs.getStackForType(CombType.STICKY), 0.30f); beeSpecies.setHumidity(EnumHumidity.DAMP); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -65,7 +68,7 @@ public enum GT_BeeDefinition implements IBeeDefinition { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.LIGNIE), 0.30f); - beeSpecies.addProduct(ForestryItem.peat.getItemStack(1), 0.15f); + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.15f); beeSpecies.setHumidity(EnumHumidity.NORMAL); beeSpecies.setTemperature(EnumTemperature.NORMAL); } @@ -83,7 +86,7 @@ public enum GT_BeeDefinition implements IBeeDefinition { STICKYRESIN(GT_BranchDefinition.ORGANIC, "StickyResin", true, 0x2E8F5B, 0xDCC289) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.30f); + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.30f); beeSpecies.addProduct(ItemList.IC2_Resin.get(1, new Object[0]), 0.15f); beeSpecies.setHumidity(EnumHumidity.NORMAL); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -121,7 +124,7 @@ public enum GT_BeeDefinition implements IBeeDefinition { OIL(GT_BranchDefinition.ORGANIC, "Oil", true, 0x4C4C4C, 0x333333) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.30f); + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.30f); beeSpecies.addSpecialty(GT_Bees.combs.getStackForType(CombType.OIL), 0.15f); beeSpecies.setHumidity(EnumHumidity.DAMP); beeSpecies.setTemperature(EnumTemperature.NORMAL);