aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r--src/main/java/gregtech/api/GregTech_API.java23
-rw-r--r--src/main/java/gregtech/api/enums/GT_Values.java13
-rw-r--r--src/main/java/gregtech/api/enums/HeatingCoilLevel.java69
-rw-r--r--src/main/java/gregtech/api/enums/ItemList.java57
-rw-r--r--src/main/java/gregtech/api/enums/Materials.java2
-rw-r--r--src/main/java/gregtech/api/enums/Textures.java18
-rw-r--r--src/main/java/gregtech/api/interfaces/IHeatingCoil.java18
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java7
-rw-r--r--src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java109
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java104
-rw-r--r--src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java4
-rw-r--r--src/main/java/gregtech/api/metatileentity/MetaTileEntity.java27
-rw-r--r--src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java2
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java14
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java14
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java21
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java100
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java8
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java8
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java4
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java103
-rw-r--r--src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java10
-rw-r--r--src/main/java/gregtech/api/objects/GT_RenderedTexture.java99
-rw-r--r--src/main/java/gregtech/api/objects/GT_SidedTexture.java75
-rw-r--r--src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java41
-rw-r--r--src/main/java/gregtech/api/objects/ReverseShapedRecipe.java43
-rw-r--r--src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java43
-rw-r--r--src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java140
-rw-r--r--src/main/java/gregtech/api/util/GT_LanguageManager.java8
-rw-r--r--src/main/java/gregtech/api/util/GT_ModHandler.java391
-rw-r--r--src/main/java/gregtech/api/util/GT_OreDictUnificator.java50
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java2
-rw-r--r--src/main/java/gregtech/api/util/GT_Shaped_Recipe.java25
-rw-r--r--src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java36
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java419
35 files changed, 1543 insertions, 564 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java
index 932d267a34..0fbb1cd745 100644
--- a/src/main/java/gregtech/api/GregTech_API.java
+++ b/src/main/java/gregtech/api/GregTech_API.java
@@ -25,6 +25,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
@@ -89,8 +90,16 @@ public class GregTech_API {
* 9728 - 10239 are reserved for 28Smiles.
* 10240 - 10751 are reserved for VirMan.
* 10752 - 11263 are reserved for Briareos81.
- * 11264 - 12000 are reserved for the next one who asks me.
- * 9728 - 32766 are currently free.
+ * 11264 - 12000 are reserved for Quantum64.
+ * 12001 - 12500 are reserved for RedMage17.
+ * 12501 - 13000 are reserved for bartimaeusnek.
+ * 13001 - 13100 are reserved for Techlone
+ * 13101 - 13500 are reserved for kekzdealer
+ * 13501 - 14999 are currently free.
+ * 15000 - 16999 are reserved for TecTech.
+ * 17000 - 29999 are currently free.
+ * 30000 - 31999 are reserved for Alkalus.
+ * 32001 - 32766 are currently free.
* <p/>
* Contact me if you need a free ID-Range, which doesn't conflict with other Addons.
* You could make an ID-Config, but we all know, what "stupid" customers think about conflicting ID's
@@ -212,7 +221,6 @@ public class GregTech_API {
sRecipeFile = null,
sMachineFile = null,
sWorldgenFile = null,
- sModularArmor = null,
sMaterialProperties = null,
sMaterialComponents = null,
sUnification = null,
@@ -257,6 +265,8 @@ public class GregTech_API {
sBlockCasings5,
sBlockCasings6,
sBlockCasings8;
+ public static Block
+ sBlockLongDistancePipes;
/**
* Getting assigned by the Config
*/
@@ -285,7 +295,8 @@ public class GregTech_API {
mGTPlusPlus = false,
mTranslocator = false,
mTConstruct = false,
- mGalacticraft = false;
+ mGalacticraft = false,
+ mAE2 = false;
public static int
mEUtoRF = 360,
mRFtoEU = 20;
@@ -389,8 +400,8 @@ public class GregTech_API {
* @param aZ is the Z-Coord of the update causing Block
*/
public static boolean causeMachineUpdate(World aWorld, int aX, int aY, int aZ) {
- if (aWorld != null && !aWorld.isRemote) { //World might be null during Worldgen
- GT_Runnable_MachineBlockUpdate.setMachineUpdateValues(aWorld, aX, aY, aZ);
+ if (aWorld != null && !aWorld.isRemote) { // World might be null during Worldgen
+ GT_Runnable_MachineBlockUpdate.setMachineUpdateValues(aWorld, new ChunkCoordinates(aX, aY, aZ));
return true;
}
return false;
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java
index 66b2e8a08f..d2b391edcb 100644
--- a/src/main/java/gregtech/api/enums/GT_Values.java
+++ b/src/main/java/gregtech/api/enums/GT_Values.java
@@ -4,6 +4,7 @@ import gregtech.api.interfaces.internal.IGT_Mod;
import gregtech.api.interfaces.internal.IGT_RecipeAdder;
import gregtech.api.net.IGT_NetworkHandler;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
@@ -126,6 +127,16 @@ public class GT_Values {
"Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage",
"Ultimate Mega Voltage", "Ultimate Extended Mega Voltage", "Overpowered Voltage",
"Maximum Voltage"};
+
+ public static final String[] TIER_COLORS =
+ new String[]{
+ EnumChatFormatting.RED.toString(), EnumChatFormatting.GRAY.toString(), EnumChatFormatting.AQUA.toString(),
+ EnumChatFormatting.GOLD.toString(), EnumChatFormatting.DARK_PURPLE.toString(), EnumChatFormatting.DARK_BLUE.toString(),
+ EnumChatFormatting.LIGHT_PURPLE.toString(), EnumChatFormatting.WHITE.toString(), EnumChatFormatting.DARK_AQUA.toString(),
+ EnumChatFormatting.DARK_RED.toString(), EnumChatFormatting.GREEN.toString(), EnumChatFormatting.DARK_GREEN.toString(),
+ EnumChatFormatting.YELLOW.toString(), EnumChatFormatting.UNDERLINE.toString(), EnumChatFormatting.BOLD.toString(),
+ EnumChatFormatting.OBFUSCATED.toString()};
+
/**
* This way it is possible to have a Call Hierarchy of NullPointers in ItemStack based Functions, and also because most of the time I don't know what kind of Data Type the "null" stands for
*/
@@ -287,4 +298,6 @@ public class GT_Values {
public static boolean debugChunkloaders = false;
public static boolean cls_enabled;
+
+ public static boolean hideAssLineRecipes = false;
}
diff --git a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java
new file mode 100644
index 0000000000..f4b28ede2b
--- /dev/null
+++ b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java
@@ -0,0 +1,69 @@
+package gregtech.api.enums;
+
+import net.minecraft.util.EnumChatFormatting;
+
+public enum HeatingCoilLevel {
+ None, // 0
+ ULV, //Not implemented 901
+ LV, //Cupronickel 1801
+ MV, //KANTHAL 2701
+ HV, //NICHROME 3601
+ EV, //TUNGSTENSTEEL 4501
+ IV, //HSSG 5401
+ LuV, //HSSS 6301
+ ZPM, //NAQUADAH 7201
+ UV, //NAQUADAHALLOY 8101
+ UHV, //TRINIUM 9001
+ UEV, //ELECTRUMFLUX 9901
+ UIV, //AWAKENEDDRACONIUM 10801
+ //Not Implemented yet
+ UMV,
+ UXV,
+ OpV,
+ MAX,
+ ;
+
+ /**
+ * @return the Coils Tier Name
+ */
+ public String getTierName() {
+ if (this.ordinal() < 1 || (this.ordinal()-1) >= GT_Values.VN.length)
+ return "ERROR!";
+ return GT_Values.TIER_COLORS[this.ordinal() - 1] + GT_Values.VOLTAGE_NAMES[this.ordinal() - 1] + EnumChatFormatting.RESET;
+ }
+
+ /**
+ * @return the coil heat, used for recipes in the Electronic Blast Furnace for example
+ */
+ public long getHeat() {
+ return this == None ? 0 : 1L + (900L * this.ordinal());
+ }
+
+ /**
+ * @return the coil tier, used for discount in the Pyrolyse Ofen for example
+ */
+ public byte getTier() {
+ return (byte) (this.ordinal() - 2);
+ }
+
+ /**
+ * @return the coil Level, used for Parallels in the Multi Furnace for example
+ */
+ public byte getLevel() {
+ return (byte) Math.min(16, 2 << (this.ordinal() - 2));
+ }
+
+ /**
+ * @return the coil Discount, used for discount in the Multi Furnace for example
+ */
+ public byte getCostDiscount() {
+ return (byte) Math.max(1, 2 << (this.ordinal() - 1 - 6)); //-1 bcs. of none, -4 = offset
+ }
+
+ public static HeatingCoilLevel getFromTier(byte tier){
+ if (tier < 0 || tier > HeatingCoilLevel.values().length -1)
+ return HeatingCoilLevel.None;
+
+ return HeatingCoilLevel.values()[tier+2];
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java
index 8830ab50a5..5d6de01493 100644
--- a/src/main/java/gregtech/api/enums/ItemList.java
+++ b/src/main/java/gregtech/api/enums/ItemList.java
@@ -1,6 +1,7 @@
package gregtech.api.enums;
import gregtech.api.interfaces.IItemContainer;
+import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
@@ -9,6 +10,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
+import java.util.Locale;
+
+import static gregtech.api.enums.GT_Values.NI;
import static gregtech.api.enums.GT_Values.W;
/**
@@ -401,6 +405,12 @@ public enum ItemList implements IItemContainer {
Electric_Pump_UHV,
Electric_Pump_UEV,
+ Steam_Valve_LV,
+ Steam_Valve_MV,
+ Steam_Valve_HV,
+ Steam_Valve_EV,
+ Steam_Valve_IV,
+
Conveyor_Module_LV,
Conveyor_Module_MV,
Conveyor_Module_HV,
@@ -1215,9 +1225,6 @@ public enum ItemList implements IItemContainer {
Machine_HV_Massfab,
Machine_EV_Massfab,
Machine_IV_Massfab,
- Machine_LuV_Massfab,
- Machine_ZPM_Massfab,
- Machine_UV_Massfab,
Machine_LV_Amplifab,
Machine_MV_Amplifab,
@@ -1395,6 +1402,14 @@ public enum ItemList implements IItemContainer {
Super_Chest_HV,
Super_Chest_EV,
Super_Chest_IV,
+
+ Long_Distance_Pipeline_Fluid,
+ Long_Distance_Pipeline_Item,
+
+ Long_Distance_Pipeline_Fluid_Pipe,
+ Long_Distance_Pipeline_Item_Pipe,
+
+ Hatch_Output_Bus_ME,
NULL,
Cover_RedstoneTransmitterExternal,
@@ -1434,7 +1449,9 @@ public enum ItemList implements IItemContainer {
Casing_Coil_Nichrome,
Casing_Coil_TungstenSteel,
Casing_Coil_HSSG,
+ Casing_Coil_HSSS,
Casing_Coil_Naquadah,
+ Casing_Coil_Trinium,
Casing_Coil_NaquadahAlloy,
Casing_Coil_ElectrumFlux,
Casing_Coil_AwakenedDraconium,
@@ -1542,20 +1559,6 @@ public enum ItemList implements IItemContainer {
Moxcell_2,
Moxcell_4,
- ModularBasicHelmet,
- ModularBasicChestplate,
- ModularBasicLeggings,
- ModularBasicBoots,
-
- ModularElectric1Helmet,
- ModularElectric1Chestplate,
- ModularElectric1Leggings,
- ModularElectric1Boots,
-
- ModularElectric2Helmet,
- ModularElectric2Chestplate,
- ModularElectric2Leggings,
- ModularElectric2Boots,
Block_Powderbarrel,
GelledToluene,
@@ -2010,8 +2013,24 @@ public enum ItemList implements IItemContainer {
public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) {
ItemStack rStack = get(1, aReplacements);
if (GT_Utility.isStackInvalid(rStack))
- return null;
- rStack.setStackDisplayName(aDisplayName);
+ return NI;
+
+ // CamelCase alphanumeric words from aDisplayName
+ StringBuilder tCamelCasedDisplayNameBuilder = new StringBuilder();
+ final String[] tDisplayNameWords = aDisplayName.split("\\W");
+ for (String tWord : tDisplayNameWords){
+ if (tWord.length() > 0) tCamelCasedDisplayNameBuilder.append(tWord.substring(0, 1).toUpperCase(Locale.US));
+ if (tWord.length() > 1) tCamelCasedDisplayNameBuilder.append(tWord.substring(1).toLowerCase(Locale.US));
+ }
+ if (tCamelCasedDisplayNameBuilder.length() == 0) {
+ // CamelCased DisplayName is empty, so use hash of aDisplayName
+ tCamelCasedDisplayNameBuilder.append(((Long) (long)aDisplayName.hashCode()).toString());
+ }
+
+ // Construct a translation key from UnlocalizedName and CamelCased DisplayName
+ final String tKey = rStack.getUnlocalizedName() + ".with." + tCamelCasedDisplayNameBuilder.toString() + ".name";
+
+ rStack.setStackDisplayName(GT_LanguageManager.addStringLocalization(tKey, aDisplayName));
return GT_Utility.copyAmount(aAmount, rStack);
}
diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java
index b46d26e02d..d00c3bd8fc 100644
--- a/src/main/java/gregtech/api/enums/Materials.java
+++ b/src/main/java/gregtech/api/enums/Materials.java
@@ -649,7 +649,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials Cryotheum = new Materials( 898, TextureSet.SET_SHINY , 1.0F, 0, 1, 1 , 0, 148, 203, 0, "Cryotheum" , "Cryotheum" , 2, 62, -1, 0, false, false, 2, 3, 1, Dyes.dyeLightBlue , 2, Arrays.asList(new MaterialStack(Saltpeter, 1), new MaterialStack(Redstone, 1), new MaterialStack(Snow, 1), new MaterialStack(Blizz, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.PRAECANTATIO, 2), new TC_AspectStack(TC_Aspects.ELECTRUM, 1), new TC_AspectStack(TC_Aspects.GELUM, 1)));
public static Materials HydratedCoal = new Materials( 818, TextureSet.SET_ROUGH , 1.0F, 0, 1, 1 , 70, 70, 100, 0, "HydratedCoal" , "Hydrated Coal" , 0, 0, -1, 0, false, false, 1, 9, 8, Dyes.dyeBlack , 2, Arrays.asList(new MaterialStack(Coal, 8), new MaterialStack(Water, 1)));
public static Materials Apatite = new Materials( 530, TextureSet.SET_DIAMOND , 1.0F, 0, 1, 1 |4|8 , 200, 200, 255, 0, "Apatite" , "Apatite" , 0, 0, -1, 0, false, false, 2, 1, 1, Dyes.dyeCyan , 1, Arrays.asList(new MaterialStack(Calcium, 5), new MaterialStack(Phosphate, 3), new MaterialStack(Chlorine, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.MESSIS, 2)));
- public static Materials Alumite = new Materials( 400, TextureSet.SET_METALLIC , 5.0F, 768, 2, 1|2 |128 , 255, 105, 180, 0, "Alumite" , "Alumite" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyePink , 2, Arrays.asList(new MaterialStack(Aluminium, 5), new MaterialStack(Steel, 2), new MaterialStack(Obsidian, 2)), Arrays.asList(new TC_AspectStack(TC_Aspects.STRONTIO, 2)));
+ public static Materials Alumite = new Materials( 400, TextureSet.SET_METALLIC , 5.0F, 768, 2, 1|2 |64|128 , 255, 105, 180, 0, "Alumite" , "Alumite" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyePink , 2, Arrays.asList(new MaterialStack(Aluminium, 5), new MaterialStack(Steel, 2), new MaterialStack(Obsidian, 2)), Arrays.asList(new TC_AspectStack(TC_Aspects.STRONTIO, 2)));
public static Materials Manyullyn = new Materials( 386, TextureSet.SET_SHINY , 25.0F, 2048, 5, 1|2 |8 |64|128 , 154, 76, 185, 0, "Manyullyn" , "Manyullyn" , 0, 0, 3600, 3600, true, false, 1, 1, 1, Dyes.dyePurple , 2, Arrays.asList(new MaterialStack(Cobalt, 1), new MaterialStack(Ardite, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.STRONTIO, 2))).disableAutoGeneratedBlastFurnaceRecipes();
public static Materials Steeleaf = new Materials( 339, TextureSet.SET_LEAF , 8.0F, 768, 3, 1|2 |64|128 , 50, 127, 50, 0, "Steeleaf" , "Steeleaf" , 5, 24, -1, 0, false, false, 4, 1, 1, Dyes.dyeGreen , 2, Arrays.asList(new MaterialStack(Steel, 1), new MaterialStack(Magic, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.HERBA, 2), new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.PRAECANTATIO, 1)));
public static Materials Knightmetal = new Materials( 362, TextureSet.SET_METALLIC , 8.0F, 1024, 3, 1|2 |64|128 , 210, 240, 200, 0, "Knightmetal" , "Knightmetal" , 5, 24, -1, 0, false, false, 4, 1, 1, Dyes.dyeLime , 2, Arrays.asList(new MaterialStack(Steel, 2), new MaterialStack(Magic, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.LUCRUM, 1), new TC_AspectStack(TC_Aspects.METALLUM, 2)));
diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java
index 22dfc810d2..3a9af71aa2 100644
--- a/src/main/java/gregtech/api/enums/Textures.java
+++ b/src/main/java/gregtech/api/enums/Textures.java
@@ -45,6 +45,17 @@ public class Textures {
OVERLAY_SCHEST,
OVERLAY_STANK,
+
+ OVERLAY_PIPELINE_FLUID_BACK,
+ OVERLAY_PIPELINE_FLUID_FRONT,
+ OVERLAY_PIPELINE_FLUID_SIDE,
+
+ OVERLAY_PIPELINE_ITEM_BACK,
+ OVERLAY_PIPELINE_ITEM_FRONT,
+ OVERLAY_PIPELINE_ITEM_SIDE,
+
+ LONG_DISTANCE_PIPE_FLUID,
+ LONG_DISTANCE_PIPE_ITEM,
MACHINE_CASING_TANK_1,
MACHINE_CASING_TANK_2,
@@ -284,6 +295,8 @@ public class Textures {
MACHINE_COIL_NAQUADAHALLOY,
MACHINE_COIL_ELECTRUMFLUX,
MACHINE_COIL_AWAKENEDDRACONIUM,
+ MACHINE_COIL_HSSS,
+ MACHINE_COIL_TRINIUM,
BOILER_SOLAR,
BOILER_FRONT,
@@ -399,6 +412,7 @@ public class Textures {
OVERLAY_DATA_ACCESS,
OVERLAY_CONVEYOR,
OVERLAY_PUMP,
+ OVERLAY_VALVE,
OVERLAY_ARM,
OVERLAY_DRAIN,
OVERLAY_CRAFTING,
@@ -890,7 +904,9 @@ public class Textures {
PIPE_RESTRICTOR_UR,
PIPE_RESTRICTOR_DL,
PIPE_RESTRICTOR_DR,
- PIPE_RESTRICTOR_LR;
+ PIPE_RESTRICTOR_LR,
+
+ OVERLAY_ME_HATCH;
/**
* Icon for Fresh CFoam
diff --git a/src/main/java/gregtech/api/interfaces/IHeatingCoil.java b/src/main/java/gregtech/api/interfaces/IHeatingCoil.java
new file mode 100644
index 0000000000..c8ceccf941
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/IHeatingCoil.java
@@ -0,0 +1,18 @@
+package gregtech.api.interfaces;
+
+import gregtech.api.enums.HeatingCoilLevel;
+import net.minecraft.item.ItemStack;
+
+import java.util.function.Consumer;
+
+public interface IHeatingCoil {
+
+ HeatingCoilLevel getCoilHeat(int meta);
+ default HeatingCoilLevel getCoilHeat(ItemStack stack) {
+ return getCoilHeat(stack.getItemDamage());
+ }
+
+ void setOnCoilCheck(Consumer<IHeatingCoil> callback);
+ Consumer<IHeatingCoil> getOnCoilCheck();
+}
+
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
index 8e135fbc85..9ab1ac0f67 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
@@ -141,8 +141,7 @@ public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTil
*/
@Override
default void onMachineBlockUpdate(){
- if(!isDead() && getMetaTileEntity()!=null &&
- getMetaTileEntity().getBaseMetaTileEntity()==this){
+ if(!isDead() && getMetaTileEntity() != null && getMetaTileEntity().getBaseMetaTileEntity() == this){
getMetaTileEntity().onMachineBlockUpdate();
}
}
@@ -152,8 +151,8 @@ public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTil
*/
@Override
default boolean isMachineBlockUpdateRecursive() {
- return !isDead() && getMetaTileEntity()!=null &&
- getMetaTileEntity().getBaseMetaTileEntity()==this &&
+ return !isDead() && getMetaTileEntity() != null &&
+ getMetaTileEntity().getBaseMetaTileEntity() == this &&
getMetaTileEntity().isMachineBlockUpdateRecursive();
}
} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java
new file mode 100644
index 0000000000..734eae19f4
--- /dev/null
+++ b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java
@@ -0,0 +1,109 @@
+package gregtech.api.items;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.common.blocks.GT_Item_LongDistancePipe;
+import gregtech.common.blocks.GT_Material_Machines;
+import net.minecraft.block.Block;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+import java.util.List;
+import java.util.Random;
+
+public class GT_Block_LongDistancePipe extends GT_Generic_Block {
+ public IIconContainer[] mIcons;
+ public GT_Block_LongDistancePipe() {
+ super(GT_Item_LongDistancePipe.class, "gt.block.longdistancepipe", new GT_Material_Machines());
+ setStepSound(soundTypeMetal);
+ setCreativeTab(GregTech_API.TAB_GREGTECH);
+ GregTech_API.registerMachineBlock(this, -1);
+
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName()+".0.name", "Long Distance Fluid Pipeline Pipe");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName()+".1.name", "Long Distance Item Pipeline Pipe");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this");
+
+ ItemList.Long_Distance_Pipeline_Fluid_Pipe.set(new ItemStack(this, 1, 0));
+ ItemList.Long_Distance_Pipeline_Item_Pipe.set(new ItemStack(this, 1, 1));
+ mIcons = new IIconContainer[]{Textures.BlockIcons.LONG_DISTANCE_PIPE_FLUID, Textures.BlockIcons.LONG_DISTANCE_PIPE_ITEM};
+ }
+ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
+ super.onBlockAdded(aWorld, aX, aY, aZ);
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ super.breakBlock(aWorld, aX, aY, aZ, par5, par6);
+ }
+ public String getHarvestTool(int aMeta) {
+ return "wrench";
+ }
+
+ public int getHarvestLevel(int aMeta) {
+ return 2;
+ }
+
+ public float getBlockHardness(World aWorld, int aX, int aY, int aZ) {
+ return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ);
+ }
+
+ public float getExplosionResistance(Entity aTNT) {
+ return Blocks.iron_block.getExplosionResistance(aTNT);
+ }
+
+
+ public String getUnlocalizedName() {
+ return this.mUnlocalizedName;
+ }
+
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal(this.mUnlocalizedName + ".name");
+ }
+
+ public IIcon getIcon(int aSide, int aMeta) {
+ return mIcons[aMeta % mIcons.length].getIcon();
+ }
+
+ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+ public int quantityDropped(Random par1Random) {
+ return 1;
+ }
+
+ public Item getItemDropped(int par1, Random par2Random, int par3) {
+ return Item.getItemFromBlock(this);
+ }
+
+ public int damageDropped(int par1) {
+ return par1;
+ }
+
+ public int getDamageValue(World par1World, int par2, int par3, int par4) {
+ return par1World.getBlockMetadata(par2, par3, par4);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) {
+ for (int i = 0; i < 3; i++) {
+ ItemStack aStack = new ItemStack(aItem, 1, i);
+ if (!aStack.getDisplayName().contains(".name")) aList.add(aStack);
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index cfb34eb34e..9fd8e75754 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -1,5 +1,15 @@
package gregtech.api.metatileentity;
+import appeng.api.networking.IGridNode;
+import appeng.api.networking.security.IActionHost;
+import appeng.api.util.AECableType;
+import appeng.api.util.DimensionalCoord;
+import appeng.me.helpers.AENetworkProxy;
+import appeng.me.helpers.IGridProxyable;
+import appeng.tile.TileEvent;
+import appeng.tile.events.TileEventType;
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.Optional;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
@@ -51,7 +61,10 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
* <p/>
* This is the main TileEntity for EVERYTHING.
*/
-public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity {
+@Optional.InterfaceList(value = {
+ @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true),
+ @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)})
+public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable {
private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior};
protected MetaTileEntity mMetaTileEntity;
protected long mStoredEnergy = 0, mStoredSteam = 0;
@@ -843,8 +856,16 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (isValidFacing(aFacing)) {
mFacing = aFacing;
mMetaTileEntity.onFacingChange();
- onMachineBlockUpdate();
+
doEnetUpdate();
+
+ if (mMetaTileEntity.shouldTriggerBlockUpdate()) {
+ // If we're triggering a block update this will call onMachineBlockUpdate()
+ GregTech_API.causeMachineUpdate(worldObj, xCoord, yCoord, zCoord);
+ } else {
+ // If we're not trigger a cascading one, call the update here.
+ onMachineBlockUpdate();
+ }
}
}
@@ -910,11 +931,15 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mMetaTileEntity.setBaseMetaTileEntity(null);
}
super.invalidate();
+ if (GregTech_API.mAE2)
+ invalidateAE();
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
+ if (GregTech_API.mAE2)
+ onChunkUnloadAE();
}
@Override
@@ -2202,5 +2227,78 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
return slotIndex + indexShift;
}
-}
+ @Override
+ @Optional.Method(modid = "appliedenergistics2")
+ public IGridNode getGridNode(ForgeDirection forgeDirection) {
+ if (mFacing != forgeDirection.ordinal())
+ return null;
+ AENetworkProxy gp = getProxy();
+ return gp != null ? gp.getNode() : null;
+ }
+
+ @Override
+ @Optional.Method(modid = "appliedenergistics2")
+ public AECableType getCableConnectionType(ForgeDirection forgeDirection) {
+ return mMetaTileEntity == null ? AECableType.NONE : mMetaTileEntity.getCableConnectionType(forgeDirection);
+ }
+
+ @Override
+ @Optional.Method(modid = "appliedenergistics2")
+ public void securityBreak() {}
+
+ @Override
+ @Optional.Method(modid = "appliedenergistics2")
+ public IGridNode getActionableNode() {
+ AENetworkProxy gp = getProxy();
+ return gp != null ? gp.getNode() : null;
+ }
+
+ @Override
+ @Optional.Method(modid = "appliedenergistics2")
+ public AENetworkProxy getProxy() {
+ return mMetaTileEntity == null ? null : mMetaTileEntity.getProxy();
+ }
+
+ @Override
+ @Optional.Method(modid = "appliedenergistics2")
+ public DimensionalCoord getLocation() { return new DimensionalCoord( this ); }
+
+ @Override
+ @Optional.Method(modid = "appliedenergistics2")
+ public void gridChanged() {
+ if (mMetaTileEntity != null)
+ mMetaTileEntity.gridChanged();
+ }
+
+ @TileEvent( TileEventType.WORLD_NBT_READ )
+ @Optional.Method(modid = "appliedenergistics2")
+ public void readFromNBT_AENetwork( final NBTTagCompound data )
+ {
+ AENetworkProxy gp = getProxy();
+ if (gp != null)
+ getProxy().readFromNBT( data );
+ }
+
+ @TileEvent( TileEventType.WORLD_NBT_WRITE )
+ @Optional.Method(modid = "appliedenergistics2")
+ public void writeToNBT_AENetwork( final NBTTagCompound data )
+ {
+ AENetworkProxy gp = getProxy();
+ if (gp != null)
+ gp.writeToNBT( data );
+ }
+ @Optional.Method(modid = "appliedenergistics2")
+ void onChunkUnloadAE() {
+ AENetworkProxy gp = getProxy();
+ if (gp != null)
+ gp.onChunkUnload();
+ }
+
+ @Optional.Method(modid = "appliedenergistics2")
+ void invalidateAE() {
+ AENetworkProxy gp = getProxy();
+ if (gp != null)
+ gp.invalidate();
+ }
+}
diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
index 9fa16b9890..31ec73d04b 100644
--- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
@@ -130,6 +130,10 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable {
*/
public abstract boolean renderInside(byte aSide);
+ public boolean isDisplaySecondaryDescription() {
+ return false;
+ }
+
@Override
public IGregTechTileEntity getBaseMetaTileEntity() {
return mBaseMetaTileEntity;
diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
index d08a8d9da5..79447a96cb 100644
--- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
@@ -1,5 +1,9 @@
package gregtech.api.metatileentity;
+import appeng.api.util.AECableType;
+import appeng.me.helpers.AENetworkProxy;
+import appeng.me.helpers.IGridProxyable;
+import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
@@ -95,6 +99,14 @@ public abstract class MetaTileEntity implements IMetaTileEntity {
mName = aName;
}
+ /**
+ * This method will only be called on client side
+ * @return whether the secondary description should be display. default is false
+ */
+ public boolean isDisplaySecondaryDescription() {
+ return false;
+ }
+
@Override
public IGregTechTileEntity getBaseMetaTileEntity() {
return mBaseMetaTileEntity;
@@ -933,4 +945,19 @@ public abstract class MetaTileEntity implements IMetaTileEntity {
}
public boolean shouldJoinIc2Enet() { return false; }
+
+ public boolean shouldTriggerBlockUpdate() { return false; }
+
+ @Optional.Method(modid = "appliedenergistics2")
+ public AECableType getCableConnectionType(ForgeDirection forgeDirection) {
+ return AECableType.NONE;
+ }
+
+ @Optional.Method(modid = "appliedenergistics2")
+ public AENetworkProxy getProxy() {
+ return null;
+ }
+
+ @Optional.Method(modid = "appliedenergistics2")
+ public void gridChanged() {}
}
diff --git a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java
index 4d54a142cd..d0f3074af1 100644
--- a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java
+++ b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java
@@ -44,7 +44,7 @@ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null;
+ return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (mDisableFilter || GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null);
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
index 2afc996df2..e472305a36 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
@@ -111,7 +111,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
if (aSide >= 0 && aSide < 6) {
for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i;
//Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate
- if (aSide == 5 || aSide == 2 || aSide == 0)
+ if (aSide == 5 || aSide == 2)
if (tMask > 3 && tMask < 12)
tMask = (byte) (tMask ^ 12);
}
@@ -675,4 +675,16 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
}
}
+ @Override
+ public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
+ if (aFluid == null)
+ return null;
+ for (int i = 0; i < mFluids.length; ++i) {
+ final FluidStack f = mFluids[i];
+ if (f == null || !f.isFluidEqual(aFluid))
+ continue;
+ return drainFromIndex(aFluid.amount, doDrain, i);
+ }
+ return null;
+ }
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
index c73e95e95b..6ed5a9edd0 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
@@ -38,6 +38,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
public int mTransferredItems = 0;
public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0;
public boolean mIsRestrictive = false;
+ private int[] cacheSides;
public GT_MetaPipeEntity_Item(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aInvSlotCount, int aStepSize, boolean aIsRestrictive, int aTickTime) {
super(aID, aName, aNameRegional, aInvSlotCount, false);
@@ -313,6 +314,19 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
}
@Override
+ public int[] getAccessibleSlotsFromSide(int aSide) {
+ IGregTechTileEntity tTileEntity = getBaseMetaTileEntity();
+ boolean tAllow = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity);
+ if (tAllow) {
+ if (cacheSides == null)
+ cacheSides = super.getAccessibleSlotsFromSide(aSide);
+ return cacheSides;
+ } else {
+ return new int[0];
+ }
+ }
+
+ @Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return isConnectedAtSide(aSide);
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
index 2c632c596b..fa653df16f 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
@@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
@@ -53,6 +54,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
public final ItemStack[] mOutputItems;
public final int mInputSlotCount, mAmperage;
public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false;
+ public boolean mDisableFilter = true;
public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0;
public FluidStack mOutputFluid;
public String mGUIName, mNEIName;
@@ -418,6 +420,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
aNBT.setBoolean("mItemTransfer", mItemTransfer);
aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated);
aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide);
+ aNBT.setBoolean("mDisableFilter", mDisableFilter);
aNBT.setInteger("mEUt", mEUt);
aNBT.setInteger("mMainFacing", mMainFacing);
aNBT.setInteger("mProgresstime", mProgresstime);
@@ -437,6 +440,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mItemTransfer = aNBT.getBoolean("mItemTransfer");
mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated");
mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide");
+ mDisableFilter = aNBT.getBoolean("mDisableFilter");
mEUt = aNBT.getInteger("mEUt");
mMainFacing = aNBT.getInteger("mMainFacing");
mProgresstime = aNBT.getInteger("mProgresstime");
@@ -516,8 +520,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
if (tMaxStacks > mOutputItems.length)
tMaxStacks = mOutputItems.length;
- int tCost = moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks);
- aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCost, true);
+ moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks);
// for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) {
// tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
// if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true);
@@ -792,8 +795,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
@Override
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) {
- mAllowInputFromOutputSide = !mAllowInputFromOutputSide;
- GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? trans("095","Input from Output Side allowed") : trans("096","Input from Output Side forbidden"));
+ if (aPlayer.isSneaking()){
+ mDisableFilter = !mDisableFilter;
+ GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter." + mDisableFilter));
+ } else {
+ mAllowInputFromOutputSide = !mAllowInputFromOutputSide;
+ GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? trans("095", "Input from Output Side allowed") : trans("096", "Input from Output Side forbidden"));
+ }
}
}
@@ -811,11 +819,16 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing()))
return false;
+ if (mDisableFilter) return true;
for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++)
if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex;
return true;
}
+ protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return true;
+ }
+
/**
* @return the Recipe List which is used for this Machine, this is a useful Default Handler
*/
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
index 17dbd560a2..147973b183 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
@@ -1,7 +1,11 @@
package gregtech.api.metatileentity.implementations;
import cpw.mods.fml.common.Loader;
-import gregtech.api.enums.*;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.Textures;
+import gregtech.api.enums.Tier;
import gregtech.api.gui.GT_Container_BasicMachine;
import gregtech.api.gui.GT_GUIContainer_BasicMachine;
import gregtech.api.interfaces.ITexture;
@@ -22,7 +26,10 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.Locale;
import java.util.Random;
-import static gregtech.api.enums.GT_Values.*;
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.enums.GT_Values.VN;
+import static gregtech.api.enums.GT_Values.W;
+import static gregtech.api.enums.GT_Values.ticksBetweenSounds;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -36,8 +43,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
private final String mSound;
private final boolean mSharedTank, mRequiresFluidForFiltering;
private final byte mGUIParameterA, mGUIParameterB;
- public GT_MetaTileEntity_BasicMachine_GT_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) {
- super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM")));
+
+ public GT_MetaTileEntity_BasicMachine_GT_Recipe(
+ int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes,
+ int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank,
+ boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe
+ ) {
+ super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName,
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")),
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")),
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")),
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")),
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")),
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")),
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")),
+ new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM")));
this.mSharedTank = aSharedTank;
this.mTankCapacity = aTankCapacity;
this.mSpecialEffect = aSpecialEffect;
@@ -657,13 +677,22 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
throw new IllegalArgumentException("MISSING TIER MAPPING FOR: " + aRecipe[i] + " AT TIER " + mTier);
}
- if (!GT_ModHandler.addCraftingRecipe(getStackForm(1), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, aRecipe)) {
+ if (
+ !GT_ModHandler.addCraftingRecipe(
+ getStackForm(1),
+ GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, aRecipe
+ )
+ ) {
throw new IllegalArgumentException("INVALID CRAFTING RECIPE FOR: " + getStackForm(1).getDisplayName());
}
}
}
- public GT_MetaTileEntity_BasicMachine_GT_Recipe(String aName, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) {
+ public GT_MetaTileEntity_BasicMachine_GT_Recipe(
+ String aName, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage,
+ int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank,
+ boolean aRequiresFluidForFiltering, int aSpecialEffect
+ ) {
super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName);
this.mSharedTank = aSharedTank;
this.mTankCapacity = aTankCapacity;
@@ -675,7 +704,11 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
this.mGUIParameterB = (byte) aGUIParameterB;
}
- public GT_MetaTileEntity_BasicMachine_GT_Recipe(String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) {
+ public GT_MetaTileEntity_BasicMachine_GT_Recipe(
+ String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage,
+ int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank,
+ boolean aRequiresFluidForFiltering, int aSpecialEffect
+ ) {
super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName);
this.mSharedTank = aSharedTank;
this.mTankCapacity = aTankCapacity;
@@ -689,7 +722,11 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
- return new GT_MetaTileEntity_BasicMachine_GT_Recipe(this.mName, this.mTier, this.mDescriptionArray, this.mRecipes, this.mInputSlotCount, this.mOutputItems == null ? 0 : this.mOutputItems.length, this.mTankCapacity, this.mAmperage, this.mGUIParameterA, this.mGUIParameterB, this.mTextures, this.mGUIName, this.mNEIName, this.mSound, this.mSharedTank, this.mRequiresFluidForFiltering, this.mSpecialEffect);
+ return new GT_MetaTileEntity_BasicMachine_GT_Recipe(
+ this.mName, this.mTier, this.mDescriptionArray, this.mRecipes, this.mInputSlotCount, this.mOutputItems == null ? 0 : this.mOutputItems.length,
+ this.mTankCapacity, this.mAmperage, this.mGUIParameterA, this.mGUIParameterB, this.mTextures, this.mGUIName, this.mNEIName, this.mSound,
+ this.mSharedTank, this.mRequiresFluidForFiltering, this.mSpecialEffect
+ );
}
@Override
@@ -699,23 +736,54 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName, GT_Utility.isStringValid(this.mNEIName) ? this.mNEIName : this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "", this.mGUIParameterA, this.mGUIParameterB);
+ return new GT_GUIContainer_BasicMachine(
+ aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName,
+ GT_Utility.isStringValid(this.mNEIName) ? this.mNEIName : this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "",
+ this.mGUIParameterA, this.mGUIParameterB
+ );
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false;
- if (this.mInventory[aIndex] != null) return true;
+ if (this.mInventory[aIndex] != null || mDisableFilter) return true;
switch (this.mInputSlotCount) {
case 0:
return false;
case 1:
- return this.getFillableStack() == null ? !this.mRequiresFluidForFiltering && this.getRecipeList().containsInput(aStack) : null != this.getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, this.getSpecialSlot(), new ItemStack[]{aStack});
+ if (this.getFillableStack() == null)
+ return !this.mRequiresFluidForFiltering && this.getRecipeList().containsInput(aStack);
+ else
+ return this.getRecipeList().findRecipe(
+ this.getBaseMetaTileEntity(), this.mLastRecipe, true, V[this.mTier], new FluidStack[]{this.getFillableStack()},
+ this.getSpecialSlot(), new ItemStack[]{aStack}
+ ) != null;
case 2:
- return (!this.mRequiresFluidForFiltering || this.getFillableStack() != null) && (((this.getInputAt(0) != null && this.getInputAt(1) != null) || (this.getInputAt(0) == null && this.getInputAt(1) == null ? this.getRecipeList().containsInput(aStack) : (this.getRecipeList().containsInput(aStack) && null != this.getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, this.getSpecialSlot(), aIndex == this.getInputSlot() ? new ItemStack[]{aStack, this.getInputAt(1)} : new ItemStack[]{this.getInputAt(0), aStack})))));
+
+ return (
+ !this.mRequiresFluidForFiltering || this.getFillableStack() != null) &&
+ (
+ (
+ (this.getInputAt(0) != null && this.getInputAt(1) != null) ||
+ (
+ this.getInputAt(0) == null && this.getInputAt(1) == null ?
+ this.getRecipeList().containsInput(aStack) :
+ (
+ this.getRecipeList().containsInput(aStack) &&
+ this.getRecipeList().findRecipe(
+ this.getBaseMetaTileEntity(), this.mLastRecipe, true, V[this.mTier],
+ new FluidStack[]{this.getFillableStack()},
+ this.getSpecialSlot(), aIndex == this.getInputSlot() ?
+ new ItemStack[]{aStack, this.getInputAt(1)} :
+ new ItemStack[]{this.getInputAt(0), aStack}
+ ) != null
+ )
+ )
+ )
+ );
default:{
int tID = this.getBaseMetaTileEntity().getMetaTileID();
- if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) {//assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev
+ if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) { //assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev
if (GT_Utility.isStackValid(aStack))
for (int oreID : OreDictionary.getOreIDs(aStack)) {
if (OreDictionary.getOreName(oreID).contains("circuit"))
@@ -739,7 +807,11 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 1:
if (aBaseMetaTileEntity.getFrontFacing() != 1 && aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0 && !aBaseMetaTileEntity.getOpacityAtSide((byte) 1)) {
Random tRandom = aBaseMetaTileEntity.getWorld().rand;
- aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F, 0.0D, 0.0D, 0.0D);
+ aBaseMetaTileEntity.getWorld().spawnParticle(
+ "smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F,
+ aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F,
+ aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F, 0.0D, 0.0D, 0.0D
+ );
}
break;
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
index 8758ea1a02..7c57076ae9 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
@@ -97,10 +97,10 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
break;
case WEST:
switch (side) {
- case DOWN:
case UP:
case SOUTH:
return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT
+ case DOWN:
case NORTH:
return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT
default:
@@ -108,10 +108,10 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
break;
case EAST:
switch (side) {
- case DOWN:
case UP:
case SOUTH:
return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT
+ case DOWN:
case NORTH:
return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT
default:
@@ -248,7 +248,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
- if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) {
+ if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) {
mSuccess--;
moveItems(aBaseMetaTileEntity, aTimer);
for(byte b = 0;b<6;b++)
@@ -261,7 +261,6 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
if (mInventory[i] == null) {
for(byte b = 0;b<6;b++)
aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b,bInvert ? (byte)15 : (byte)0);
- aBaseMetaTileEntity.decreaseStoredEnergyUnits(1, true);
break;
}
}
@@ -284,7 +283,6 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
mSuccess = 50;
- aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true);
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
index b3998b62e7..1e5c86108b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
@@ -35,8 +35,8 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length);
desc[mDescriptionArray.length] = "DO NOT OBSTRUCT THE OUTPUT!";
desc[mDescriptionArray.length + 1] = "Reduces Pollution to " + calculatePollutionReduction(100) + "%";
- //Pollution Recovery scales from 5% at LV to 100% at MAX Voltage
- desc[mDescriptionArray.length + 2] = "Recovers " + (105 - calculatePollutionReduction(100)) + "% of CO2/CO/SO2";
+ //Pollution Recovery scales from 0% at LV to 100% at UHV Voltage
+ desc[mDescriptionArray.length + 2] = "Recovers " + (100 - calculatePollutionReduction(100)) + "% of CO2/CO/SO2";
return desc;
}
@@ -97,7 +97,9 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
}
public int calculatePollutionReduction(int aPollution) {
- return (int) (aPollution * (Math.pow(0.85F, mTier - 1)));
+ if ((float) mTier < 2)
+ return aPollution;
+ return (int) ((float) aPollution * ((100F - (12.5F * ((float) mTier - 1F))) / 100F));
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
index 1dafbcce5a..aaa0dc9df5 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
@@ -20,6 +20,10 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch {
"Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")});
}
+ public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier, String[] aDescription) {
+ super(aID, aName, aNameRegional, aTier, getSlots(aTier), aDescription);
+ }
+
public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures);
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 202e542c88..6f211631f2 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -16,6 +16,8 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Pollution;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
+import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -23,6 +25,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
@@ -34,21 +37,21 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public static boolean disableMaintenance;
public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mRunningOnLoad = false;
public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0;
- public volatile int mUpdate = 0;
+ public volatile int mUpdate = 0; //TODO: Replace with AtomicInteger
public ItemStack[] mOutputItems = null;
public FluidStack[] mOutputFluids = null;
public String mNEI;
public int damageFactorLow = 5;
public float damageFactorHigh = 0.6f;
- public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>();
- public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>();
- public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>();
- public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>();
- public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>();
- public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>();
- public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>();
- public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<>();
public GT_MetaTileEntity_MultiBlockBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional, 2);
@@ -70,6 +73,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
@Override
+ public boolean isDisplaySecondaryDescription() {
+ return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
+ }
+
+ @Override
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
return aSide != getBaseMetaTileEntity().getFrontFacing();
}
@@ -727,11 +735,25 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public boolean addOutput(ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack)) return false;
aStack = GT_Utility.copy(aStack);
-// FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true);
-// if (aLiquid == null) {
boolean outputSuccess = true;
while (outputSuccess && aStack.stackSize > 0) {
outputSuccess = false;
+
+ if (GregTech_API.mAE2) {
+ // this separate cycle may be refactored out, after this function will hopefully be totally refactored
+ // for now it is here to avoid splitting stack when we have ME output bus
+ for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
+ // TODO: If ever there will be another hatch storing in some external storage, here should be an interface check
+ if (tHatch instanceof GT_MetaTileEntity_Hatch_OutputBus_ME && isValidMetaTileEntity(tHatch)) {
+ int rest = ((GT_MetaTileEntity_Hatch_OutputBus_ME) tHatch).store(aStack);
+ if (rest != aStack.stackSize)
+ outputSuccess = true;
+ aStack.stackSize = rest;
+ if (rest == 0)
+ return true;
+ }
+ }
+ }
ItemStack single = aStack.splitStack(1);
for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
if (!outputSuccess && isValidMetaTileEntity(tHatch)) {
@@ -746,16 +768,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
}
}
-// }else {
-// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
-// if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) {
-// int tAmount = tHatch.fill(aLiquid, false);
-// if (tAmount >= aLiquid.amount) {
-// return tHatch.fill(aLiquid, true) >= aLiquid.amount;
-// }
-// }
-// }
-// }
return outputSuccess;
}
@@ -791,7 +803,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public ArrayList<ItemStack> getStoredOutputs() {
- ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ ArrayList<ItemStack> rList = new ArrayList<>();
// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
// if (isValidMetaTileEntity(tHatch)) {
// rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1));
@@ -808,7 +820,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public ArrayList<FluidStack> getStoredFluids() {
- ArrayList<FluidStack> rList = new ArrayList<FluidStack>();
+ ArrayList<FluidStack> rList = new ArrayList<>();
for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
tHatch.mRecipeMap = getRecipeMap();
if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
@@ -819,7 +831,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public ArrayList<ItemStack> getStoredInputs() {
- ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ ArrayList<ItemStack> rList = new ArrayList<>();
// for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
// tHatch.mRecipeMap = getRecipeMap();
// if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) {
@@ -1003,4 +1015,47 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
+
+ protected ItemStack[] getCompactedInputs(){
+ //TODO: repalce method with a cleaner one
+ ArrayList<ItemStack> tInputList = getStoredInputs();
+ int tInputList_sS = tInputList.size();
+ for (int i = 0; i < tInputList_sS - 1; i++) {
+ for (int j = i + 1; j < tInputList_sS; j++) {
+ if (!GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j)))
+ continue;
+ if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) {
+ tInputList.remove(j--);
+ tInputList_sS = tInputList.size();
+ } else {
+ tInputList.remove(i--);
+ tInputList_sS = tInputList.size();
+ break;
+ }
+ }
+ }
+ return tInputList.toArray(new ItemStack[0]);
+ }
+
+ protected FluidStack[] getCompactedFluids(){
+ //TODO: repalce method with a cleaner one
+ ArrayList<FluidStack> tFluidList = getStoredFluids();
+ int tFluidList_sS = tFluidList.size();
+ for (int i = 0; i < tFluidList_sS - 1; i++) {
+ for (int j = i + 1; j < tFluidList_sS; j++) {
+ if (!GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j)))
+ continue;
+
+ if (tFluidList.get(i).amount >= tFluidList.get(j).amount) {
+ tFluidList.remove(j--);
+ tFluidList_sS = tFluidList.size();
+ } else {
+ tFluidList.remove(i--);
+ tFluidList_sS = tFluidList.size();
+ break;
+ }
+ }
+ }
+ return tFluidList.toArray(new FluidStack[0]);
+ }
}
diff --git a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java
index 59059fce8a..e7138d04ed 100644
--- a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java
+++ b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java
@@ -36,7 +36,7 @@ public class GT_CopiedBlockTexture implements ITexture {
this(aBlock, aSide, aMeta, Dyes._NULL.mRGBa);
}
- private final IIcon getIcon(int aSide) {
+ private IIcon getIcon(int aSide) {
if (mSide == 6) return mBlock.getIcon(aSide, mMeta);
return mBlock.getIcon(mSide, mMeta);
}
@@ -45,9 +45,9 @@ public class GT_CopiedBlockTexture implements ITexture {
public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
IIcon aIcon = getIcon(5);
Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255);
-// aRenderer.flipTexture = !aRenderer.flipTexture;
+ aRenderer.field_152631_f = true;
aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon);
-// aRenderer.flipTexture = !aRenderer.flipTexture;
+ aRenderer.field_152631_f = false;
}
@Override
@@ -82,9 +82,9 @@ public class GT_CopiedBlockTexture implements ITexture {
public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
IIcon aIcon = getIcon(2);
Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255);
-// aRenderer.flipTexture = !aRenderer.flipTexture;
+ aRenderer.field_152631_f = true;
aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon);
-// aRenderer.flipTexture = !aRenderer.flipTexture;
+ aRenderer.field_152631_f = false;
}
@Override
diff --git a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java
index 074cabf341..bbfc90fa6f 100644
--- a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java
+++ b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java
@@ -10,8 +10,8 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
public class GT_RenderedTexture implements ITexture, IColorModulationContainer {
- private final IIconContainer mIconContainer;
- private final boolean mAllowAlpha;
+ final IIconContainer mIconContainer;
+ final boolean mAllowAlpha;
/**
* DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!!
* <p/>
@@ -37,12 +37,12 @@ public class GT_RenderedTexture implements ITexture, IColorModulationContainer {
@Override
public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tesselator = Tessellator.instance;
- tesselator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255);
+ final Tessellator tessellator = Tessellator.instance;
+ tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255);
aRenderer.field_152631_f = true;
aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
if (mIconContainer.getOverlayIcon() != null) {
- tesselator.setColorRGBA(153, 153, 153, 255);
+ tessellator.setColorRGBA(153, 153, 153, 255);
aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
}
aRenderer.field_152631_f = false;
@@ -51,60 +51,107 @@ public class GT_RenderedTexture implements ITexture, IColorModulationContainer {
@Override
public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tesselator = Tessellator.instance;
- tesselator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255);
+ final Tessellator tessellator = Tessellator.instance;
+ tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255);
aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
if (mIconContainer.getOverlayIcon() != null) {
- tesselator.setColorRGBA(153, 153, 153, 255);
+ tessellator.setColorRGBA(153, 153, 153, 255);
aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
}
}
@Override
public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tesselator = Tessellator.instance;
- tesselator.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255);
+ final Tessellator tessellator = Tessellator.instance;
+ tessellator.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255);
aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
if (mIconContainer.getOverlayIcon() != null) {
- tesselator.setColorRGBA(255, 255, 255, 255);
+ tessellator.setColorRGBA(255, 255, 255, 255);
aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
}
}
@Override
public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tesselator = Tessellator.instance;
- tesselator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255);
- aRenderer.field_152631_f = true;
- aRenderer.flipTexture = true;
- aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ final Tessellator tessellator = Tessellator.instance;
+ tessellator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255);
+ IIcon aIcon = mIconContainer.getIcon();
+
+ float minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D);
+ float maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D);
+ float minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D);
+ float maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D);
+
+ if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) {
+ minU = 16.0F - aIcon.getMaxU();
+ maxU = 16.0F - aIcon.getMinU();
+ }
+
+ if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) {
+ minV = aIcon.getMinV();
+ maxV = aIcon.getMaxV();
+ }
+
+ double minX = aX + aRenderer.renderMinX;
+ double maxX = aX + aRenderer.renderMaxX;
+ double minY = aY + aRenderer.renderMinY;
+ double minZ = aZ + aRenderer.renderMinZ;
+ double maxZ = aZ + aRenderer.renderMaxZ;
+
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV);
if (mIconContainer.getOverlayIcon() != null) {
- tesselator.setColorRGBA(128, 128, 128, 255);
- aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ tessellator.setColorRGBA(128, 128, 128, 255);
+
+ minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D);
+ maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D);
+ minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D);
+ maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D);
+
+ if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) {
+ minU = 16.0F - aIcon.getMaxU();
+ maxU = 16.0F - aIcon.getMinU();
+ }
+
+ if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) {
+ minV = aIcon.getMinV();
+ maxV = aIcon.getMaxV();
+ }
+
+ minX = aX + (float)aRenderer.renderMinX;
+ maxX = aX + (float)aRenderer.renderMaxX;
+ minY = aY + (float)aRenderer.renderMinY;
+ minZ = aZ + (float)aRenderer.renderMinZ;
+ maxZ = aZ + (float)aRenderer.renderMaxZ;
+
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV);
}
- aRenderer.field_152631_f = false;
- aRenderer.flipTexture = false;
}
@Override
public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tesselator = Tessellator.instance;
- tesselator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255);
+ final Tessellator tessellator = Tessellator.instance;
+ tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255);
aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
if (mIconContainer.getOverlayIcon() != null) {
- tesselator.setColorRGBA(204, 204, 204, 255);
+ tessellator.setColorRGBA(204, 204, 204, 255);
aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
}
}
@Override
public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tesselator = Tessellator.instance;
- tesselator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255);
+ final Tessellator tessellator = Tessellator.instance;
+ tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255);
aRenderer.field_152631_f = true;
aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
if (mIconContainer.getOverlayIcon() != null) {
- tesselator.setColorRGBA(204, 204, 204, 255);
+ tessellator.setColorRGBA(204, 204, 204, 255);
aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
}
aRenderer.field_152631_f = false;
diff --git a/src/main/java/gregtech/api/objects/GT_SidedTexture.java b/src/main/java/gregtech/api/objects/GT_SidedTexture.java
index ab88225781..86b16c8438 100644
--- a/src/main/java/gregtech/api/objects/GT_SidedTexture.java
+++ b/src/main/java/gregtech/api/objects/GT_SidedTexture.java
@@ -6,11 +6,9 @@ import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.ITexture;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
-import net.minecraft.client.renderer.Tessellator;
public class GT_SidedTexture implements ITexture, IColorModulationContainer {
- private final IIconContainer[] mIconContainer;
- private final boolean mAllowAlpha;
+ private final ITexture[] mTextures;
/**
* DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!!
* <p/>
@@ -21,8 +19,14 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer {
public GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, IIconContainer aIcon4, IIconContainer aIcon5, short[] aRGBa, boolean aAllowAlpha) {
if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture");
- mIconContainer = new IIconContainer[]{aIcon0, aIcon1, aIcon2, aIcon3, aIcon4, aIcon5};
- mAllowAlpha = aAllowAlpha;
+ mTextures = new ITexture[]{
+ new GT_RenderedTexture(aIcon0, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon1, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon2, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon3, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon4, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon5, aRGBa, aAllowAlpha)
+ };
mRGBa = aRGBa;
}
@@ -44,76 +48,32 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer {
@Override
public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tessellator = Tessellator.instance;
- tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255);
- aRenderer.field_152631_f = true;
- aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer[5].getIcon());
- if (mIconContainer[5].getOverlayIcon() != null) {
- tessellator.setColorRGBA(153, 153, 153, 255);
- aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer[5].getOverlayIcon());
- }
- aRenderer.field_152631_f = false;
+ mTextures[5].renderXPos(aRenderer, aBlock, aX ,aY, aZ);
}
@Override
public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tessellator = Tessellator.instance;
- tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255);
- aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer[4].getIcon());
- if (mIconContainer[4].getOverlayIcon() != null) {
- tessellator.setColorRGBA(153, 153, 153, 255);
- aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer[4].getOverlayIcon());
- }
+ mTextures[4].renderXNeg(aRenderer, aBlock, aX ,aY, aZ);
}
@Override
public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tessellator = Tessellator.instance;
- tessellator.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255);
- aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer[1].getIcon());
- if (mIconContainer[1].getOverlayIcon() != null) {
- tessellator.setColorRGBA(255, 255, 255, 255);
- aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer[1].getOverlayIcon());
- }
+ mTextures[1].renderYPos(aRenderer, aBlock, aX ,aY, aZ);
}
@Override
public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tessellator = Tessellator.instance;
- tessellator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255);
- aRenderer.field_152631_f = true;
- aRenderer.flipTexture = true;
- aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer[1].getIcon());
- if (mIconContainer[0].getOverlayIcon() != null) {
- tessellator.setColorRGBA(128, 128, 128, 255);
- aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer[1].getOverlayIcon());
- }
- aRenderer.field_152631_f = false;
- aRenderer.flipTexture = false;
+ mTextures[0].renderYNeg(aRenderer, aBlock, aX ,aY, aZ);
}
@Override
public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tessellator = Tessellator.instance;
- tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255);
- aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer[3].getIcon());
- if (mIconContainer[3].getOverlayIcon() != null) {
- tessellator.setColorRGBA(204, 204, 204, 255);
- aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer[3].getOverlayIcon());
- }
+ mTextures[3].renderZPos(aRenderer, aBlock, aX ,aY, aZ);
}
@Override
public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
- final Tessellator tessellator = Tessellator.instance;
- tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255);
- aRenderer.field_152631_f = true;
- aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer[2].getIcon());
- if (mIconContainer[2].getOverlayIcon() != null) {
- tessellator.setColorRGBA(204, 204, 204, 255);
- aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer[2].getOverlayIcon());
- }
- aRenderer.field_152631_f = false;
+ mTextures[2].renderZNeg(aRenderer, aBlock, aX ,aY, aZ);
}
@Override
@@ -123,6 +83,9 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer {
@Override
public boolean isValidTexture() {
- return mIconContainer != null && mIconContainer[0] != null && mIconContainer[1] != null && mIconContainer[2] != null && mIconContainer[3] != null && mIconContainer[4] != null && mIconContainer[5] != null;
+ for (ITexture renderedTexture : mTextures) {
+ if (!renderedTexture.isValidTexture()) return false;
+ }
+ return true;
}
} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java b/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java
new file mode 100644
index 0000000000..db475c9561
--- /dev/null
+++ b/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java
@@ -0,0 +1,41 @@
+package gregtech.api.objects;
+
+import gregtech.api.enums.Dyes;
+import gregtech.api.interfaces.IIconContainer;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+
+/**
+ * This ITexture implementation extends the GT_RenderedTexture class
+ * to render with bottom side flipped as with dumb blocks rendering.
+ * It is used in Ore blocks rendering so they better blends with dumb block ores
+ * from vanilla or other mods, when seen from bottom.
+ */
+public class GT_StdRenderedTexture extends GT_RenderedTexture{
+
+ @SuppressWarnings("unused")
+ public GT_StdRenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) {
+ super(aIcon, aRGBa, aAllowAlpha);
+ }
+
+ public GT_StdRenderedTexture(IIconContainer aIcon, short[] aRGBa) {
+ super(aIcon, aRGBa, true);
+ }
+
+ @SuppressWarnings("unused")
+ public GT_StdRenderedTexture(IIconContainer aIcon) {
+ super(aIcon, Dyes._NULL.mRGBa);
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ final Tessellator tessellator = Tessellator.instance;
+ tessellator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255);
+ aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ tessellator.setColorRGBA(128, 128, 128, 255);
+ aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java
new file mode 100644
index 0000000000..cb9e7d4d83
--- /dev/null
+++ b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java
@@ -0,0 +1,43 @@
+package gregtech.api.objects;
+
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler;
+import net.minecraft.item.ItemStack;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.Optional;
+import java.util.Queue;
+
+import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes;
+
+public class ReverseShapedRecipe {
+ private static Queue<ReverseShapedRecipe> reverseRecipes = new LinkedList<>();
+ private ItemStack aResult;
+ private Object[] aRecipe;
+
+ public static Queue<ReverseShapedRecipe> getReverseRecipes() {
+ return reverseRecipes;
+ }
+
+ public ReverseShapedRecipe(ItemStack output, Object[] aRecipe) {
+ this.aResult = output;
+ this.aRecipe = aRecipe;
+ reverseRecipes.add(this);
+ }
+
+ public static void runReverseRecipes() {
+ for (ReverseShapedRecipe x : reverseRecipes) {
+ Optional<GT_Recipe> recipeOptional = GT_Utility.reverseShapedRecipe(x.aResult, x.aRecipe);
+ if (!recipeOptional.isPresent())
+ continue;
+ GT_Recipe recipe = recipeOptional.get();
+ ItemStack[] replacement = new ItemStack[recipe.mOutputs.length];
+ GT_MetaTileEntity_Disassembler.handleRecipeTransformation(recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs));
+
+ recipe.mOutputs = replacement;
+ sDisassemblerRecipes.add(recipe);
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java
new file mode 100644
index 0000000000..1c5e27d246
--- /dev/null
+++ b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java
@@ -0,0 +1,43 @@
+package gregtech.api.objects;
+
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler;
+import net.minecraft.item.ItemStack;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.Optional;
+import java.util.Queue;
+
+import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes;
+
+public class ReverseShapelessRecipe {
+ private static Queue<ReverseShapelessRecipe> reverseRecipes = new LinkedList<>();
+ private ItemStack aResult;
+ private Object[] aRecipe;
+
+ public static Queue<ReverseShapelessRecipe> getReverseRecipes() {
+ return reverseRecipes;
+ }
+
+ public ReverseShapelessRecipe(ItemStack output, Object[] aRecipe) {
+ this.aResult = output;
+ this.aRecipe = aRecipe;
+ reverseRecipes.add(this);
+ }
+
+ public static void runReverseRecipes() {
+ for (ReverseShapelessRecipe x : reverseRecipes) {
+ Optional<GT_Recipe> recipeOptional = GT_Utility.reverseShapelessRecipe(x.aResult, x.aRecipe);
+ if (!recipeOptional.isPresent())
+ continue;
+ GT_Recipe recipe = recipeOptional.get();
+ ItemStack[] replacement = new ItemStack[recipe.mOutputs.length];
+ GT_MetaTileEntity_Disassembler.handleRecipeTransformation(recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs));
+
+ recipe.mOutputs = replacement;
+ sDisassemblerRecipes.add(recipe);
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java
index ee56a0b0c0..3ce1daf9b2 100644
--- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java
+++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java
@@ -3,11 +3,14 @@ package gregtech.api.threads;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable;
+import gregtech.common.GT_Proxy;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.ChunkPosition;
+import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -15,12 +18,13 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
public class GT_Runnable_MachineBlockUpdate implements Runnable {
- //used by runner thread
- private final int x, y, z;
+ // used by runner thread
+ private final ChunkCoordinates mCoords;
private final World world;
- private final Set<ChunkPosition> visited = new HashSet<>(80);
-
- //Threading
+ private final Set<ChunkCoordinates> visited = new HashSet<>(80);
+ private final Queue<ChunkCoordinates> tQueue = new LinkedList<>();
+
+ // Threading
private static final ThreadFactory THREAD_FACTORY = r -> {
Thread thread = new Thread(r);
thread.setName("GT_MachineBlockUpdate");
@@ -28,12 +32,13 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
};
private static ExecutorService EXECUTOR_SERVICE;
- //This class should never be initiated outside of this class!
- private GT_Runnable_MachineBlockUpdate(World aWorld, int aX, int aY, int aZ) {
+ // This class should never be initiated outside of this class!
+ private GT_Runnable_MachineBlockUpdate(World aWorld, ChunkCoordinates aCoords) {
this.world = aWorld;
- this.x = aX;
- this.y = aY;
- this.z = aZ;
+ this.mCoords = aCoords;
+ visited.add(aCoords);
+ tQueue.add(aCoords);
+
}
public static boolean isEnabled() {
@@ -54,16 +59,15 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
private static boolean isEnabled = true;
- public static void setMachineUpdateValues(World aWorld, int aX, int aY, int aZ) {
- if (isEnabled)
- EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ));
+ public static void setMachineUpdateValues(World aWorld, ChunkCoordinates aCoords) {
+ if (isEnabled) {
+ aWorld.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ);
+ EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aCoords));
+ }
}
public static void initExecutorService() {
- EXECUTOR_SERVICE = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), THREAD_FACTORY);
- //Executors.newSingleThreadExecutor(THREAD_FACTORY);
- //Executors.newCachedThreadPool(THREAD_FACTORY);
- //Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),THREAD_FACTORY);
+ EXECUTOR_SERVICE = Executors.newFixedThreadPool((Runtime.getRuntime().availableProcessors() * 2 / 3), THREAD_FACTORY);
}
public static void shutdownExecutorService() {
@@ -85,7 +89,7 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
// Preserve interrupt status
Thread.currentThread().interrupt();
}catch (Exception e){
- GT_Mod.GT_FML_LOGGER.error("Well this didn't terminated well...",e);
+ GT_Mod.GT_FML_LOGGER.error("Well this didn't terminated well...", e);
// (Re-)Cancel in case
EXECUTOR_SERVICE.shutdownNow();
}finally {
@@ -93,70 +97,50 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
}
}
- private boolean shouldRecurse(TileEntity aTileEntity, int aX, int aY, int aZ) {
- //no check on IGregTechTileEntity as it should call the underlying meta tile isMachineBlockUpdateRecursive
- //if (aTileEntity instanceof IGregTechTileEntity) {
- // return ((IGregTechTileEntity) aTileEntity).isMachineBlockUpdateRecursive();
- //}
- return (aTileEntity instanceof IMachineBlockUpdateable &&
- ((IMachineBlockUpdateable) aTileEntity).isMachineBlockUpdateRecursive()) ||
- GregTech_API.isMachineBlock(world.getBlock(aX, aY, aZ), world.getBlockMetadata(aX, aY, aZ));
- }
-
- private void causeUpdate(TileEntity tileEntity) {
- //no check for IGregTechTileEntity as it should call the underlying meta tile onMachineBlockUpdate
- if (tileEntity instanceof IMachineBlockUpdateable) {
- ((IMachineBlockUpdateable) tileEntity).onMachineBlockUpdate();
- }
- }
-
- private void stepToUpdateMachine(int aX, int aY, int aZ) {
- if (!visited.add(new ChunkPosition(aX, aY, aZ)))
- return;
- TileEntity tTileEntity = world.getTileEntity(aX, aY, aZ);
-
- causeUpdate(tTileEntity);
-
- if (visited.size() < 5 || shouldRecurse(tTileEntity, aX, aY, aZ)) {
- stepToUpdateMachine(aX + 1, aY, aZ);
- stepToUpdateMachine(aX - 1, aY, aZ);
- stepToUpdateMachine(aX, aY + 1, aZ);
- stepToUpdateMachine(aX, aY - 1, aZ);
- stepToUpdateMachine(aX, aY, aZ + 1);
- stepToUpdateMachine(aX, aY, aZ - 1);
- }
- }
-
@Override
public void run() {
try {
- stepToUpdateMachine(x, y, z);
+ while (!tQueue.isEmpty()) {
+ final ChunkCoordinates aCoords = tQueue.poll();
+ final TileEntity tTileEntity;
+ final boolean isMachineBlock;
+
+ // This might load a chunk... which might load a TileEntity... which might get added to `loadedTileEntityList`... which might be in the process
+ // of being iterated over during `UpdateEntities()`... which might cause a ConcurrentModificationException. So, lock that shit.
+ GT_Proxy.TICK_LOCK.lock();
+ try {
+ tTileEntity = world.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ);
+ isMachineBlock = GregTech_API.isMachineBlock(world.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ), world.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ));
+ } finally {
+ GT_Proxy.TICK_LOCK.unlock();
+ }
+
+ // See if the block itself needs an update
+ if (tTileEntity instanceof IMachineBlockUpdateable)
+ ((IMachineBlockUpdateable) tTileEntity).onMachineBlockUpdate();
+
+ // Now see if we should add the nearby blocks to the queue:
+ // 1) If we've visited less than 5 blocks, then yes
+ // 2) If the tile says we should recursively updated (pipes don't, machine blocks do)
+ // 3) If the block at the coordinates is marked as a machine block
+ if (visited.size() < 5
+ || (tTileEntity instanceof IMachineBlockUpdateable && ((IMachineBlockUpdateable) tTileEntity).isMachineBlockUpdateRecursive())
+ || isMachineBlock)
+ {
+ ChunkCoordinates tCoords;
+
+ if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ))) tQueue.add(tCoords);
+ if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ))) tQueue.add(tCoords);
+ if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY + 1, aCoords.posZ))) tQueue.add(tCoords);
+ if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY - 1, aCoords.posZ))) tQueue.add(tCoords);
+ if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ + 1))) tQueue.add(tCoords);
+ if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ - 1))) tQueue.add(tCoords);
+ }
+ }
} catch (Exception e) {
- GT_Mod.GT_FML_LOGGER.error("Well this update was broken... " + new Coordinates(x, y, z, world), e);
+ GT_Mod.GT_FML_LOGGER.error(
+ "Well this update was broken... " + mCoords + ", mWorld={" + world.getProviderName() + " @dimId " + world.provider.dimensionId + "}", e);
}
}
- public static class Coordinates {
- public final int mX;
- public final int mY;
- public final int mZ;
- public final World mWorld;
-
- public Coordinates(int mX, int mY, int mZ, World mWorld) {
- this.mX = mX;
- this.mY = mY;
- this.mZ = mZ;
- this.mWorld = mWorld;
- }
-
- @Override
- public String toString() {
- return "Coordinates{" +
- "mX=" + mX +
- ", mY=" + mY +
- ", mZ=" + mZ +
- ", mWorld=" + mWorld.getProviderName() + " @dimId " + mWorld.provider.dimensionId +
- '}';
- }
- }
}
diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java
index c87e0f7417..5046af9e5f 100644
--- a/src/main/java/gregtech/api/util/GT_LanguageManager.java
+++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java
@@ -33,8 +33,12 @@ public class GT_LanguageManager {
TEMPMAP.put(aKey.trim(), aEnglish);
LanguageRegistry.instance().injectLanguage("en_US", TEMPMAP);
TEMPMAP.clear();
- if(sUseEnglishFile && !aWriteIntoLangFile && LANGMAP.containsKey(aKey)){
- aEnglish = LANGMAP.get(aKey);
+ if(sUseEnglishFile && !aWriteIntoLangFile){
+ if (!LANGMAP.containsKey(aKey)) {
+ Property tProperty = sEnglishFile.get("LanguageFile", aKey, aEnglish);
+ aEnglish = tProperty.getString();
+ LANGMAP.put(aKey, aEnglish);
+ } else aEnglish = LANGMAP.get(aKey);
}
return aEnglish;
}
diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
index 5cfcac0a89..484e4d29b9 100644
--- a/src/main/java/gregtech/api/util/GT_ModHandler.java
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -6,7 +6,12 @@ import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
+import gregtech.api.enums.ConfigCategories;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OreDictNames;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.ToolDictNames;
import gregtech.api.interfaces.IDamagableItem;
import gregtech.api.interfaces.IItemContainer;
import gregtech.api.interfaces.internal.IGT_CraftingRecipe;
@@ -31,7 +36,11 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
-import net.minecraft.item.crafting.*;
+import net.minecraft.item.crafting.CraftingManager;
+import net.minecraft.item.crafting.FurnaceRecipes;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.item.crafting.ShapedRecipes;
+import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.World;
@@ -40,11 +49,27 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Set;
import java.util.stream.Collectors;
-import static gregtech.api.enums.GT_Values.*;
+import static gregtech.GT_Mod.GT_FML_LOGGER;
+import static gregtech.api.enums.GT_Values.B;
+import static gregtech.api.enums.GT_Values.D1;
+import static gregtech.api.enums.GT_Values.DW;
+import static gregtech.api.enums.GT_Values.E;
+import static gregtech.api.enums.GT_Values.M;
+import static gregtech.api.enums.GT_Values.RA;
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.enums.GT_Values.W;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -54,22 +79,28 @@ import static gregtech.api.enums.GT_Values.*;
* Due to the many imports, this File can cause compile Problems if not all the APIs are installed
*/
public class GT_ModHandler {
- public static final List<IRecipe> sSingleNonBlockDamagableRecipeList = new ArrayList<IRecipe>(1000);
- private static final Map<String, ItemStack> sIC2ItemMap = new HashMap<String, ItemStack>();
- private static final List<IRecipe> sAllRecipeList = /*Collections.synchronizedList(*/new ArrayList<IRecipe>(5000)/*)*/, sBufferRecipeList = new ArrayList<IRecipe>(1000);
+ public static final List<IRecipe> sSingleNonBlockDamagableRecipeList = new ArrayList<>(1000);
+ private static final Map<String, ItemStack> sIC2ItemMap = new HashMap<>();
+
+ private static final List<IRecipe> sAllRecipeList = new ArrayList<>(5000), sBufferRecipeList = new ArrayList<>(1000);
+ private static final List<ItemStack> delayedRemovalByOutput = new ArrayList<>();
+ private static final List<InventoryCrafting> delayedRemovalByRecipe = new ArrayList<>();
+
+
public static volatile int VERSION = 509;
- public static Collection<String> sNativeRecipeClasses = new HashSet<String>(), sSpecialRecipeClasses = new HashSet<String>();
- public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<GT_ItemStack>();
+ public static Collection<String> sNativeRecipeClasses = new HashSet<>(), sSpecialRecipeClasses = new HashSet<>();
+ public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<>();
public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false);
- private static Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
+ private static final Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new HashMap<>();
+ private static final Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new HashMap<>();
+ private static final Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new HashMap<>();
+ private static final Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new HashMap<>();
+ private static final Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new HashMap<>();
+ private static final Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new HashMap<>();
+
private static boolean sBufferCraftingRecipes = true;
- public static List<Integer> sSingleNonBlockDamagableRecipeList_list = new ArrayList<Integer>(100);
- private static boolean sSingleNonBlockDamagableRecipeList_create = true;
+ public static List<Integer> sSingleNonBlockDamagableRecipeList_list = new ArrayList<>(100);
+ private static final boolean sSingleNonBlockDamagableRecipeList_create = true;
private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0);
private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R";
private static final ItemStack[][]
@@ -119,12 +150,14 @@ public class GT_ModHandler {
{sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null},
{null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2}
};
- public static List<Integer> sSingleNonBlockDamagableRecipeList_validsShapes1 = new ArrayList<Integer>(44);
+ public static List<Integer> sSingleNonBlockDamagableRecipeList_validsShapes1 = new ArrayList<>(44);
public static boolean sSingleNonBlockDamagableRecipeList_validsShapes1_update = false;
- public static List<Integer> sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList<Integer>(50);
- public static List<Integer> sVanillaRecipeList_warntOutput = new ArrayList<Integer>(50);
- public static final List<IRecipe> sSingleNonBlockDamagableRecipeList_verified = new ArrayList<IRecipe>(1000);
- private static Cache<GT_ItemStack, ItemStack> sSmeltingRecipeCache = CacheBuilder.newBuilder().maximumSize(1000).build();
+ public static List<Integer> sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList<>(50);
+ public static List<Integer> sVanillaRecipeList_warntOutput = new ArrayList<>(50);
+ public static final List<IRecipe> sSingleNonBlockDamagableRecipeList_verified = new ArrayList<>(1000);
+ private static final Cache<GT_ItemStack, ItemStack> sSmeltingRecipeCache = CacheBuilder.newBuilder().maximumSize(1000).build();
+ public static List<Integer> sAnySteamFluidIDs = new ArrayList<>();
+ public static List<Integer> sSuperHeatedSteamFluidIDs = new ArrayList<>();
static {
sNativeRecipeClasses.add(ShapedRecipes.class.getName());
@@ -217,6 +250,20 @@ public class GT_ModHandler {
}
/**
+ * Returns if that Liquid is Any Steam (including other mods)
+ */
+ public static boolean isAnySteam(FluidStack aFluid) {
+ return(aFluid != null && (isSteam(aFluid) || sAnySteamFluidIDs.contains(aFluid.getFluidID())));
+ }
+
+ /**
+ * Returns if that Liquid is Super Heated Steam (including other mods)
+ */
+ public static boolean isSuperHeatedSteam(FluidStack aFluid) {
+ return(aFluid != null && sSuperHeatedSteamFluidIDs.contains(aFluid.getFluidID()));
+ }
+
+ /**
* Returns a Liquid Stack with given amount of Steam.
*/
public static FluidStack getSteam(long aAmount) {
@@ -502,10 +549,8 @@ public class GT_ModHandler {
public static boolean addExtractionRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false;
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.extractor, aInput, true)) return false;
RA.addExtractorRecipe(aInput, aOutput, 300, 2);
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.addSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null, aOutput);
return true;
}
@@ -557,12 +602,8 @@ public class GT_ModHandler {
aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
if (GT_Utility.isStackInvalid(aInput) || GT_Utility.isStackInvalid(aOutput1)) return false;
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null);
if (GT_Utility.getContainerItem(aInput, false) == null) {
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) {
- GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1);
- }
addMagneticraftRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3);
addImmersiveEngineeringRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3);
RA.addPulveriserRecipe(aInput, new ItemStack[]{aOutput1, aOutput2, aOutput3}, new int[]{10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, 400, 2);
@@ -680,39 +721,34 @@ public class GT_ModHandler {
*/
public static void addIC2RecipesToGT(Map<IRecipeInput, RecipeOutput> aIC2RecipeList, GT_Recipe.GT_Recipe_Map aGTRecipeMap, boolean aAddGTRecipe, boolean aRemoveIC2Recipe, boolean aExcludeGTIC2Items) {
Map<ItemStack, ItemStack> aRecipesToRemove = new HashMap<>();
- for (Iterator i$ = aIC2RecipeList.entrySet().iterator(); i$.hasNext(); ) {
- Entry tRecipe = (Map.Entry) i$.next();
- if (((RecipeOutput) tRecipe.getValue()).items.size() > 0) {
- for (ItemStack tStack : ((IRecipeInput) tRecipe.getKey()).getInputs()) {
+ for (Entry<IRecipeInput, RecipeOutput> iRecipeInputRecipeOutputEntry : aIC2RecipeList.entrySet()) {
+ if ((iRecipeInputRecipeOutputEntry.getValue()).items.size() > 0) {
+ for (ItemStack tStack : (iRecipeInputRecipeOutputEntry.getKey()).getInputs()) {
if (GT_Utility.isStackValid(tStack)) {
if (aAddGTRecipe && (aGTRecipeMap.findRecipe(null, false, Long.MAX_VALUE, null, tStack) == null)) {
- try{
- if (aExcludeGTIC2Items && ((tStack.getUnlocalizedName().contains("gt.metaitem.01") || tStack.getUnlocalizedName().contains("gt.blockores") || tStack.getUnlocalizedName().contains("ic2.itemCrushed") || tStack.getUnlocalizedName().contains("ic2.itemPurifiedCrushed")))) continue;
- switch (aGTRecipeMap.mUnlocalizedName) {
- case "gt.recipe.macerator":
- aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 300, 2, 0);
- break;
- case "gt.recipe.compressor":
- aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 300, 2, 0);
- break;
- case "gt.recipe.extractor":
- aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 300, 2, 0);
- break;
- case "gt.recipe.thermalcentrifuge":
- aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 500, 48, 0);
- break;
+ try {
+ if (aExcludeGTIC2Items && ((tStack.getUnlocalizedName().contains("gt.metaitem.01") || tStack.getUnlocalizedName().contains("gt.blockores") || tStack.getUnlocalizedName().contains("ic2.itemCrushed") || tStack.getUnlocalizedName().contains("ic2.itemPurifiedCrushed"))))
+ continue;
+ switch (aGTRecipeMap.mUnlocalizedName) {
+ case "gt.recipe.macerator":
+ case "gt.recipe.extractor":
+ case "gt.recipe.compressor":
+ aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount((iRecipeInputRecipeOutputEntry.getKey()).getAmount(), tStack)}, (ItemStack[]) (iRecipeInputRecipeOutputEntry.getValue()).items.toArray(), null, null, null, null, 300, 2, 0);
+ break;
+ case "gt.recipe.thermalcentrifuge":
+ aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount((iRecipeInputRecipeOutputEntry.getKey()).getAmount(), tStack)}, (ItemStack[]) (iRecipeInputRecipeOutputEntry.getValue()).items.toArray(), null, null, null, null, 500, 48, 0);
+ break;
+ }
+ } catch (Exception e) {
+ System.err.println(e);
}
- }catch(Exception e){System.err.println(e);}
- //GT_FML_LOGGER.info("#####Processed IC2 " + aGTRecipeMap.mUnlocalizedName + " Recipe: In(" + tStack.getUnlocalizedName() + ") - Out(" + ((RecipeOutput) tRecipe.getValue()).items.get(0).getUnlocalizedName() + ")");
}
- if (aRemoveIC2Recipe) aRecipesToRemove.put(tStack, ((RecipeOutput) tRecipe.getValue()).items.get(0));
+ if (aRemoveIC2Recipe) aRecipesToRemove.put(tStack, ((RecipeOutput) iRecipeInputRecipeOutputEntry.getValue()).items.get(0));
}
}
}
}
- for (Entry<ItemStack, ItemStack> aEntry : aRecipesToRemove.entrySet()) {
- GT_Utility.removeSimpleIC2MachineRecipe(aEntry.getKey(), aIC2RecipeList, aEntry.getValue());
- }
+ GT_Utility.bulkRemoveSimpleIC2MachineRecipe(aRecipesToRemove, aIC2RecipeList);
}
public static Map<IRecipeInput, RecipeOutput> getExtractorRecipeList() {
@@ -762,14 +798,8 @@ public class GT_ModHandler {
*/
public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false;
RA.addThermalCentrifugeRecipe(aInput, aOutput.length >= 1 ? (ItemStack)aOutput[0] : null, aOutput.length >= 2 ? (ItemStack)aOutput[1] : null, aOutput.length >= 3 ? (ItemStack)aOutput[2] : null, 500, 48);
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) {
- NBTTagCompound tNBT = new NBTTagCompound();
- tNBT.setInteger("minHeat", aHeat);
- GT_Utility.addSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), tNBT, aOutput);
- }
return true;
}
@@ -778,15 +808,9 @@ public class GT_ModHandler {
*/
public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false;
RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(1000L), 500, 16);
RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getDistilledWater(200L), 300, 16);
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) {
- NBTTagCompound tNBT = new NBTTagCompound();
- tNBT.setInteger("amount", aWaterAmount);
- GT_Utility.addSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), tNBT, aOutput);
- }
return true;
}
@@ -796,10 +820,8 @@ public class GT_ModHandler {
public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null || GT_Utility.areStacksEqual(aInput, aOutput, true)) return false;
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.compression, aInput, true)) return false;
RA.addCompressorRecipe(aInput, aOutput, 300, 2);
- if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.addSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null, aOutput);
return true;
}
@@ -833,7 +855,13 @@ public class GT_ModHandler {
public static void stopBufferingCraftingRecipes() {
sBufferCraftingRecipes = false;
- for (IRecipe tRecipe : sBufferRecipeList) {GameRegistry.addRecipe(tRecipe);}
+
+ bulkRemoveRecipeByOutput(delayedRemovalByOutput);
+ bulkRemoveByRecipe(delayedRemovalByRecipe);
+ sBufferRecipeList.forEach(GameRegistry::addRecipe);
+
+ delayedRemovalByOutput.clear();
+ delayedRemovalByRecipe.clear();
sBufferRecipeList.clear();
}
@@ -897,18 +925,54 @@ public class GT_ModHandler {
* 'x' ToolDictNames.craftingToolWireCutter,
*/
public static boolean addCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) {
- return addCraftingRecipe(aResult, new Enchantment[0], new int[0], (aBitMask & RecipeBits.MIRRORED) != 0, (aBitMask & RecipeBits.BUFFERED) != 0, (aBitMask & RecipeBits.KEEPNBT) != 0, (aBitMask & RecipeBits.DISMANTLEABLE) != 0, (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, (aBitMask & RecipeBits.REVERSIBLE) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0, (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0, (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0, (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0, aRecipe);
+ return addCraftingRecipe(
+ aResult,
+ new Enchantment[0],
+ new int[0],
+ (aBitMask & RecipeBits.MIRRORED) != 0,
+ (aBitMask & RecipeBits.BUFFERED) != 0,
+ (aBitMask & RecipeBits.KEEPNBT) != 0,
+ (aBitMask & RecipeBits.DISMANTLEABLE) != 0,
+ (aBitMask & RecipeBits.NOT_REMOVABLE) == 0,
+ (aBitMask & RecipeBits.REVERSIBLE) != 0,
+ (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0,
+ (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0,
+ (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0,
+ (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0,
+ (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0,
+ (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0,
+ (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0,
+ aRecipe);
}
/**
* Internal realisation of the Crafting Recipe adding Process.
*/
- private static boolean addCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, boolean aReversible, boolean aRemoveAllOthersWithSameOutput, boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, boolean aRemoveAllOtherShapedsWithSameOutput, boolean aRemoveAllOtherNativeRecipes, boolean aCheckForCollisions, boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe) {
+ private static boolean addCraftingRecipe(
+ ItemStack aResult,
+ Enchantment[] aEnchantmentsAdded,
+ int[] aEnchantmentLevelsAdded,
+ boolean aMirrored,
+ boolean aBuffered,
+ boolean aKeepNBT,
+ boolean aDismantleable,
+ boolean aRemovable,
+ boolean aReversible,
+ boolean aRemoveAllOthersWithSameOutput,
+ boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT,
+ boolean aRemoveAllOtherShapedsWithSameOutput,
+ boolean aRemoveAllOtherNativeRecipes,
+ boolean aCheckForCollisions,
+ boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis,
+ boolean aOnlyAddIfResultIsNotNull,
+ Object[] aRecipe
+ ) {
aResult = GT_OreDictUnificator.get(true, aResult);
if (aOnlyAddIfResultIsNotNull && aResult == null) return false;
if (aResult != null && Items.feather.getDamage(aResult) == W) Items.feather.setDamage(aResult, 0);
if (aRecipe == null || aRecipe.length <= 0) return false;
+ boolean tDoWeCareIfThereWasARecipe = aOnlyAddIfThereIsAnyRecipeOutputtingThis;
boolean tThereWasARecipe = false;
for (byte i = 0; i < aRecipe.length; i++) {
@@ -921,21 +985,21 @@ public class GT_ModHandler {
}
try {
- String shape = E;
+ StringBuilder shape = new StringBuilder(E);
int idx = 0;
if (aRecipe[idx] instanceof Boolean) {
throw new IllegalArgumentException();
}
- ArrayList<Object> tRecipeList = new ArrayList<Object>(Arrays.asList(aRecipe));
+ ArrayList<Object> tRecipeList = new ArrayList<>(Arrays.asList(aRecipe));
while (aRecipe[idx] instanceof String) {
- String s = (String) aRecipe[idx++];
- shape += s;
- while (s.length() < 3) s += " ";
+ StringBuilder s = new StringBuilder((String) aRecipe[idx++]);
+ shape.append(s);
+ while (s.length() < 3) s.append(" ");
if (s.length() > 3) throw new IllegalArgumentException();
- for (char c : s.toCharArray()) {
+ for (char c : s.toString().toCharArray()) {
switch (c) {
case 'b':
tRecipeList.add(c);
@@ -1002,8 +1066,8 @@ public class GT_ModHandler {
if (aRecipe[idx] instanceof Boolean) {
idx++;
}
- /*ConcurrentHash*/Map<Character, ItemStack> tItemStackMap = new /*ConcurrentHash*/HashMap<Character, ItemStack>();
- /*ConcurrentHash*/Map<Character, ItemData> tItemDataMap = new /*ConcurrentHash*/HashMap<Character, ItemData>();
+ Map<Character, ItemStack> tItemStackMap = new HashMap<>();
+ Map<Character, ItemData> tItemDataMap = new HashMap<>();
tItemStackMap.put(' ', null);
boolean tRemoveRecipe = true;
@@ -1023,16 +1087,22 @@ public class GT_ModHandler {
tItemDataMap.put(chr, GT_OreDictUnificator.getItemData((ItemStack) in));
} else if (in instanceof ItemData) {
String tString = in.toString();
- if (tString.equals("plankWood")) {
- tItemDataMap.put(chr, new ItemData(Materials.Wood, M));
- } else if (tString.equals("stoneNetherrack")) {
- tItemDataMap.put(chr, new ItemData(Materials.Netherrack, M));
- } else if (tString.equals("stoneObsidian")) {
- tItemDataMap.put(chr, new ItemData(Materials.Obsidian, M));
- } else if (tString.equals("stoneEndstone")) {
- tItemDataMap.put(chr, new ItemData(Materials.Endstone, M));
- } else {
- tItemDataMap.put(chr, (ItemData) in);
+ switch (tString) {
+ case "plankWood":
+ tItemDataMap.put(chr, new ItemData(Materials.Wood, M));
+ break;
+ case "stoneNetherrack":
+ tItemDataMap.put(chr, new ItemData(Materials.Netherrack, M));
+ break;
+ case "stoneObsidian":
+ tItemDataMap.put(chr, new ItemData(Materials.Obsidian, M));
+ break;
+ case "stoneEndstone":
+ tItemDataMap.put(chr, new ItemData(Materials.Endstone, M));
+ break;
+ default:
+ tItemDataMap.put(chr, (ItemData) in);
+ break;
}
ItemStack tStack = GT_OreDictUnificator.getFirstOre(in, 1);
if (tStack == null) tRemoveRecipe = false;
@@ -1062,7 +1132,7 @@ public class GT_ModHandler {
if (aReversible && aResult != null) {
ItemData[] tData = new ItemData[9];
int x = -1;
- for (char chr : shape.toCharArray()) tData[++x] = tItemDataMap.get(chr);
+ for (char chr : shape.toString().toCharArray()) tData[++x] = tItemDataMap.get(chr);
if (GT_Utility.arrayContainsNonNull(tData))
GT_OreDictUnificator.addItemData(aResult, new ItemData(tData));
}
@@ -1070,12 +1140,15 @@ public class GT_ModHandler {
if (aCheckForCollisions && tRemoveRecipe) {
ItemStack[] tRecipe = new ItemStack[9];
int x = -1;
- for (char chr : shape.toCharArray()) {
+ for (char chr : shape.toString().toCharArray()) {
tRecipe[++x] = tItemStackMap.get(chr);
if (tRecipe[x] != null && Items.feather.getDamage(tRecipe[x]) == W)
Items.feather.setDamage(tRecipe[x], 0);
}
- tThereWasARecipe = removeRecipe(tRecipe) != null || tThereWasARecipe;
+ if (tDoWeCareIfThereWasARecipe || !aBuffered)
+ tThereWasARecipe = removeRecipe(tRecipe) != null || tThereWasARecipe;
+ else
+ removeRecipeDelayed(tRecipe);
}
} catch (Throwable e) {
e.printStackTrace(GT_Log.err);
@@ -1083,10 +1156,14 @@ public class GT_ModHandler {
if (aResult == null || aResult.stackSize <= 0) return false;
- if (aRemoveAllOthersWithSameOutput || aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT || aRemoveAllOtherShapedsWithSameOutput || aRemoveAllOtherNativeRecipes)
- tThereWasARecipe = removeRecipeByOutput(aResult, !aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, aRemoveAllOtherShapedsWithSameOutput, aRemoveAllOtherNativeRecipes) || tThereWasARecipe;
-
- if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tThereWasARecipe) {
+ if (aRemoveAllOthersWithSameOutput || aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT || aRemoveAllOtherShapedsWithSameOutput || aRemoveAllOtherNativeRecipes) {
+ if(tDoWeCareIfThereWasARecipe || !aBuffered)
+ tThereWasARecipe = removeRecipeByOutput(aResult, !aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, aRemoveAllOtherShapedsWithSameOutput, aRemoveAllOtherNativeRecipes) || tThereWasARecipe;
+ else
+ removeRecipeByOutputDelayed(aResult);
+ }
+
+ if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tDoWeCareIfThereWasARecipe && !tThereWasARecipe) {
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
int tList_sS=tList.size();
for (int i = 0; i < tList_sS && !tThereWasARecipe; i++) {
@@ -1163,14 +1240,13 @@ public class GT_ModHandler {
} else if (tObject instanceof String) {
tRecipe[i] = GT_OreDictUnificator.getFirstOre(tObject, 1);
if (tRecipe[i] == null) break;
- }/* else if (tObject instanceof Boolean) {
- //
- } else {
- throw new IllegalArgumentException();
- }*/
+ }
i++;
}
- removeRecipe(tRecipe);
+ if (sBufferCraftingRecipes && aBuffered)
+ removeRecipeDelayed(tRecipe);
+ else
+ removeRecipe(tRecipe);
} catch (Throwable e) {
e.printStackTrace(GT_Log.err);
}
@@ -1212,14 +1288,8 @@ public class GT_ModHandler {
*/
public static ItemStack removeRecipe(ItemStack... aRecipe) {
if (aRecipe == null) return null;
- boolean temp = false;
- for (byte i = 0; i < aRecipe.length; i++) {
- if (aRecipe[i] != null) {
- temp = true;
- break;
- }
- }
- if (!temp) return null;
+ if (Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return null;
+
ItemStack rReturn = null;
InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
@Override
@@ -1242,6 +1312,53 @@ public class GT_ModHandler {
return rReturn;
}
+
+ public static void removeRecipeDelayed(ItemStack... aRecipe) {
+ if (!sBufferCraftingRecipes) {
+ removeRecipe(aRecipe);
+ return;
+ }
+
+ if (aRecipe == null) return;
+ if (Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return;
+
+ InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return false;
+ }
+ }, 3, 3);
+ for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
+ delayedRemovalByRecipe.add(aCrafting);
+ }
+
+ public static void bulkRemoveByRecipe(List<InventoryCrafting> toRemove) {
+ ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
+ GT_FML_LOGGER.info("BulkRemoveByRecipe: tList: " + tList.size() + " toRemove: " + toRemove.size() );
+
+ Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> {
+ if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false;
+ return toRemove.stream().anyMatch(aCrafting -> tRecipe.matches(aCrafting, DW));
+ }).collect(Collectors.toSet());
+
+ tList.removeIf(tListToRemove::contains);
+ }
+
+ public static boolean removeRecipeByOutputDelayed(ItemStack aOutput) {
+ if (sBufferCraftingRecipes)
+ return delayedRemovalByOutput.add(aOutput);
+ else
+ return removeRecipeByOutput(aOutput);
+ }
+
+ public static boolean removeRecipeByOutputDelayed (ItemStack aOutput, boolean aIgnoreNBT, boolean aNotRemoveShapelessRecipes, boolean aOnlyRemoveNativeHandlers) {
+ if (sBufferCraftingRecipes && (aIgnoreNBT && !aNotRemoveShapelessRecipes && !aOnlyRemoveNativeHandlers))
+ // Too lazy to handle deferred versions of the parameters that aren't used very often
+ return delayedRemovalByOutput.add(aOutput);
+ else
+ return removeRecipeByOutput(aOutput, aIgnoreNBT, aNotRemoveShapelessRecipes, aOnlyRemoveNativeHandlers);
+ }
+
public static boolean removeRecipeByOutput(ItemStack aOutput) {
return removeRecipeByOutput(aOutput, true, false, false);
}
@@ -1268,7 +1385,10 @@ public class GT_ModHandler {
if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue;
}
ItemStack tStack = tRecipe.getRecipeOutput();
- if ((!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT)) {
+ if (
+ (!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable())
+ && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT)
+ ) {
tList.remove(i--); tList_sS=tList.size();
rReturn = true;
}
@@ -1276,6 +1396,24 @@ public class GT_ModHandler {
return rReturn;
}
+ public static boolean bulkRemoveRecipeByOutput(List<ItemStack> toRemove) {
+ ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
+
+ Set<ItemStack> setToRemove = toRemove.parallelStream().map(GT_OreDictUnificator::get_nocopy).collect(Collectors.toSet());
+
+ GT_FML_LOGGER.info("BulkRemoveRecipeByOutput: tList: " + tList.size() + " setToRemove: " + setToRemove.size() );
+
+ Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> {
+ if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false;
+ if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) return false;
+ final ItemStack tStack = GT_OreDictUnificator.get_nocopy(tRecipe.getRecipeOutput());
+ return setToRemove.stream().anyMatch(aOutput -> GT_Utility.areStacksEqual(tStack, aOutput, true));
+ }).collect(Collectors.toSet());
+
+ tList.removeIf(tListToRemove::contains);
+ return true;
+ }
+
/**
* Checks all Crafting Handlers for Recipe Output
* Used for the Autocrafting Table
@@ -1286,8 +1424,8 @@ public class GT_ModHandler {
if (aWorld == null) aWorld = DW;
boolean temp = false;
- for (byte i = 0; i < aRecipe.length; i++) {
- if (aRecipe[i] != null) {
+ for (ItemStack itemStack : aRecipe) {
+ if (itemStack != null) {
temp = true;
break;
}
@@ -1353,15 +1491,8 @@ public class GT_ModHandler {
* Used for Recipe Detection.
*/
public static ItemStack getRecipeOutput(boolean aUncopiedStack, ItemStack... aRecipe) {
- if (aRecipe == null) return null;
- boolean temp = false;
- for (byte i = 0; i < aRecipe.length; i++) {
- if (aRecipe[i] != null) {
- temp = true;
- break;
- }
- }
- if (!temp) return null;
+ if (aRecipe == null || Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return null;
+
InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
@Override
public boolean canInteractWith(EntityPlayer var1) {
@@ -1370,15 +1501,17 @@ public class GT_ModHandler {
}, 3, 3);
for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
- for (int i = 0; i < tList.size(); i++) {
- temp = false;
+ boolean found = false;
+
+ for (IRecipe iRecipe : tList) {
+ found = false;
try {
- temp = tList.get(i).matches(aCrafting, DW);
+ found = iRecipe.matches(aCrafting, DW);
} catch (Throwable e) {
e.printStackTrace(GT_Log.err);
}
- if (temp) {
- ItemStack tOutput = aUncopiedStack ? tList.get(i).getRecipeOutput() : tList.get(i).getCraftingResult(aCrafting);
+ if (found) {
+ ItemStack tOutput = aUncopiedStack ? iRecipe.getRecipeOutput() : iRecipe.getCraftingResult(aCrafting);
if (tOutput == null || tOutput.stackSize <= 0) {
// Seriously, who would ever do that shit?
if (!GregTech_API.sPostloadFinished)
@@ -1595,7 +1728,7 @@ public class GT_ModHandler {
for (Entry<IRecipeInput, RecipeOutput> tEntry : aRecipeList.entrySet()) {
if (tEntry.getKey().matches(aInput)) {
if (tEntry.getKey().getAmount() <= aInput.stackSize) {
- ItemStack[] tList = tEntry.getValue().items.toArray(new ItemStack[tEntry.getValue().items.size()]);
+ ItemStack[] tList = tEntry.getValue().items.toArray(new ItemStack[0]);
if (tList.length == 0) break;
ItemStack[] rList = new ItemStack[aOutputSlots.length];
rRecipeMetaData.setTag("return", tEntry.getValue().metadata);
@@ -1917,6 +2050,10 @@ public class GT_ModHandler {
* Only adds the Recipe if it has an Output
*/
public static long ONLY_ADD_IF_RESULT_IS_NOT_NULL = B[12];
+ /**
+ * Don't remove shapeless recipes with this output
+ */
+ public static long DONT_REMOVE_SHAPELESS = B[13];
}
/**
diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
index 188af9cfaa..a45e002cfa 100644
--- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
+++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
@@ -13,10 +13,8 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import javax.annotation.Nullable;
+import java.util.*;
import java.util.Map.Entry;
import static gregtech.api.enums.GT_Values.*;
@@ -31,10 +29,10 @@ import static gregtech.api.enums.GT_Values.*;
* P.S. It is intended to be named "Unificator" and not "Unifier", because that sounds more awesome.
*/
public class GT_OreDictUnificator {
- private static final /*ConcurrentHash*/Map<String, ItemStack> sName2StackMap = new /*ConcurrentHash*/HashMap<String, ItemStack>();
- private static final /*ConcurrentHash*/Map<GT_ItemStack, ItemData> sItemStack2DataMap = new /*ConcurrentHash*/HashMap<GT_ItemStack, ItemData>();
- private static final /*ConcurrentHash*/Map<GT_ItemStack, List<ItemStack>> sUnificationTable = new /*ConcurrentHash*/HashMap<GT_ItemStack, List<ItemStack>>();
- private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>();
+ private static final Map<String, ItemStack> sName2StackMap = new HashMap<>();
+ private static final Map<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<>();
+ private static final Map<GT_ItemStack, List<ItemStack>> sUnificationTable = new HashMap<>();
+ private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<>();
public static volatile int VERSION = 509;
private static int isRegisteringOre = 0, isAddingOre = 0;
private static boolean mRunThroughTheList = true;
@@ -81,7 +79,7 @@ public class GT_OreDictUnificator {
if (GT_Utility.isStringInvalid(aName)) return null;
ItemStack tStack = sName2StackMap.get(aName.toString());
if (GT_Utility.isStackValid(tStack)) return GT_Utility.copyAmount(aAmount, tStack);
- return GT_Utility.copyAmount(aAmount, getOres(aName).toArray());
+ return GT_Utility.copyAmount(aAmount, getOresImmutable(aName).toArray());
}
public static ItemStack get(Object aName, long aAmount) {
@@ -158,6 +156,12 @@ public class GT_OreDictUnificator {
/** Doesn't copy the returned stack or set quantity. Be careful and do not mutate it;
* intended only to optimize comparisons */
+ public static ItemStack get_nocopy(ItemStack aStack) {
+ return get_nocopy(true, aStack);
+ }
+
+ /** Doesn't copy the returned stack or set quantity. Be careful and do not mutate it;
+ * intended only to optimize comparisons */
static ItemStack get_nocopy(boolean aUseBlackList, ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack)) return null;
ItemData tPrefixMaterial = getAssociation(aStack);
@@ -217,10 +221,8 @@ public class GT_OreDictUnificator {
ItemStack tStack1 = get(false, tStack0);
if (!GT_Utility.areStacksEqual(tStack0, tStack1)) {
GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1);
- List<ItemStack> list = sUnificationTable.get(tGTStack1);
- if (list == null)
- sUnificationTable.put(tGTStack1, list = new ArrayList<ItemStack>());
- if (!list.contains(tStack0))
+ List<ItemStack> list = sUnificationTable.computeIfAbsent(tGTStack1, k -> new ArrayList<>());
+ if (!list.contains(tStack0))
list.add(tStack0);
}
}
@@ -233,7 +235,7 @@ public class GT_OreDictUnificator {
aStacks = (ItemStack[]) obj;
else if (obj instanceof List) aStacks = (ItemStack[])
((List)obj).toArray(new ItemStack[0]);
- List<ItemStack> rList = new ArrayList<ItemStack>();
+ List<ItemStack> rList = new ArrayList<>();
for (ItemStack aStack : aStacks) {
rList.add(aStack);
List<ItemStack> tList = sUnificationTable.get(new GT_ItemStack(aStack));
@@ -309,7 +311,7 @@ public class GT_OreDictUnificator {
public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) {
if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false;
- for (ItemStack tOreStack : getOres(aName.toString()))
+ for (ItemStack tOreStack : getOresImmutable(aName.toString()))
if (GT_Utility.areStacksEqual(tOreStack, aStack, true)) return true;
return false;
}
@@ -338,10 +340,8 @@ public class GT_OreDictUnificator {
if (GT_Utility.isStringInvalid(tName))
return false;
- ArrayList<ItemStack> tList = getOres(tName);
-
- for (int i = 0; i < tList.size(); i++)
- if (GT_Utility.areStacksEqual(tList.get(i), aStack, true))
+ for (ItemStack itemStack : getOresImmutable(tName))
+ if (GT_Utility.areStacksEqual(itemStack, aStack, true))
return false;
isRegisteringOre++;
@@ -463,8 +463,18 @@ public class GT_OreDictUnificator {
*/
public static ArrayList<ItemStack> getOres(Object aOreName) {
String aName = aOreName == null ? E : aOreName.toString();
- ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ ArrayList<ItemStack> rList = new ArrayList<>();
if (GT_Utility.isStringValid(aName)) rList.addAll(OreDictionary.getOres(aName));
return rList;
}
+
+ /**
+ * Fast version of {@link #getOres(Object)},
+ * which doesn't call {@link System#arraycopy(Object, int, Object, int, int)} in {@link ArrayList#addAll}
+ */
+ public static List<ItemStack> getOresImmutable(@Nullable Object aOreName) {
+ String aName = aOreName == null ? E : aOreName.toString();
+
+ return GT_Utility.isStringValid(aName) ? Collections.unmodifiableList(OreDictionary.getOres(aName)) : Collections.emptyList();
+ }
}
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 537d92b365..9756a8199a 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -561,7 +561,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false);
public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false);
public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false);
-
+ public static final GT_Recipe_Map sDisassemblerRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.disassembler", "Disassembler", null, RES_PATH_GUI + "basicmachines/Disassembler", 1, 9, 1, 0, 1, E, 1, E, true, false);
public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true);
public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true);
public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true);
diff --git a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java
index e51c490519..f00fc7758e 100644
--- a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java
@@ -1,7 +1,7 @@
package gregtech.api.util;
import gregtech.api.interfaces.internal.IGT_CraftingRecipe;
-import gregtech.api.items.GT_MetaGenerated_Tool;
+import gregtech.api.objects.ReverseShapedRecipe;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.inventory.InventoryCrafting;
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRecipe {
- public final boolean mDismantleable, mRemovableByGT, mKeepingNBT;
+ public final boolean mRemovableByGT, mKeepingNBT;
private final Enchantment[] mEnchantmentsAdded;
private final int[] mEnchantmentLevelsAdded;
@@ -21,7 +21,9 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec
mEnchantmentLevelsAdded = aEnchantmentLevelsAdded;
mRemovableByGT = aRemovableByGT;
mKeepingNBT = aKeepingNBT;
- mDismantleable = aDismantleAble;
+ if (aDismantleAble) {
+ new ReverseShapedRecipe(aResult, aRecipe);
+ }
}
@Override
@@ -65,23 +67,6 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec
if (tCharge > 0) GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false);
}
- // Saving Ingredients inside the Item.
- if (mDismantleable) {
- NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound();
- if (rNBT == null) rNBT = new NBTTagCompound();
- for (int i = 0; i < 9; i++) {
- ItemStack tStack = aGrid.getStackInSlot(i);
- if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) {
- tStack = GT_Utility.copyAmount(1, tStack);
- if(GT_Utility.isStackValid(tStack)){
- GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
- tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));}
- }
- }
- rNBT.setTag("GT.CraftingComponents", tNBT);
- rStack.setTagCompound(rNBT);
- }
-
// Add Enchantments
for (int i = 0; i < mEnchantmentsAdded.length; i++)
GT_Utility.ItemNBT.addEnchantment(rStack, mEnchantmentsAdded[i], EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + mEnchantmentLevelsAdded[i]);
diff --git a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java
index 937ba0a837..fce135dfe6 100644
--- a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java
@@ -1,7 +1,7 @@
package gregtech.api.util;
import gregtech.api.interfaces.internal.IGT_CraftingRecipe;
-import gregtech.api.items.GT_MetaGenerated_Tool;
+import gregtech.api.objects.ReverseShapelessRecipe;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.inventory.InventoryCrafting;
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapelessOreRecipe;
public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_CraftingRecipe {
- public final boolean mDismantleable, mRemovableByGT, mKeepingNBT;
+ public final boolean /*mDismantleable,*/ mRemovableByGT, mKeepingNBT;
private final Enchantment[] mEnchantmentsAdded;
private final int[] mEnchantmentLevelsAdded;
@@ -21,7 +21,9 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft
mEnchantmentLevelsAdded = aEnchantmentLevelsAdded;
mRemovableByGT = aRemovableByGT;
mKeepingNBT = aKeepingNBT;
- mDismantleable = aDismantleAble;
+ if (aDismantleAble){
+ new ReverseShapelessRecipe(aResult, aRecipe);
+ }
}
@Override
@@ -66,20 +68,20 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft
}
// Saving Ingredients inside the Item.
- if (mDismantleable) {
- NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound();
- if (rNBT == null) rNBT = new NBTTagCompound();
- for (int i = 0; i < 9; i++) {
- ItemStack tStack = aGrid.getStackInSlot(i);
- if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) {
- tStack = GT_Utility.copyAmount(1, tStack);
- GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
- tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));
- }
- }
- rNBT.setTag("GT.CraftingComponents", tNBT);
- rStack.setTagCompound(rNBT);
- }
+// if (mDismantleable) {
+// NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound();
+// if (rNBT == null) rNBT = new NBTTagCompound();
+// for (int i = 0; i < 9; i++) {
+// ItemStack tStack = aGrid.getStackInSlot(i);
+// if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) {
+// tStack = GT_Utility.copyAmount(1, tStack);
+// GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
+// tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));
+// }
+// }
+// rNBT.setTag("GT.CraftingComponents", tNBT);
+// rStack.setTagCompound(rNBT);
+// }
// Add Enchantments
for (int i = 0; i < mEnchantmentsAdded.length; i++)
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 05e0874e7a..3055285ecf 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -1,6 +1,7 @@
package gregtech.api.util;
import cofh.api.transport.IItemDuct;
+import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import gregtech.api.GregTech_API;
@@ -14,6 +15,7 @@ import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.*;
import gregtech.api.items.GT_EnergyArmor_Item;
import gregtech.api.items.GT_Generic_Item;
+import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.net.GT_Packet_Sound;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gregtech.api.objects.GT_ItemStack;
@@ -90,12 +92,12 @@ public class GT_Utility {
/**
* Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there.
*/
- private static final List<FluidContainerData> sFluidContainerList = new ArrayList<FluidContainerData>();
- private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<GT_ItemStack, FluidContainerData>();
- private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<GT_ItemStack, Map<Fluid, FluidContainerData>>();
+ private static final List<FluidContainerData> sFluidContainerList = new ArrayList<>();
+ private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<>();
+ private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<>();
public static volatile int VERSION = 509;
public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false;
- public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<GT_PlayedSound, Integer>();
+ public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<>();
private static int sBookCount = 0;
public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000");
@@ -250,8 +252,7 @@ public class GT_Utility {
Field[] var3 = EntityLiving.class.getDeclaredFields();
int var4 = var3.length;
- for (int var5 = 0; var5 < var4; ++var5) {
- Field var6 = var3[var5];
+ for (Field var6 : var3) {
if (var6.getType() == HashMap.class) {
tPotionHashmap = var6;
tPotionHashmap.setAccessible(true);
@@ -260,7 +261,7 @@ public class GT_Utility {
}
if (tPotionHashmap != null)
- return ((HashMap) tPotionHashmap.get(aPlayer)).get(Integer.valueOf(aPotionIndex)) != null;
+ return ((HashMap) tPotionHashmap.get(aPlayer)).get(aPotionIndex) != null;
} catch (Throwable e) {
if (D1) e.printStackTrace(GT_Log.err);
}
@@ -279,8 +280,7 @@ public class GT_Utility {
Field[] var3 = EntityLiving.class.getDeclaredFields();
int var4 = var3.length;
- for (int var5 = 0; var5 < var4; ++var5) {
- Field var6 = var3[var5];
+ for (Field var6 : var3) {
if (var6.getType() == HashMap.class) {
tPotionHashmap = var6;
tPotionHashmap.setAccessible(true);
@@ -288,7 +288,7 @@ public class GT_Utility {
}
}
- if (tPotionHashmap != null) ((HashMap) tPotionHashmap.get(aPlayer)).remove(Integer.valueOf(aPotionIndex));
+ if (tPotionHashmap != null) ((HashMap) tPotionHashmap.get(aPlayer)).remove(aPotionIndex);
} catch (Throwable e) {
if (D1) e.printStackTrace(GT_Log.err);
}
@@ -393,16 +393,16 @@ public class GT_Utility {
if (aTileEntity2 != null) {
checkAvailabilities();
if (TE_CHECK && aTileEntity2 instanceof IItemDuct) {
- for (int i = 0; i < aGrabSlots.length; i++) {
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
- if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
- ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
+ for (int aGrabSlot : aGrabSlots) {
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) {
+ if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) {
+ ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot));
ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack));
byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize));
if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) {
//((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack), F);
- aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
+ aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount);
aTileEntity1.markDirty();
return tMovedItemCount;
}
@@ -413,15 +413,15 @@ public class GT_Utility {
return 0;
}
if (BC_CHECK && aTileEntity2 instanceof buildcraft.api.transport.IPipeTile) {
- for (int i = 0; i < aGrabSlots.length; i++) {
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
- if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
- ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
+ for (int aGrabSlot : aGrabSlots) {
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) {
+ if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) {
+ ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot));
byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copy(tStack), false, ForgeDirection.getOrientation(aPutTo));
if (tMovedItemCount >= Math.max(aMinMoveAtOnce, aMinTargetStackSize)) {
tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyAmount(tMovedItemCount, tStack), true, ForgeDirection.getOrientation(aPutTo)));
- aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
+ aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount);
aTileEntity1.markDirty();
return tMovedItemCount;
}
@@ -437,15 +437,15 @@ public class GT_Utility {
if (aTileEntity1 instanceof TileEntity && tDirection != ForgeDirection.UNKNOWN && tDirection.getOpposite() == ForgeDirection.getOrientation(aPutTo)) {
int tX = ((TileEntity) aTileEntity1).xCoord + tDirection.offsetX, tY = ((TileEntity) aTileEntity1).yCoord + tDirection.offsetY, tZ = ((TileEntity) aTileEntity1).zCoord + tDirection.offsetZ;
if (!hasBlockHitBox(((TileEntity) aTileEntity1).getWorldObj(), tX, tY, tZ) && dropItem) {
- for (int i = 0; i < aGrabSlots.length; i++) {
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
- if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
- ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
+ for (int aGrabSlot : aGrabSlots) {
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) {
+ if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) {
+ ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot));
EntityItem tEntity = new EntityItem(((TileEntity) aTileEntity1).getWorldObj(), tX + 0.5, tY + 0.5, tZ + 0.5, tStack);
tEntity.motionX = tEntity.motionY = tEntity.motionZ = 0;
((TileEntity) aTileEntity1).getWorldObj().spawnEntityInWorld(tEntity);
- aTileEntity1.decrStackSize(aGrabSlots[i], tStack.stackSize);
+ aTileEntity1.decrStackSize(aGrabSlot, tStack.stackSize);
aTileEntity1.markDirty();
return (byte) tStack.stackSize;
}
@@ -479,11 +479,10 @@ public class GT_Utility {
if (tStack3 != null) {
if (tStack2 == null) {
aTileEntity2.setInventorySlotContents(aPutTo, copy(tStack3));
- aTileEntity2.markDirty();
} else {
tStack2.stackSize += tStack3.stackSize;
- aTileEntity2.markDirty();
}
+ aTileEntity2.markDirty();
return (byte) tStack3.stackSize;
}
}
@@ -537,24 +536,46 @@ public class GT_Utility {
public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aMaxStackTransfer, boolean aDoCheckChests) {
if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce || aMaxStackTransfer == 0)
return 0;
- int tGrabInventorySize = aTileEntity1.getSizeInventory();
+
+ int[] tGrabSlots = null;
+ if (aTileEntity1 instanceof ISidedInventory)
+ tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom);
+ if (tGrabSlots == null) {
+ tGrabSlots = new int[aTileEntity1.getSizeInventory()];
+ for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i;
+ }
+
+
+
+
+ int tGrabInventorySize = tGrabSlots.length;
if (aTileEntity2 instanceof IInventory)
{
+ int[] tPutSlots = null;
+ if (aTileEntity2 instanceof ISidedInventory)
+ tPutSlots = ((ISidedInventory) aTileEntity2).getAccessibleSlotsFromSide(aPutTo);
+
+ if (tPutSlots == null) {
+ tPutSlots = new int[((IInventory) aTileEntity2).getSizeInventory()];
+ for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i;
+ }
+
IInventory tPutInventory = (IInventory) aTileEntity2;
- int tPutInventorySize = tPutInventory.getSizeInventory();
+ int tPutInventorySize = tPutSlots.length;
int tFirstsValidSlot = 0,tStacksMoved = 0,tTotalItemsMoved = 0;
- for (int tGrabSlot = 0;tGrabSlot<tGrabInventorySize;tGrabSlot++)
- {
+ for (int grabSlot : tGrabSlots) {
//ItemStack tInventoryStack : mInventory
int tMovedItems;
do {
- tMovedItems = 0;
+ int tGrabSlot = grabSlot;
+ tMovedItems = 0;
ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlot);
if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter) &&
- (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) {
+ (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) {
int tStackSize = tGrabStack.stackSize;
-
- for (int tPutSlot = tFirstsValidSlot; tPutSlot < tPutInventorySize; tPutSlot++) {
+
+ for (int tPutSlotIndex = tFirstsValidSlot; tPutSlotIndex < tPutInventorySize; tPutSlotIndex++) {
+ int tPutSlot = tPutSlots[tPutSlotIndex];
if (isAllowedToPutIntoSlot(tPutInventory, tPutSlot, aPutTo, tGrabStack, (byte) 64)) {
int tMoved = moveStackFromSlotAToSlotB(aTileEntity1, tPutInventory, tGrabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItems), aMinMoveAtOnce);
tTotalItemsMoved += tMoved;
@@ -568,7 +589,7 @@ public class GT_Utility {
return tTotalItemsMoved;
}
}
- } while (tGrabInventorySize == 2 && tMovedItems > 0); //to suport draweres and barrels
+ } while (tMovedItems > 0); //suport inventorys thgat store motre then a stack in a aslot
}
if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) {
TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1;
@@ -609,10 +630,6 @@ public class GT_Utility {
}
//there should be a function to transfer more then 1 stack in a pipe
//ut i dont see any ways to improve it too much work for what it is worth
- int[] tGrabSlots = new int[tGrabInventorySize];
- for (int i = 0; i < tGrabInventorySize; i++) {
- tGrabSlots[i] = i;
- }
int tTotalItemsMoved = 0;
for (int i = 0; i < tGrabInventorySize; i++) {
int tMoved = moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests);
@@ -661,21 +678,21 @@ public class GT_Utility {
for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i;
}
- for (int i = 0; i < tGrabSlots.length; i++) {
- byte tMovedItemCount = 0;
- ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlots[i]);
+ for (int tGrabSlot : tGrabSlots) {
+ byte tMovedItemCount = 0;
+ ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlot);
if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter)) {
- if (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, tGrabStack)) {
- for (int j = 0; j < tPutSlots.length; j++) {
- if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, tGrabStack, aMaxTargetStackSize)) {
- tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce);
- if (tMovedItemCount >= aMaxMoveAtOnce ||(tMovedItemCount > 0 && aMaxTargetStackSize < 64))
- return tMovedItemCount;
+ if (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack)) {
+ for (int tPutSlot : tPutSlots) {
+ if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlot, aPutTo, tGrabStack, aMaxTargetStackSize)) {
+ tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce);
+ if (tMovedItemCount >= aMaxMoveAtOnce || (tMovedItemCount > 0 && aMaxTargetStackSize < 64))
+ return tMovedItemCount;
}
}
}
}
- if (tMovedItemCount > 0) return tMovedItemCount;
+ if (tMovedItemCount > 0) return tMovedItemCount;
}
if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) {
@@ -733,11 +750,11 @@ public class GT_Utility {
}
if (aTileEntity2 instanceof IInventory) {
- for (int i = 0; i < tGrabSlots.length; i++) {
- if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlots[i], aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]))) {
- if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, aPutTo, (byte) 6, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) {
- byte tMovedItemCount = moveStackFromSlotAToSlotB((IInventory) aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
+ for (int tGrabSlot : tGrabSlots) {
+ if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlot, aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot))) {
+ if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, aPutTo, (byte) 6, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), aMaxTargetStackSize)) {
+ byte tMovedItemCount = moveStackFromSlotAToSlotB((IInventory) aTileEntity1, (IInventory) aTileEntity2, tGrabSlot, aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
if (tMovedItemCount > 0) return tMovedItemCount;
}
}
@@ -829,7 +846,7 @@ public class GT_Utility {
public static boolean listContainsItem(Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) {
if (aStack == null || aStack.stackSize < 1) return false;
if (aList == null) return aTIfListEmpty;
- while (aList.contains(null)) aList.remove(null);
+ aList.removeIf(Objects::isNull);
if (aList.size() < 1) return aTIfListEmpty;
Iterator<ItemStack> tIterator = aList.iterator();
ItemStack tStack = null;
@@ -859,7 +876,9 @@ public class GT_Utility {
}
public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) {
- return aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem() && (aIgnoreNBT || ((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound()))) && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W);
+ return aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem()
+ && (aIgnoreNBT || (((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound()))))
+ && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W);
}
public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2) {
@@ -890,7 +909,7 @@ public class GT_Utility {
sFilledContainerToData.put(new GT_ItemStack(tData.filledContainer), tData);
Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer));
if (tFluidToContainer == null) {
- sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
+ sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<>());
GregTech_API.sFluidMappings.add(tFluidToContainer);
}
tFluidToContainer.put(tData.fluid.getFluid(), tData);
@@ -902,7 +921,7 @@ public class GT_Utility {
sFilledContainerToData.put(new GT_ItemStack(aData.filledContainer), aData);
Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aData.emptyContainer));
if (tFluidToContainer == null) {
- sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
+ sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<>());
GregTech_API.sFluidMappings.add(tFluidToContainer);
}
tFluidToContainer.put(aData.fluid.getFluid(), aData);
@@ -1003,7 +1022,7 @@ public class GT_Utility {
return copyMetaData(Items.feather.getDamage(aStack) + 1, aStack);
return null;
}
-
+
public static synchronized boolean removeIC2BottleRecipe(ItemStack aContainer, ItemStack aInput, Map<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> aRecipeList, ItemStack aOutput){
if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false;
boolean rReturn = false;
@@ -1044,11 +1063,27 @@ public class GT_Utility {
return rReturn;
}
+ public static synchronized void bulkRemoveSimpleIC2MachineRecipe(Map<ItemStack, ItemStack> toRemove, Map<IRecipeInput, RecipeOutput> aRecipeList) {
+ if (aRecipeList == null || aRecipeList.isEmpty()) return;
+ toRemove.entrySet().removeIf(aEntry -> (isStackInvalid(aEntry.getKey()) && isStackInvalid(aEntry.getValue())));
+ final Map<ItemStack, ItemStack> finalToRemove = Maps.transformValues(toRemove, GT_OreDictUnificator::get_nocopy);
+
+ aRecipeList.entrySet().removeIf(tEntry -> finalToRemove.entrySet().stream().anyMatch(aEntry -> {
+ final ItemStack aInput = aEntry.getKey(), aOutput = aEntry.getValue();
+ final List<ItemStack> tList = tEntry.getValue().items;
+
+ if (tList == null) return false;
+ if (aInput != null && !tEntry.getKey().matches(aInput)) return false;
+
+ return tList.stream().anyMatch(tOutput -> (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)));
+ }));
+ }
+
public static boolean addSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, NBTTagCompound aNBT, Object... aOutput) {
if (isStackInvalid(aInput) || aOutput.length == 0 || aRecipeList == null) return false;
ItemData tOreName = GT_OreDictUnificator.getAssociation(aInput);
- for (int i = 0; i < aOutput.length; i++) {
- if (aOutput[i] == null) {
+ for (Object o : aOutput) {
+ if (o == null) {
GT_FML_LOGGER.info("EmptyIC2Output!" + aInput.getUnlocalizedName());
return false;
}
@@ -1183,15 +1218,15 @@ public class GT_Utility {
}
public static <T> ArrayList<T> getArrayListWithoutNulls(T... aArray) {
- if (aArray == null) return new ArrayList<T>();
- ArrayList<T> rList = new ArrayList<T>(Arrays.asList(aArray));
+ if (aArray == null) return new ArrayList<>();
+ ArrayList<T> rList = new ArrayList<>(Arrays.asList(aArray));
for (int i = 0; i < rList.size(); i++) if (rList.get(i) == null) rList.remove(i--);
return rList;
}
public static <T> ArrayList<T> getArrayListWithoutTrailingNulls(T... aArray) {
- if (aArray == null) return new ArrayList<T>();
- ArrayList<T> rList = new ArrayList<T>(Arrays.asList(aArray));
+ if (aArray == null) return new ArrayList<>();
+ ArrayList<T> rList = new ArrayList<>(Arrays.asList(aArray));
for (int i = rList.size() - 1; i >= 0 && rList.get(i) == null; ) rList.remove(i--);
return rList;
}
@@ -1662,8 +1697,7 @@ public class GT_Utility {
* re-maps all Keys of a Map after the Keys were weakened.
*/
public static <X, Y> Map<X, Y> reMap(Map<X, Y> aMap) {
- Map<X, Y> tMap = new /*Concurrent*/HashMap<X, Y>();
- tMap.putAll(aMap);
+ Map<X, Y> tMap = new HashMap<>(aMap);
aMap.clear();
aMap.putAll(tMap);
return aMap;
@@ -1673,14 +1707,9 @@ public class GT_Utility {
* Why the fuck do neither Java nor Guava have a Function to do this?
*/
public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesAcending(Map<X, Y> aMap) {
- List<Map.Entry<X, Y>> tEntrySet = new LinkedList<Map.Entry<X, Y>>(aMap.entrySet());
- Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() {
- @Override
- public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) {
- return aValue1.getValue().compareTo(aValue2.getValue());
- }
- });
- LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
+ List<Map.Entry<X, Y>> tEntrySet = new LinkedList<>(aMap.entrySet());
+ tEntrySet.sort(Entry.comparingByValue());
+ LinkedHashMap<X, Y> rMap = new LinkedHashMap<>();
for (Map.Entry<X, Y> tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue());
return rMap;
}
@@ -1689,14 +1718,11 @@ public class GT_Utility {
* Why the fuck do neither Java nor Guava have a Function to do this?
*/
public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesDescending(Map<X, Y> aMap) {
- List<Map.Entry<X, Y>> tEntrySet = new LinkedList<Map.Entry<X, Y>>(aMap.entrySet());
- Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() {
- @Override
- public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) {
- return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO
- }
+ List<Map.Entry<X, Y>> tEntrySet = new LinkedList<>(aMap.entrySet());
+ tEntrySet.sort((aValue1, aValue2) -> {
+ return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO
});
- LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
+ LinkedHashMap<X, Y> rMap = new LinkedHashMap<>();
for (Map.Entry<X, Y> tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue());
return rMap;
}
@@ -1723,7 +1749,7 @@ public class GT_Utility {
if(aDimensionID<=1 && aDimensionID>=-1 && !GregTech_API.sDimensionalList.contains(aDimensionID)) return true;
return !GregTech_API.sDimensionalList.contains(aDimensionID) && DimensionManager.isDimensionRegistered(aDimensionID);
}
-
+
//public static boolean isRealDimension(int aDimensionID) {
// try {
// if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("com.xcompwiz.mystcraft"))
@@ -1737,7 +1763,7 @@ public class GT_Utility {
// } catch (Throwable e) {/*Do nothing*/}
// return GregTech_API.sDimensionalList.contains(aDimensionID);
//}
-
+
public static boolean moveEntityToDimensionAtCoords(Entity entity, int aDimension, double aX, double aY, double aZ) {
//Credit goes to BrandonCore Author :!:
@@ -1836,7 +1862,7 @@ public class GT_Utility {
public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) {
if (aList == null) return 0;
- ArrayList<String> tList = new ArrayList<String>();
+ ArrayList<String> tList = new ArrayList<>();
int rEUAmount = 0;
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
@@ -2021,7 +2047,7 @@ public class GT_Utility {
if (D1) e.printStackTrace(GT_Log.err);
}
}
-
+
if (aPlayer.capabilities.isCreativeMode) {
FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ));//-# to only read
if (tFluid!=null)
@@ -2176,16 +2202,10 @@ public class GT_Utility {
public static ArrayList<String> sortByValueToList( Map<String, Integer> map ) {
List<Map.Entry<String, Integer>> list =
- new LinkedList<Map.Entry<String, Integer>>( map.entrySet() );
- Collections.sort( list, new Comparator<Map.Entry<String, Integer>>()
- {
- public int compare( Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2 )
- {
- return o2.getValue() - o1.getValue();
- }
- } );
+ new LinkedList<>(map.entrySet());
+ list.sort((o1, o2) -> o2.getValue() - o1.getValue());
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<String> result = new ArrayList<>();
for (Map.Entry<String, Integer> e : list)
result.add(e.getKey());
return result;
@@ -2199,7 +2219,7 @@ public class GT_Utility {
}
public static ItemStack getIntegratedCircuit(int config){
- return ItemList.Circuit_Integrated.getWithDamage(0, config, new Object[0]);
+ return ItemList.Circuit_Integrated.getWithDamage(0, config);
}
public static float getBlockHardnessAt(World aWorld, int aX, int aY, int aZ) {
@@ -2242,7 +2262,7 @@ public class GT_Utility {
aStack.setTagCompound(null);
return;
}
- ArrayList<String> tTagsToRemove = new ArrayList<String>();
+ ArrayList<String> tTagsToRemove = new ArrayList<>();
for (Object tKey : aNBT.func_150296_c()) {
NBTBase tValue = aNBT.getTag((String) tKey);
if (tValue == null || (tValue instanceof NBTPrimitive && ((NBTPrimitive) tValue).func_150291_c() == 0) || (tValue instanceof NBTTagString && isStringInvalid(((NBTTagString) tValue).func_150285_a_())))
@@ -2315,13 +2335,13 @@ public class GT_Utility {
public static void setProspectionData(ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String... aOres) {
NBTTagCompound tNBT = getNBT(aStack);
- String tData = aX + "," + aY + "," + aZ + "," + aDim + ",";
+ StringBuilder tData = new StringBuilder(aX + "," + aY + "," + aZ + "," + aDim + ",");
if (aFluid!=null)
- tData += (aFluid.amount) + "," + aFluid.getLocalizedName() + ",";//TODO CHECK IF THAT /5000 is needed (Not needed)
+ tData.append(aFluid.amount).append(",").append(aFluid.getLocalizedName()).append(",");//TODO CHECK IF THAT /5000 is needed (Not needed)
for (String tString : aOres) {
- tData += tString + ",";
+ tData.append(tString).append(",");
}
- tNBT.setString("prospection", tData);
+ tNBT.setString("prospection", tData.toString());
setNBT(aStack, tNBT);
}
@@ -2336,7 +2356,7 @@ public class GT_Utility {
setBookTitle(aStack, "Raw Prospection Data");
NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack);
-
+
tNBT.setByte("prospection_tier", aTier);
tNBT.setString("prospection_pos", "Dim: " + aDim + "\nX: " + aX + " Y: " + aY + " Z: " + aZ);
@@ -2345,32 +2365,32 @@ public class GT_Utility {
tNBT.setString("prospection_ores", joinListToString(aOres));
// oils
- ArrayList<String> tOilsTransformed = new ArrayList<String>(aOils.size());
+ ArrayList<String> tOilsTransformed = new ArrayList<>(aOils.size());
for (String aStr : aOils) {
String[] aStats = aStr.split(",");
tOilsTransformed.add(aStats[0] + ": " + aStats[1] + "L " + aStats[2]);
}
-
+
tNBT.setString("prospection_oils", joinListToString(tOilsTransformed));
String tOilsPosStr = "X: " + Math.floorDiv(aX, 16*8)*16*8 + " Z: " + Math.floorDiv(aZ, 16*8)*16*8 + "\n";
int xOff = aX - Math.floorDiv(aX, 16*8)*16*8;
xOff = xOff/16;
int xOffRemain = 7 - xOff;
-
+
int zOff = aZ - Math.floorDiv(aZ, 16*8)*16*8;
zOff = zOff/16;
int zOffRemain = 7 - zOff;
-
+
for( ; zOff > 0; zOff-- ) {
tOilsPosStr = tOilsPosStr.concat("--------\n");
}
for( ; xOff > 0; xOff-- ) {
tOilsPosStr = tOilsPosStr.concat("-");
}
-
+
tOilsPosStr = tOilsPosStr.concat("P");
-
+
for( ; xOffRemain > 0; xOffRemain-- ) {
tOilsPosStr = tOilsPosStr.concat("-");
}
@@ -2397,14 +2417,13 @@ public class GT_Utility {
if (tDataArray.length > 6) {
tNBT.setString("author", " Dim: " + tDataArray[3] + "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2]);
NBTTagList tNBTList = new NBTTagList();
- String tOres = " Prospected Ores: ";
+ StringBuilder tOres = new StringBuilder(" Prospected Ores: ");
for (int i = 6; tDataArray.length > i; i++) {
- tOres += (tDataArray[i] + " ");
+ tOres.append(tDataArray[i]).append(" ");
}
tNBTList.appendTag(new NBTTagString("Tier " + tTier + " Prospecting Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres));
tNBT.setTag("pages", tNBTList);
}
- setNBT(aStack, tNBT);
} else { // advanced prospection data
String tPos = tNBT.getString("prospection_pos");
String tRadius = tNBT.getString("prospection_radius");
@@ -2425,11 +2444,11 @@ public class GT_Utility {
+ "Location is center of orevein\n\n"
+ "Check NEI to confirm orevein type";
tNBTList.appendTag(new NBTTagString(tPageText));
-
+
if (tOres != null)
fillBookWithList(tNBTList, "Ores Found %s\n\n", "\n", 7, tOres);
-
+
if (tOils != null)
fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils);
@@ -2447,31 +2466,31 @@ public class GT_Utility {
tOilsPosStr + "\n" +
"P - Prospector in 8x8 field";
tNBTList.appendTag(new NBTTagString(tPageText));
-
+
tNBT.setString("author", tPos.replace("\n"," "));
tNBT.setTag("pages", tNBTList);
- setNBT(aStack, tNBT);
}
+ setNBT(aStack, tNBT);
}
public static void fillBookWithList(NBTTagList aBook, String aPageHeader, String aListDelimiter, int aItemsPerPage, String[] list) {
String aPageFormatter = " %d/%d";
int tTotalPages = list.length / aItemsPerPage + (list.length % aItemsPerPage > 0 ? 1 : 0);
int tPage = 0;
- String tPageText;
+ StringBuilder tPageText;
do {
- tPageText = "";
+ tPageText = new StringBuilder();
for (int i = tPage*aItemsPerPage; i < (tPage+1)*aItemsPerPage && i < list.length; i += 1)
- tPageText += (tPageText.isEmpty() ? "" : aListDelimiter) + list[i];
+ tPageText.append((tPageText.length() == 0) ? "" : aListDelimiter).append(list[i]);
- if (!tPageText.isEmpty()) {
+ if (tPageText.length() > 0) {
String tPageCounter = tTotalPages > 1 ? String.format(aPageFormatter, tPage + 1, tTotalPages) : "";
NBTTagString tPageTag = new NBTTagString(String.format(aPageHeader, tPageCounter) + tPageText);
aBook.appendTag(tPageTag);
}
++tPage;
- } while (!tPageText.isEmpty());
+ } while (tPageText.length() > 0);
}
public static void addEnchantment(ItemStack aStack, Enchantment aEnchantment, int aLevel) {
@@ -2587,11 +2606,11 @@ public class GT_Utility {
}
public static boolean isPartOfMaterials(ItemStack aStack, Materials aMaterials){
- return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial.equals(aMaterials) : false;
+ return GT_OreDictUnificator.getAssociation(aStack) != null && GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial.equals(aMaterials);
}
public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix){
- return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix) : false;
+ return GT_OreDictUnificator.getAssociation(aStack) != null && GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix);
}
public static boolean isOre(ItemStack aStack) {
for (int id: OreDictionary.getOreIDs(aStack)) {
@@ -2601,4 +2620,152 @@ public class GT_Utility {
return false;
}
+ public static Optional<GT_Recipe> reverseShapelessRecipe(ItemStack output, Object... aRecipe) {
+ if (output == null) {
+ return Optional.empty();
+ }
+
+ List<ItemStack> inputs = new ArrayList<>();
+
+ for (Object o : aRecipe) {
+ if (o instanceof ItemStack) {
+ ItemStack toAdd = ((ItemStack) o).copy();
+ inputs.add(toAdd);
+ } else if (o instanceof String) {
+ ItemStack stack = GT_OreDictUnificator.get(o, 1);
+ if (stack == null) {
+ Optional<ItemStack> oStack = OreDictionary.getOres((String) o)
+ .stream()
+ .findAny();
+ if (oStack.isPresent()) {
+ ItemStack copy = oStack.get().copy();
+ inputs.add(copy);
+ }
+ } else {
+ ItemStack copy = stack.copy();
+ inputs.add(copy);
+ }
+ } else if (o instanceof Item)
+ inputs.add(new ItemStack((Item) o));
+ else if (o instanceof Block)
+ inputs.add(new ItemStack((Block) o));
+ else
+ throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output);
+ }
+
+ inputs.removeIf(x -> x.getItem() instanceof GT_MetaGenerated_Tool);
+
+ return Optional.of(
+ new GT_Recipe(
+ false,
+ new ItemStack[]{output},
+ inputs.toArray(new ItemStack[0]),
+ null, null,
+ null, null,
+ 300, 30, 0
+ )
+ );
+ }
+
+
+ public static Optional<GT_Recipe> reverseShapedRecipe(ItemStack output, Object... aRecipe) {
+ if (output == null) {
+// System.out.println("Null Recipe detected!");
+ return Optional.empty();
+ }
+// System.out.println("Registering Reverse Recipe for: " + GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(output) + "|" + output.getUnlocalizedName()));
+// for (Object o : aRecipe) {
+// String toPrint;
+// if (o instanceof String) {
+// toPrint = (String) o;
+// toPrint += " String";
+// } else if (o instanceof ItemStack) {
+// toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName((ItemStack) o));
+// toPrint += " ItemStack";
+// } else if (o instanceof List) {
+// toPrint = String.join(", ", ((List<String>) o));
+// toPrint += " List<String>";
+// } else if (o instanceof Item) {
+// toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Item) o)));
+// toPrint += " Item";
+// } else if (o instanceof Block) {
+// toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Block) o)));
+// toPrint += " Block";
+// } else if (o != null) {
+// toPrint = o.toString();
+// toPrint += " Other";
+// } else {
+// toPrint = "NULL";
+// }
+// System.out.println(toPrint);
+// }
+ Map<Object, Integer> recipeAsMap = new HashMap<>();
+ Map<Character, Object> ingridients = new HashMap<>();
+ Map<Character, Integer> amounts = new HashMap<>();
+ boolean startFound = false;
+ for (int i = 0, aRecipeLength = aRecipe.length; i < aRecipeLength; i++) {
+ Object o = aRecipe[i];
+ if (!startFound) {
+ if (o instanceof String) {
+ for (Character c : ((String) o).toCharArray())
+ amounts.merge(c, 1, (a, b) -> ++a);
+ } else if (o instanceof Character)
+ startFound = true;
+ } else if (!(o instanceof Character))
+ ingridients.put((Character) aRecipe[i - 1], o);
+ }
+ for (Map.Entry<Character, Object> characterObjectEntry : ingridients.entrySet()) {
+ for (Map.Entry<Character, Integer> characterIntegerEntry : amounts.entrySet()) {
+ if (characterObjectEntry.getKey() != characterIntegerEntry.getKey())
+ continue;
+ recipeAsMap.put(characterObjectEntry.getValue(), characterIntegerEntry.getValue());
+ }
+ }
+ List<ItemStack> inputs = new ArrayList<>();
+
+ for (Map.Entry<Object, Integer> o : recipeAsMap.entrySet()) {
+ if (o.getKey() instanceof ItemStack) {
+ ItemStack toAdd = ((ItemStack) o.getKey()).copy();
+ toAdd.stackSize = o.getValue();
+ inputs.add(toAdd);
+ } else if (o.getKey() instanceof String) {
+// System.out.println("Found OreDictEntry: "+o.getKey());
+ ItemStack stack = GT_OreDictUnificator.get(o.getKey(), o.getValue());
+ if (stack == null) {
+ Optional<ItemStack> oStack = OreDictionary.getOres((String) o.getKey())
+ .stream()
+ .findAny();
+ if (oStack.isPresent()) {
+ ItemStack copy = oStack.get().copy();
+ copy.stackSize = o.getValue();
+ inputs.add(copy);
+ }
+// else
+// System.out.println("OreDict Entry "+o.getKey()+" couldn't be found!");
+ } else {
+ ItemStack copy = stack.copy();
+ copy.stackSize = o.getValue();
+ inputs.add(copy);
+ }
+ } else if (o.getKey() instanceof Item)
+ inputs.add(new ItemStack((Item) o.getKey(), o.getValue()));
+ else if (o.getKey() instanceof Block)
+ inputs.add(new ItemStack((Block) o.getKey(), o.getValue()));
+ else
+ throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output);
+ }
+
+ inputs.removeIf(x -> x.getItem() instanceof GT_MetaGenerated_Tool);
+
+ return Optional.of(
+ new GT_Recipe(
+ false,
+ new ItemStack[]{output},
+ inputs.toArray(new ItemStack[0]),
+ null, null,
+ null, null,
+ 300, 30, 0
+ )
+ );
+ }
}