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 Connected. [III]");
+ }
+ }
+ if (isWoodLog(W.getBlock(x, y, z-1)) || isLeaves(W.getBlock(x, y, z-1))) {
+ BlockPos L = new BlockPos(x, y, z-1);
+ if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found Connected. [III]");
+ }
+ }
+ if (isWoodLog(W.getBlock(x, y, z+1)) || isLeaves(W.getBlock(x, y, z+1))) {
+ BlockPos L = new BlockPos(x, y, z+1);
+ if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found Connected. [III]");
+ }
+ }
+ }
+ else {
+ if (isWoodLog(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))) {
+ 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))) {
+ 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))) {
+ 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, z-1))) {
+ BlockPos L = new BlockPos(x, y, z-1);
+ //if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found Connected. [III]");
+ //}
+ }
+ if (isWoodLog(W.getBlock(x, y, z+1))) {
+ BlockPos L = new BlockPos(x, y, z+1);
+ //if (!checkedSpaces.contains(L)) {
+ mConnected.add(L);
+ Logger.INFO("Found Connected. [III]");
+ //}
+ }
+ }
+ return mConnected;
+ }
+
+ public static <T> Set<T> combineSetData(Set<T> S, Set<T> J) {
+ Set<T> mData = new HashSet<T>();
+ T[] array1 = (T[]) S.toArray();
+ Collections.addAll(mData, array1);
+ T[] array2 = (T[]) J.toArray();
+ Collections.addAll(mData, array2);
+ return mData;
+ }
+
+
+
+ /**
+ * Tree Cutting
+ */
+
+ public static class TreeCutter {
+
+ private final World mWorld;
+ private Map<String, BlockPos> mQueue = new ConcurrentHashMap<String, BlockPos>();
+ private AutoMap<ItemStack[]> mDrops = new AutoMap<ItemStack[]>();
+ private boolean isValid = true;
+
+ public TreeCutter(World world) {
+ this.mWorld = world;
+ }
+
+ public boolean queue(BlockPos pos) {
+ if (isValid && pos != null) {
+ //Logger.INFO("Queued: "+pos.getLocationString());
+ String hash = Utils.calculateChecksumMD5(pos);
+ if (hash != null && !mQueue.containsKey(hash)) {
+ mQueue.put(hash, pos);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean emptyQueue() {
+ if (isValid) {
+ Logger.INFO("Emptying Queue.");
+ if (this.mQueue.size() > 0) {
+ int totalRemoved = 0;
+ for (BlockPos h : mQueue.values()) {
+ final Block block = mWorld.getBlock(h.xPos, h.yPos, h.zPos);
+ if (block != null) {
+ final int dropMeta = mWorld.getBlockMetadata(h.xPos, h.yPos, h.zPos);
+ final ArrayList<ItemStack> blockDrops = block.getDrops(mWorld, h.xPos, h.yPos, h.zPos, dropMeta, 0);
+ final ItemStack[] drops = ItemUtils.getBlockDrops(blockDrops);
+ mDrops.put(drops);
+ //Remove drop that was added to the bus.
+ mWorld.setBlockToAir(h.xPos, h.yPos, h.zPos);
+ //new BlockBreakParticles(mWorld, h.xPos, h.yPos, h.zPos, block);
+ totalRemoved++;
+ }
+ }
+ if (totalRemoved > 0 && mDrops.size() > 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public ItemStack[] getDrops() {
+ //If Queue is successfully cleared and drops are created, let us continue.
+ if (isValid && emptyQueue()) {
+ AutoMap<ItemStack> mCollective = new AutoMap<ItemStack>();
+ //Iterate ALL of the arrays, add output to a collective.
+ for (ItemStack[] i : this.mDrops) {
+ //Array is not null.
+ if (i != null) {
+ //Iterate this array.
+ for (int d=0;d<i.length;d++) {
+ //Put Output into collective if valid
+ if (i[d] != null && i[d].stackSize > 0) {
+ mCollective.put(i[d]);
+ }
+ }
+ }
+ }
+ //Build an ItemStack array.
+ ItemStack[] drops = new ItemStack[mCollective.size()];
+ for (int m=0;m<drops.length;m++) {
+ drops[m] = mCollective.get(m);
+ }
+ //Return drops array if it's valid.
+ if (drops.length > 0) {
+ isValid = false;
+ return drops;
+ }
+ }
+ //Invalid or no drops, return empty array.
+ isValid = false;
+ return new ItemStack[] {};
+ }
+
+ }
+
+
+ /**
+ * Farm AI
+ */
+ private static EntityPlayerMP farmerAI;
+ public EntityPlayerMP getFakePlayer(World world) {
+ return farmerAI = checkFakePlayer(world);
+ }
+
+ public static EntityPlayerMP checkFakePlayer(World world) {
+ if (farmerAI == null) {
+ return new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(world.provider.dimensionId));
+ }
+ return farmerAI;
+ }
+
+ public static boolean onBlockStartBreak (int x, int y, int z, World world){
+ final Block wood = world.getBlock(x, y, z);
+ if (wood == null){
+ return false;
+ }
+ if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge)
+ if(detectTree(world, x,y,z)) {
+ TreeChopTask chopper = new TreeChopTask(new ChunkPosition(x, y, z), checkFakePlayer(world), 128);
+ FMLCommonHandler.instance().bus().register(chopper);
+ // custom block breaking code, don't call vanilla code
+ return true;
+ }
+ //return onBlockStartBreak(stack, x, y, z, player);
+ return false;
+ }
+
+ public static boolean detectTree(World world, int pX, int pY, int pZ) {
+ ChunkPosition pos = null;
+ Stack<ChunkPosition> candidates = new Stack<>();
+ candidates.add(new ChunkPosition(pX, pY, pZ));
+
+ while (!candidates.isEmpty()) {
+ ChunkPosition candidate = candidates.pop();
+ int curX = candidate.chunkPosX, curY = candidate.chunkPosY, curZ = candidate.chunkPosZ;
+
+ Block block = world.getBlock(curX, curY, curZ);
+ if ((pos == null || candidate.chunkPosY > pos.chunkPosY) && block.isWood(world, curX, curY, curZ)) {
+ pos = new ChunkPosition(curX, candidate.chunkPosY + 1, curZ);
+ // go up
+ while (world.getBlock(curX, pos.chunkPosY, curZ).isWood(world, curX, pos.chunkPosY, curZ)) {
+ pos = new ChunkPosition(curX, pos.chunkPosY + 1, curZ);
+ }
+ // check if we still have a way diagonally up
+ candidates.add(new ChunkPosition(curX + 1, pos.chunkPosY + 1, curZ ));
+ candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ + 1));
+ candidates.add(new ChunkPosition(curX - 1, pos.chunkPosY + 1, curZ ));
+ candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ - 1));
+ }
+ }
+
+ // not even one match, so there were no logs.
+ if (pos == null) {
+ return false;
+ }
+
+ // check if there were enough leaves around the last position
+ // pos now contains the block above the topmost log
+ // we want at least 5 leaves in the surrounding 26 blocks
+ int d = 3;
+ int leaves = 0;
+ for (int offX = 0; offX < d; offX++) {
+ for (int offY = 0; offY < d; offY++) {
+ for (int offZ = 0; offZ < d; offZ++) {
+ int xPos = pos.chunkPosX -1 + offX, yPos = pos.chunkPosY - 1 + offY, zPos = pos.chunkPosZ - 1 + offZ;
+ Block leaf = world.getBlock(xPos, yPos, zPos);
+ if (leaf != null && leaf.isLeaves(world, xPos, yPos, zPos)) {
+ if (++leaves >= 5) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ // not enough leaves. sorreh
+ return false;
+ }
+
+ public static class TreeChopTask {
+
+ public final World world;
+ public final EntityPlayer player;
+ public final int blocksPerTick;
+
+ public Queue<ChunkPosition> blocks = Lists.newLinkedList();
+ public Set<ChunkPosition> visited = new THashSet<>();
+
+ public TreeChopTask(ChunkPosition start, EntityPlayer player, int blocksPerTick) {
+ this.world = player.getEntityWorld();
+ this.player = player;
+ this.blocksPerTick = blocksPerTick;
+
+ this.blocks.add(start);
+ }
+
+ private void queueCoordinate(int x, int y, int z) {
+ ChunkPosition pos = new ChunkPosition(x, y, z);
+ if (!visited.contains(pos)) {
+ blocks.add(pos);
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldTick(TickEvent.WorldTickEvent event) {
+ if (event.side.isClient()) {
+ finish();
+ return;
+ }
+ // only if same dimension
+ if (event.world.provider.dimensionId != world.provider.dimensionId) {
+ return;
+ }
+
+ // setup
+ int left = blocksPerTick;
+ //NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
+
+ // continue running
+ ChunkPosition pos;
+ while (left > 0) {
+ // completely done or can't do our job anymore?!
+ if (blocks.isEmpty()/* || tags.getBoolean("Broken")*/) {
+ finish();
+ return;
+ }
+
+ pos = blocks.remove();
+ if (!visited.add(pos)) {
+ continue;
+ }
+ int x = pos.chunkPosX, y = pos.chunkPosY, z = pos.chunkPosZ;
+
+ Block block = world.getBlock(x, y, z);
+ int meta = world.getBlockMetadata(x, y, z);
+
+ // can we harvest the block and is effective?
+ if (!block.isWood(world, x, y, z) || !isWoodLog(block)) {
+ continue;
+ }
+
+ // save its neighbors
+ queueCoordinate(x + 1, y, z );
+ queueCoordinate(x, y, z + 1);
+ queueCoordinate(x - 1, y, z );
+ queueCoordinate(x, y, z - 1);
+
+ // also add the layer above.. stupid acacia trees
+ for (int offX = 0; offX < 3; offX++) {
+ for (int offZ = 0; offZ < 3; offZ++) {
+ queueCoordinate(x - 1 + offX, y + 1, z - 1 + offZ);
+ }
+ }
+
+ // break it, wooo!
+ breakExtraBlock(player.worldObj, x, y, z, 0, player, x, y, z);
+ left--;
+ }
+ }
+
+ private void finish() {
+ // goodbye cruel world
+ FMLCommonHandler.instance().bus().unregister(this);
+ }
+ }
+
+
+ public static void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) {
+ // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events
+ if (world.isAirBlock(x, y, z))
+ return;
+
+ // what?
+ if(!(playerEntity instanceof EntityPlayerMP))
+ return;
+ EntityPlayerMP player = (EntityPlayerMP) playerEntity;
+
+ // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian
+ // or precious ores you can't harvest while mining stone
+ Block block = world.getBlock(x, y, z);
+ int meta = world.getBlockMetadata(x, y, z);
+
+ // only effective materials
+ if (!isWoodLog(block))
+ return;
+
+ Block refBlock = world.getBlock(refX, refY, refZ);
+ float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ);
+ float strength = ForgeHooks.blockStrength(block, player, world, x,y,z);
+
+ // only harvestable blocks that aren't impossibly slow to harvest
+ if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f)
+ return;
+
+ // send the blockbreak event
+ BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z);
+ if(event.isCanceled())
+ return;
+
+ if (player.capabilities.isCreativeMode) {
+ block.onBlockHarvested(world, x, y, z, meta, player);
+ if (block.removedByPlayer(world, player, x, y, z, false))
+ block.onBlockDestroyedByPlayer(world, x, y, z, meta);
+
+ // send update to client
+ if (!world.isRemote) {
+ player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
+ }
+ return;
+ }
+
+ // callback to the tool the player uses. Called on both sides. This damages the tool n stuff.
+ player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player);
+
+ // server sided handling
+ if (!world.isRemote) {
+ // serverside we reproduce ItemInWorldManager.tryHarvestBlock
+
+ // ItemInWorldManager.removeBlock
+ block.onBlockHarvested(world, x,y,z, meta, player);
+
+ if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above
+ {
+ block.onBlockDestroyedByPlayer( world, x,y,z, meta);
+ block.harvestBlock(world, player, x,y,z, meta);
+ block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop());
+ }
+
+ // always send block update to client
+ player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
+ }
+ // client sided handling
+ else {
+ //PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController;
+ // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets
+ // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy.
+
+ // following code can be found in PlayerControllerMP.onPlayerDestroyBlock
+ world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
+ if(block.removedByPlayer(world, player, x,y,z, true))
+ {
+ block.onBlockDestroyedByPlayer(world, x,y,z, meta);
+ }
+ // callback to the tool
+ ItemStack itemstack = player.getCurrentEquippedItem();
+ if (itemstack != null)
+ {
+ itemstack.func_150999_a(world, block, x, y, z, player);
+
+ if (itemstack.stackSize == 0)
+ {
+ player.destroyCurrentEquippedItem();
+ }
+ }
+
+ // send an update to the server, so we get an update back
+ //if(PHConstruct.extraBlockUpdates)
+ //Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit));
+ }
+ }
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
index 7bdc5ae2f2..297db1d7a0 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
@@ -1,7 +1,8 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic;
import static gregtech.api.enums.GT_Values.V;
-import static gtPlusPlus.api.objects.ChunkManager.mChunkLoaderManagerMap;
+import static gtPlusPlus.api.objects.minecraft.ChunkManager.mChunkLoaderManagerMap;
+
import java.io.File;
import java.io.IOException;
import java.util.Map;
@@ -17,11 +18,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachi
import gregtech.api.objects.GT_RenderedTexture;
import gtPlusPlus.GTplusplus;
import gtPlusPlus.api.interfaces.IChunkLoader;
-import gtPlusPlus.api.objects.ChunkManager;
-import gtPlusPlus.api.objects.DimChunkPos;
import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.util.array.BlockPos;
-import gtPlusPlus.core.util.array.Triplet;
+import gtPlusPlus.api.objects.data.Triplet;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.api.objects.minecraft.ChunkManager;
+import gtPlusPlus.api.objects.minecraft.DimChunkPos;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
index 7f70712ee9..e88840573d 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
@@ -11,8 +11,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.array.BlockPos;
import gtPlusPlus.core.util.entity.EntityUtils;
import gtPlusPlus.core.util.player.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java
index b2b6b83d0b..4540c41bd5 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java
@@ -19,10 +19,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energ
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.entity.EntityTeslaTowerLightning;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.array.Pair;
import gtPlusPlus.core.util.materials.MaterialUtils;
import gtPlusPlus.core.util.player.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java
index da83b3c3d1..7b7e4414b3 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java
@@ -1,397 +1,82 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi;
-import java.lang.reflect.Field;
-
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
-import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.objects.GT_RenderedTexture;
-import gregtech.api.util.GT_Recipe;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.lib.LoadedMods;
-import gtPlusPlus.xmod.forestry.trees.TreefarmManager;
-import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
-public class GregtechMetaTileEntityAnimalFarm extends GT_MetaTileEntity_MultiBlockBase {
-
-
- private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Tumbaga)};
- private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE)};
- private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE_ACTIVE)};
-
-
- //public ArrayList<GT_MetaTileEntity_TieredMachineBlock> mCasings = new ArrayList();
+public abstract class GregtechMetaTileEntityAnimalFarm extends GT_MetaTileEntity_MultiBlockBase {
- private final boolean running = false;
- private boolean p1, p2, p3, p4, p5, p6;
- public ItemStack mOutputItem1;
- public ItemStack mOutputItem2;
- private Block Humus;
- private final boolean isForestryLoaded = TreefarmManager.isForestryValid();
-
- public GregtechMetaTileEntityAnimalFarm(final int aID, final String aName, final String aNameRegional) {
- super(aID, aName, aNameRegional);
- }
-
- public GregtechMetaTileEntityAnimalFarm(final String aName) {
+ public GregtechMetaTileEntityAnimalFarm(String aName) {
super(aName);
+ // TODO Auto-generated constructor stub
}
-
- @Override
- public String[] getDescription() {
- return new String[]{
- "Controller Block for the Animal Farmer",
- "How to get your first logs without an axe.",
- "Max Size(WxHxD): 9x1x9 (Controller, with upto 4 dirt out each direction on a flat plane.)",
- "Dirt for the rest! [D = Dirt, X = Controller]"
- };
- }
-
- @Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
- if (aSide == 1) {
- return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)};
- }
- return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)};
+
+ public GregtechMetaTileEntityAnimalFarm(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ // TODO Auto-generated constructor stub
}
@Override
- public GT_Recipe.GT_Recipe_Map getRecipeMap() {
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity p0) {
+ // TODO Auto-generated method stub
return null;
}
@Override
- public boolean isTeleporterCompatible() {
- return false;
- }
-
- @Override
- public boolean isFacingValid(final byte aFacing) {
- return aFacing > 1;
- }
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- @Override
- public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) {
- return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
- }
-
- @Override
- public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaTileEntityAnimalFarm(this.mName);
+ public String[] getDescription() {
+ // TODO Auto-generated method stub
+ return null;
}
@Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
-
- return true;
+ public ITexture[] getTexture(IGregTechTileEntity p0, byte p1, byte p2, byte p3, boolean p4, boolean p5) {
+ // TODO Auto-generated method stub
+ return null;
}
@Override
- public boolean isCorrectMachinePart(final ItemStack aStack) {
- return true;
+ public boolean isCorrectMachinePart(ItemStack p0) {
+ // TODO Auto-generated method stub
+ return false;
}
@Override
- public boolean checkRecipe(final ItemStack aStack) {
- Logger.INFO("Working");
- /*if (!checkRecursiveBlocks()) {
- this.mEfficiency = 0;
- this.mEfficiencyIncrease = 0;
- this.mMaxProgresstime = 0;
- running = false;
- return false;
- }
-
- if (mEfficiency == 0) {
- this.mEfficiency = 10000;
- this.mEfficiencyIncrease = 10000;
- this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
- //GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), mMaxProgresstime*5);
- return true;
- }*/
- this.mEfficiency = 0;
- this.mEfficiencyIncrease = 0;
- this.mMaxProgresstime = 0;
+ public boolean checkRecipe(ItemStack p0) {
+ // TODO Auto-generated method stub
return false;
}
-
- private Block getHumus(){
- if (!LoadedMods.Forestry){
- return null;
- }
- return TreefarmManager.getHumus();
- }
-
@Override
- public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) {
-
- //this.mCasings.clear();
- Logger.INFO("Step 1");
- 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++) {
- Logger.INFO("Step 2");
- for (int j = -7; j <= 7; j++) {
- Logger.INFO("Step 3");
- for (int h = 0; h <= 1; h++) {
- Logger.INFO("Step 4");
-
- final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
-
- //Farm Floor inner 14x14
- if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) {
- Logger.INFO("Step 5 - H:"+h);
- // Farm Dirt Floor and Inner Air/Log space.
- if (h == 0) {
- //Dirt Floor
- if (!TreefarmManager.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
- Logger.INFO("Dirt like block missing from inner 14x14.");
- Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- aBaseMetaTileEntity.getWorld().setBlock(
- (aBaseMetaTileEntity.getXCoord()+(xDir+i)),
- (aBaseMetaTileEntity.getYCoord()+(h)),
- (aBaseMetaTileEntity.getZCoord()+(zDir+j)),
- Blocks.melon_block);
- return false;
- }
- }
- // Inside fenced area, mostly air or trees or saplings
- else if (h == 1){
- //Farm Inner 14x14
- /*if (!TreefarmManager.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || !TreefarmManager.isAirBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || !aBaseMetaTileEntity.getAirOffset(xDir+i, h, zDir+j)) {
- Utils.LOG_INFO("Wood like block missing from inner 14x14, layer 2."); //TODO
- Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- Utils.LOG_INFO("Found at x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j));
- //return false;
- }*/
- }
-
- }
- //Dealt with inner 5x5, now deal with the exterior.
- else {
- Logger.INFO("Step 6 - H:"+h);
- //Deal with all 4 sides (Fenced area)
- if (h == 1) {
- if (!TreefarmManager.isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
- Logger.INFO("Fence/Gate missing from outside the second layer.");
- Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- return false;
- }
- }
- //Deal with Bottom edges (Add Hatches/Busses first, othercheck make sure it's dirt) //TODO change the casings to not dirt~
- else if (h == 0) {
-
- try {
- this.addCasingToCasingList(tTileEntity);
- } catch (final Throwable t){}
-
- if ((!this.addMaintenanceToMachineList(tTileEntity, 77)) && (!this.addInputToMachineList(tTileEntity, 77)) && (!this.addOutputToMachineList(tTileEntity, 77)) && (!this.addEnergyInputToMachineList(tTileEntity, 77))) {
- if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller
-
- if (!(aBaseMetaTileEntity.getMetaTileID() != 752)) {
- Logger.INFO("Fark Keeper Casings Missing from one of the edges on the bottom edge. x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)+" | "+aBaseMetaTileEntity.getClass());
- Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- return false;
- }
- Logger.INFO("Found a farm keeper.");
- }
- }
- }
- Logger.INFO("Step a");
-
- }
- Logger.INFO("Step b");
- }
- Logger.INFO("Step c");
- }
- Logger.INFO("Step d");
- }
- Logger.INFO("Step 7");
-
- //Must have at least one energy hatch.
- if (this.mEnergyHatches != null) {
- for (int i = 0; i < this.mEnergyHatches.size(); i++) {
- if (this.mEnergyHatches.get(i).mTier < 2){
- Logger.INFO("You require at LEAST MV tier Energy Hatches.");
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
- return false;
- }
- }
- }
- //Must have at least one output hatch.
- if (this.mOutputHatches != null) {
- for (int i = 0; i < this.mOutputHatches.size(); i++) {
-
- if ((this.mOutputHatches.get(i).mTier < 2) && (this.mOutputHatches.get(i).getBaseMetaTileEntity() instanceof GregtechMTE_NuclearReactor)){
- Logger.INFO("You require at LEAST MV tier Output Hatches.");
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
- return false;
- }
- }
- }
- //Must have at least one input hatch.
- if (this.mInputHatches != null) {
- for (int i = 0; i < this.mInputHatches.size(); i++) {
- if (this.mInputHatches.get(i).mTier < 2){
- Logger.INFO("You require at LEAST MV tier Input Hatches.");
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
- return false;
- }
- }
- }
- this.mSolderingTool = true;
- //turnCasingActive(true);
- Logger.INFO("Multiblock Formed.");
- return true;
+ public boolean checkMachine(IGregTechTileEntity p0, ItemStack p1) {
+ // TODO Auto-generated method stub
+ return false;
}
@Override
- public int getMaxEfficiency(final ItemStack aStack) {
- return 10000;
+ public int getMaxEfficiency(ItemStack p0) {
+ // TODO Auto-generated method stub
+ return 0;
}
@Override
- public int getPollutionPerTick(final ItemStack aStack) {
+ public int getPollutionPerTick(ItemStack p0) {
+ // TODO Auto-generated method stub
return 0;
}
@Override
- public int getDamageToComponent(final ItemStack aStack) {
+ public int getDamageToComponent(ItemStack p0) {
+ // TODO Auto-generated method stub
return 0;
}
- public int getAmountOfOutputs() {
- return 1;
- }
-
@Override
- public boolean explodesOnComponentBreak(final ItemStack aStack) {
- return false;
- }
-
- public boolean addCasingToCasingList(final IGregTechTileEntity aTileEntity) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) {
- //return this.mCasings.add((GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity);
- }
+ public boolean explodesOnComponentBreak(ItemStack p0) {
+ // TODO Auto-generated method stub
return false;
}
- private GT_MetaTileEntity_TieredMachineBlock changeTextureswithReflection(final GT_MetaTileEntity_TieredMachineBlock casing, final ITexture[][][] textureSet){
- final GT_MetaTileEntity_TieredMachineBlock cv = casing;
- //System.out.println("Before: "+cv.mTextures.hashCode());
- //Get declared field from class
- Field f;
- try {
- final Field[] x = cv.getClass().getFields();
- for (int i =0; i<x.length;i++){
- //Utils.LOG_INFO(x[i].getName());
- }
- try {
- //Try get the field variable
- f = cv.getClass().getField("mTextures");
- // set the accessiblity of the field to true, this will enable you to change the value
- f.setAccessible(true);
- //change the field value
- f.set(cv, textureSet);
- //Verify change in texture set
- //System.out.println("After: "+cv.mTextures.hashCode());
- return cv;
- } catch (final NoSuchFieldException e) {
- Logger.INFO("Could not find mTextures.");
- return casing;
- }
- } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- return casing;
- }
- }
-
-
- public ITexture[][][] getTextureSet() {
- final ITexture[][][] rTextures = new ITexture[10][17][];
- for (byte i = -1; i < 16; i++) {
- rTextures[0][i + 1] = this.getFront(i);
- rTextures[1][i + 1] = this.getBack(i);
- rTextures[2][i + 1] = this.getBottom(i);
- rTextures[3][i + 1] = this.getTop(i);
- rTextures[4][i + 1] = this.getSides(i);
- rTextures[5][i + 1] = this.getFrontActive(i);
- rTextures[6][i + 1] = this.getBackActive(i);
- rTextures[7][i + 1] = this.getBottomActive(i);
- rTextures[8][i + 1] = this.getTopActive(i);
- rTextures[9][i + 1] = this.getSidesActive(i);
- }
- return rTextures;
- }
-
- public ITexture[] getFront(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getBack(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getBottom(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getTop(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getSides(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getFrontActive(final byte aColor) {
- return this.getFront(aColor);
- }
-
- public ITexture[] getBackActive(final byte aColor) {
- return this.getBack(aColor);
- }
-
- public ITexture[] getBottomActive(final byte aColor) {
- return this.getBottom(aColor);
- }
-
- public ITexture[] getTopActive(final byte aColor) {
- return this.getTop(aColor);
- }
-
- public ITexture[] getSidesActive(final byte aColor) {
- return this.getSides(aColor);
- }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java
index a6323726c3..f0123c2a08 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java
@@ -1,37 +1,39 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi;
import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.enums.TAE;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.*;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.players.FakeFarmer;
+import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL;
import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_TreeFarmer;
import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper;
+import net.minecraft.block.Block;
import net.minecraft.entity.player.*;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase {
public final static int TEX_INDEX = 31;
-
- /**
- * Farm AI
- */
-
- private EntityPlayerMP farmerAI;
+ protected boolean mIsCurrentlyWorking = false;
+
+
- public EntityPlayerMP getFakePlayer() {
- return this.farmerAI;
- }
-
public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -41,6 +43,10 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
super(aName);
}
+ public boolean isCurrentlyWorking() {
+ return this.mIsCurrentlyWorking;
+ }
+
@Override
public String[] getDescription() {
return new String[]{
@@ -66,9 +72,33 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
}
@Override
+ public boolean drainEnergyInput(final long aEU) {
+ if (aEU <= 0L) {
+ return true;
+ }
+
+ //Special Override, so that this function uses internally stored power first.
+ if (this.getEUVar() >= aEU) {
+ this.setEUVar(this.getEUVar()-aEU);
+ return true;
+ }
+
+ for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) {
+ if (isValidMetaTileEntity((MetaTileEntity) tHatch)
+ && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
+ if (aSide == 0) {
+ return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)};
+ }
if (aSide == 1) {
- return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(true ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)};
+ return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(isCurrentlyWorking() ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)};
}
return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)};
}
@@ -78,6 +108,18 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
return null;
}
+
+ @Override
+ public void loadNBTData(NBTTagCompound arg0) {
+ super.loadNBTData(arg0);
+ }
+
+
+ @Override
+ public void saveNBTData(NBTTagCompound arg0) {
+ super.saveNBTData(arg0);
+ }
+
@Override
public boolean isAccessAllowed(final EntityPlayer aPlayer) {
return true;
@@ -118,9 +160,18 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
return true;
}
- @Override
- public boolean onRunningTick(final ItemStack aStack) {
- return super.onRunningTick(aStack);
+ public Block getCasingBlock() {
+ return ModBlocks.blockCasings2Misc;
+ }
+
+
+ public byte getCasingMeta() {
+ return 15;
+ }
+
+
+ public byte getCasingTextureIndex() {
+ return (byte) TAE.GTPP_INDEX(31);
}
@Override
@@ -130,34 +181,201 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
@Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ String[] mSuper = super.getInfoData();
+ String[] mDesc = new String[mSuper.length+1];
+ mDesc[0] = "Yggdrasil"; // Machine name
+ for (int i=0;i<mSuper.length;i++) {
+ mDesc[i+1] = mSuper[i];
+ }
+ return mDesc;
+ };
+
+ @Override
public boolean explodesOnComponentBreak(ItemStack p0) {
return false;
}
+ @Override
+ public boolean onRunningTick(final ItemStack aStack) {
+ //Logger.INFO("s");
+
+ return super.onRunningTick(aStack);
+ }
@Override
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- //super.onPostTick(aBaseMetaTileEntity, aTick);
- if (aBaseMetaTileEntity.isServerSide()) {
- //Set Forestry Fake player Sapling Planter
- if (this.farmerAI == null) {
- this.farmerAI = new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(this.getBaseMetaTileEntity().getWorld().provider.dimensionId));
+ //Do Main Multi Logic first
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+
+ //Do Tree Farm logic next on server side, once per second
+ if (aBaseMetaTileEntity.isServerSide() && (aTick % 20 == 0)) {
+
+ //Simple Repairs for a simple machine
+ if (isCurrentlyWorking()) {
+ this.mSolderingTool = true;
+ }
+
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ if (this.mEnergyHatches.size() > 0) {
+ for (GT_MetaTileEntity_Hatch_Energy j : this.mEnergyHatches) {
+ //Logger.INFO(""+j.getInputTier());
+ if (this.getEUVar() <= (this.maxEUStore()-GT_Values.V[(int) j.getInputTier()])) {
+ this.setEUVar(this.getEUVar()+GT_Values.V[(int) j.getInputTier()]);
+ j.setEUVar(j.getEUVar()-GT_Values.V[(int) j.getInputTier()]);
+ }
+ else if (this.getEUVar() > (this.maxEUStore()-GT_Values.V[(int) j.getInputTier()])) {
+ long diff = (this.maxEUStore()-this.getEUVar());
+ this.setEUVar(this.getEUVar()+diff);
+ j.setEUVar(j.getEUVar()-diff);
+ }
+ }
+ }
}
-
+
+
+ //Try Work
+ if (this.drainEnergyInput(32)) {
+ BlockPos t;
+ if ((t = TreeFarmHelper.checkForLogsInGrowArea(this.getBaseMetaTileEntity())) != null) {
+ //Logger.INFO("Lets try find new logs/branches.");
+ TreeFarmHelper.findTreeFromBase(this.getBaseMetaTileEntity().getWorld(), t);
+ }
+ }
+
}
- //Client Side - do nothing
}
@Override
- public boolean checkRecipe(ItemStack p0) {
+ public boolean checkRecipe(ItemStack p0) {
+ mIsCurrentlyWorking = (isCorrectMachinePart(p0) && this.getEUVar() > 0);
+ if (isCurrentlyWorking()) {
+ return true;
+ }
return false;
}
@Override
- public boolean checkMachine(IGregTechTileEntity p0, ItemStack p1) {
- return false;
+ public boolean isCorrectMachinePart(final ItemStack aStack) {
+ boolean isValid = false;
+ final SAWTOOL currentInputItem = TreeFarmHelper.isCorrectMachinePart(aStack);
+ if (currentInputItem != SAWTOOL.NONE){
+ isValid = true;
+ }
+ return isValid;
+ }
+
+ @Override
+ public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) {
+ Logger.WARNING("Step 1");
+ 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++) {
+ Logger.WARNING("Step 2");
+ for (int j = -7; j <= 7; j++) {
+ Logger.WARNING("Step 3");
+ for (int h = 0; h <= 1; h++) {
+ Logger.WARNING("Step 4");
+ final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
+ //Farm Floor inner 14x14
+ if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) {
+ Logger.WARNING("Step 5 - H:"+h);
+ // Farm Dirt Floor and Inner Air/Log space.
+ if (h == 0) {
+ //Dirt Floor
+ if (!TreeFarmHelper.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
+ Logger.MACHINE_INFO("Dirt like block missing from inner 14x14.");
+ Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
+ return false;
+ }
+ }
+ }
+ //Dealt with inner 5x5, now deal with the exterior.
+ else {
+ Logger.WARNING("Step 6 - H:"+h);
+ //Deal with all 4 sides (Fenced area)
+ if (h == 1) {
+ if (!TreeFarmHelper.isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
+ Logger.MACHINE_INFO("Fence/Gate missing from outside the second layer.");
+ Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
+ return false;
+ }
+ }
+ //Deal with Bottom edges (Add Hatches/Busses first, othercheck make sure it's dirt) //TODO change the casings to not dirt~?
+ else if (h == 0) {
+ if (tTileEntity != null)
+ if ((!this.addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX)))) {
+ if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller
+
+ if (tTileEntity.getMetaTileID() != 752) {
+ Logger.MACHINE_INFO("Farm Keeper Casings Missing from one of the edges on the bottom edge. x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)+" | "+aBaseMetaTileEntity.getClass());
+ Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" "+tTileEntity.getMetaTileID());
+ return false;
+ }
+ Logger.WARNING("Found a farm keeper.");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //Must have at least one energy hatch.
+ if (this.mEnergyHatches != null) {
+ for (int i = 0; i < this.mEnergyHatches.size(); i++) {
+ if (this.mEnergyHatches.get(i).mTier < 1){
+ Logger.MACHINE_INFO("You require at LEAST MV tier Energy Hatches.");
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
+ return false;
+ }
+ }
+ }
+ //Must have at least one output hatch.
+ if (this.mOutputHatches != null) {
+ for (int i = 0; i < this.mOutputHatches.size(); i++) {
+
+ if (this.mOutputHatches.get(i).mTier < 1){
+ Logger.MACHINE_INFO("You require at LEAST MV tier Output Hatches.");
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
+ return false;
+ }
+ }
+ }
+ //Must have at least one input hatch.
+ if (this.mInputHatches != null) {
+ for (int i = 0; i < this.mInputHatches.size(); i++) {
+ if (this.mInputHatches.get(i).mTier < 1){
+ Logger.MACHINE_INFO("You require at LEAST MV tier Input Hatches.");
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
+ return false;
+ }
+ }
+ }
+ Logger.MACHINE_INFO("Multiblock Formed.");
+ return true;
+ }
+
+
+ @Override
+ public int getPollutionPerTick(ItemStack arg0) {
+ return 0;
+ }
+
+
+ @Override
+ public void onServerStart() {
+ super.onServerStart();
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java
index 76c6490480..4b93adad37 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java
@@ -137,7 +137,7 @@ extends GregtechMeta_MultiBlockBase {
}
}
}
- if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() < 0)) {
+ if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() != 0)) {
Logger.INFO("Use Busses, Not Hatches for Input/Output.");
return false;
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java
index 98dc3140bb..62279f0461 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java
@@ -17,10 +17,10 @@ import gregtech.api.util.FishPondFakeRecipe;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.recipe.common.CI;
-import gtPlusPlus.core.util.array.AutoMap;
import gtPlusPlus.core.util.fluid.FluidUtils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.math.MathUtils;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java
index a64057f3cc..f5cf674578 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java
@@ -24,15 +24,15 @@ import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.Recipe_GT;
-import gtPlusPlus.api.objects.GenericStack;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.Pair;
+import gtPlusPlus.api.objects.data.Triplet;
+import gtPlusPlus.api.objects.minecraft.GenericStack;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.recipe.common.CI;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.array.AutoMap;
-import gtPlusPlus.core.util.array.Pair;
-import gtPlusPlus.core.util.array.Triplet;
import gtPlusPlus.core.util.fluid.FluidUtils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.math.MathUtils;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java
index 7176db5d97..db6b1d9e6a 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java
@@ -14,9 +14,9 @@ import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.array.Pair;
import gtPlusPlus.core.util.fluid.FluidUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java
index c57ad71fc7..b36ba2f69e 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java
@@ -7,9 +7,9 @@ import java.util.Map;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.array.AutoMap;
import gtPlusPlus.core.util.materials.MaterialUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java
index 32fa282b0c..590296eee9 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java
@@ -4,12 +4,12 @@ import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_Recipe;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.material.MaterialStack;
import gtPlusPlus.core.material.state.MaterialState;
-import gtPlusPlus.core.util.array.AutoMap;
-import gtPlusPlus.core.util.array.Pair;
import gtPlusPlus.core.util.item.ItemUtils;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java
index bdcb30f930..d7fb58366b 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java
@@ -5,14 +5,14 @@ import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Recipe;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.ELEMENT;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.material.MaterialStack;
import gtPlusPlus.core.material.state.MaterialState;
import gtPlusPlus.core.recipe.common.CI;
-import gtPlusPlus.core.util.array.AutoMap;
-import gtPlusPlus.core.util.array.Pair;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.recipe.RecipeUtils;
import net.minecraft.item.ItemStack;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java
index 98fb6050d4..00feb26ca5 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java
@@ -11,10 +11,11 @@ import gregtech.api.enums.GT_Values;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.*;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.material.state.MaterialState;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.array.Pair;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
import net.minecraft.item.ItemStack;
@@ -22,6 +23,16 @@ import net.minecraftforge.oredict.OreDictionary;
public class RecipeGen_Recycling implements Runnable {
+ public static AutoMap<Runnable> mQueuedRecyclingGenerators = new AutoMap<Runnable>();
+
+ public static void executeGenerators() {
+ if (mQueuedRecyclingGenerators.size() > 0) {
+ for (Runnable R : mQueuedRecyclingGenerators.values()) {
+ R.run();
+ }
+ }
+ }
+
final Material toGenerate;
public static Map<String, ItemStack> mNameMap;
@@ -30,14 +41,14 @@ public class RecipeGen_Recycling implements Runnable {
if (mNameMap == null){
mNameMap = this.getNameMap();
}
- if (mNameMap != null){
- generateRecipes(this.toGenerate);
- }
+ mQueuedRecyclingGenerators.put(this);
}
@Override
public void run() {
-
+ if (mNameMap != null){
+ generateRecipes(this.toGenerate);
+ }
}
public static void generateRecipes(final Material material) {