aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java6
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java67
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java115
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java4
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java767
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java11
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java379
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java266
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java8
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java4
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java4
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java21
20 files changed, 1194 insertions, 474 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java
index 82bc38aa9a..240ca6cfe8 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java
@@ -58,7 +58,7 @@ public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine {
super.detectAndSendChanges();
for(final ICrafting crafting : (List<ICrafting>)this.crafters) {
crafting.sendProgressBarUpdate(this, 100, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).maxEUStore());
- crafting.sendProgressBarUpdate(this, 101, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getStoredInternalPower());
+ crafting.sendProgressBarUpdate(this, 101, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getEUVar());
if (((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).isCorrectMachinePart(this.mTileEntity.getStackInSlot(1))){
this.mTileEntity.markDirty();
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
index 565c378179..3a60a3e93e 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
@@ -24,9 +24,9 @@ public class GUI_TreeFarmer extends GT_GUIContainerMetaTile_Machine {
this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU;
this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU;
if (((CONTAINER_TreeFarmer) this.mContainer).mDisplayErrorCode == 0) {
- this.fontRendererObj.drawString("Current Power Stored: "+this.storedPower+"EU", 10, 52, 16448255);
- this.fontRendererObj.drawString("Max Power Storage: "+this.maxPower+"EU", 10, 60, 16448255);
- this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 10, 68, 16448255);
+ this.fontRendererObj.drawString("Current Power: "+this.storedPower+"EU", 8, 52, 16448255);
+ this.fontRendererObj.drawString("Max Power: "+this.maxPower+"EU", 8, 60, 16448255);
+ this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 8, 68, 16448255);
}
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java
index df886220c2..14586a91f8 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java
@@ -15,7 +15,7 @@ import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.api.objects.XSTR;
+import gtPlusPlus.api.objects.random.XSTR;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index 22248814ce..0eec457d66 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -4,6 +4,7 @@ import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import gregtech.api.util.GT_Utility;
import net.minecraftforge.fluids.FluidStack;
@@ -30,6 +31,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import static gtPlusPlus.core.util.array.ArrayUtils.removeNulls;
@@ -39,6 +41,7 @@ GT_MetaTileEntity_MultiBlockBase {
public GT_Recipe mLastRecipe;
private boolean mInternalCircuit = false;
+ protected long mTotalRunTime = 0;
public ArrayList<GT_MetaTileEntity_Hatch_InputBattery> mChargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_InputBattery>();
public ArrayList<GT_MetaTileEntity_Hatch_OutputBattery> mDischargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_OutputBattery>();
@@ -59,7 +62,7 @@ GT_MetaTileEntity_MultiBlockBase {
.getMetaTileEntity() == aMetaTileEntity)
&& !aMetaTileEntity.getBaseMetaTileEntity().isDead();
}
-
+
public abstract boolean hasSlotInGUI();
@Override
@@ -83,11 +86,27 @@ GT_MetaTileEntity_MultiBlockBase {
}
@Override
- public String[] getInfoData() {
- return new String[]{"Progress:", (this.mProgresstime / 20) + "secs",
- (this.mMaxProgresstime / 20) + "secs", "Efficiency:",
- (this.mEfficiency / 100.0F) + "%", "Problems:",
- "" + (this.getIdealStatus() - this.getRepairStatus())};
+ public String[] getInfoData() {
+
+ long seconds = (this.mTotalRunTime/20);
+ int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7);
+ int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks);
+ long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks);
+ long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60);
+ long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60);
+
+ String[] g = {
+ "Progress: " + (this.mProgresstime / 20) +" / "+ (this.mMaxProgresstime / 20) + " secs",
+ "Efficiency: "+(this.mEfficiency / 100.0F) + "%",
+ "Problems: " + "" + (this.getIdealStatus() - this.getRepairStatus()),
+ "Total Time Since Built: " + ""+weeks+" Weeks, " + ""+days+" Days, ",
+ ""+hours+" Hours, " + ""+minutes+" Minutes, " + ""+second+" Seconds.",
+ "Total Time in ticks: "+this.mTotalRunTime};
+
+ return g;
+
+
+
}
@Override
@@ -128,7 +147,7 @@ GT_MetaTileEntity_MultiBlockBase {
// Gendustry custom comb with a billion centrifuge outputs? Do it anyway.
return true;
}
-
+
// Count slots available in output buses
ArrayList<ItemStack> tBusStacks = new ArrayList<>();
@@ -353,16 +372,16 @@ GT_MetaTileEntity_MultiBlockBase {
GT_Recipe cloneRecipe = null;
baseRecipe = tRecipe.copy();
- if ((cloneRecipe != baseRecipe) || (cloneRecipe == null)) {
+ if ((baseRecipe != null) && ((cloneRecipe != baseRecipe) || (cloneRecipe == null))) {
cloneRecipe = baseRecipe.copy();
Logger.WARNING("Setting Recipe");
}
- if ((cloneTime != baseRecipe.mDuration) || (cloneTime == 0)) {
+ if ((baseRecipe != null) && ((cloneTime != baseRecipe.mDuration) || (cloneTime == 0))) {
cloneTime = baseRecipe.mDuration;
Logger.WARNING("Setting Time");
}
- if (cloneRecipe.mDuration > 0) {
+ if ((cloneRecipe != null) && cloneRecipe.mDuration > 0) {
final int originalTime = cloneRecipe.mDuration;
final int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration,
(100 - percentage));
@@ -385,6 +404,12 @@ GT_MetaTileEntity_MultiBlockBase {
@Override
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity,
final long aTick) {
+
+ //Time Counter
+ if (aBaseMetaTileEntity.isServerSide()){
+ this.mTotalRunTime++;
+ }
+
super.onPostTick(aBaseMetaTileEntity, aTick);
//this.mChargeHatches.clear();
//this.mDischargeHatches.clear();
@@ -408,7 +433,7 @@ GT_MetaTileEntity_MultiBlockBase {
}
super.explodeMultiblock();
}
-
+
protected int getGUICircuit(ItemStack[] t) {
Item g = CI.getNumberedCircuit(0).getItem();
ItemStack guiSlot = this.mInventory[1];
@@ -420,12 +445,12 @@ GT_MetaTileEntity_MultiBlockBase {
else {
this.mInternalCircuit = false;
}
-
+
if (!this.mInternalCircuit) {
for (ItemStack j : t) {
if (j.getItem() == g) {
- mMode = j.getItemDamage();
- break;
+ mMode = j.getItemDamage();
+ break;
}
}
}
@@ -593,7 +618,7 @@ GT_MetaTileEntity_MultiBlockBase {
* This is the array Used to Store the Tectech Multi-Amp hatches.
*/
- public ArrayList<GT_MetaTileEntity_Hatch> mMultiDynamoHatches = new ArrayList();
+ public ArrayList<GT_MetaTileEntity_Hatch> mMultiDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>();
/**
* TecTech Multi-Amp Dynamo Support
@@ -652,4 +677,16 @@ GT_MetaTileEntity_MultiBlockBase {
return 0;
}
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setLong("mTotalRunTime", this.mTotalRunTime);
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ this.mTotalRunTime = aNBT.getLong("mTotalRunTime");
+ super.loadNBTData(aNBT);
+ }
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java
index d3bf4dfe51..148e92b7fa 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java
@@ -8,61 +8,68 @@ public class CasingTextureHandler2 {
public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57]
if ((aMeta >= 0) && (aMeta < 16)) {
switch (aMeta) {
- //Centrifuge
- case 0:
- return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
- //Coke Oven Frame
- case 1:
- return TexturesGtBlock.Casing_Material_HastelloyX.getIcon();
- //Coke Oven Casing Tier 1
- case 2:
- return TexturesGtBlock.Casing_Material_HastelloyN.getIcon();
- //Coke Oven Casing Tier 2
- case 3:
- return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon();
- //Material Press Casings
- case 4:
- return TexturesGtBlock.Casing_Material_Grisium.getIcon();
- //Sifter Structural
- case 5:
- return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon();
- //Sifter Sieve
- case 6:
- return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon();
-
- //Vanadium Radox Battery
- case 7:
- return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon();
- //Power Sub-Station Casing
- case 8:
- return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon();
- //Cyclotron Coil
- case 9:
- return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon();
- //Cyclotron External Casing
- case 10:
- return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon();
- //Multitank Exterior Casing
- case 11:
- return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon();
- //Reactor Casing I
- case 12:
- return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon();
- //Reactor Casing II
- case 13:
- if (aSide <2) {
- return TexturesGtBlock.TEXTURE_TECH_A.getIcon();
- }
- else {
- return TexturesGtBlock.TEXTURE_TECH_B.getIcon();
- }
- case 14:
- return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
- case 15:
- return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon(); //Tree Farmer Textures
+ //Centrifuge
+ case 0:
+ return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
+ //Coke Oven Frame
+ case 1:
+ return TexturesGtBlock.Casing_Material_HastelloyX.getIcon();
+ //Coke Oven Casing Tier 1
+ case 2:
+ return TexturesGtBlock.Casing_Material_HastelloyN.getIcon();
+ //Coke Oven Casing Tier 2
+ case 3:
+ return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon();
+ //Material Press Casings
+ case 4:
+ return TexturesGtBlock.Casing_Material_Grisium.getIcon();
+ //Sifter Structural
+ case 5:
+ return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon();
+ //Sifter Sieve
+ case 6:
+ return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon();
- default:
- return TexturesGtBlock.Overlay_UU_Matter.getIcon();
+ //Vanadium Radox Battery
+ case 7:
+ return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon();
+ //Power Sub-Station Casing
+ case 8:
+ return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon();
+ //Cyclotron Coil
+ case 9:
+ return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon();
+ //Cyclotron External Casing
+ case 10:
+ return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon();
+ //Multitank Exterior Casing
+ case 11:
+ return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon();
+ //Reactor Casing I
+ case 12:
+ return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon();
+ //Reactor Casing II
+ case 13:
+ if (aSide <2) {
+ return TexturesGtBlock.TEXTURE_TECH_A.getIcon();
+ }
+ else {
+ return TexturesGtBlock.TEXTURE_TECH_B.getIcon();
+ }
+ case 14:
+ return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
+ case 15:
+ if (aSide <2) {
+ if (aSide == 1) {
+ return TexturesGtBlock.Casing_Machine_Podzol.getIcon();
+ }
+ return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon();
+ }
+ else {
+ return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon();
+ }
+ default:
+ return TexturesGtBlock.Overlay_UU_Matter.getIcon();
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java
index 210603ec0d..7aaabe6ef1 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java
@@ -8,9 +8,9 @@ import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_ModHandler;
import gregtech.common.items.*;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.Pair;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.array.BlockPos;
-import gtPlusPlus.core.util.array.Pair;
import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.nbt.NBTUtils;
import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
index d023307820..7b1da9738b 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
@@ -2,28 +2,63 @@ package gtPlusPlus.xmod.gregtech.common.helpers;
import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.Stack;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import com.google.common.collect.Lists;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.Event.Result;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.gameevent.TickEvent;
+import gnu.trove.set.hash.THashSet;
import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.TAE;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.common.items.GT_MetaGenerated_Item_02;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.core.players.FakeFarmer;
import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL;
+import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.fluid.FluidUtils;
+import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.particles.BlockBreakParticles;
-import gtPlusPlus.xmod.forestry.trees.TreefarmManager;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
import net.minecraft.block.Block;
+import net.minecraft.block.BlockAir;
import net.minecraft.block.IGrowable;
+import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.play.server.S23PacketBlockChange;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent;
+import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fluids.FluidStack;
public class TreeFarmHelper {
@@ -199,7 +234,7 @@ public class TreeFarmHelper {
}
- if (TreefarmManager.isLeaves(testBlock) || TreefarmManager.isWoodLog(testBlock)){
+ if (isLeaves(testBlock) || isWoodLog(testBlock)){
Logger.WARNING("1:"+testBlock.getUnlocalizedName());
int posiX, posiY, posiZ;
posiX = aBaseMetaTileEntity.getXCoord()+xDir+i;
@@ -232,7 +267,7 @@ public class TreeFarmHelper {
//Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot.");
if ((aStack.getItem() instanceof GT_MetaGenerated_Item_02) || (aStack.getItem() instanceof GT_MetaGenerated_Tool)){
if (OrePrefixes.craftingTool.contains(aStack)){
- if (aStack.getDisplayName().toLowerCase().contains("saw") || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.10")){
+ if (aStack.getDisplayName().toLowerCase().contains("saw") || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01")){
if (aStack.getItemDamage() == 10){
return SAWTOOL.SAW;
}
@@ -258,4 +293,730 @@ public class TreeFarmHelper {
return SAWTOOL.NONE;
}
+ public static boolean isHumusLoaded = false;
+ public static boolean isForestryLogsLoaded = false;
+ public static boolean isForestryFenceLoaded = false;
+ public static boolean isForestrySaplingsLoaded = false;
+ public static boolean isForestryLeavesLoaded = false;
+ public static Block blockHumus;
+
+ public static boolean isForestryValid(){
+ if (!LoadedMods.Forestry){
+ return false;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
+ isHumusLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){
+ isForestryLogsLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){
+ isForestryFenceLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){
+ isForestrySaplingsLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){
+ isForestryLeavesLoaded = true;
+ }
+ return true;
+ }
+
+ @Optional.Method(modid = "Forestry")
+ public static Block getHumus(){
+ if(blockHumus != null){
+ return blockHumus;
+ }
+ else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
+ try {
+ final Class<?> humusClass = Class.forName("forestry.core.blocks.BlockSoil");
+ final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1);
+ if (humusClass != null){
+ blockHumus = Block.getBlockFromItem(humusStack.getItem());
+ return Block.getBlockFromItem(humusStack.getItem());
+ }
+ } catch (final ClassNotFoundException e) {}
+ }
+ return null;
+ }
+
+ public static boolean isWoodLog(final Block log){
+ final String tTool = log.getHarvestTool(0);
+
+ if ((log == Blocks.log) || (log == Blocks.log2)){
+ return true;
+ }
+
+ //Forestry/General Compat
+ if (log.getClass().getName().toLowerCase().contains("blocklog")){
+ return true;
+ }
+
+ //IC2 Rubber Tree Compat
+ if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){
+ return true;
+ }
+
+ return (OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe")))) || (log.getMaterial() != Material.wood) ? false : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true);
+ }
+
+ public static boolean isLeaves(final Block log){
+ if (log.getUnlocalizedName().toLowerCase().contains("leaf")){
+ return true;
+ }
+ if (log.getUnlocalizedName().toLowerCase().contains("leaves")){
+ return true;
+ }
+ if (log.getLocalizedName().toLowerCase().contains("leaf")){
+ return true;
+ }
+ if (log.getLocalizedName().toLowerCase().contains("leaves")){
+ return true;
+ }
+ return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.leaves || OrePrefixes.treeLeaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.vine || OrePrefixes.mushroom.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.cactus;
+ }
+
+ public static boolean isSapling(final Block log){
+ if (log != null){
+ if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){
+ Logger.WARNING(""+log.getLocalizedName());
+ }
+ if (log.getLocalizedName().toLowerCase().contains("sapling")){
+ Logger.WARNING(""+log.getLocalizedName());
+ return true;
+ }
+ }
+ return OrePrefixes.sapling.contains(new ItemStack(log, 1));
+ }
+
+ public static boolean isDirtBlock(final Block dirt){
+ return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false))));
+ }
+
+ public static boolean isFenceBlock(final Block fence){
+ return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false))));
+ }
+
+ public static boolean isAirBlock(final Block air){
+ if (air.getLocalizedName().toLowerCase().contains("air")){
+ return true;
+ }
+ if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){
+ return true;
+ }
+ return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false));
+ }
+
+ /*public static boolean isSaplingBlock(Block sapling){
+ return (sapling == Blocks.sapling ? true : (sapling == Blocks.))
+ }*/
+
+ public static BlockPos checkForLogsInGrowArea(final IGregTechTileEntity aBaseMetaTileEntity) {
+ final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7;
+ final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7;
+ for (int i = -7; i <= 7; i++) {
+ for (int j = -7; j <= 7; j++) {
+ for (int h = 0; h <= 1; h++) {
+ //Farm Floor inner 14x14
+ if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) {
+ if (h == 1) {
+ if (TreeFarmHelper.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
+ Logger.INFO("Found a Log");
+ return new BlockPos(aBaseMetaTileEntity.getXCoord()+xDir + i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir + j);
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static ItemStack[] findTreeFromBase(World world, BlockPos h) {
+ int HARD_LIMIT = 10000;
+ int mCount = 0;
+ Logger.INFO("Finding Rest of Tree.");
+ BlockPos mFirstSpot = h;
+ Set<BlockPos> mSearchedSpaces = new HashSet<BlockPos>();
+ Set<BlockPos> mTreeSet = getConnectedBlocks(world, mFirstSpot, mSearchedSpaces);
+ Set<Set<BlockPos>> mTreeSet2 = new HashSet<Set<BlockPos>>();
+ Set<BlockPos> mFinalTree = new HashSet<BlockPos>();
+ Iterator<BlockPos> it = mTreeSet.iterator();
+
+
+ Logger.INFO("Running first iteration.");
+ while(it.hasNext()){
+ BlockPos G = it.next();
+ mSearchedSpaces.add(G);
+ mTreeSet2.add(getConnectedBlocks(world, G, mSearchedSpaces));
+ mCount++;
+ Logger.INFO("First Search: "+G.getLocationString());
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+
+ mCount = 0;
+ Iterator<Set<BlockPos>> it2 = mTreeSet2.iterator();
+ Iterator<BlockPos> it3;
+ Logger.INFO("Running second iteration.");
+ while(it2.hasNext()){
+ Set<BlockPos> G = it2.next();
+ it3 = G.iterator();
+ while(it3.hasNext()){
+ BlockPos G2 = it3.next();
+ mSearchedSpaces.add(G2);
+ mFinalTree.add(G2);
+ mCount++;
+ Logger.INFO("Second Search: "+G2.getLocationString());
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+
+
+ if (mFinalTree.size() > 0) {
+ Logger.INFO("Queuing "+mFinalTree.size()+" to Harvest Manager.");
+ TreeCutter harvestManager = new TreeCutter(world);
+
+ Iterator<BlockPos> ith = mFinalTree.iterator();
+ while(ith.hasNext()){
+ BlockPos G = ith.next();
+ harvestManager.queue(G);
+ mCount++;
+ Logger.INFO("Queued: "+G.getLocationString());
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+
+ if (harvestManager.isValid) {
+ ItemStack[] loot = harvestManager.getDrops();
+ if (loot.length > 0) {
+ //Logger.INFO("Returning Drops from harvestManager Queue.");
+ return loot;
+ }
+ }
+ }
+ return new ItemStack[] {};
+ }
+
+
+ public static Set<BlockPos> getConnectedBlocks(World W, BlockPos P, Set<BlockPos> checkedSpaces) {
+ int HARD_LIMIT = 1000;
+ int mCount = 0;
+ Logger.INFO("Finding blocks connected to "+P.getLocationString()+".");
+ Set<BlockPos> mCheckedSpaces = checkedSpaces;
+ Set<BlockPos> mStartSearch = searchSixFaces(W, P, mCheckedSpaces, false);
+ Set<BlockPos> mSecondSearch = new HashSet<BlockPos>();
+ Set<BlockPos> mThirdSearch = new HashSet<BlockPos>();
+ Iterator<BlockPos> it = mStartSearch.iterator();
+ while(it.hasNext()){
+ Logger.INFO("Running first iteration. [II]");
+ BlockPos G = it.next();
+ mCheckedSpaces.add(G);
+ Set<BlockPos> mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true);
+ Iterator<BlockPos> it2 = mBranchSearch.iterator();
+ while(it2.hasNext()){
+ Logger.INFO("Running second iteration. [II]");
+ BlockPos G2 = it2.next();
+ mCheckedSpaces.add(G2);
+ mSecondSearch.add(G2);
+ mCount++;
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+ mCount = 0;
+ Iterator<BlockPos> itx = mSecondSearch.iterator();
+ while(itx.hasNext()){
+ BlockPos G = itx.next();
+ mCheckedSpaces.add(G);
+ Set<BlockPos> mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true);
+ Iterator<BlockPos> it2 = mBranchSearch.iterator();
+ while(it2.hasNext()){
+ BlockPos G2 = it2.next();
+ mCheckedSpaces.add(G2);
+ mThirdSearch.add(G2);
+ mCount++;
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+ if (mCount > HARD_LIMIT) {
+ break;
+ }
+ }
+ return mThirdSearch;
+ }
+
+ public static Set<BlockPos> searchSixFaces(World W, BlockPos P, Set<BlockPos> checkedSpaces, boolean checkLeaves) {
+ Set<BlockPos> mConnected = new HashSet<BlockPos>();
+ int x = P.xPos;
+ int y = P.yPos;
+ int z = P.zPos;
+ if (checkLeaves) {
+ if (isWoodLog(W.getBlock(x-1, y, z)) || isLeaves(W.getBlock(x-1, y, z))) {
+ BlockPos L = new BlockPos(x-1, y, z);
+ if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found Connected. [III]");
+ }
+ }
+ if (isWoodLog(W.getBlock(x+1, y, z)) || isLeaves(W.getBlock(x+1, y, z))) {
+ BlockPos L = new BlockPos(x+1, y, z);
+ if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found Connected. [III]");
+ }
+ }
+ if (isWoodLog(W.getBlock(x, y-1, z)) || isLeaves(W.getBlock(x, y-1, z))) {
+ BlockPos L = new BlockPos(x, y-1, z);
+ if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found Connected. [III]");
+ }
+ }
+ if (isWoodLog(W.getBlock(x, y+1, z)) || isLeaves(W.getBlock(x, y+1, z))) {
+ BlockPos L = new BlockPos(x, y+1, z);
+ if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found