aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api
diff options
context:
space:
mode:
authorJohann Bernhardt <johann.bernhardt@tum.de>2021-11-24 11:02:48 +0100
committerJohann Bernhardt <johann.bernhardt@tum.de>2021-11-24 11:02:48 +0100
commit68ae7b8b23a672e2d16d57f84424e02f41db85e6 (patch)
tree7372767acad1380550af443d434637adccca6ff2 /src/main/java/gregtech/api
parent4253f35d24f6973143dbbaab438acd5dd07bc9c9 (diff)
parente6a9dd1221c2f822383000f7dbf4481e1f768b84 (diff)
downloadGT5-Unofficial-68ae7b8b23a672e2d16d57f84424e02f41db85e6.tar.gz
GT5-Unofficial-68ae7b8b23a672e2d16d57f84424e02f41db85e6.tar.bz2
GT5-Unofficial-68ae7b8b23a672e2d16d57f84424e02f41db85e6.zip
Merge remote-tracking branch 'origin/experimental' into unify-build-script
# Conflicts: # .gitignore # build.gradle # build.properties
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r--src/main/java/gregtech/api/GregTech_API.java45
-rw-r--r--src/main/java/gregtech/api/enums/GT_Values.java4
-rw-r--r--src/main/java/gregtech/api/enums/Materials.java43
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java12
-rw-r--r--src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java2
-rw-r--r--src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java8
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java28
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java218
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java165
-rw-r--r--src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java20
-rw-r--r--src/main/java/gregtech/api/metatileentity/MetaTileEntity.java4
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java15
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java22
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java16
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java6
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java2
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java10
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java4
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java2
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java36
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java30
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java24
-rw-r--r--src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java3
-rw-r--r--src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java46
-rw-r--r--src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java113
-rw-r--r--src/main/java/gregtech/api/objects/GT_UO_Dimension.java7
-rw-r--r--src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java440
-rw-r--r--src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java437
-rw-r--r--src/main/java/gregtech/api/util/GT_CoverBehavior.java202
-rw-r--r--src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java482
-rw-r--r--src/main/java/gregtech/api/util/GT_LanguageManager.java2
-rw-r--r--src/main/java/gregtech/api/util/GT_ModHandler.java2
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java274
-rw-r--r--src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java284
-rw-r--r--src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java212
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java70
-rw-r--r--src/main/java/gregtech/api/util/ISerializableObject.java150
37 files changed, 3072 insertions, 368 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java
index fe48f6506f..ff875c4884 100644
--- a/src/main/java/gregtech/api/GregTech_API.java
+++ b/src/main/java/gregtech/api/GregTech_API.java
@@ -113,7 +113,7 @@ public class GregTech_API {
/**
* The List of Cover Behaviors for the Covers
*/
- public static final Map<GT_ItemStack, GT_CoverBehavior> sCoverBehaviors = new ConcurrentHashMap<>();
+ public static final Map<GT_ItemStack, GT_CoverBehaviorBase<?>> sCoverBehaviors = new ConcurrentHashMap<>();
/**
* The List of Circuit Behaviors for the Redstone Circuit Block
*/
@@ -615,6 +615,10 @@ public class GregTech_API {
}
public static void registerCover(ItemStack aStack, ITexture aCover, GT_CoverBehavior aBehavior) {
+ registerCover(aStack, aCover, (GT_CoverBehaviorBase<?>) aBehavior);
+ }
+
+ public static void registerCover(ItemStack aStack, ITexture aCover, GT_CoverBehaviorBase<?> aBehavior) {
if (!sCovers.containsKey(new GT_ItemStack(aStack)))
sCovers.put(new GT_ItemStack(aStack), aCover == null || !aCover.isValidTexture() ? Textures.BlockIcons.ERROR_RENDERING[0] : aCover);
if (aBehavior != null)
@@ -622,6 +626,10 @@ public class GregTech_API {
}
public static void registerCoverBehavior(ItemStack aStack, GT_CoverBehavior aBehavior) {
+ registerCoverBehavior(aStack, (GT_CoverBehaviorBase<?>) aBehavior);
+ }
+
+ public static void registerCoverBehavior(ItemStack aStack, GT_CoverBehaviorBase<?> aBehavior) {
sCoverBehaviors.put(new GT_ItemStack(aStack), aBehavior == null ? sDefaultBehavior : aBehavior);
}
@@ -631,6 +639,15 @@ public class GregTech_API {
* @param aBehavior can be null
*/
public static void registerCover(Collection<ItemStack> aStackList, ITexture aCover, GT_CoverBehavior aBehavior) {
+ registerCover(aStackList, aCover, aBehavior);
+ }
+
+ /**
+ * Registers multiple Cover Items. I use that for the OreDict Functionality.
+ *
+ * @param aBehavior can be null
+ */
+ public static void registerCover(Collection<ItemStack> aStackList, ITexture aCover, GT_CoverBehaviorBase<?> aBehavior) {
if (aCover.isValidTexture())
aStackList.forEach(tStack -> GregTech_API.registerCover(tStack, aCover, aBehavior));
}
@@ -638,10 +655,24 @@ public class GregTech_API {
/**
* returns a Cover behavior, guaranteed to not return null after preload
*/
+ @Deprecated
public static GT_CoverBehavior getCoverBehavior(ItemStack aStack) {
if (aStack == null || aStack.getItem() == null)
return sNoBehavior;
- GT_CoverBehavior rCover = sCoverBehaviors.get(new GT_ItemStack(aStack));
+ GT_CoverBehaviorBase<?> rCover = sCoverBehaviors.get(new GT_ItemStack(aStack));
+ if (!(rCover instanceof GT_CoverBehavior) || rCover == null)
+ return sDefaultBehavior;
+ return (GT_CoverBehavior) rCover;
+ }
+
+ /**
+ * returns a Cover behavior, guaranteed to not return null after preload
+ * @return
+ */
+ public static GT_CoverBehaviorBase<?> getCoverBehaviorNew(ItemStack aStack) {
+ if (aStack == null || aStack.getItem() == null)
+ return sNoBehavior;
+ GT_CoverBehaviorBase<?> rCover = sCoverBehaviors.get(new GT_ItemStack(aStack));
if (rCover == null)
return sDefaultBehavior;
return rCover;
@@ -650,6 +681,7 @@ public class GregTech_API {
/**
* returns a Cover behavior, guaranteed to not return null
*/
+ @Deprecated
public static GT_CoverBehavior getCoverBehavior(int aStack) {
if (aStack == 0)
return sNoBehavior;
@@ -657,6 +689,15 @@ public class GregTech_API {
}
/**
+ * returns a Cover behavior, guaranteed to not return null
+ */
+ public static GT_CoverBehaviorBase<?> getCoverBehaviorNew(int aStack) {
+ if (aStack == 0)
+ return sNoBehavior;
+ return getCoverBehaviorNew(GT_Utility.intToStack(aStack));
+ }
+
+ /**
* Register a Wrench to be usable on GregTech Machines.
* The Wrench MUST have some kind of Durability unlike certain Buildcraft Wrenches.
* <p/>
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java
index f30360ca58..6505c34423 100644
--- a/src/main/java/gregtech/api/enums/GT_Values.java
+++ b/src/main/java/gregtech/api/enums/GT_Values.java
@@ -272,6 +272,10 @@ public class GT_Values {
*/
public static boolean debugEntityCramming = false;
/**
+ * Debug parameter for {@link gregtech.api.util.GT_ChunkAssociatedData}
+ */
+ public static boolean debugWorldData = false;
+ /**
* Number of ticks between sending sound packets to clients for electric machines. Default is 1.5 seconds. Trying to mitigate lag and FPS drops.
*/
public static int ticksBetweenSounds = 30;
diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java
index 706e20769a..bb86c7ea4e 100644
--- a/src/main/java/gregtech/api/enums/Materials.java
+++ b/src/main/java/gregtech/api/enums/Materials.java
@@ -53,35 +53,35 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials Beryllium = new Materials( 8, TextureSet.SET_METALLIC , 14.0F, 64, 2, 1|2 |8 |32|64 , 100, 180, 100, 0, "Beryllium" , "Beryllium" , 0, 0, 1560, 0, false, false, 6, 1, 1, Dyes.dyeGreen , Element.Be , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.LUCRUM, 1)));
public static Materials Bismuth = new Materials( 90, TextureSet.SET_METALLIC , 6.0F, 64, 1, 1|2 |8 |32|64|128 , 100, 160, 160, 0, "Bismuth" , "Bismuth" , 0, 0, 544, 0, false, false, 2, 1, 1, Dyes.dyeCyan , Element.Bi , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.INSTRUMENTUM, 1)));
public static Materials Boron = new Materials( 9, TextureSet.SET_DULL , 1.0F, 0, 2, 1|32 , 210, 250, 210, 0, "Boron" , "Boron" , 0, 0, 2349, 0, false, false, 1, 1, 1, Dyes.dyeWhite , Element.B , Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 3)));
- public static Materials Caesium = new Materials( 62, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Caesium" , "Caesium" , 0, 0, 301, 0, false, false, 4, 1, 1, Dyes._NULL , Element.Cs , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Caesium = new Materials( 62, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 176, 196, 222, 0, "Caesium" , "Caesium" , 0, 0, 301, 0, false, false, 4, 1, 1, Dyes._NULL , Element.Cs , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Calcium = new Materials( 26, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1 |32 , 255, 245, 245, 0, "Calcium" , "Calcium" , 0, 0, 1115, 1115, true, false, 4, 1, 1, Dyes.dyePink , Element.Ca , Arrays.asList(new TC_AspectStack(TC_Aspects.SANO, 1), new TC_AspectStack(TC_Aspects.TUTAMEN, 1)));
public static Materials Carbon = new Materials( 10, TextureSet.SET_DULL , 1.0F, 64, 2, 1|2 |16|32|64|128 , 20, 20, 20, 0, "Carbon" , "Carbon" , 0, 0, 3800, 0, false, false, 2, 1, 1, Dyes.dyeBlack , Element.C , Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 1), new TC_AspectStack(TC_Aspects.IGNIS, 1)));
public static Materials Cadmium = new Materials( 55, TextureSet.SET_SHINY , 1.0F, 0, 2, 1 |8 |32 , 50, 50, 60, 0, "Cadmium" , "Cadmium" , 0, 0, 594, 0, false, false, 3, 1, 1, Dyes.dyeGray , Element.Cd , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 1), new TC_AspectStack(TC_Aspects.POTENTIA, 1), new TC_AspectStack(TC_Aspects.VENENUM, 1)));
- public static Materials Cerium = new Materials( 65, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Cerium" , "Cerium" , 0, 0, 1068, 1068, true, false, 4, 1, 1, Dyes._NULL , Element.Ce , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Cerium = new Materials( 65, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 123, 212, 144, 0, "Cerium" , "Cerium" , 0, 0, 1068, 1068, true, false, 4, 1, 1, Dyes._NULL , Element.Ce , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Chlorine = new Materials( 23, TextureSet.SET_FLUID , 1.0F, 0, 2, 16|32 , 255, 255, 255, 0, "Chlorine" , "Chlorine" , 0, 0, 171, 0, false, false, 2, 1, 1, Dyes.dyeCyan , Element.Cl , Arrays.asList(new TC_AspectStack(TC_Aspects.AQUA, 2), new TC_AspectStack(TC_Aspects.PANNUS, 1)));
public static Materials Chrome = new Materials( 30, TextureSet.SET_SHINY , 11.0F, 256, 3, 1|2 |8 |32|64|128 , 255, 230, 230, 0, "Chrome" , "Chrome" , 0, 0, 2180, 1700, true, false, 5, 1, 1, Dyes.dyePink , Element.Cr , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.MACHINA, 1)));
public static Materials Cobalt = new Materials( 33, TextureSet.SET_METALLIC , 8.0F, 512, 3, 1|2 |8 |32|64|128 , 80, 80, 250, 0, "Cobalt" , "Cobalt" , 0, 0, 1768, 1700, true, false, 3, 1, 1, Dyes.dyeBlue , Element.Co , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.INSTRUMENTUM, 1))).disableAutoGeneratedBlastFurnaceRecipes();
public static Materials Copper = new Materials( 35, TextureSet.SET_SHINY , 1.0F, 0, 1, 1|2 |8 |32 |128 , 255, 100, 0, 0, "Copper" , "Copper" , 0, 0, 1357, 0, false, false, 3, 1, 1, Dyes.dyeOrange , Element.Cu , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.PERMUTATIO, 1)));
public static Materials Deuterium = new Materials( 2, TextureSet.SET_FLUID , 1.0F, 0, 2, 16|32 , 255, 255, 0, 240, "Deuterium" , "Deuterium" , 0, 0, 14, 0, false, true, 10, 1, 1, Dyes.dyeYellow , Element.D , Arrays.asList(new TC_AspectStack(TC_Aspects.AQUA, 3)));
- public static Materials Dysprosium = new Materials( 73, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Dysprosium" , "Dysprosium" , 0, 0, 1680, 1680, true, false, 4, 1, 1, Dyes._NULL , Element.Dy , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 3)));
+ public static Materials Dysprosium = new Materials( 73, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 105, 209, 80, 0, "Dysprosium" , "Dysprosium" , 0, 0, 1680, 1680, true, false, 4, 1, 1, Dyes._NULL , Element.Dy , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 3)));
public static Materials Empty = new Materials( 0, TextureSet.SET_NONE , 1.0F, 0, 2, 256/*Only when needed*/ , 255, 255, 255, 255, "Empty" , "Empty" , 0, 0, -1, 0, false, true, 1, 1, 1, Dyes._NULL , Element._NULL , Arrays.asList(new TC_AspectStack(TC_Aspects.VACUOS, 2)));
- public static Materials Erbium = new Materials( 75, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Erbium" , "Erbium" , 0, 0, 1802, 1802, true, false, 4, 1, 1, Dyes._NULL , Element.Er , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
- public static Materials Europium = new Materials( 70, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Europium" , "Europium" , 0, 0, 1099, 1099, true, false, 4, 1, 1, Dyes._NULL , Element.Eu , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Erbium = new Materials( 75, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 176, 152, 81, 0, "Erbium" , "Erbium" , 0, 0, 1802, 1802, true, false, 4, 1, 1, Dyes._NULL , Element.Er , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Europium = new Materials( 70, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 246, 181, 255, 0, "Europium" , "Europium" , 0, 0, 1099, 1099, true, false, 4, 1, 1, Dyes._NULL , Element.Eu , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Fluorine = new Materials( 14, TextureSet.SET_FLUID , 1.0F, 0, 2, 16|32 , 255, 255, 255, 127, "Fluorine" , "Fluorine" , 0, 0, 53, 0, false, true, 2, 1, 1, Dyes.dyeGreen , Element.F , Arrays.asList(new TC_AspectStack(TC_Aspects.PERDITIO, 2)));
- public static Materials Gadolinium = new Materials( 71, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Gadolinium" , "Gadolinium" , 0, 0, 1585, 1585, true, false, 4, 1, 1, Dyes._NULL , Element.Gd , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Gadolinium = new Materials( 71, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 59, 186, 28, 0, "Gadolinium" , "Gadolinium" , 0, 0, 1585, 1585, true, false, 4, 1, 1, Dyes._NULL , Element.Gd , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Gallium = new Materials( 37, TextureSet.SET_SHINY , 1.0F, 64, 2, 1|2 |8 |32 , 220, 220, 255, 0, "Gallium" , "Gallium" , 0, 0, 302, 0, false, false, 5, 1, 1, Dyes.dyeLightGray , Element.Ga , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.ELECTRUM, 1)));
public static Materials Gold = new Materials( 86, TextureSet.SET_SHINY , 12.0F, 64, 2, 1|2 |8 |32|64|128 , 255, 255, 30, 0, "Gold" , "Gold" , 0, 0, 1337, 0, false, false, 4, 1, 1, Dyes.dyeYellow , Element.Au , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.LUCRUM, 2)));
- public static Materials Holmium = new Materials( 74, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Holmium" , "Holmium" , 0, 0, 1734, 1734, true, false, 4, 1, 1, Dyes._NULL , Element.Ho , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Holmium = new Materials( 74, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 22, 8, 166, 0, "Holmium" , "Holmium" , 0, 0, 1734, 1734, true, false, 4, 1, 1, Dyes._NULL , Element.Ho , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Hydrogen = new Materials( 1, TextureSet.SET_FLUID , 1.0F, 0, 2, 16|32 , 0, 0, 255, 240, "Hydrogen" , "Hydrogen" , 1, 20, 14, 0, false, true, 2, 1, 1, Dyes.dyeBlue , Element.H , Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 1)));
public static Materials Helium = new Materials( 4, TextureSet.SET_FLUID , 1.0F, 0, 2, 16|32 , 255, 255, 0, 240, "Helium" , "Helium" , 0, 0, 1, 0, false, true, 5, 1, 1, Dyes.dyeYellow , Element.He , Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AER, 2)));
public static Materials Helium_3 = new Materials( 5, TextureSet.SET_FLUID , 1.0F, 0, 2, 16|32 , 255, 255, 0, 240, "Helium_3" , "Helium-3" , 0, 0, 1, 0, false, true, 10, 1, 1, Dyes.dyeYellow , Element.He_3 , Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AER, 3)));
public static Materials Indium = new Materials( 56, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 64, 0, 128, 0, "Indium" , "Indium" , 0, 0, 429, 0, false, false, 4, 1, 1, Dyes.dyeGray , Element.In , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Iridium = new Materials( 84, TextureSet.SET_DULL , 6.0F, 2560, 3, 1|2 |8 |32|64|128 , 240, 240, 245, 0, "Iridium" , "Iridium" , 0, 0, 2719, 4500, true, false, 10, 1, 1, Dyes.dyeWhite , Element.Ir , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.MACHINA, 1))).disableAutoGeneratedBlastFurnaceRecipes();
public static Materials Iron = new Materials( 32, TextureSet.SET_METALLIC , 6.0F, 256, 2, 1|2 |8 |32|64|128 , 200, 200, 200, 0, "Iron" , "Iron" , 0, 0, 1811, 0, false, false, 3, 1, 1, Dyes.dyeLightGray , Element.Fe , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 3)));
- public static Materials Lanthanum = new Materials( 64, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Lanthanum" , "Lanthanum" , 0, 0, 1193, 1193, true, false, 4, 1, 1, Dyes._NULL , Element.La , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Lanthanum = new Materials( 64, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 138, 138, 138, 0, "Lanthanum" , "Lanthanum" , 0, 0, 1193, 1193, true, false, 4, 1, 1, Dyes._NULL , Element.La , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Lead = new Materials( 89, TextureSet.SET_DULL , 8.0F, 64, 1, 1|2 |8 |32|64|128 , 140, 100, 140, 0, "Lead" , "Lead" , 0, 0, 600, 0, false, false, 3, 1, 1, Dyes.dyePurple , Element.Pb , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.ORDO, 1)));
public static Materials Lithium = new Materials( 6, TextureSet.SET_DULL , 1.0F, 0, 2, 1|2 |8 |32 , 225, 220, 255, 0, "Lithium" , "Lithium" , 0, 0, 454, 0, false, false, 4, 1, 1, Dyes.dyeLightBlue , Element.Li , Arrays.asList(new TC_AspectStack(TC_Aspects.VITREUS, 1), new TC_AspectStack(TC_Aspects.POTENTIA, 2)));
- public static Materials Lutetium = new Materials( 78, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Lutetium" , "Lutetium" , 0, 0, 1925, 1925, true, false, 4, 1, 1, Dyes._NULL , Element.Lu , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Lutetium = new Materials( 78, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 188, 62, 199, 0, "Lutetium" , "Lutetium" , 0, 0, 1925, 1925, true, false, 4, 1, 1, Dyes._NULL , Element.Lu , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Magic = new Materials(-128, TextureSet.SET_SHINY , 8.0F, 5120, 5, 1|2|4|8|16|32|64|128 , 100, 0, 200, 0, "Magic" , "Magic" , 5, 32, 5000, 0, false, false, 7, 1, 1, Dyes.dyePurple , Element.Ma , Arrays.asList(new TC_AspectStack(TC_Aspects.PRAECANTATIO, 4)));
public static Materials Magnesium = new Materials( 18, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 200, 200, 0, "Magnesium" , "Magnesium" , 0, 0, 923, 0, false, false, 3, 1, 1, Dyes.dyePink , Element.Mg , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.SANO, 1)));
public static Materials Manganese = new Materials( 31, TextureSet.SET_DULL , 7.0F, 512, 2, 1|2 |8 |32|64 , 250, 250, 250, 0, "Manganese" , "Manganese" , 0, 0, 1519, 0, false, false, 3, 1, 1, Dyes.dyeWhite , Element.Mn , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 3)));
@@ -100,22 +100,22 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials Plutonium = new Materials( 100, TextureSet.SET_METALLIC , 6.0F, 512, 3, 1|2 |8 |32|64 , 240, 50, 50, 0, "Plutonium" , "Plutonium 239" , 0, 0, 912, 0, false, false, 6, 1, 1, Dyes.dyeLime , Element.Pu , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 2)));
public static Materials Plutonium241 = new Materials( 101, TextureSet.SET_SHINY , 6.0F, 512, 3, 1|2 |8 |32|64 , 250, 70, 70, 0, "Plutonium241" , "Plutonium 241" , 0, 0, 912, 0, false, false, 6, 1, 1, Dyes.dyeLime , Element.Pu_241 , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 3)));
public static Materials Potassium = new Materials( 25, TextureSet.SET_METALLIC , 1.0F, 0, 1, 1|2 |32 , 154, 172, 223, 0, "Potassium" , "Potassium" , 0, 0, 336, 0, false, false, 2, 1, 1, Dyes.dyeWhite , Element.K , Arrays.asList(new TC_AspectStack(TC_Aspects.VITREUS, 1), new TC_AspectStack(TC_Aspects.POTENTIA, 1)));
- public static Materials Praseodymium = new Materials( 66, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Praseodymium" , "Praseodymium" , 0, 0, 1208, 1208, true, false, 4, 1, 1, Dyes._NULL , Element.Pr , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
- public static Materials Promethium = new Materials( 68, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Promethium" , "Promethium" , 0, 0, 1315, 1315, true, false, 4, 1, 1, Dyes._NULL , Element.Pm , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Praseodymium = new Materials( 66, TextureSet.SET_DULL , 1.0F, 0, 2, 1|2 |8 |32 , 117, 214, 129, 0, "Praseodymium" , "Praseodymium" , 0, 0, 1208, 1208, true, false, 4, 1, 1, Dyes._NULL , Element.Pr , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Promethium = new Materials( 68, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 36, 181, 53, 0, "Promethium" , "Promethium" , 0, 0, 1315, 1315, true, false, 4, 1, 1, Dyes._NULL , Element.Pm , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Radon = new Materials( 93, TextureSet.SET_FLUID , 1.0F, 0, 2, 16|32 , 255, 0, 255, 240, "Radon" , "Radon" , 0, 0, 202, 0, false, true, 5, 1, 1, Dyes.dyePurple , Element.Rn , Arrays.asList(new TC_AspectStack(TC_Aspects.AER, 1), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Rubidium = new Materials( 43, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 240, 30, 30, 0, "Rubidium" , "Rubidium" , 0, 0, 312, 0, false, false, 4, 1, 1, Dyes.dyeRed , Element.Rb , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.VITREUS, 1)));
public static Materials Samarium = new Materials( 69, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 204, 0, "Samarium" , "Samarium" , 0, 0, 1345, 1345, true, false, 4, 1, 1, Dyes.dyeWhite , Element.Sm , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1), new TC_AspectStack(TC_Aspects.MAGNETO,10)));
- public static Materials Scandium = new Materials( 27, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Scandium" , "Scandium" , 0, 0, 1814, 1814, true, false, 2, 1, 1, Dyes.dyeYellow , Element.Sc , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Scandium = new Materials( 27, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 204, 204, 204, 0, "Scandium" , "Scandium" , 0, 0, 1814, 1814, true, false, 2, 1, 1, Dyes.dyeYellow , Element.Sc , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Silicon = new Materials( 20, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 60, 60, 80, 0, "Silicon" , "Silicon" , 0, 0, 1687, 1687, true, false, 1, 1, 1, Dyes.dyeBlack , Element.Si , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.TENEBRAE, 1))).disableAutoGeneratedBlastFurnaceRecipes();
public static Materials Silver = new Materials( 54, TextureSet.SET_SHINY , 10.0F, 64, 2, 1|2 |8 |32|64|128 , 220, 220, 255, 0, "Silver" , "Silver" , 0, 0, 1234, 0, false, false, 3, 1, 1, Dyes.dyeLightGray , Element.Ag , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.LUCRUM, 1)));
public static Materials Sodium = new Materials( 17, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1 |32 , 0, 0, 150, 0, "Sodium" , "Sodium" , 0, 0, 370, 0, false, false, 1, 1, 1, Dyes.dyeBlue , Element.Na , Arrays.asList(new TC_AspectStack(TC_Aspects.VITREUS, 2), new TC_AspectStack(TC_Aspects.LUX, 1)));
public static Materials Strontium = new Materials( 44, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1 |8 |32 , 200, 200, 200, 0, "Strontium" , "Strontium" , 0, 0, 1050, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Element.Sr , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.STRONTIO, 1)));
public static Materials Sulfur = new Materials( 22, TextureSet.SET_DULL , 1.0F, 0, 2, 1 |8 |32 , 200, 200, 0, 0, "Sulfur" , "Sulfur" , 0, 0, 388, 0, false, false, 2, 1, 1, Dyes.dyeYellow , Element.S , Arrays.asList(new TC_AspectStack(TC_Aspects.IGNIS, 1)));
- public static Materials Tantalum = new Materials( 80, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Tantalum" , "Tantalum" , 0, 0, 3290, 0, false, false, 4, 1, 1, Dyes._NULL , Element.Ta , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.VINCULUM, 1)));
- public static Materials Tellurium = new Materials( 59, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Tellurium" , "Tellurium" , 0, 0, 722, 0, false, false, 4, 1, 1, Dyes.dyeGray , Element.Te , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Tantalum = new Materials( 80, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 105, 183, 255, 0, "Tantalum" , "Tantalum" , 0, 0, 3290, 0, false, false, 4, 1, 1, Dyes._NULL , Element.Ta , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.VINCULUM, 1)));
+ public static Materials Tellurium = new Materials( 59, TextureSet.SET_DULL , 1.0F, 0, 2, 1|2 |8 |32 , 206, 277, 86, 0, "Tellurium" , "Tellurium" , 0, 0, 722, 0, false, false, 4, 1, 1, Dyes.dyeGray , Element.Te , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Terbium = new Materials( 72, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Terbium" , "Terbium" , 0, 0, 1629, 1629, true, false, 4, 1, 1, Dyes._NULL , Element.Tb , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Thorium = new Materials( 96, TextureSet.SET_SHINY , 6.0F, 512, 2, 1|2 |8 |32|64 , 0, 30, 0, 0, "Thorium" , "Thorium" , 0, 0, 2115, 0, false, false, 4, 1, 1, Dyes.dyeBlack , Element.Th , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
- public static Materials Thulium = new Materials( 76, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Thulium" , "Thulium" , 0, 0, 1818, 1818, true, false, 4, 1, 1, Dyes._NULL , Element.Tm , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Thulium = new Materials( 76, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 89, 107, 194, 0, "Thulium" , "Thulium" , 0, 0, 1818, 1818, true, false, 4, 1, 1, Dyes._NULL , Element.Tm , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Tin = new Materials( 57, TextureSet.SET_DULL , 1.0F, 0, 3, 1|2 |8 |32 |128 , 220, 220, 220, 0, "Tin" , "Tin" , 0, 0, 505, 505, false, false, 3, 1, 1, Dyes.dyeWhite , Element.Sn , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.VITREUS, 1)));
public static Materials Titanium = new Materials( 28, TextureSet.SET_METALLIC , 7.0F, 1600, 3, 1|2 |8 |32|64|128 , 220, 160, 240, 0, "Titanium" , "Titanium" , 0, 0, 1941, 1940, true, false, 5, 1, 1, Dyes.dyePurple , Element.Ti , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.TUTAMEN, 1))).disableAutoGeneratedBlastFurnaceRecipes();
public static Materials Tritanium = new Materials( 329, TextureSet.SET_METALLIC , 20.0F,1435392, 6, 1|2 |64 , 96, 0, 0, 0, "Tritanium" , "Tritanium" , 0, 0, 9900, 9900, true, false, 1, 1, 1, Dyes.dyeWhite , Element.Tn ,Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.ORDO, 2)));
@@ -124,7 +124,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials Uranium = new Materials( 98, TextureSet.SET_METALLIC , 6.0F, 512, 3, 1|2 |8 |32|64 , 50, 240, 50, 0, "Uranium" , "Uranium 238" , 0, 0, 1405, 0, false, false, 4, 1, 1, Dyes.dyeGreen , Element.U , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Uranium235 = new Materials( 97, TextureSet.SET_SHINY , 6.0F, 512, 3, 1|2 |8 |32|64 , 70, 250, 70, 0, "Uranium235" , "Uranium 235" , 0, 0, 1405, 0, false, false, 4, 1, 1, Dyes.dyeGreen , Element.U_235 , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 2)));
public static Materials Vanadium = new Materials( 29, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 50, 50, 50, 0, "Vanadium" , "Vanadium" , 0, 0, 2183, 2183, true, false, 2, 1, 1, Dyes.dyeBlack , Element.V , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
- public static Materials Ytterbium = new Materials( 77, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 255, 255, 255, 0, "Ytterbium" , "Ytterbium" , 0, 0, 1097, 1097, true, false, 4, 1, 1, Dyes._NULL , Element.Yb , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
+ public static Materials Ytterbium = new Materials( 77, TextureSet.SET_SHINY , 1.0F, 0, 2, 1|2 |8 |32 , 44, 199, 80, 0, "Ytterbium" , "Ytterbium" , 0, 0, 1097, 1097, true, false, 4, 1, 1, Dyes._NULL , Element.Yb , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Yttrium = new Materials( 45, TextureSet.SET_METALLIC , 1.0F, 0, 2, 1|2 |8 |32 , 220, 250, 220, 0, "Yttrium" , "Yttrium" , 0, 0, 1799, 1799, true, false, 4, 1, 1, Dyes._NULL , Element.Y , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.RADIO, 1)));
public static Materials Zinc = new Materials( 36, TextureSet.SET_METALLIC , 1.0F, 0, 1, 1|2 |8 |32 , 250, 240, 240, 0, "Zinc" , "Zinc" , 0, 0, 692, 0, false, false, 2, 1, 1, Dyes.dyeWhite , Element.Zn , Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 2), new TC_AspectStack(TC_Aspects.SANO, 1)));
@@ -660,7 +660,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials RoseGold = new Materials( 351, TextureSet.SET_SHINY , 14.0F, 128, 2, 1|2 |64|128 , 255, 230, 30, 0, "RoseGold" , "Rose Gold" , 0, 0, -1, 1600, true, false, 4, 1, 1, Dyes.dyeOrange , 2, Arrays.asList(new MaterialStack(Copper, 1), new MaterialStack(Gold, 4)));
public static Materials BlackBronze = new Materials( 352, TextureSet.SET_DULL , 12.0F, 256, 2, 1|2 |64|128 , 100, 50, 125, 0, "BlackBronze" , "Black Bronze" , 0, 0, -1, 2000, true, false, 4, 1, 1, Dyes.dyePurple , 2, Arrays.asList(new MaterialStack(Gold, 1), new MaterialStack(Silver, 1), new MaterialStack(Copper, 3)));
public static Materials BismuthBronze = new Materials( 353, TextureSet.SET_DULL , 8.0F, 256, 2, 1|2 |64|128 , 100, 125, 125, 0, "BismuthBronze" , "Bismuth Bronze" , 0, 0, -1, 1100, true, false, 4, 1, 1, Dyes.dyeCyan , 2, Arrays.asList(new MaterialStack(Bismuth, 1), new MaterialStack(Zinc, 1), new MaterialStack(Copper, 3)));
- public static Materials BlackSteel = new Materials( 334, TextureSet.SET_METALLIC , 6.5F, 768, 3, 1|2 |64|128 , 100, 100, 100, 0, "BlackSteel" , "Black Steel" , 0, 0, -1, 1200, true, false, 4, 1, 1, Dyes.dyeBlack , 2, Arrays.asList(new MaterialStack(Nickel, 1), new MaterialStack(BlackBronze, 1), new MaterialStack(Steel, 3)));
+ public static Materials BlackSteel = new Materials( 334, TextureSet.SET_METALLIC , 6.5F, 768, 3, 1|2 |64|128 , 100, 100, 100, 0, "BlackSteel" , "Black Steel" , 0, 0, -1, 1200, true, false, 4, 1, 1, Dyes.dyeBlack , 2, Arrays.asList(new MaterialStack(Nickel, 1), new MaterialStack(BlackBronze, 1), new MaterialStack(Steel, 3))).disableAutoGeneratedBlastFurnaceRecipes();
public static Materials RedSteel = new Materials( 348, TextureSet.SET_METALLIC , 7.0F, 896, 4, 1|2 |64|128 , 140, 100, 100, 0, "RedSteel" , "Red Steel" , 0, 0, -1, 1300, true, false, 4, 1, 1, Dyes.dyeRed , 2, Arrays.asList(new MaterialStack(SterlingSilver, 1), new MaterialStack(BismuthBronze, 1), new MaterialStack(Steel, 2), new MaterialStack(BlackSteel, 4)));
public static Materials BlueSteel = new Materials( 349, TextureSet.SET_METALLIC , 7.5F, 1024, 4, 1|2 |64|128 , 100, 100, 140, 0, "BlueSteel" , "Blue Steel" , 0, 0, -1, 1400, true, false, 4, 1, 1, Dyes.dyeBlue , 2, Arrays.asList(new MaterialStack(RoseGold, 1), new MaterialStack(Brass, 1), new MaterialStack(Steel, 2), new MaterialStack(BlackSteel, 4)));
public static Materials DamascusSteel = new Materials( 335, TextureSet.SET_METALLIC , 8.0F, 1280, 3, 1|2 |64|128 , 110, 110, 110, 0, "DamascusSteel" , "Damascus Steel" , 0, 0, 2000, 1500, true, false, 4, 1, 1, Dyes.dyeGray , 2, Arrays.asList(new MaterialStack(Steel, 1))).disableAutoGeneratedBlastFurnaceRecipes();
@@ -743,7 +743,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials PotassiumNitrade = new MaterialBuilder(590, TextureSet.SET_DULL , "Potassium Nitrade").setName("PotassiumNitrade").addDustItems().setRGB(129, 34, 141).setColor(Dyes.dyePurple).setMaterialList(new MaterialStack(Potassium, 1), new MaterialStack(Nitrogen, 1), new MaterialStack(Oxygen, 3)).addElectrolyzerRecipe().constructMaterial();
public static Materials ChromiumTrioxide = new MaterialBuilder(591, TextureSet.SET_DULL , "Chromium Trioxide").setName("Chromiumtrioxide").addDustItems().setRGB(255, 228, 225).setColor(Dyes.dyePink).setMaterialList(new MaterialStack(Chrome, 1), new MaterialStack(Oxygen, 3)).addElectrolyzerRecipe().constructMaterial();
public static Materials Nitrochlorobenzene = new MaterialBuilder(592, TextureSet.SET_FLUID , "2-Nitrochlorobenzene").addCell().addFluid().setRGB(143, 181, 26).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 6), new MaterialStack(Hydrogen, 4), new MaterialStack(Chlorine, 1), new MaterialStack(Nitrogen, 1), new MaterialStack(Oxygen, 2)).constructMaterial();
- public static Materials Dimethylbenzene = new MaterialBuilder(593, TextureSet.SET_FLUID , "Dimethylbenzene").addCell().addFluid().setRGB(102, 156, 64).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 10)).constructMaterial();
+ public static Materials Dimethylbenzene = new MaterialBuilder(593, TextureSet.SET_FLUID , "Dimethylbenzene").addCell().addFluid().setRGB(102, 156, 64).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 10)).addElectrolyzerRecipe().constructMaterial();
public static Materials Potassiumdichromate = new MaterialBuilder(594, TextureSet.SET_DULL , "Potassium Dichromate").setName("PotassiumDichromate").addDustItems().setRGB(255, 8, 127).setColor(Dyes.dyePink).setMaterialList(new MaterialStack(Potassium, 2), new MaterialStack(Chrome, 2), new MaterialStack(Oxygen, 7)).addElectrolyzerRecipe().constructMaterial();
public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phthalic Acid").setName("phtalicacid").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial();
public static Materials Dichlorobenzidine = new MaterialBuilder(596, TextureSet.SET_FLUID , "3,3-Dichlorobenzidine").addCell().addFluid().setRGB(161, 222, 166).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 10), new MaterialStack(Nitrogen, 2), new MaterialStack(Chlorine, 2)).constructMaterial();
@@ -752,8 +752,9 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials Polybenzimidazole = new Materials(599, TextureSet.SET_DULL ,3.0F, 64, 1, 1|2 |64|128 , 45, 45, 45, 0, "Polybenzimidazole" , "Polybenzimidazole" , 0, 0, 1450, 0, false, false, 1, 1, 1, Dyes.dyeBlack , 0, Arrays.asList(new MaterialStack(Carbon, 20), new MaterialStack(Nitrogen, 4), new MaterialStack(Hydrogen, 12)), Arrays.asList(new TC_AspectStack(TC_Aspects.ORDO, 2),new TC_AspectStack(TC_Aspects.VOLATUS, 1)));
+ public static Materials MTBEMixture = new MaterialBuilder(983, TextureSet.SET_FLUID , "MTBE Reaction Mixture").addCell().addGas().setRGB(255, 255, 255).setColor(Dyes.dyeWhite).constructMaterial();
public static Materials NitrousOxide = new MaterialBuilder(993, TextureSet.SET_FLUID , "Nitrous Oxide").addCell().addGas().setRGB(125, 200, 255).setColor(Dyes.dyeBlue).setMaterialList(new MaterialStack(Nitrogen, 2), new MaterialStack(Oxygen, 1)).addElectrolyzerRecipe().constructMaterial();
- public static Materials AntiKnock = new MaterialBuilder(994, TextureSet.SET_FLUID , "Ethyl Tert-Butyl Ether").addCell().addFluid().setRGB(255, 255, 255).setColor(Dyes.dyeWhite).constructMaterial();
+ public static Materials AntiKnock = new MaterialBuilder(994, TextureSet.SET_FLUID , "Anti-Knock Agent").setName("EthylTertButylEther").addCell().addFluid().setRGB(255, 255, 255).setColor(Dyes.dyeWhite).constructMaterial();
public static Materials Octane = new MaterialBuilder(995, TextureSet.SET_FLUID , "Octane").addCell().addFluid().setRGB(255, 255, 255).setColor(Dyes.dyeWhite).setFuelType(MaterialBuilder.DIESEL).setFuelPower(80).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 18)).constructMaterial();
public static Materials GasolineRaw = new MaterialBuilder(996, TextureSet.SET_FLUID , "Raw Gasoline").addCell().addFluid().setRGB(255,100,0).setColor(Dyes.dyeOrange).constructMaterial();
public static Materials GasolineRegular = new MaterialBuilder(997, TextureSet.SET_FLUID , "Gasoline").addCell().addFluid().setRGB(255,165,0).setColor(Dyes.dyeOrange).setFuelType(MaterialBuilder.DIESEL).setFuelPower(576).constructMaterial();
@@ -820,7 +821,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials Tetraindiumditindibariumtitaniumheptacoppertetrakaidekaoxid = new Materials( 991, TextureSet.SET_METALLIC , 1.0F, 0, 3, 1|2 , 153, 76, 0, 0, "Tetraindiumditindibariumtitaniumheptacoppertetrakaidekaoxid" , "Superconductor Base LuV" , 0, 0, 6000, 6000, true, false, 1, 1, 1, Dyes.dyeBrown , 1, Arrays.asList(new MaterialStack(Indium, 4), new MaterialStack(Tin, 2), new MaterialStack(Barium, 2), new MaterialStack(Titanium, 1), new MaterialStack(Copper, 7), new MaterialStack(Oxygen, 14)), Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 15)));
public static Materials Tetranaquadahdiindiumhexaplatiumosminid = new Materials( 992, TextureSet.SET_METALLIC , 1.0F, 0, 3, 1|2 , 10, 10, 10, 0, "Tetranaquadahdiindiumhexaplatiumosminid" , "Superconductor Base ZPM" , 0, 0, 9000, 9000, true, false, 1, 1, 1, Dyes.dyeBlack , 1, Arrays.asList(new MaterialStack(Naquadah, 4), new MaterialStack(Indium, 2), new MaterialStack(Palladium, 6), new MaterialStack(Osmium, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 18)));
public static Materials Longasssuperconductornameforuvwire = new Materials( 986, TextureSet.SET_METALLIC , 1.0F, 0, 3, 1|2 , 224,210, 7, 0, "Longasssuperconductornameforuvwire" , "Superconductor Base UV" , 0, 0, 9900, 9900, true, false, 1, 1, 1, Dyes.dyeYellow , 1, Arrays.asList(new MaterialStack(Naquadria, 4), new MaterialStack(Osmiridium, 3), new MaterialStack(Europium, 1), new MaterialStack(Samarium, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 21)));
- public static Materials Longasssuperconductornameforuhvwire = new Materials( 985, TextureSet.SET_METALLIC , 1.0F, 0, 3, 1|2 , 255,255, 255, 0, "Longasssuperconductornameforuhvwire" , "Superconductor Base UHV" , 0, 0, 10800, 10800, true, false, 1, 1, 1, Dyes.dyeWhite , 1, Arrays.asList(new MaterialStack(Draconium, 6), new MaterialStack(CosmicNeutronium, 7), new MaterialStack(Tritanium, 5), new MaterialStack(Americium, 6)), Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 24)));
+ public static Materials Longasssuperconductornameforuhvwire = new Materials( 985, TextureSet.SET_SHINY , 1.0F, 0, 3, 1|2 , 38,129, 189, 0, "Longasssuperconductornameforuhvwire" , "Superconductor Base UHV" , 0, 0, 10800, 10800, true, false, 1, 1, 1, Dyes.dyeWhite , 1, Arrays.asList(new MaterialStack(Draconium, 6), new MaterialStack(CosmicNeutronium, 7), new MaterialStack(Tritanium, 5), new MaterialStack(Americium, 6)), Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 24)));
public static Materials SuperconductorMV = new Materials( -1, TextureSet.SET_SHINY , 1.0F, 0, 0, 0 , 85, 85, 85, 0, "SuperconductorMV" , "Superconductor MV" , 0, 0, -1, -1, false, false, 1, 1, 1, Dyes.dyeGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 6)));
public static Materials SuperconductorHV = new Materials( -1, TextureSet.SET_SHINY , 1.0F, 0, 0, 0 , 51, 25, 0, 0, "SuperconductorHV" , "Superconductor HV" , 0, 0, -1, -1, false, false, 1, 1, 1, Dyes.dyeBrown , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 12)));
@@ -829,7 +830,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials SuperconductorLuV = new Materials( -1, TextureSet.SET_SHINY , 1.0F, 0, 0, 0 , 153, 76, 0, 0, "SuperconductorLuV" , "Superconductor LuV" , 0, 0, -1, -1, false, false, 1, 1, 1, Dyes.dyeBrown , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 28)));
public static Materials SuperconductorZPM = new Materials( -1, TextureSet.SET_SHINY , 1.0F, 0, 0, 0 , 10, 10, 10, 0, "SuperconductorZPM" , "Superconductor ZPM" , 0, 0, -1, -1, false, false, 1, 1, 1, Dyes.dyeBlack , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 32)));
public static Materials SuperconductorUV = new Materials( -1, TextureSet.SET_SHINY , 1.0F, 0, 0, 0 , 224,210, 7, 0, "SuperconductorUV" , "Superconductor UV" , 0, 0, -1, -1, false, false, 1, 1, 1, Dyes.dyeYellow , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 48)));
- public static Materials SuperconductorUHV = new Materials( -1, TextureSet.SET_SHINY , 1.0F, 0, 0, 0 , 255,255, 255, 0, "Superconductor" , "Superconductor UHV" , 0, 0, -1, -1, false, false, 1, 1, 1, Dyes.dyeWhite , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 64)));
+ public static Materials SuperconductorUHV = new Materials( -1, TextureSet.SET_SHINY , 1.0F, 0, 0, 0 , 38,129, 189, 0, "Superconductor" , "Superconductor UHV" , 0, 0, -1, -1, false, false, 1, 1, 1, Dyes.dyeWhite , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 64)));
public static Materials SuperCoolant = new MaterialBuilder( -1, TextureSet.SET_DULL,"Super Coolant").setRGB(2, 91, 111).addFluid().constructMaterial().setLiquidTemperature(1);
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
index 010ac78654..e7b6b9971d 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
@@ -3,13 +3,22 @@ package gregtech.api.gui.widgets;
import gregtech.api.interfaces.IGuiScreen;
public class GT_GuiIconCheckButton extends GT_GuiIconButton {
- private GT_GuiIcon checkedIcon, normalIcon;
+ private final GT_GuiIcon checkedIcon;
+ private final GT_GuiIcon normalIcon;
+ private final String checkedTooltip;
+ private final String normalTooltip;
private boolean checked = false;
public GT_GuiIconCheckButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon checkedIcon, GT_GuiIcon normalIcon) {
+ this(gui, id, x, y, checkedIcon, normalIcon, null, null);
+ }
+
+ public GT_GuiIconCheckButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon checkedIcon, GT_GuiIcon normalIcon, String checkedTooltip, String normalTooltip) {
super(gui, id, x, y, normalIcon);
this.checkedIcon = checkedIcon;
this.normalIcon = normalIcon;
+ this.checkedTooltip = checkedTooltip;
+ this.normalTooltip = normalTooltip;
}
@Override
@@ -27,6 +36,7 @@ public class GT_GuiIconCheckButton extends GT_GuiIconButton {
public void setChecked(boolean checked) {
super.setIcon(checked ? checkedIcon : normalIcon);
+ super.setTooltipText(checked ? checkedTooltip : normalTooltip);
this.checked = checked;
}
}
diff --git a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java
index 4bf8b211e0..2267b6c241 100644
--- a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java
+++ b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java
@@ -630,6 +630,8 @@ public interface IGT_RecipeAdder {
boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, ItemStack aInput5, ItemStack aInput6, ItemStack aInput7, ItemStack aInput8, ItemStack aInput9, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput, int aDuration, int aEUt);
+ boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, ItemStack aInput5, ItemStack aInput6, ItemStack aInput7, ItemStack aInput8, ItemStack aInput9, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt);
+
/**
* Adds a Recipe for the Laser Engraver
*/
diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java
index f136f4f32b..90933b501f 100644
--- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java
+++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java
@@ -59,7 +59,7 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity {
continue;
j = GT_Utility.getOppositeSide(i);
if (aSuckItems) {
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -2, aBaseMetaTileEntity)) {
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSideNew(i).letsItemsIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getComplexCoverDataAtSide(i), -2, aBaseMetaTileEntity)) {
IGregTechTileEntity tItemPipe = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(i);
if (aBaseMetaTileEntity.getColorization() >= 0) {
byte tColor = tItemPipe.getColorization();
@@ -69,13 +69,13 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity {
}
if (tItemPipe instanceof BaseMetaPipeEntity) {
IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity();
- if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
+ if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSideNew(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getComplexCoverDataAtSide(j), -2, tItemPipe)) {
scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity);
}
}
}
} else {
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -2, aBaseMetaTileEntity)) {
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSideNew(i).letsItemsOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getComplexCoverDataAtSide(i), -2, aBaseMetaTileEntity)) {
IGregTechTileEntity tItemPipe = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(i);
if (tItemPipe != null) {
if (aBaseMetaTileEntity.getColorization() >= 0) {
@@ -86,7 +86,7 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity {
}
if (tItemPipe instanceof BaseMetaPipeEntity) {
IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity();
- if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
+ if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSideNew(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getComplexCoverDataAtSide(j), -2, tItemPipe)) {
scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity);
}
}
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java
index 560d47c595..ebfae9d90e 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java
@@ -1,6 +1,9 @@
package gregtech.api.interfaces.tileentity;
import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_CoverBehaviorBase;
+import gregtech.api.util.ISerializableObject;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEnergyContainer {
@@ -10,20 +13,36 @@ public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEn
boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced);
+ @Deprecated
void setCoverDataAtSide(byte aSide, int aData);
+ default void setCoverDataAtSide(byte aSide, ISerializableObject aData) {
+ if (aData instanceof ISerializableObject.LegacyCoverData)
+ setCoverDataAtSide(aSide, ((ISerializableObject.LegacyCoverData) aData).get());
+ }
+
void setCoverIDAtSide(byte aSide, int aID);
void setCoverItemAtSide(byte aSide, ItemStack aCover);
+ @Deprecated
int getCoverDataAtSide(byte aSide);
+ default ISerializableObject getComplexCoverDataAtSide(byte aSide) {
+ return new ISerializableObject.LegacyCoverData(getCoverDataAtSide(aSide));
+ }
+
int getCoverIDAtSide(byte aSide);
ItemStack getCoverItemAtSide(byte aSide);
+ @Deprecated
GT_CoverBehavior getCoverBehaviorAtSide(byte aSide);
+ default GT_CoverBehaviorBase<?> getCoverBehaviorAtSideNew(byte aSide) {
+ return getCoverBehaviorAtSide(aSide);
+ }
+
/**
* For use by the regular MetaTileEntities. Returns the Cover Manipulated input Redstone.
* Don't use this if you are a Cover Behavior. Only for MetaTileEntities.
@@ -46,4 +65,13 @@ public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEn
* Receiving a packet with cover data.
*/
void receiveCoverData(byte coverSide, int coverID, int coverData);
+
+ /**
+ * Receiving a packet with cover data.
+ * @param aPlayer the player who made the change
+ */
+ default void receiveCoverData(byte aCoverSide, int aCoverID, ISerializableObject aCoverData, EntityPlayerMP aPlayer) {
+ if (aCoverData instanceof ISerializableObject.LegacyCoverData)
+ receiveCoverData(aCoverSide, aCoverID, ((ISerializableObject.LegacyCoverData) aCoverData).get());
+ }
}
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
index c2465c1a53..bff79743be 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
@@ -1,5 +1,14 @@
package gregtech.api.metatileentity;
+import static gregtech.GT_Mod.GT_FML_LOGGER;
+import static gregtech.api.enums.GT_Values.NW;
+import static gregtech.api.metatileentity.BaseMetaTileEntity.COVER_DATA_NBT_KEYS;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
@@ -11,16 +20,22 @@ import gregtech.api.interfaces.metatileentity.IConnectable;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity;
-import gregtech.api.metatileentity.BaseMetaTileEntity.ClientEvents;
import gregtech.api.net.GT_Packet_TileEntity;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.*;
+import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_CoverBehaviorBase;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
import gregtech.common.GT_Client;
import gregtech.common.covers.GT_Cover_Fluidfilter;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -32,27 +47,18 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-
-import static gregtech.GT_Mod.GT_FML_LOGGER;
-import static gregtech.api.enums.GT_Values.NW;
-
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
* This is the main TileEntity for EVERYTHING.
*/
public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileEntity, IPipeRenderedTileEntity {
- 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};
+ private final GT_CoverBehaviorBase<?>[] mCoverBehaviors = new GT_CoverBehaviorBase<?>[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior};
public byte mConnections = IConnectable.NO_CONNECTION;
protected MetaPipeEntity mMetaTileEntity;
private byte[] mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
- private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
- private int[] mCoverData = new int[]{0, 0, 0, 0, 0, 0};
- private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
+ private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
+ private ISerializableObject[] mCoverData = new ISerializableObject[6];
private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false;
private final boolean mCheckConnections = false;
private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0;
@@ -92,27 +98,18 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
try {
aNBT.setInteger("mID", mID);
- aNBT.setIntArray("mCoverData", mCoverData);
+ for (int i = 0; i < mCoverData.length; i++) {
+ if (mCoverData[i] != null)
+ aNBT.setTag(COVER_DATA_NBT_KEYS[i], mCoverData[i].saveDataToNBT());
+ }
aNBT.setIntArray("mCoverSides", mCoverSides);
aNBT.setByteArray("mRedstoneSided", mSidedRedstone);
aNBT.setByte("mConnections", mConnections);
aNBT.setByte("mColor", mColor);
aNBT.setByte("mStrongRedstone", mStrongRedstone);
aNBT.setBoolean("mWorks", !mWorks);
-
- for(int i=0;i < mCoverData.length; i++) {
- if (GregTech_API.getCoverBehavior(mCoverSides[i]) instanceof GT_Cover_Fluidfilter) {
- final int fluidId = mCoverData[i] >>> 3;
- final Fluid fluid = FluidRegistry.getFluid(fluidId);
- if(fluid != null) {
- final String fluidName = FluidRegistry.getFluidName(fluid);
- aNBT.setString(String.format("fluidFilter%d", i), fluidName);
- }
- }
- }
-
} catch (Throwable e) {
- GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
+ GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk would've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err);
}
try {
@@ -158,28 +155,61 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (aID <= 0) mID = (short) aNBT.getInteger("mID");
else mID = aID;
mCoverSides = aNBT.getIntArray("mCoverSides");
- mCoverData = aNBT.getIntArray("mCoverData");
mSidedRedstone = aNBT.getByteArray("mRedstoneSided");
mConnections = aNBT.getByte("mConnections");
mColor = aNBT.getByte("mColor");
mStrongRedstone = aNBT.getByte("mStrongRedstone");
mWorks = !aNBT.getBoolean("mWorks");
- if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0};
if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
+ // check old form of data
+ mCoverData = null;
+ if (aNBT.hasKey("mCoverData", 11)) {
+ int[] tOldData = aNBT.getIntArray("mCoverData");
+ if (tOldData.length == 6)
+ mCoverData = Arrays.stream(tOldData).mapToObj(ISerializableObject.LegacyCoverData::new).toArray(ISerializableObject[]::new);
+ }
+ // if no old data
+ if (mCoverData == null) {
+ mCoverData = new ISerializableObject[6];
+ for (byte i = 0; i<6; i++) {
+ GT_CoverBehaviorBase<?> tBehavior = getCoverBehaviorAtSideNew(i);
+ if (tBehavior == null)
+ continue;
+ mCoverData[i] = tBehavior.createDataObject();
+ if (aNBT.hasKey(COVER_DATA_NBT_KEYS[i]))
+ mCoverData[i].loadDataFromNBT(aNBT.getTag(COVER_DATA_NBT_KEYS[i]));
+ }
+ }
if (mSidedRedstone.length != 6) mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
- for (byte i = 0; i < 6; i++) {
- mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
- if(mCoverBehaviors[i] instanceof GT_Cover_Fluidfilter) {
- final String filterKey = String.format("fluidFilter%d", i);
- if (aNBT.hasKey(filterKey)) {
- mCoverData[i] = (mCoverData[i] & 7) | (FluidRegistry.getFluidID(aNBT.getString(filterKey)) << 3);
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
+
+ // check old form of data
+ mCoverData = new ISerializableObject[6];
+ if (aNBT.hasKey("mCoverData", 11) && aNBT.getIntArray("mCoverData").length == 6) {
+ int[] tOldData = aNBT.getIntArray("mCoverData");
+ for (int i = 0; i < tOldData.length; i++) {
+ if(mCoverBehaviors[i] instanceof GT_Cover_Fluidfilter) {
+ final String filterKey = String.format("fluidFilter%d", i);
+ if (aNBT.hasKey(filterKey)) {
+ mCoverData[i] = mCoverBehaviors[i].createDataObject((tOldData[i] & 7) | (FluidRegistry.getFluidID(aNBT.getString(filterKey)) << 3));
+ }
+ } else if (mCoverBehaviors[i] != null && mCoverBehaviors[i] != GregTech_API.sNoBehavior) {
+ mCoverData[i] = mCoverBehaviors[i].createDataObject(tOldData[i]);
}
}
+ } else {
+ // no old data
+ for (byte i = 0; i<6; i++) {
+ if (mCoverBehaviors[i] == null)
+ continue;
+ if (aNBT.hasKey(COVER_DATA_NBT_KEYS[i]))
+ mCoverData[i] = mCoverBehaviors[i].createDataObject(aNBT.getTag(COVER_DATA_NBT_KEYS[i]));
+ else
+ mCoverData[i] = mCoverBehaviors[i].createDataObject();
+ }
}
-
-
if (mID != 0 && createNewMetatileEntity(mID)) {
NBTTagList tItemList = aNBT.getTagList("Inventory", 10);
for (int i = 0; i < tItemList.tagCount(); i++) {
@@ -199,11 +229,11 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
}
- if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0};
+ if (mCoverData == null || mCoverData.length != 6) mCoverData = new ISerializableObject[6];
if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
if (mSidedRedstone.length != 6) mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
- for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
}
private boolean createNewMetatileEntity(short aID) {
@@ -271,7 +301,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
for (byte i = (byte) (tCode - 2); i < 6; i++)
if (getCoverIDAtSide(i) != 0) {
tCode++;
- GT_CoverBehavior tCover = getCoverBehaviorAtSide(i);
+ GT_CoverBehaviorBase<?> tCover = getCoverBehaviorAtSideNew(i);
int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this);
if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) {
byte tRedstone = tCover.isRedstoneSensitive(i, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer) ? getInputRedstoneSignal(i) : 0;
@@ -298,7 +328,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (isServerSide()) {
if (mTickTimer == 10) {
for (byte i = 0; i < 6; i++)
- mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
issueBlockUpdate();
joinEnet();
}
@@ -326,15 +356,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
if (mTickTimer > 10) {
- if (mConnections != oTextureData)
- sendBlockEvent(ClientEvents.CHANGE_COMMON_DATA, oTextureData = mConnections);
+ if (mConnections != oTextureData) sendBlockEvent((byte) 0, oTextureData = mConnections);
byte tData = mMetaTileEntity.getUpdateData();
- if (tData != oUpdateData)
- sendBlockEvent(ClientEvents.CHANGE_CUSTOM_DATA, oUpdateData = tData);
- if (mColor != oColor) sendBlockEvent(ClientEvents.CHANGE_COLOR, oColor = mColor);
+ if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData);
+ if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor);
tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0));
- if (tData != oRedstoneData)
- sendBlockEvent(ClientEvents.CHANGE_REDSTONE_OUTPUT, oRedstoneData = tData);
+ if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData);
}
if (mNeedsBlockUpdate) {
@@ -384,7 +411,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
mCoverSides[4] = aCover4;
mCoverSides[5] = aCover5;
- for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
receiveClientEvent(0, aTextureData);
receiveClientEvent(1, aUpdateData);
@@ -498,6 +525,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ public void receiveCoverData(byte aCoverSide, int aCoverID, ISerializableObject aCoverData, EntityPlayerMP aPlayer) {
+ if ((aCoverSide >= 0 && aCoverSide < 6) && (mCoverSides[aCoverSide] == aCoverID))
+ setCoverDataAtSide(aCoverSide, aCoverData);
+ }
+
+ @Override
public byte getStrongestRedstone() {
return (byte) Math.max(getInternalInputRedstoneSignal((byte) 0), Math.max(getInternalInputRedstoneSignal((byte) 1), Math.max(getInternalInputRedstoneSignal((byte) 2), Math.max(getInternalInputRedstoneSignal((byte) 3), Math.max(getInternalInputRedstoneSignal((byte) 4), getInternalInputRedstoneSignal((byte) 5))))));
}
@@ -869,7 +902,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (mStrongRedstone > 0) tNBT.setByte("mStrongRedstone", mStrongRedstone);
for (byte i = 0; i < mCoverSides.length; i++) {
if (mCoverSides[i] != 0) {
- tNBT.setIntArray("mCoverData", mCoverData);
+ if (mCoverData[i] != null) // this really shouldn't be null if a cover is there already, but whatever
+ tNBT.setTag(COVER_DATA_NBT_KEYS[i], mCoverData[i].saveDataToNBT());
tNBT.setIntArray("mCoverSides", mCoverSides);
break;
}
@@ -909,13 +943,13 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) {
if (getCoverIDAtSide(aSide) == 0 && getCoverIDAtSide(tSide) != 0) {
if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) {
- setCoverDataAtSide(tSide, getCoverBehaviorAtSide(tSide).onCoverScrewdriverclick(tSide, getCoverIDAtSide(tSide), getCoverDataAtSide(tSide), this, aPlayer, 0.5F, 0.5F, 0.5F));
+ setCoverDataAtSide(tSide, getCoverBehaviorAtSideNew(tSide).onCoverScrewdriverClick(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), this, aPlayer, 0.5F, 0.5F, 0.5F));
mMetaTileEntity.onScrewdriverRightClick(tSide, aPlayer, aX, aY, aZ);
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord);
}
} else {
if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
- setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ));
+ setCoverDataAtSide(aSide, getCoverBehaviorAtSideNew(aSide).onCoverScrewdriverClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ));
mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord);
}
@@ -968,7 +1002,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (getCoverIDAtSide(coverSide) == 0) {
if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) {
- if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(coverSide, new GT_ItemStack(tCurrentItem), this) &&
+ if (GregTech_API.getCoverBehaviorNew(tCurrentItem).isCoverPlaceable(coverSide, new GT_ItemStack(tCurrentItem), this) &&
mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem)))
{
setCoverItemAtSide(coverSide, tCurrentItem);
@@ -989,14 +1023,14 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
else if (aPlayer.isSneaking()) { //Sneak click, no tool -> open cover config or turn back.
aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide;
- return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSide(aSide).onCoverShiftRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer);
+ return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSideNew(aSide).onCoverShiftRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer);
}
- if (getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ))
+ if (getCoverBehaviorAtSideNew(aSide).onCoverRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ))
return true;
}
- if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
try {
@@ -1053,7 +1087,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
*/
@Override
public int[] getAccessibleSlotsFromSide(int aSide) {
- if (canAccessData() && (getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this)))
+ if (canAccessData() && (getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this)))
return mMetaTileEntity.getAccessibleSlotsFromSide(aSide);
return new int[0];
}
@@ -1063,7 +1097,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
*/
@Override
public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
- return canAccessData() && getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
+ return canAccessData() && getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
}
/**
@@ -1071,7 +1105,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
*/
@Override
public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
- return canAccessData() && getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
+ return canAccessData() && getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
}
@Override
@@ -1081,7 +1115,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
@Override
public byte getInternalInputRedstoneSignal(byte aSide) {
- return (byte) (getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) & 15);
+ return (byte) (getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) & 15);
}
@Override
@@ -1091,12 +1125,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
@Override
public byte getOutputRedstoneSignal(byte aSide) {
- return (byte) (getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) || (getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) ? mSidedRedstone[aSide] & 15 : 0);
+ return (byte) (getCoverBehaviorAtSideNew(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) || (getCoverBehaviorAtSideNew(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) ? mSidedRedstone[aSide] & 15 : 0);
}
@Override
public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) {
- if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
setOutputRedstoneSignal(aSide, aStrength);
}
@@ -1159,16 +1193,19 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ @Deprecated
public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) {
- return aSide >= 0 && aSide < mCoverBehaviors.length ? mCoverBehaviors[aSide] : GregTech_API.sNoBehavior;
+ if (aSide >= 0 && aSide < mCoverBehaviors.length && mCoverBehaviors[aSide] instanceof GT_CoverBehavior)
+ return (GT_CoverBehavior) mCoverBehaviors[aSide];
+ return GregTech_API.sNoBehavior;
}
@Override
public void setCoverIDAtSide(byte aSide, int aID) {
if (aSide >= 0 && aSide < 6) {
mCoverSides[aSide] = aID;
- mCoverData[aSide] = 0;
- mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID);
+ mCoverBehaviors[aSide] = GregTech_API.getCoverBehaviorNew(aID);
+ mCoverData[aSide] = mCoverBehaviors[aSide].createDataObject();
issueCoverUpdate(aSide);
issueBlockUpdate();
}
@@ -1176,7 +1213,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
@Override
public void setCoverItemAtSide(byte aSide, ItemStack aCover) {
- GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this);
+ GregTech_API.getCoverBehaviorNew(aCover).placeCover(aSide, aCover, this);
}
@Override
@@ -1201,17 +1238,41 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ @Deprecated
public void setCoverDataAtSide(byte aSide, int aData) {
- if (aSide >= 0 && aSide < 6) mCoverData[aSide] = aData;
+ if (aSide >= 0 && aSide < 6 && mCoverData[aSide] instanceof ISerializableObject.LegacyCoverData)
+ mCoverData[aSide] = new ISerializableObject.LegacyCoverData(aData);
}
@Override
+ @Deprecated
public int getCoverDataAtSide(byte aSide) {
- if (aSide >= 0 && aSide < 6) return mCoverData[aSide];
+ if (aSide >= 0 && aSide < 6 && mCoverData[aSide] instanceof ISerializableObject.LegacyCoverData)
+ return ((ISerializableObject.LegacyCoverData) mCoverData[aSide]).get();
return 0;
}
@Override
+ public void setCoverDataAtSide(byte aSide, ISerializableObject aData) {
+ if (aSide >= 0 && aSide < 6 && getCoverBehaviorAtSideNew(aSide) != null && getCoverBehaviorAtSideNew(aSide).cast(aData) != null)
+ mCoverData[aSide] = aData;
+ }
+
+ @Override
+ public ISerializableObject getComplexCoverDataAtSide(byte aSide) {
+ if (aSide >= 0 && aSide < 6 && getCoverBehaviorAtSideNew(aSide) != null)
+ return mCoverData[aSide];
+ return GregTech_API.sNoBehavior.createDataObject();
+ }
+
+ @Override
+ public GT_CoverBehaviorBase<?> getCoverBehaviorAtSideNew(byte aSide) {
+ if (aSide >= 0 && aSide < 6)
+ return mCoverBehaviors[aSide];
+ return GregTech_API.sNoBehavior;
+ }
+
+ @Override
public void setLightValue(byte aLightValue) {
//
}
@@ -1228,8 +1289,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
@Override
public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) {
- if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) {
- ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this);
+ if (getCoverBehaviorAtSideNew(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) {
+ ItemStack tStack = getCoverBehaviorAtSideNew(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this);
if (tStack != null) {
tStack.setTagCompound(null);
EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack);
@@ -1323,12 +1384,15 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (tTileEntity != null && !mMetaTileEntity.isConnectedAtSide((byte) aSide.ordinal()))
return false;
- if (isFill && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
- && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))
+ if(isFill && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
+ && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))
return true;
- return !isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
- && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this);
+ if (!isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
+ && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()),aFluid, this))
+ return true;
+
+ return false;
}
@Override
@@ -1371,8 +1435,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (canAccessData()
&& (aSide == ForgeDirection.UNKNOWN
|| (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
- && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this))
- || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this))
+ && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), null, this))
+ || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), null, this))
// Doesn't need to be connected to get Tank Info -- otherwise things can't connect
)
)
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 10d5ec774a..9176d063ce 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -40,6 +40,7 @@ import net.minecraft.block.BlockFire;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -74,23 +75,22 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
* This is the main TileEntity for EVERYTHING.
*/
@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)})
+ @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, IAlignmentProvider, IConstructableProvider {
- 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};
+ static final String[] COVER_DATA_NBT_KEYS = Arrays.stream(ForgeDirection.VALID_DIRECTIONS).mapToInt(Enum::ordinal).mapToObj(i -> "mCoverData" + i).toArray(String[]::new);
+ private final GT_CoverBehaviorBase<?>[] mCoverBehaviors = new GT_CoverBehaviorBase<?>[]{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;
protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0;
protected boolean mReleaseEnergy = false;
protected long[] mAverageEUInput = new long[]{0, 0, 0, 0, 0}, mAverageEUOutput = new long[]{0, 0, 0, 0, 0};
- private final boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false};
- private final boolean[] mActiveEUOutputs = new boolean[]{false, false, false, false, false, false};
+ private boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false};
private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
- private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
- private int[] mCoverData = new int[]{0, 0, 0, 0, 0, 0};
- private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
+ private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
+ private ISerializableObject[] mCoverData = new ISerializableObject[6];
private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false;
- private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
+ private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0;
private short mID = 0;
public long mTickTimer = 0;
@@ -139,7 +139,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aNBT.setInteger("mID", mID);
aNBT.setLong("mStoredSteam", mStoredSteam);
aNBT.setLong("mStoredEnergy", mStoredEnergy);
- aNBT.setIntArray("mCoverData", mCoverData);
+ for (int i = 0; i < mCoverData.length; i++) {
+ if (mCoverData[i] != null)
+ aNBT.setTag(COVER_DATA_NBT_KEYS[i], mCoverData[i].saveDataToNBT());
+ }
aNBT.setIntArray("mCoverSides", mCoverSides);
aNBT.setByteArray("mRedstoneSided", mSidedRedstone);
aNBT.setByte("mColor", mColor);
@@ -230,19 +233,37 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mOutputDisabled = aNBT.getBoolean("mOutputDisabled");
mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries"));
mCoverSides = aNBT.getIntArray("mCoverSides");
- mCoverData = aNBT.getIntArray("mCoverData");
mSidedRedstone = aNBT.getByteArray("mRedstoneSided");
mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents");
int nbtVersion = aNBT.getInteger("nbtVersion");
- if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0};
if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
if (mSidedRedstone.length != 6)
if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior())
mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
- for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
+
+ // check legacy data
+ mCoverData = new ISerializableObject[6];
+ if (aNBT.hasKey("mCoverData", 11) && aNBT.getIntArray("mCoverData").length == 6) {
+ int[] tOldData = aNBT.getIntArray("mCoverData");
+ for (int i = 0; i < tOldData.length; i++) {
+ if (mCoverBehaviors[i] != null)
+ mCoverData[i] = mCoverBehaviors[i].createDataObject(tOldData[i]);
+ }
+ } else {
+ // no old data
+ for (byte i = 0; i<6; i++) {
+ if (mCoverBehaviors[i] == null)
+ continue;
+ if (aNBT.hasKey(COVER_DATA_NBT_KEYS[i]))
+ mCoverData[i] = mCoverBehaviors[i].createDataObject(aNBT.getTag(COVER_DATA_NBT_KEYS[i]));
+ else
+ mCoverData[i] = mCoverBehaviors[i].createDataObject();
+ }
+ }
if (mID != 0 && createNewMetatileEntity(mID)) {
NBTTagList tItemList = aNBT.getTagList("Inventory", 10);
@@ -264,14 +285,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
}
- if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0};
+ if (mCoverData == null || mCoverData.length != 6) mCoverData = new ISerializableObject[6];
if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
if (mSidedRedstone.length != 6)
if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior())
mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
- for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
}
private boolean createNewMetatileEntity(short aID) {
@@ -380,7 +401,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
for (byte i = (byte) (tCode - 2); i < 6; i++)
if (getCoverIDAtSide(i) != 0) {
tCode++;
- GT_CoverBehavior tCover = getCoverBehaviorAtSide(i);
+ GT_CoverBehaviorBase<?> tCover = getCoverBehaviorAtSideNew(i);
int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this);
if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) {
byte tRedstone = tCover.isRedstoneSensitive(i, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer) ? getInputRedstoneSignal(i) : 0;
@@ -414,7 +435,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (aSideServer) {
if (mRedstone != oRedstone || mTickTimer == 10) {
for (byte i = 0; i < 6; i++)
- mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
oRedstone = mRedstone;
issueBlockUpdate();
}
@@ -492,7 +513,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) {
if (getRandomNumber(10) == 0) {
try{
- GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
+ GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
}catch(Exception e){
}
@@ -508,9 +529,9 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
return;
}
if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) {
- try {
- GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
- }catch(Exception e){
+ try{
+ GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
+ }catch(Exception e){
}
GT_Log.exp.println("Machine at: "+ this.getXCoord()+" | "+ this.getYCoord()+" | "+ this.getZCoord()+" DIMID: " +this.worldObj.provider.dimensionId + " explosion due to Thunderstorm!");
@@ -678,7 +699,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mCoverSides[4] = aCover4;
mCoverSides[5] = aCover5;
- for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
receiveClientEvent(ClientEvents.CHANGE_COMMON_DATA, aTextureData);
receiveClientEvent(ClientEvents.CHANGE_CUSTOM_DATA, aUpdateData & 0x7F);
@@ -702,7 +723,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mCoverSides[4] = aCover4;
mCoverSides[5] = aCover5;
- for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]);
receiveClientEvent(ClientEvents.CHANGE_COMMON_DATA, aTextureData);
receiveClientEvent(ClientEvents.CHANGE_CUSTOM_DATA, aUpdateData & 0x7F);
@@ -851,6 +872,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ public void receiveCoverData(byte aCoverSide, int aCoverID, ISerializableObject aCoverData, EntityPlayerMP aPlayer) {
+ if ((aCoverSide >= 0 && aCoverSide < 6) && (mCoverSides[aCoverSide] == aCoverID))
+ setCoverDataAtSide(aCoverSide, aCoverData);
+ }
+
+ @Override
public byte getStrongestRedstone() {
return (byte) Math.max(getInternalInputRedstoneSignal((byte) 0), Math.max(getInternalInputRedstoneSignal((byte) 1), Math.max(getInternalInputRedstoneSignal((byte) 2), Math.max(getInternalInputRedstoneSignal((byte) 3), Math.max(getInternalInputRedstoneSignal((byte) 4), getInternalInputRedstoneSignal((byte) 5))))));
}
@@ -1028,7 +1055,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public boolean increaseProgress(int aProgressAmountInTicks) {
- return canAccessData() && mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks;
+ return canAccessData() ? mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false;
}
@Override
@@ -1252,7 +1279,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
private boolean isEnergyInputSide(byte aSide) {
if (aSide >= 0 && aSide < 6) {
- if (!getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide).letsEnergyIn(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
if (isInvalid() || mReleaseEnergy) return false;
if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput())
@@ -1263,7 +1290,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
private boolean isEnergyOutputSide(byte aSide) {
if (aSide >= 0 && aSide < 6) {
- if (!getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
if (isInvalid() || mReleaseEnergy) return mReleaseEnergy;
if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput())
@@ -1413,7 +1440,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (mStrongRedstone > 0) tNBT.setByte("mStrongRedstone", mStrongRedstone);
for (byte i = 0; i < mCoverSides.length; i++) {
if (mCoverSides[i] != 0) {
- tNBT.setIntArray("mCoverData", mCoverData);
+ if (mCoverData[i] != null) // this really shouldn't be null if a cover is there already, but whatever
+ tNBT.setTag(COVER_DATA_NBT_KEYS[i], mCoverData[i].saveDataToNBT());
tNBT.setIntArray("mCoverSides", mCoverSides);
break;
}
@@ -1433,12 +1461,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
//Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron
if (aPlayer.isSneaking()) {
byte tSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide;
- return (getCoverBehaviorAtSide(tSide).hasCoverGUI());
- } else if (getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) {
+ return (getCoverBehaviorAtSideNew(tSide).hasCoverGUI());
+ } else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) {
return true;
}
- if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
}
if (isServerSide()) {
@@ -1465,7 +1493,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) {
if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) {
- setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ));
+ setCoverDataAtSide(aSide, getCoverBehaviorAtSideNew(aSide).onCoverScrewdriverClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ));
mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord);
}
@@ -1529,7 +1557,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (getCoverIDAtSide(coverSide) == 0) {
if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) {
- if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(coverSide, new GT_ItemStack(tCurrentItem), this) &&
+ if (GregTech_API.getCoverBehaviorNew(tCurrentItem).isCoverPlaceable(coverSide, new GT_ItemStack(tCurrentItem), this) &&
mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem)))
{
setCoverItemAtSide(coverSide, tCurrentItem);
@@ -1550,13 +1578,13 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
else if (aPlayer.isSneaking()) { //Sneak click, no tool -> open cover config if possible.
aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide;
- return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSide(aSide).onCoverShiftRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer);
+ return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSideNew(aSide).onCoverShiftRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer);
}
- if (getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ))
+ if (getCoverBehaviorAtSideNew(aSide).onCoverRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ))
return true;
- if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
if (isUpgradable() && tCurrentItem != null) {/*
@@ -1645,7 +1673,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
*/
@Override
public int[] getAccessibleSlotsFromSide(int aSide) {
- if (canAccessData() && (getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this)))
+ if (canAccessData() && (getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this)))
return mMetaTileEntity.getAccessibleSlotsFromSide(aSide);
return new int[0];
}
@@ -1655,7 +1683,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
*/
@Override
public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
- return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
+ return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
}
/**
@@ -1663,7 +1691,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
*/
@Override
public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
- return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
+ return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
}
@Override
@@ -1673,7 +1701,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public byte getInternalInputRedstoneSignal(byte aSide) {
- return (byte) (getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) & 15);
+ return (byte) (getCoverBehaviorAtSideNew(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) & 15);
}
@Override
@@ -1683,7 +1711,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public byte getOutputRedstoneSignal(byte aSide) {
- return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : getGeneralRS(aSide);
+ return getCoverBehaviorAtSideNew(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : getGeneralRS(aSide);
}
public byte getGeneralRS(byte aSide){
@@ -1693,7 +1721,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) {
- if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
setOutputRedstoneSignal(aSide, aStrength);
}
@@ -1779,16 +1807,19 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ @Deprecated
public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) {
- return aSide >= 0 && aSide < mCoverBehaviors.length ? mCoverBehaviors[aSide] : GregTech_API.sNoBehavior;
+ if (aSide >= 0 && aSide < mCoverBehaviors.length && mCoverBehaviors[aSide] instanceof GT_CoverBehavior)
+ return (GT_CoverBehavior) mCoverBehaviors[aSide];
+ return GregTech_API.sNoBehavior;
}
@Override
public void setCoverIDAtSide(byte aSide, int aID) {
if (aSide >= 0 && aSide < 6) {
mCoverSides[aSide] = aID;
- mCoverData[aSide] = 0;
- mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID);
+ mCoverBehaviors[aSide] = GregTech_API.getCoverBehaviorNew(aID);
+ mCoverData[aSide] = mCoverBehaviors[aSide].createDataObject();
issueCoverUpdate(aSide);
issueBlockUpdate();
}
@@ -1796,7 +1827,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public void setCoverItemAtSide(byte aSide, ItemStack aCover) {
- GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this);
+ GregTech_API.getCoverBehaviorNew(aCover).placeCover(aSide, aCover, this);
}
@Override
@@ -1821,15 +1852,37 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ @Deprecated
public void setCoverDataAtSide(byte aSide, int aData) {
- if (aSide >= 0 && aSide < 6) mCoverData[aSide] = aData;
+ if (aSide >= 0 && aSide < 6) mCoverData[aSide] = new ISerializableObject.LegacyCoverData(aData);
}
@Override
+ @Deprecated
public int getCoverDataAtSide(byte aSide) {
- if (aSide >= 0 && aSide < 6) return mCoverData[aSide];
+ if (aSide >= 0 && aSide < 6 && mCoverData[aSide] instanceof ISerializableObject.LegacyCoverData)
+ return ((ISerializableObject.LegacyCoverData) mCoverData[aSide]).get();
return 0;
}
+ @Override
+ public void setCoverDataAtSide(byte aSide, ISerializableObject aData) {
+ if (aSide >= 0 && aSide < 6 && getCoverBehaviorAtSideNew(aSide) != null && getCoverBehaviorAtSideNew(aSide).cast(aData) != null)
+ mCoverData[aSide] = aData;
+ }
+
+ @Override
+ public ISerializableObject getComplexCoverDataAtSide(byte aSide) {
+ if (aSide >= 0 && aSide < 6 && getCoverBehaviorAtSideNew(aSide) != null)
+ return mCoverData[aSide];
+ return GregTech_API.sNoBehavior.createDataObject();
+ }
+
+ @Override
+ public GT_CoverBehaviorBase<?> getCoverBehaviorAtSideNew(byte aSide) {
+ if (aSide >= 0 && aSide < 6)
+ return mCoverBehaviors[aSide];
+ return GregTech_API.sNoBehavior;
+ }
public byte getLightValue() {
return mLightValue;
@@ -1860,8 +1913,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) {
- if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) {
- ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this);
+ if (getCoverBehaviorAtSideNew(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) {
+ ItemStack tStack = getCoverBehaviorAtSideNew(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this);
if (tStack != null) {
tStack.setTagCompound(null);
EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack);
@@ -1976,7 +2029,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aSide == ForgeDirection.UNKNOWN ||
(
mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)
+ getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)
)
)
)
@@ -1992,7 +2045,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aSide == ForgeDirection.UNKNOWN ||
(
mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this)
+ getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this)
)
)
)
@@ -2008,7 +2061,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aSide == ForgeDirection.UNKNOWN ||
(
mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)
+ getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)
)
)
)
@@ -2024,7 +2077,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aSide == ForgeDirection.UNKNOWN ||
(
mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)
+ getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)
)
)
)
@@ -2040,7 +2093,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aSide == ForgeDirection.UNKNOWN ||
(
mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)
+ getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)
)
)
)
@@ -2055,8 +2108,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aSide == ForgeDirection.UNKNOWN ||
(
mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)
+ getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
+ getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), null, this)
)
)
)
diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
index 99e018ecdf..73a33fb9eb 100644
--- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
@@ -178,7 +178,10 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable {
if (difference > 1.05 && difference < 1.4) {
aSide = 5;
}
- boolean tCovered = aSide < 6 && mBaseMetaTileEntity.getCoverIDAtSide(aSide) > 0;
+ boolean tCovered = false;
+ if (aSide < 6 && mBaseMetaTileEntity.getCoverIDAtSide(aSide) > 0) {
+ tCovered = true;
+ }
if(isConnectedAtSide(aSide)){
tCovered = true;
}
@@ -518,9 +521,9 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable {
public int[] getAccessibleSlotsFromSide(int aSide) {
ArrayList<Integer> tList = new ArrayList<Integer>();
IGregTechTileEntity tTileEntity = getBaseMetaTileEntity();
- boolean tSkip = 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);
+ boolean tSkip = tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity);
for (int i = 0; i < getSizeInventory(); i++)
- if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity)))
+ if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity)))
tList.add(i);
int[] rArray = new int[tList.size()];
for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i);
@@ -766,7 +769,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable {
if (tTileEntity instanceof IColoredTileEntity) {
if (getBaseMetaTileEntity().getColorization() >= 0) {
byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
- return tColor < 0 || tColor == getBaseMetaTileEntity().getColorization();
+ if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) return false;
}
}
@@ -781,9 +784,9 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable {
final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
if (baseMetaTile == null || !baseMetaTile.isServerSide()) return 0;
- final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
- final int coverId = baseMetaTile.getCoverIDAtSide(aSide),
- coverData = baseMetaTile.getCoverDataAtSide(aSide);
+ final GT_CoverBehaviorBase<?> coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide);
+ final int coverId = baseMetaTile.getCoverIDAtSide(aSide);
+ ISerializableObject coverData = baseMetaTile.getComplexCoverDataAtSide(aSide);
boolean alwaysLookConnected = coverBehavior.alwaysLookConnected(aSide, coverId, coverData, baseMetaTile);
boolean letsIn = letsIn(coverBehavior, aSide, coverId, coverData, baseMetaTile);
@@ -853,6 +856,9 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable {
public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; }
public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; }
+ public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return false; }
+ public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return false; }
+
public boolean canConnect(byte aSide, TileEntity tTileEntity) { return false; }
public boolean getGT6StyleConnection() { return false; }
diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
index e1a8d65149..b3c25ff345 100644
--- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
@@ -714,9 +714,9 @@ public abstract class MetaTileEntity implements IMetaTileEntity {
public int[] getAccessibleSlotsFromSide(int aSide) {
ArrayList<Integer> tList = new ArrayList<Integer>();
IGregTechTileEntity tTileEntity = getBaseMetaTileEntity();
- boolean tSkip = 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);
+ boolean tSkip = tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity);
for (int i = 0; i < getSizeInventory(); i++)
- if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity)))
+ if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity)))
tList.add(i);
int[] rArray = new int[tList.size()];
for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i);
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
index 439cacff91..2764eeb07e 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
@@ -1,7 +1,6 @@
package gregtech.api.metatileentity.implementations;
import cofh.api.energy.IEnergyReceiver;
-import com.google.common.collect.Sets;
import cpw.mods.fml.common.Loader;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
@@ -159,7 +158,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
if (!isConnectedAtSide(aSide) && aSide != 6)
return 0;
- if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity()))
return 0;
HashSet<TileEntity> nul = null;
return transferElectricity(aSide, aVoltage, aAmperage,nul);
@@ -254,11 +253,21 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity);
}
+ @Override
+ public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsEnergyIn(aSide, aCoverID, aCoverVariable, aTileEntity);
+ }
+
+ @Override
+ public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity);
+ }
+
@Override
public boolean canConnect(byte aSide, TileEntity tTileEntity) {
final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
- final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
+ final GT_CoverBehaviorBase<?> coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide);
final byte tSide = GT_Utility.getOppositeSide(aSide);
final ForgeDirection tDir = ForgeDirection.getOrientation(tSide);
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 128f6fa916..8cce529050 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
@@ -15,8 +15,10 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_CoverBehaviorBase;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
import gregtech.api.util.WorldSpawnedEventBuilder;
import gregtech.common.GT_Client;
import gregtech.common.covers.GT_Cover_Drain;
@@ -336,6 +338,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
// Tank, From, Amount to receive
List<MutableTriple<IFluidHandler, ForgeDirection, Integer>> tTanks = new ArrayList<>();
+ int amount = tFluid.amount;
for (byte aSide, i = 0, j = (byte) aBaseMetaTileEntity.getRandomNumber(6); i < 6; i++) {
// Get a list of tanks accepting fluids, and what side they're on
@@ -345,11 +348,12 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
final IGregTechTileEntity gTank = tTank instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTank : null;
if (isConnectedAtSide(aSide) && tTank != null && (mLastReceivedFrom & (1 << aSide)) == 0 &&
- getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsFluidOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), tFluid.getFluid(), getBaseMetaTileEntity()) &&
- (gTank == null || gTank.getCoverBehaviorAtSide(tSide).letsFluidIn(tSide, gTank.getCoverIDAtSide(tSide), gTank.getCoverDataAtSide(tSide), tFluid.getFluid(), gTank))) {
+ getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsFluidOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), tFluid.getFluid(), getBaseMetaTileEntity()) &&
+ (gTank == null || gTank.getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, gTank.getCoverIDAtSide(tSide), gTank.getComplexCoverDataAtSide(tSide), tFluid.getFluid(), gTank))) {
if (tTank.fill(ForgeDirection.getOrientation(tSide), tFluid, false) > 0) {
tTanks.add(new MutableTriple<>(tTank, ForgeDirection.getOrientation(tSide), 0));
}
+ tFluid.amount = amount; // Because some mods do actually modify input fluid stack
}
}
@@ -420,6 +424,16 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
}
@Override
+ public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsFluidIn(aSide, aCoverID, aCoverVariable, null, aTileEntity);
+ }
+
+ @Override
+ public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsFluidOut(aSide, aCoverID, aCoverVariable, null, aTileEntity);
+ }
+
+ @Override
public boolean canConnect(byte aSide, TileEntity tTileEntity) {
if (tTileEntity == null)
return false;
@@ -429,7 +443,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
if (baseMetaTile == null)
return false;
- final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
+ final GT_CoverBehaviorBase<?> coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide);
final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null;
if (coverBehavior instanceof GT_Cover_Drain || (GregTech_API.mTConstruct && isTConstructFaucet(tTileEntity)))
@@ -442,7 +456,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
if (tInfo != null) {
return tInfo.length > 0
|| (GregTech_API.mTranslocator && isTranslocator(tTileEntity))
- || gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator;
+ || gTileEntity != null && gTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof GT_Cover_FluidRegulator;
}
}
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 edec79fe65..e316a44c80 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
@@ -13,7 +13,9 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_CoverBehaviorBase;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
import gregtech.common.GT_Client;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -216,6 +218,16 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
}
@Override
+ public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsItemsIn(aSide, aCoverID, aCoverVariable, -1, aTileEntity);
+ }
+
+ @Override
+ public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsItemsOut(aSide, aCoverID, aCoverVariable, -1, aTileEntity);
+ }
+
+ @Override
public boolean canConnect(byte aSide, TileEntity tTileEntity) {
if (tTileEntity == null) return false;
@@ -271,7 +283,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
@Override
public boolean insertItemStackIntoTileEntity(Object aSender, byte aSide) {
- if (getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsItemsOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), -1, getBaseMetaTileEntity())) {
+ if (getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsItemsOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), -1, getBaseMetaTileEntity())) {
TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide);
if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) {
if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) {
@@ -320,7 +332,7 @@ 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);
+ boolean tAllow = tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity);
if (tAllow) {
if (cacheSides == null)
cacheSides = super.getAccessibleSlotsFromSide(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 7c15137691..e8cac808dd 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
@@ -10,6 +10,7 @@ import gregtech.api.interfaces.metatileentity.IMachineCallback;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_CoverBehaviorBase;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
@@ -823,8 +824,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
@Override
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
- return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity()));
- }
+ if (aSide != mMainFacing) return true;
+ GT_CoverBehaviorBase<?> tBehavior = GregTech_API.getCoverBehaviorNew(aCoverID.toStack());
+ return tBehavior.isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), tBehavior.createDataObject(), getBaseMetaTileEntity());}
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java
index 3cdb26c9e1..d573c6bfd1 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java
@@ -186,7 +186,7 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE
@Override
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
- return GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover() && super.allowCoverOnSide(aSide, aCoverID);
+ return GregTech_API.getCoverBehaviorNew(aCoverID.toStack()).isSimpleCover() && super.allowCoverOnSide(aSide, aCoverID);
}
public float getSteamDamage() {
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 d5741f599d..1df2dac0f0 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
@@ -262,6 +262,16 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
}
@Override
+ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ aWrenchingSide = GT_Utility.getOppositeSide(aWrenchingSide);
+ if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) {
+ getBaseMetaTileEntity().setFrontFacing(aWrenchingSide);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) {
mSuccess--;
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java
index 2ff1e87348..972ac87d02 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java
@@ -21,7 +21,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_Input(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 3, new String[]{
"Fluid Input for Multiblocks",
- "Capacity: " + GT_Utility.formatNumbers(8000+8000*(aTier*(aTier+1)>>1)) + "L"});
+ "Capacity: " + GT_Utility.formatNumbers(8000*(1<<aTier)) + "L"});
}
public GT_MetaTileEntity_Hatch_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
@@ -139,7 +139,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch {
@Override
public int getCapacity() {
- return 8000+8000*(mTier*(mTier+1)>>1);
+ return 8000*(1<<mTier);
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
index 37a98162b8..2b7e50519d 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
@@ -185,7 +185,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
@Override
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity()))
return;
if (aPlayer.isSneaking()) {
if(disableSort) {
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java
index 9067f5bb7b..88506d928e 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java
@@ -16,12 +16,16 @@ import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
+import ic2.core.IHasGui;
+import ic2.core.Ic2Items;
+import ic2.core.item.ItemToolbox;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import java.util.HashSet;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_GLOW;
@@ -218,17 +222,37 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) {
if (aStack == null || aPlayer == null) return;
- if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
+
+ // Allow IC2 Toolbox with tools to function for maint issues.
+ if (aStack.getItem() instanceof ItemToolbox && aPlayer instanceof EntityPlayer) {
+ EntityPlayer aPlayerEntity = (EntityPlayer) aPlayer;
+ ItemToolbox aToolbox = (ItemToolbox) aStack.getItem();
+ IHasGui aToolboxGUI = aToolbox.getInventory(aPlayerEntity, aStack);
+ HashSet<ItemStack> aToolboxContents = new HashSet<ItemStack>();
+ for (int i=0; i<aToolboxGUI.getSizeInventory(); i++) {
+ ItemStack aTemp = aToolboxGUI.getStackInSlot(i);
+ if (aTemp != null) {
+ aToolboxContents.add(aTemp);
+ }
+ }
+ if (!aToolboxContents.isEmpty()) {
+ for (ItemStack aTool : aToolboxContents) {
+ onToolClick(aTool, aPlayer);
+ }
+ }
+ }
+
+ if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) && !mWrench && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mWrench = true;
- if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
+ if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList) && !mScrewdriver && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mScrewdriver = true;
- if (GT_Utility.isStackInList(aStack, GregTech_API.sSoftHammerList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
+ if (GT_Utility.isStackInList(aStack, GregTech_API.sSoftHammerList) && !mSoftHammer && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mSoftHammer = true;
- if (GT_Utility.isStackInList(aStack, GregTech_API.sHardHammerList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
+ if (GT_Utility.isStackInList(aStack, GregTech_API.sHardHammerList) && !mHardHammer && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mHardHammer = true;
- if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
+ if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList) && !mCrowbar && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mCrowbar = true;
- if (GT_ModHandler.useSolderingIron(aStack, aPlayer)) mSolderingTool = true;
+ if (!mSolderingTool && GT_ModHandler.useSolderingIron(aStack, aPlayer)) mSolderingTool = true;
if (GT_OreDictUnificator.isItemStackInstanceOf(aStack, "craftingDuctTape")) {
mWrench = mScrewdriver = mSoftHammer = mHardHammer = mCrowbar = mSolderingTool = true;
getBaseMetaTileEntity().setActive(false);
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
index 0919961af0..d848b06b07 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
@@ -29,7 +29,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_Output(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 4, new String[]{
"Fluid Output for Multiblocks",
- "Capacity: " + GT_Utility.formatNumbers(8000+8000*(aTier*(aTier+1)>>1)) + "L",
+ "Capacity: " + GT_Utility.formatNumbers(8000*(1<<aTier)) + "L",
"Right click with screwdriver to restrict output",
"Can be restricted to put out Items and/or Steam/No Steam/1 specific Fluid",
"Restricted Output Hatches are given priority for Multiblock Fluid output"});
@@ -92,18 +92,14 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
- if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick&0x7)==0) {
+ if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && mFluid != null) {
IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing());
if (tTileEntity != null) {
- for (boolean temp = true; temp && mFluid != null; ) {
- temp = false;
- FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), Math.max(1, mFluid.amount), false);
- if (tDrained != null) {
- int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false);
- if (tFilledAmount > 0) {
- temp = true;
- tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), tFilledAmount, true), true);
- }
+ FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), Math.max(1, mFluid.amount), false);
+ if (tDrained != null) {
+ int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false);
+ if (tFilledAmount > 0) {
+ tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), tFilledAmount, true), true);
}
}
}
@@ -162,7 +158,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
if (lockedFluidName == null || mMode < 8) mInventory[3] = null;
else {
FluidStack tLockedFluid = FluidRegistry.getFluidStack(lockedFluidName.replace("fluid.", "")
- .replace(".name", "").replace("ic2.fluid", "ic2").toLowerCase(), 1);
+ .replace("tile.", "").replace(".name", "").replace("ic2.fluid", "ic2").toLowerCase(), 1);
// Because getStackDisplaySlot() only allow return one int, this place I only can manually set.
if (tLockedFluid != null) {
mInventory[3] = GT_Utility.getFluidDisplayStack(tLockedFluid, false, true);
@@ -201,12 +197,12 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
@Override
public int getCapacity() {
- return 8000+8000*(mTier*(mTier+1)>>1);
+ return 8000*(1<<mTier);
}
@Override
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity()))
return;
if (aPlayer.isSneaking()) {
mMode = (byte) ((mMode + 9) % 10);
@@ -273,7 +269,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
}
private boolean tryToLockHatch(EntityPlayer aPlayer, byte aSide) {
- if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity()))
return false;
if (!isFluidLocked())
return false;
@@ -329,7 +325,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
return mMode % 4 < 2 && mMode != 9;
}
- public boolean isFluidLocked(){
+ public boolean isFluidLocked() {
return mMode == 8 || mMode == 9;
}
@@ -367,7 +363,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
EnumChatFormatting.GOLD + (mFluid == null ? "No Fluid" : mFluid.getLocalizedName()) + EnumChatFormatting.RESET,
EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mFluid == null ? 0 : mFluid.amount) + " L" + EnumChatFormatting.RESET + " " +
EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L"+ EnumChatFormatting.RESET,
- lockedFluidName == null ? "Not Locked" : ("Locked to " + StatCollector.translateToLocal(getLockedFluidName()))
+ (!isFluidLocked() || lockedFluidName == null) ? "Not Locked" : ("Locked to " + StatCollector.translateToLocal(getLockedFluidName()))
};
}
} \ No newline at end of file
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 7a2f1bedac..6369c48f8e 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
@@ -13,6 +13,7 @@ import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_Single_Recipe_Check;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Pollution;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
@@ -43,6 +44,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public int damageFactorLow = 5;
public float damageFactorHigh = 0.6f;
+ public boolean mLockedToSingleRecipe = false;
+ public GT_Single_Recipe_Check mSingleRecipeCheck = null;
+
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<>();
@@ -81,6 +85,24 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
return aSide != getBaseMetaTileEntity().getFrontFacing();
}
+ /** Override this if you are a multi-block that has added support for single recipe locking. */
+ public boolean supportsSingleRecipeLocking() {
+ return false;
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (supportsSingleRecipeLocking()) {
+ mLockedToSingleRecipe = !mLockedToSingleRecipe;
+ if (mLockedToSingleRecipe) {
+ GT_Utility.sendChatToPlayer(aPlayer, trans("219","Single recipe locking enabled. Will lock to next recipe."));
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, trans("220","Single recipe locking disabled."));
+ mSingleRecipeCheck = null;
+ }
+ }
+ }
+
@Override
public boolean isSimpleMachine() {
return false;
@@ -125,6 +147,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
aNBT.setInteger("mEfficiency", mEfficiency);
aNBT.setInteger("mPollution", mPollution);
aNBT.setInteger("mRuntime", mRuntime);
+ aNBT.setBoolean("mLockedToSingleRecipe", mLockedToSingleRecipe);
if (mOutputItems != null) {
aNBT.setInteger("mOutputItemsLength", mOutputItems.length);
@@ -162,6 +185,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
mEfficiency = aNBT.getInteger("mEfficiency");
mPollution = aNBT.getInteger("mPollution");
mRuntime = aNBT.getInteger("mRuntime");
+ mLockedToSingleRecipe = aNBT.getBoolean("mLockedToSingleRecipe");
int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength");
if (aOutputItemsLength > 0) {
diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java
index 29220e05ab..8035030f19 100644
--- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java
+++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java
@@ -10,9 +10,8 @@ import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
/**
- * Client -> Server: Update cover data
+ * Client -> Server: Update cover data. use this only if you are using the legacy data storage
*/
-
public class GT_Packet_TileEntityCover extends GT_Packet_New {
protected int mX;
protected short mY;
diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java
index 2a8091144d..e5cb184339 100644
--- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java
+++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java
@@ -1,9 +1,11 @@
package gregtech.api.net;
import com.google.common.io.ByteArrayDataInput;
+import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.ISerializableObject;
import gregtech.common.GT_Proxy;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
@@ -16,14 +18,14 @@ import net.minecraft.world.World;
/**
* Server -> Client: Show GUI
*/
-
public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New {
protected int mX;
protected short mY;
protected int mZ;
protected byte side;
- protected int coverID, coverData, dimID, playerID;
+ protected int coverID, dimID, playerID;
+ protected ISerializableObject coverData;
public GT_Packet_TileEntityCoverGUI() {
super(true);
@@ -37,12 +39,25 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New {
this.side = coverSide;
this.coverID = coverID;
- this.coverData = coverData;
+ this.coverData = new ISerializableObject.LegacyCoverData(coverData);
this.dimID = dimID;
this.playerID = playerID;
}
+ public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, byte coverSide, int coverID, ISerializableObject coverData, int dimID, int playerID) {
+ super(false);
+ this.mX = mX;
+ this.mY = mY;
+ this.mZ = mZ;
+
+ this.side = coverSide;
+ this.coverID = coverID;
+ this.coverData = coverData;
+ this.dimID = dimID;
+ this.playerID = playerID;
+ }
+
public GT_Packet_TileEntityCoverGUI(byte side, int coverID, int coverData, ICoverable tile, EntityPlayerMP aPlayer) {
super(false);
@@ -53,7 +68,7 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New {
this.side = side;
this.coverID = coverID;
- this.coverData = coverData;
+ this.coverData = new ISerializableObject.LegacyCoverData(coverData);
this.dimID = tile.getWorld().provider.dimensionId;
this.playerID = aPlayer.getEntityId();
@@ -67,11 +82,25 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New {
this.side = coverSide;
this.coverID = coverID;
- this.coverData = coverData;
+ this.coverData = new ISerializableObject.LegacyCoverData(coverData);
this.dimID = tile.getWorld().provider.dimensionId;
}
+ public GT_Packet_TileEntityCoverGUI(byte side, int coverID, ISerializableObject coverData, ICoverable tile, EntityPlayerMP aPlayer) {
+ super(false);
+ this.mX = tile.getXCoord();
+ this.mY = tile.getYCoord();
+ this.mZ = tile.getZCoord();
+
+ this.side = side;
+ this.coverID = coverID;
+ this.coverData = coverData.copy(); // make a copy so we don't get a race condition
+
+ this.dimID = tile.getWorld().provider.dimensionId;
+ this.playerID = aPlayer.getEntityId();
+ }
+
@Override
public byte getPacketID() {
return 7;
@@ -85,7 +114,7 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New {
aOut.writeByte(side);
aOut.writeInt(coverID);
- aOut.writeInt(coverData);
+ coverData.writeToByteBuf(aOut);
aOut.writeInt(dimID);
aOut.writeInt(playerID);
@@ -93,14 +122,15 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New {
@Override
public GT_Packet_New decode(ByteArrayDataInput aData) {
+ int coverID;
return new GT_Packet_TileEntityCoverGUI(
aData.readInt(),
aData.readShort(),
aData.readInt(),
aData.readByte(),
- aData.readInt(),
- aData.readInt(),
+ coverID = aData.readInt(),
+ GregTech_API.getCoverBehaviorNew(coverID).createDataObject().readFromPacket(aData, null),
aData.readInt(),
aData.readInt());
diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java
new file mode 100644
index 0000000000..f600fb1d82
--- /dev/null
+++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java
@@ -0,0 +1,113 @@
+package gregtech.api.net;
+
+import com.google.common.io.ByteArrayDataInput;
+import gregtech.api.GregTech_API;
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.ISerializableObject;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.network.INetHandler;
+import net.minecraft.network.NetHandlerPlayServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.DimensionManager;
+
+/**
+ * Client -> Server: Update cover data
+ */
+
+public class GT_Packet_TileEntityCoverNew extends GT_Packet_New {
+ protected int mX;
+ protected short mY;
+ protected int mZ;
+
+ protected byte side;
+ protected int coverID, dimID;
+ protected ISerializableObject coverData;
+
+ protected EntityPlayerMP mPlayer;
+
+ public GT_Packet_TileEntityCoverNew() {
+ super(true);
+ }
+
+ public GT_Packet_TileEntityCoverNew(int mX, short mY, int mZ, byte coverSide, int coverID, ISerializableObject coverData, int dimID) {
+ super(false);
+ this.mX = mX;
+ this.mY = mY;
+ this.mZ = mZ;
+
+ this.side = coverSide;
+ this.coverID = coverID;
+ this.coverData = coverData;
+
+ this.dimID = dimID;
+ }
+ public GT_Packet_TileEntityCoverNew(byte coverSide, int coverID, ISerializableObject coverData, ICoverable tile) {
+ super(false);
+ this.mX = tile.getXCoord();
+ this.mY = tile.getYCoord();
+ this.mZ = tile.getZCoord();
+
+ this.side = coverSide;
+ this.coverID = coverID;
+ this.coverData = coverData;
+
+ this.dimID = tile.getWorld().provider.dimensionId;
+ }
+
+ @Override
+ public byte getPacketID() {
+ return 11;
+ }
+
+ @Override
+ public void setINetHandler(INetHandler aHandler) {
+ if (aHandler instanceof NetHandlerPlayServer) {
+ mPlayer = ((NetHandlerPlayServer) aHandler).playerEntity;
+ }
+ }
+
+ @Override
+ public void encode(ByteBuf aOut) {
+ aOut.writeInt(mX);
+ aOut.writeShort(mY);
+ aOut.writeInt(mZ);
+
+ aOut.writeByte(side);
+ aOut.writeInt(coverID);
+ coverData.writeToByteBuf(aOut);
+
+ aOut.writeInt(dimID);
+ }
+
+ @Override
+ public GT_Packet_New decode(ByteArrayDataInput aData) {
+ int coverId;
+ return new GT_Packet_TileEntityCoverNew(
+ aData.readInt(),
+ aData.readShort(),
+ aData.readInt(),
+
+ aData.readByte(),
+ coverId = aData.readInt(),
+ GregTech_API.getCoverBehaviorNew(coverId).createDataObject().readFromPacket(aData, mPlayer),
+
+ aData.readInt());
+ }
+
+ @Override
+ public void process(IBlockAccess aWorld) {
+ if (mPlayer == null) // impossible, but who knows
+ return;
+ World world = DimensionManager.getWorld(dimID);
+ if (world != null) {
+ TileEntity tile = world.getTileEntity(mX, mY, mZ);
+ if (tile instanceof IGregTechTileEntity && !((IGregTechTileEntity) tile).isDead()) {
+ ((IGregTechTileEntity) tile).receiveCoverData(side, coverID, coverData, mPlayer);
+ }
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/objects/GT_UO_Dimension.java b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java
index 1c090eb9b5..0d05e6d229 100644
--- a/src/main/java/gregtech/api/objects/GT_UO_Dimension.java
+++ b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java
@@ -39,4 +39,11 @@ public class GT_UO_Dimension {
return null;
}
+ public String getUOFluidKey(GT_UO_Fluid uoFluid) {
+ return fFluids.inverse().get(uoFluid);
+ }
+
+ public GT_UO_Fluid getUOFluid(String key) {
+ return fFluids.get(key);
+ }
}
diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
new file mode 100644
index 0000000000..f35f1962d1
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
@@ -0,0 +1,440 @@
+package gregtech.api.util;
+
+import static gregtech.GT_Mod.GT_FML_LOGGER;
+
+import java.util.HashMap;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.enums.ItemList;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.NBTTagString;
+import net.minecraftforge.fluids.FluidStack;
+import scala.actors.threadpool.Arrays;
+
+public class GT_AssemblyLineUtils {
+
+ /**
+ * A cache of Recipes using the Output as Key.
+ */
+ private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = new HashMap<GT_ItemStack, GT_Recipe_AssemblyLine>();
+ /**
+ * A cache of Recipes using the Recipe Hash String as Key.
+ */
+ private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = new HashMap<String, GT_Recipe_AssemblyLine>();
+
+
+
+ /**
+ * Checks the DataStick for deprecated/invalid recipes, updating them as required.
+ * @param aDataStick - The DataStick to process
+ * @return Is this DataStick now valid with a current recipe?
+ */
+ public static boolean processDataStick(ItemStack aDataStick) {
+ if (!isItemDataStick(aDataStick)) {
+ return false;
+ }
+ if (doesDataStickNeedUpdate(aDataStick)) {
+ ItemStack aStickOutput = getDataStickOutput(aDataStick);
+ if (aStickOutput != null) {
+ GT_Recipe_AssemblyLine aIntendedRecipe = findAssemblyLineRecipeByOutput(aStickOutput);
+ if (aIntendedRecipe != null) {
+ return setAssemblyLineRecipeOnDataStick(aDataStick, aIntendedRecipe);
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ * Finds an Assembly Line recipe from a DataStick.
+ * @param aDataStick - The DataStick to check.
+ * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any.
+ */
+ public static GT_Recipe_AssemblyLine findAssemblyLineRecipeFromDataStick(ItemStack aDataStick) {
+ return findAssemblyLineRecipeFromDataStick(aDataStick, false);
+ }
+
+ /**
+ * Finds an Assembly Line recipe from a DataStick.
+ * @param aDataStick - The DataStick to check.
+ * @param aReturnBuiltRecipe - Do we return a GT_Recipe_AssemblyLine built from the data on the Data Stick instead of searching the Recipe Map?
+ * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any.
+ */
+ public static GT_Recipe_AssemblyLine findAssemblyLineRecipeFromDataStick(ItemStack aDataStick, boolean aReturnBuiltRecipe) {
+ if (!isItemDataStick(aDataStick)) {
+ return null;
+ }
+ ItemStack[] aInputs = new ItemStack[15];
+ ItemStack[] aOutputs = new ItemStack[1];
+ FluidStack[] aFluidInputs = new FluidStack[4];
+
+ NBTTagCompound aTag = aDataStick.getTagCompound();
+ if (aTag == null) {
+ return null;
+ }
+
+ //Get From Cache
+ if (doesDataStickHaveRecipeHash(aDataStick)) {
+ GT_Recipe_AssemblyLine aRecipeFromCache = sRecipeCacheByRecipeHash.get(getHashFromDataStack(aDataStick));
+ if (aRecipeFromCache != null) {
+ return aRecipeFromCache;
+ }
+ }
+
+ for (int i = 0; i < 15; i++) {
+ int count = aTag.getInteger("a" + i);
+ if (!aTag.hasKey("" + i) && count <= 0) {
+ continue;
+ }
+
+ boolean flag = true;
+ if (count > 0) {
+ for (int j = 0; j < count; j++) {
+ aInputs[i] = GT_Utility.loadItem(aTag, "a" + i + ":" + j);
+ if (aInputs[i] == null) {
+ continue;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Item " + i + " : " + aInputs[i].getUnlocalizedName());
+ }
+ flag = false;
+ break;
+ }
+ }
+ if (flag) {
+ aInputs[i] = GT_Utility.loadItem(aTag, "" + i);
+ if (aInputs[i] == null) {
+ flag = false;
+ continue;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Item " + i + " : " + aInputs[i].getUnlocalizedName());
+ }
+ flag = false;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info(i + (flag ? " not accepted" : " accepted"));
+ }
+ }
+
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("All Items done, start fluid check");
+ }
+ for (int i = 0; i < 4; i++) {
+ if (!aTag.hasKey("f" + i)) continue;
+ aFluidInputs[i] = GT_Utility.loadFluid(aTag, "f" + i);
+ if (aFluidInputs[i] == null) continue;
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Fluid " + i + " " + aFluidInputs[i].getUnlocalizedName());
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info(i + " accepted");
+ }
+ }
+ aOutputs = new ItemStack[]{GT_Utility.loadItem(aTag, "output")};
+ if (!aTag.hasKey("output") || !aTag.hasKey("time") || aTag.getInteger("time") <= 0 || !aTag.hasKey("eu") || aOutputs[0] == null || !GT_Utility.isStackValid(aOutputs[0])) {
+ return null;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Found Data Stick recipe");
+ }
+
+ int aTime = aTag.getInteger("time");
+ int aEU = aTag.getInteger("eu");
+
+ // Try build a recipe instance
+ if (aReturnBuiltRecipe) {
+ GT_Recipe_AssemblyLine aBuiltRecipe = new GT_Recipe_AssemblyLine(null, 0, aInputs, aFluidInputs, aOutputs[0], aTime, aEU);
+ return aBuiltRecipe;
+ }
+
+
+ for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) {
+ if (aRecipe.mEUt == aEU && aRecipe.mDuration == aTime) {
+ if (GT_Utility.areStacksEqual(aOutputs[0], aRecipe.mOutput, true)) {
+ if (Arrays.equals(aRecipe.mInputs, aInputs) && Arrays.equals(aRecipe.mFluidInputs, aFluidInputs)) {
+ // Cache it
+ String aRecipeHash = generateRecipeHash(aRecipe);
+ sRecipeCacheByRecipeHash.put(aRecipeHash, aRecipe);
+ sRecipeCacheByOutput.put(new GT_ItemStack(aRecipe.mOutput), aRecipe);
+ return aRecipe;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Finds a GT_Recipe_AssemblyLine based on the expected output ItemStack.
+ * @param aOutput - The Output of a GT_Recipe_AssemblyLine.
+ * @return First found GT_Recipe_AssemblyLine with matching output.
+ */
+ public static GT_Recipe_AssemblyLine findAssemblyLineRecipeByOutput(ItemStack aOutput) {
+ if (aOutput == null) {
+ return null;
+ }
+
+ // Check the cache
+ GT_ItemStack aCacheStack = new GT_ItemStack(aOutput);
+ GT_Recipe_AssemblyLine aRecipeFromCache = sRecipeCacheByOutput.get(aCacheStack);
+ if (aRecipeFromCache != null) {
+ return aRecipeFromCache;
+ }
+
+ // Iterate all recipes and return the first matching based on Output.
+ for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) {
+ ItemStack aRecipeOutput = aRecipe.mOutput;
+ if (GT_Utility.areStacksEqual(aRecipeOutput, aOutput)) {
+ // Cache it to prevent future iterations of all recipes
+ sRecipeCacheByOutput.put(aCacheStack, aRecipe);
+ sRecipeCacheByRecipeHash.put(generateRecipeHash(aRecipe), aRecipe);
+ return aRecipe;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param aRecipe - The recipe to generate a Recipe Hash String from.
+ * @return The Recipe Hash String.
+ */
+ public static String generateRecipeHash(GT_Recipe_AssemblyLine aRecipe) {
+ String aHash = "Invalid.Recipe.Hash";
+ if (aRecipe != null) {
+ aHash = "Hash."+aRecipe.hashCode();
+ }
+ return aHash;
+ }
+
+ /**
+ * @param aHash - Recipe hash String, may be null but will just be treated as invalid.
+ * @return Is this Recipe Hash String valid?
+ */
+ public static boolean isValidHash(String aHash) {
+ if (aHash != null && aHash.length() > 0) {
+ if (!aHash.equals("Invalid.Recipe.Hash") && aHash.contains("Hash.")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param aStack - The ItemStack to check.
+ * @return Is this ItemStack a Data Stick?
+ */
+ public static boolean isItemDataStick(ItemStack aStack) {
+ return GT_Utility.isStackValid(aStack) && ItemList.Tool_DataStick.isStackEqual(aStack, false, true);
+ }
+
+ /**
+ * @param aDataStick - The Data Stick to check.
+ * @return Does this Data Stick have a valid output ItemStack?
+ */
+ public static boolean doesDataStickHaveOutput(ItemStack aDataStick) {
+ if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound() && aDataStick.getTagCompound().hasKey("output")) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param aDataStick - The Data Stick to check.
+ * @return Does this Data Stick need recipe data updated.
+ */
+ public static boolean doesDataStickNeedUpdate(ItemStack aDataStick) {
+ if (isItemDataStick(aDataStick) && doesDataStickHaveRecipeHash(aDataStick)) {
+ String aStickHash = getHashFromDataStack(aDataStick);
+ if (isValidHash(aStickHash) && doesDataStickHaveOutput(aDataStick)) {
+ ItemStack aStickOutput = getDataStickOutput(aDataStick);
+ GT_Recipe_AssemblyLine aIntendedRecipe = findAssemblyLineRecipeByOutput(aStickOutput);
+ if (aStickHash.equals(generateRecipeHash(aIntendedRecipe))) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @param aDataStick - The Data Stick to check.
+ * @return Does this have a Recipe Hash String at all?
+ */
+ public static boolean doesDataStickHaveRecipeHash(ItemStack aDataStick) {
+ if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) {
+ NBTTagCompound aNBT = aDataStick.getTagCompound();
+ if (aNBT.hasKey("Data.Recipe.Hash")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the Output ItemStack from a Data Stick.
+ * @param aDataStick - The Data Stick to check.
+ * @return Output ItemStack contained on the Data Stick.
+ */
+ public static ItemStack getDataStickOutput(ItemStack aDataStick) {
+ if (doesDataStickHaveOutput(aDataStick)) {
+ ItemStack aOutput = GT_Utility.loadItem(aDataStick.getTagCompound(), "output");
+ return aOutput;
+ }
+ return null;
+ }
+
+ /**
+ * @param aDataStick - The Data Stick to procces.
+ * @return The stored Recipe Hash String on the Data Stick, will return an invalid Hash if one is not found. <p>
+ * Check with isValidHash(). <p>
+ * Will not return Null.
+ */
+ public static String getHashFromDataStack(ItemStack aDataStick) {
+ if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) {
+ NBTTagCompound aNBT = aDataStick.getTagCompound();
+ if (aNBT.hasKey("Data.Recipe.Hash")) {
+ return aNBT.getString("Data.Recipe.Hash");
+
+ }
+ }
+ return "Invalid.Recipe.Hash";
+ }
+
+ /**
+ *
+ * @param aDataStick - The Data Stick to update.
+ * @param aRecipeHash - The Recipe Hash String to update with.
+ * @return Did we update the Recipe Hash String on the Data Stick?
+ */
+ public static boolean setRecipeHashOnDataStick(ItemStack aDataStick, String aRecipeHash) {
+ if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) {
+ NBTTagCompound aNBT = aDataStick.getTagCompound();
+ aNBT.setString("Data.Recipe.Hash", aRecipeHash);
+ aDataStick.setTagCompound(aNBT);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param aDataStick - The Data Stick to update.
+ * @param aNewRecipe - The New GT_Recipe_AssemblyLine recipe to update it with.
+ * @return Did we set the new recipe data & Recipe Hash String on the Data Stick?
+ */
+ public static boolean setAssemblyLineRecipeOnDataStick(ItemStack aDataStick, GT_Recipe_AssemblyLine aNewRecipe) {
+ if (isItemDataStick(aDataStick)) {
+ String s = aNewRecipe.mOutput.getDisplayName();
+ if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
+ s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName());
+ if (s == null) {
+ s = aNewRecipe.mOutput.getDisplayName();
+ }
+ }
+
+ String aHash = generateRecipeHash(aNewRecipe);
+ if (GT_Values.D1) {
+ GT_Recipe_AssemblyLine aOldRecipe = findAssemblyLineRecipeFromDataStick(aDataStick, true);
+ GT_FML_LOGGER.info("Updating data stick: "+aDataStick.getDisplayName()+" | Old Recipe Hash: "+generateRecipeHash(aOldRecipe)+", New Recipe Hash: "+aHash);
+ }
+
+
+ //remove possible old NBTTagCompound
+ aDataStick.setTagCompound(new NBTTagCompound());
+ if (GT_Values.D1) {
+ GT_Utility.ItemNBT.setBookTitle(aDataStick, s + " Construction Data ("+aHash+")");
+ }
+ else {
+ GT_Utility.ItemNBT.setBookTitle(aDataStick, s + " Construction Data");
+ }
+
+ NBTTagCompound tNBT = aDataStick.getTagCompound();
+ if (tNBT == null) {
+ tNBT = new NBTTagCompound();
+ }
+
+ tNBT.setTag("output", aNewRecipe.mOutput.writeToNBT(new NBTTagCompound()));
+ tNBT.setInteger("time", aNewRecipe.mDuration);
+ tNBT.setInteger("eu", aNewRecipe.mEUt);
+ for (int i = 0; i < aNewRecipe.mInputs.length; i++) {
+ tNBT.setTag("" + i, aNewRecipe.mInputs[i].writeToNBT(new NBTTagCompound()));
+ }
+ for (int i = 0; i < aNewRecipe.mOreDictAlt.length; i++) {
+ if (aNewRecipe.mOreDictAlt[i] != null && aNewRecipe.mOreDictAlt[i].length > 0) {
+ tNBT.setInteger("a" + i, aNewRecipe.mOreDictAlt[i].length);
+ for (int j = 0; j < aNewRecipe.mOreDictAlt[i].length; j++) {
+ tNBT.setTag("a" + i + ":" + j, aNewRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound()));
+ }
+ }
+ }
+ for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) {
+ tNBT.setTag("f" + i, aNewRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound()));
+ }
+ tNBT.setString("author", "Assembling Line Recipe Generator");
+ NBTTagList tNBTList = new NBTTagList();
+ s = aNewRecipe.mOutput.getDisplayName();
+ if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
+ s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName());
+ if (s == null)
+ s = aNewRecipe.mOutput.getDisplayName();
+ }
+ tNBTList.appendTag(new NBTTagString("Construction plan for " + aNewRecipe.mOutput.stackSize + " " + s + ". Needed EU/t: " + aNewRecipe.mEUt + " Production time: " + (aNewRecipe.mDuration / 20)));
+ for (int i = 0; i < aNewRecipe.mInputs.length; i++) {
+ if (aNewRecipe.mOreDictAlt[i] != null) {
+ int count = 0;
+ StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": ");
+ for (ItemStack tStack : aNewRecipe.mOreDictAlt[i]) {
+ if (tStack != null) {
+ s = tStack.getDisplayName();
+ if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
+ s = GT_Assemblyline_Server.lServerNames.get(tStack.getDisplayName());
+ if (s == null)
+ s = tStack.getDisplayName();
+ }
+
+
+ tBuilder.append(count == 0 ? "" : "\nOr ").append(tStack.stackSize).append(" ").append(s);
+ count++;
+ }
+ }
+ if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString()));
+ } else if (aNewRecipe.mInputs[i] != null) {
+ s = aNewRecipe.mInputs[i].getDisplayName();
+ if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
+ s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mInputs[i].getDisplayName());
+ if (s == null)
+ s = aNewRecipe.mInputs[i].getDisplayName();
+ }
+ tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + aNewRecipe.mInputs[i].stackSize + " " + s));
+ }
+ }
+ for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) {
+ if (aNewRecipe.mFluidInputs[i] != null) {
+ s = aNewRecipe.mFluidInputs[i].getLocalizedName();
+ if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
+ s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mFluidInputs[i].getLocalizedName());
+ if (s == null)
+ s = aNewRecipe.mFluidInputs[i].getLocalizedName();
+ }
+ tNBTList.appendTag(new NBTTagString("Input Hatch " + (i + 1) + ": " + aNewRecipe.mFluidInputs[i].amount + "L " + s));
+ }
+ }
+ tNBT.setTag("pages", tNBTList);
+ aDataStick.setTagCompound(tNBT);
+ // Set recipe hash
+ setRecipeHashOnDataStick(aDataStick, aHash);
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java
new file mode 100644
index 0000000000..bd9148b516
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java
@@ -0,0 +1,437 @@
+package gregtech.api.util;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.world.ChunkCoordIntPair;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.WorldEvent;
+import org.apache.commons.io.FileUtils;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Array;
+import java.nio.file.AtomicMoveNotSupportedException;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * A utility to save all kinds of data that is a function of any chunk.
+ * <p>
+ * GregTech takes care of saving and loading the data from disk, and an efficient mechanism to locate it.
+ * Subclass only need to define the exact scheme of each element data (by overriding the three protected abstract method)
+ * <p>
+ * Oh, there is no limit on how large your data is, though you'd not have the familiar NBT interface, but DataOutput
+ * should be reasonably common anyway.
+ * <p>
+ * It should be noted this class is NOT thread safe.
+ * <p>
+ * Element cannot be null.
+ * <p>
+ * TODO: Implement automatic region unloading.
+ *
+ * @param <T> data element type
+ * @author glease
+ */
+@ParametersAreNonnullByDefault
+public abstract class GT_ChunkAssociatedData<T extends GT_ChunkAssociatedData.IData> {
+ private static final Map<String, GT_ChunkAssociatedData<?>> instances = new ConcurrentHashMap<>();
+ private static final int IO_PARALLELISM = Math.min(8, Math.max(1, Runtime.getRuntime().availableProcessors()) * 2 / 3);
+ private static final ExecutorService IO_WORKERS = Executors.newWorkStealingPool(IO_PARALLELISM);
+ private static final Pattern FILE_PATTERN = Pattern.compile("(.+)\\.(-?\\d+)\\.(-?\\d+)\\.dat");
+
+ static {
+ // register event handler
+ new EventHandler();
+ }
+
+ protected final String mId;
+ protected final Class<T> elementtype;
+ private final int regionLength;
+ private final int version;
+ private final boolean saveDefaults;
+ /**
+ * Data is stored as a `(world id -> (super region id -> super region data))` hash map.
+ * where super region's size is determined by regionSize.
+ * Here it is called super region, to not confuse with vanilla's regions.
+ */
+ private final Map<Integer, Map<ChunkCoordIntPair, SuperRegion>> masterMap = new ConcurrentHashMap<>();
+
+ /**
+ * Initialize this instance.
+ *
+ * @param aId An arbitrary, but globally unique identifier for what this data is
+ * @param elementType The class of this element type. Used to create arrays.
+ * @param regionLength The length of one super region. Each super region will contain {@code regionLength * regionLength} chunks
+ * @param version An integer marking the version of this data. Useful later when the data's serialized form changed.
+ */
+ protected GT_ChunkAssociatedData(String aId, Class<T> elementType, int regionLength, byte version, boolean saveDefaults) {
+ if (regionLength * regionLength > Short.MAX_VALUE || regionLength <= 0)
+ throw new IllegalArgumentException("Region invalid: " + regionLength);
+ if (!IData.class.isAssignableFrom(elementType))
+ throw new IllegalArgumentException("Data type invalid");
+ if (aId.contains("."))
+ throw new IllegalArgumentException("ID cannot contains dot");
+ this.mId = aId;
+ this.elementtype = elementType;
+ this.regionLength = regionLength;
+ this.version = version;
+ this.saveDefaults = saveDefaults;
+ if (instances.putIfAbsent(aId, this) != null)
+ throw new IllegalArgumentException("Duplicate GT_ChunkAssociatedData: " + aId);
+ }
+
+ private ChunkCoordIntPair getRegionID(int aChunkX, int aChunkZ) {
+ return new ChunkCoordIntPair(aChunkX / regionLength, aChunkZ / regionLength);
+ }
+
+ /**
+ * Get a reference to data of the chunk that tile entity is in.
+ * The returned reference should be mutable.
+ */
+ public final T get(IGregTechTileEntity tileEntity) {
+ return get(tileEntity.getWorld(), tileEntity.getXCoord() >> 4, tileEntity.getZCoord() >> 4);
+ }
+
+ public final T get(Chunk chunk) {
+ return get(chunk.worldObj, chunk.xPosition, chunk.zPosition);
+ }
+
+ public final T get(World world, ChunkCoordIntPair coord) {
+ return get(world, coord.chunkXPos, coord.chunkZPos);
+ }
+
+ public final T get(World world, int chunkX, int chunkZ) {
+ SuperRegion region = masterMap.computeIfAbsent(world.provider.dimensionId, ignored -> new ConcurrentHashMap<>())
+ .computeIfAbsent(getRegionID(chunkX, chunkZ), c -> new SuperRegion(world, c));
+ return region.get(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength));
+ }
+
+ protected final void set(World world, int chunkX, int chunkZ, T data) {
+ SuperRegion region = masterMap.computeIfAbsent(world.provider.dimensionId, ignored -> new ConcurrentHashMap<>())
+ .computeIfAbsent(getRegionID(chunkX, chunkZ), c -> new SuperRegion(world, c));
+ region.set(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength), data);
+ }
+
+ protected final boolean isCreated(int dimId, int chunkX, int chunkZ) {
+ Map<ChunkCoordIntPair, SuperRegion> dimData = masterMap.getOrDefault(dimId, null);
+ if (dimData == null) return false;
+
+ SuperRegion region = dimData.getOrDefault(getRegionID(chunkX, chunkZ), null);
+ if (region == null) return false;
+
+ return region.isCreated(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength));
+ }
+
+ public void clear() {
+ if (GT_Values.debugWorldData) {
+ long dirtyRegionCount = masterMap.values().stream()
+ .flatMap(m -> m.values().stream())
+ .filter(SuperRegion::isDirty)
+ .count();
+ if (dirtyRegionCount > 0)
+ GT_Log.out.println("Clearing ChunkAssociatedData with " + dirtyRegionCount + " regions dirty. Data might have been lost!");
+ }
+ masterMap.clear();
+ }
+
+ public void save() {
+ saveRegions(masterMap.values().stream().flatMap(m -> m.values().stream()));
+ }
+
+ public void save(World world) {
+ Map<ChunkCoordIntPair, SuperRegion> map = masterMap.get(world.provider.dimensionId);
+ if (map != null)
+ saveRegions(map.values().stream());
+ }
+
+ private void saveRegions(Stream<SuperRegion> stream) {
+ stream.filter(r -> !r.isDirty())
+ .map(c -> (Runnable) c::save)
+ .map(r -> CompletableFuture.runAsync(r, IO_WORKERS))
+ .reduce(CompletableFuture::allOf)
+ .ifPresent(f -> {
+ try {
+ f.get();
+ } catch (Exception e) {
+ GT_Log.err.println("Data save error: " + mId);
+ e.printStackTrace(GT_Log.err);
+ }
+ });
+ }
+
+ protected abstract void writeElement(DataOutput output, T element, World world, int chunkX, int chunkZ) throws IOException;
+
+ protected abstract T readElement(DataInput input, int version, World world, int chunkX, int chunkZ) throws IOException;
+
+ protected abstract T createElement(World world, int chunkX, int chunkZ);
+
+ /**
+ * Clear all mappings, regardless of whether they are dirty
+ */
+ public static void clearAll() {
+ for (GT_ChunkAssociatedData<?> d : instances.values()) d.clear();
+ }
+
+ /**
+ * Save all mappings
+ */
+ public static void saveAll() {
+ for (GT_ChunkAssociatedData<?> d : instances.values()) d.save();
+ }
+
+ /**
+ * Load data for all chunks for a given world.
+ * Current data for that world will be discarded. If this is what you intended, call {@link #save(World)} beforehand.
+ * <p>
+ * Be aware of the memory consumption though.
+ */
+ protected void loadAll(World w) {
+ if (GT_Values.debugWorldData && masterMap.containsKey(w.provider.dimensionId))
+ GT_Log.err.println("Reloading ChunkAssociatedData " + mId + " for world " + w.provider.dimensionId + " discards old data!");
+ if (!getSaveDirectory(w).isDirectory())
+ // nothing to load...
+ return;
+ try {
+ Map<ChunkCoordIntPair, SuperRegion> worldData = Files.list(getSaveDirectory(w).toPath())
+ .map(f -> {
+ Matcher matcher = FILE_PATTERN.matcher(f.getFileName().toString());
+ return matcher.matches() ? matcher : null;
+ })
+ .filter(Objects::nonNull)
+ .filter(m -> mId.equals(m.group(1)))
+ .map(m -> CompletableFuture.supplyAsync(() -> new SuperRegion(w, Integer.parseInt(m.group(2)), Integer.parseInt(m.group(3))), IO_WORKERS))
+ .map(f -> {
+ try {
+ return f.get();
+ } catch (Exception e) {
+ GT_Log.err.println("Error loading region");
+ e.printStackTrace(GT_Log.err);
+ return null;
+ }
+ })
+ .filter(Objects::nonNull)
+ .collect(Collectors.toMap(SuperRegion::getCoord, Function.identity()));
+ masterMap.put(w.provider.dimensionId, worldData);
+ } catch (IOException e) {
+ GT_Log.err.println("Error loading all region");
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ protected File getSaveDirectory(World w) {
+ return new File(w.getSaveHandler().getWorldDirectory(), "gregtech");
+ }
+
+ public interface IData {
+ /**
+ * @return Whether the data is different from chunk default
+ */
+ boolean isSameAsDefault();
+ }
+
+ protected final class SuperRegion {
+ private final T[] data = createData();
+ private final File backingStorage;
+ private final WeakReference<World> world;
+ private final ChunkCoordIntPair coord;
+
+ private SuperRegion(World world, int chunkX, int chunkZ) {
+ this.world = new WeakReference<>(world);
+ this.coord = new ChunkCoordIntPair(chunkX, chunkZ);
+ backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, chunkX, chunkZ));
+ if (backingStorage.isFile())
+ load();
+ }
+
+ private SuperRegion(World world, ChunkCoordIntPair coord) {
+ this.world = new WeakReference<>(world);
+ this.coord = coord;
+ backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, coord.chunkXPos, coord.chunkZPos));
+ if (backingStorage.isFile())
+ load();
+ }
+
+ @SuppressWarnings("unchecked")
+ private T[] createData() {
+ return (T[]) Array.newInstance(elementtype, regionLength * regionLength);
+ }
+
+ public T get(int subRegionX, int subRegionZ) {
+ int index = getIndex(subRegionX, subRegionZ);
+ T datum = data[index];
+ if (datum == null) {
+ World world = Objects.requireNonNull(this.world.get());
+ T newElem = createElement(world, coord.chunkXPos * regionLength + subRegionX, coord.chunkZPos * regionLength + subRegionZ);
+ data[index] = newElem;
+ return newElem;
+ }
+ return datum;
+ }
+
+ public void set(int subRegionX, int subRegionZ, T data) {
+ this.data[getIndex(subRegionX, subRegionZ)] = data;
+ }
+
+ public boolean isCreated(int subRegionX, int subRegionZ) {
+ return this.data[getIndex(subRegionX, subRegionZ)] == null;
+ }
+
+ public ChunkCoordIntPair getCoord() {
+ return coord;
+ }
+
+ private int getIndex(int subRegionX, int subRegionY) {
+ return subRegionX * regionLength + subRegionY;
+ }
+
+ private int getChunkX(int index) {
+ return index / regionLength + coord.chunkXPos;
+ }
+
+ private int getChunkZ(int index) {
+ return index % regionLength + coord.chunkZPos;
+ }
+
+ public boolean isDirty() {
+ for (T datum : data) {
+ if (datum != null && datum.isSameAsDefault())
+ return true;
+ }
+ return false;
+ }
+
+ public void save() {
+ try {
+ save0();
+ } catch (IOException e) {
+ GT_Log.err.println("Error saving data " + backingStorage.getPath());
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ private void save0() throws IOException {
+ if (!isDirty())
+ return;
+ //noinspection ResultOfMethodCallIgnored
+ backingStorage.getParentFile().mkdirs();
+ File tmpFile = getTmpFile();
+ World world = Objects.requireNonNull(this.world.get(), "Attempting to save region of another world!");
+ try (DataOutputStream output = new DataOutputStream(new FileOutputStream(tmpFile))) {
+ int ptr = 0;
+ boolean nullRange = data[0] == null;
+ // write a magic byte as storage format version
+ output.writeByte(0);
+ // write a magic byte as data format version
+ output.writeByte(version);
+ output.writeBoolean(nullRange);
+ while (ptr < data.length) {
+ // work out how long is this range
+ int rangeStart = ptr;
+ while (ptr < data.length && (data[ptr] == null || (!saveDefaults && data[ptr].isSameAsDefault())) == nullRange)
+ ptr++;
+ // write range length
+ output.writeShort(ptr - rangeStart);
+ if (!nullRange)
+ // write element data
+ for (int i = rangeStart; i < ptr; i++)
+ writeElement(output, data[i], world, getChunkX(ptr), getChunkZ(ptr));
+ // or not
+ nullRange = !nullRange;
+ }
+ }
+ // first try to replace the destination file
+ // since atomic operation, no need to keep the backup in place
+ try {
+ Files.move(tmpFile.toPath(), backingStorage.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
+ } catch (AtomicMoveNotSupportedException ignored) {
+ // in case some dumb system/jre combination would cause this
+ // or if **somehow** two file inside the same directory belongs two separate filesystem
+ FileUtils.copyFile(tmpFile, backingStorage);
+ }
+ }
+
+ public void load() {
+ try {
+ loadFromFile(backingStorage);
+ } catch (IOException | RuntimeException e) {
+ GT_Log.err.println("Primary storage file broken in " + backingStorage.getPath());
+ e.printStackTrace(GT_Log.err);
+ // in case the primary storage is broken
+ try {
+ loadFromFile(getTmpFile());
+ } catch (IOException | RuntimeException e2) {
+ GT_Log.err.println("Backup storage file broken in " + backingStorage.getPath());
+ e2.printStackTrace(GT_Log.err);
+ }
+ }
+ }
+
+ private void loadFromFile(File file) throws IOException {
+ World world = Objects.requireNonNull(this.world.get(), "Attempting to load region of another world!");
+ try (DataInputStream input = new DataInputStream(new FileInputStream(file))) {
+ boolean nullRange = input.readBoolean();
+ int ptr = 0;
+ while (ptr != data.length) {
+ int rangeEnd = ptr + input.readUnsignedShort();
+ if (!nullRange) {
+ for (; ptr < rangeEnd; ptr++) {
+ data[ptr] = readElement(input, version, world, getChunkX(ptr), getChunkZ(ptr));
+ }
+ } else {
+ Arrays.fill(data, ptr, rangeEnd, null);
+ ptr = rangeEnd;
+ }
+ }
+ }
+ }
+
+ private File getTmpFile() {
+ return new File(backingStorage.getParentFile(), backingStorage.getName() + ".tmp");
+ }
+ }
+
+ public static class EventHandler {
+ private EventHandler() {
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ @SubscribeEvent
+ public void onWorldSave(WorldEvent.Save e) {
+ for (GT_ChunkAssociatedData<?> d : instances.values()) {
+ d.save(e.world);
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldUnload(WorldEvent.Unload e) {
+ for (GT_ChunkAssociatedData<?> d : instances.values()) {
+ // there is no need to explicitly do a save here
+ // forge will send a WorldEvent.Save on server thread before this event is distributed
+ d.masterMap.remove(e.world.provider.dimensionId);
+ }
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/util/GT_CoverBehavior.java b/src/main/java/gregtech/api/util/GT_CoverBehavior.java
index 14c8cc1308..9972331eb3 100644
--- a/src/main/java/gregtech/api/util/GT_CoverBehavior.java
+++ b/src/main/java/gregtech/api/util/GT_CoverBehavior.java
@@ -3,21 +3,179 @@ package gregtech.api.util;
import gregtech.api.enums.GT_Values;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.net.GT_Packet_TileEntityCoverGUI;
-import gregtech.api.objects.GT_ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import static gregtech.api.enums.GT_Values.E;
/**
- * For Covers with a special behavior.
+ * For Covers with a special behavior. Has fixed storage format of 4 byte. Not very convenient...
*/
-public abstract class GT_CoverBehavior {
+public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializableObject.LegacyCoverData> {
public EntityPlayer lastPlayer = null;
+ public GT_CoverBehavior() {
+ super(ISerializableObject.LegacyCoverData.class);
+ }
+
+ private static int convert(ISerializableObject.LegacyCoverData data) {
+ return data == null ? 0 : data.get();
+ }
+
+ // region bridge the parent call to legacy calls
+
+ @Override
+ public final ISerializableObject.LegacyCoverData createDataObject() {
+ return new ISerializableObject.LegacyCoverData();
+ }
+
+ @Override
+ public ISerializableObject.LegacyCoverData createDataObject(int aLegacyData) {
+ return new ISerializableObject.LegacyCoverData(aLegacyData);
+ }
+
+ @Override
+ protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ return isRedstoneSensitive(aSide, aCoverID, aCoverVariable.get(), aTileEntity, aTimer);
+ }
+
+ @Override
+ protected ISerializableObject.LegacyCoverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ if (aCoverVariable == null)
+ aCoverVariable = new ISerializableObject.LegacyCoverData();
+ aCoverVariable.set(doCoverThings(aSide, aInputRedstone, aCoverID, aCoverVariable.get(), aTileEntity, aTimer));
+ return aCoverVariable;
+ }
+
+ @Override
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return onCoverRightclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ);
+ }
+
+ @Override
+ protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (aCoverVariable == null)
+ aCoverVariable = new ISerializableObject.LegacyCoverData();
+ aCoverVariable.set(onCoverScrewdriverclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ));
+ return aCoverVariable;
+ }
+
+ @Override
+ protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) {
+ return onCoverShiftRightclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer);
+ }
+
+ @Override
+ protected Object getClientGUIImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) {
+ return getClientGUI(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, boolean aForced) {
+ return onCoverRemoval(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aForced);
+ }
+
+ @Override
+ protected String getDescriptionImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return getDescription(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected float getBlastProofLevelImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return getBlastProofLevel(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return letsRedstoneGoIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return letsRedstoneGoOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean letsFibreGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return letsFibreGoIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean letsFibreGoOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return letsFibreGoOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return letsEnergyIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return letsEnergyOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean letsFluidInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return letsFluidIn(aSide, aCoverID, convert(aCoverVariable), aFluid, aTileEntity);
+ }
+
+ @Override
+ protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return letsFluidOut(aSide, aCoverID, convert(aCoverVariable), aFluid, aTileEntity);
+ }
+
+ @Override
+ protected boolean letsItemsInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return letsItemsIn(aSide, aCoverID, convert(aCoverVariable), aSlot, aTileEntity);
+ }
+
+ @Override
+ protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return letsItemsOut(aSide, aCoverID, convert(aCoverVariable), aSlot, aTileEntity);
+ }
+
+ @Override
+ protected boolean isGUIClickableImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return isGUIClickable(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return manipulatesSidedRedstoneOutput(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return alwaysLookConnected(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return getRedstoneInput(aSide, aInputRedstone, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected int getTickRateImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return getTickRate(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected byte getLensColorImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return getLensColor(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ @Override
+ protected ItemStack getDropImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) {
+ return getDrop(aSide, aCoverID, convert(aCoverVariable), aTileEntity);
+ }
+
+ // endregion
+
public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
return true;
}
@@ -39,15 +197,6 @@ public abstract class GT_CoverBehavior {
}
/**
- * Called when someone rightclicks this Cover Client Side
- * <p/>
- * return true, if something actually happens.
- */
- public boolean onCoverRightclickClient(byte aSide, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- return false;
- }
-
- /**
* Called when someone rightclicks this Cover with a Screwdriver. Doesn't call @onCoverRightclick in this Case.
* <p/>
* return the new Value of the Cover Variable
@@ -68,22 +217,11 @@ public abstract class GT_CoverBehavior {
return false;
}
- public boolean hasCoverGUI() {
- return false;
- }
-
public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) {
return null;
}
/**
- * Checks if the Cover can be placed on this.
- */
- public boolean isCoverPlaceable(byte aSide, GT_ItemStack aStack, ICoverable aTileEntity) {
- return true;
- }
-
- /**
* Removes the Cover if this returns true, or if aForced is true.
* Doesn't get called when the Machine Block is getting broken, only if you break the Cover away from the Machine.
*/
@@ -219,13 +357,6 @@ public abstract class GT_CoverBehavior {
}
/**
- * If this is a simple Cover, which can also be used on Bronze Machines and similar.
- */
- public boolean isSimpleCover() {
- return false;
- }
-
- /**
* The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then).
*/
public byte getLensColor(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
@@ -238,15 +369,4 @@ public abstract class GT_CoverBehavior {
public ItemStack getDrop(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(aSide));
}
-
- /**
- * @return sets the Cover upon placement.
- */
- public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) {
- aTileEntity.setCoverIDAtSide(aSide, GT_Utility.stackToInt(aCover));
- }
-
- public String trans(String aNr, String aEnglish){
- return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aNr, aEnglish, false);
- }
}
diff --git a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java
new file mode 100644
index 0000000000..50ef2632d9
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java
@@ -0,0 +1,482 @@
+package gregtech.api.util;
+
+import gregtech.api.enums.GT_Values;
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.net.GT_Packet_TileEntityCoverGUI;
+import gregtech.api.objects.GT_ItemStack;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.Fluid;
+
+import static gregtech.api.enums.GT_Values.E;
+
+/**
+ * For Covers with a special behavior.
+ *
+ * @author glease
+ */
+public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> {
+
+ public EntityPlayer lastPlayer = null;
+ private final Class<T> typeToken;
+
+ protected GT_CoverBehaviorBase(Class<T> typeToken) {
+ this.typeToken = typeToken;
+ }
+
+ public abstract T createDataObject(int aLegacyData);
+
+ public abstract T createDataObject();
+
+ public T createDataObject(NBTBase aNBT) {
+ T ret = createDataObject();
+ ret.loadDataFromNBT(aNBT);
+ return ret;
+ }
+
+ public final T cast(ISerializableObject aData) {
+ if (typeToken.isInstance(aData))
+ return forceCast(aData);
+ return null;
+ }
+
+ private T forceCast(ISerializableObject aData) {
+ return typeToken.cast(aData);
+ }
+
+ // region facade
+
+ public final boolean isRedstoneSensitive(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ return isRedstoneSensitiveImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer);
+ }
+
+ /**
+ * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time.
+ */
+ public final T doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ return doCoverThingsImpl(aSide, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer);
+ }
+
+ /**
+ * Called when someone rightclicks this Cover.
+ * <p/>
+ * return true, if something actually happens.
+ */
+ public final boolean onCoverRightClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return onCoverRightClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ);
+ }
+
+ /**
+ * Called when someone rightclicks this Cover with a Screwdriver. Doesn't call @onCoverRightclick in this Case.
+ * <p/>
+ * return the new Value of the Cover Variable
+ */
+ public final T onCoverScrewdriverClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return onCoverScrewdriverClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ);
+ }
+
+ /**
+ * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case.
+ */
+ public final boolean onCoverShiftRightClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) {
+ return onCoverShiftRightClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer);
+ }
+
+ public final Object getClientGUI(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) {
+ return getClientGUIImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aWorld);
+ }
+
+ /**
+ * Removes the Cover if this returns true, or if aForced is true.
+ * Doesn't get called when the Machine Block is getting broken, only if you break the Cover away from the Machine.
+ */
+ public final boolean onCoverRemoval(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, boolean aForced) {
+ return onCoverRemovalImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aForced);
+ }
+
+ /**
+ * Gives a small Text for the status of the Cover.
+ */
+ public final String getDescription(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return getDescriptionImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * How Blast Proof the Cover is. 30 is normal.
+ */
+ public final float getBlastProofLevel(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return getBlastProofLevelImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * If it lets RS-Signals into the Block
+ * <p/>
+ * This is just Informative so that Machines know if their Redstone Input is blocked or not
+ */
+ public final boolean letsRedstoneGoIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return letsRedstoneGoInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * If it lets RS-Signals out of the Block
+ */
+ public final boolean letsRedstoneGoOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return letsRedstoneGoOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * If it lets Fibre-Signals into the Block
+ * <p/>
+ * This is just Informative so that Machines know if their Redstone Input is blocked or not
+ */
+ public final boolean letsFibreGoIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return letsFibreGoInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * If it lets Fibre-Signals out of the Block
+ */
+ public final boolean letsFibreGoOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return letsFibreGoOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * If it lets Energy into the Block
+ */
+ public final boolean letsEnergyIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return letsEnergyInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * If it lets Energy out of the Block
+ */
+ public final boolean letsEnergyOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return letsEnergyOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not.
+ */
+ public final boolean letsFluidIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return letsFluidInImpl(aSide, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity);
+ }
+
+ /**
+ * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not.
+ */
+ public final boolean letsFluidOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return letsFluidOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity);
+ }
+
+ /**
+ * If it lets Items into the Block, aSlot = -1 means if it is generally accepting Items (return false for no eraction at all), aSlot = -2 means if it would accept for all Slots Impl(return true to skip the Checks for each Slot).
+ */
+ public final boolean letsItemsIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return letsItemsInImpl(aSide, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity);
+ }
+
+ /**
+ * If it lets Items out of the Block, aSlot = -1 means if it is generally accepting Items (return false for no eraction at all), aSlot = -2 means if it would accept for all Slots Impl(return true to skip the Checks for each Slot).
+ */
+ public final boolean letsItemsOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return letsItemsOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity);
+ }
+
+ /**
+ * If it lets you rightclick the Machine normally
+ */
+ public final boolean isGUIClickable(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return isGUIClickableImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * Needs to return true for Covers, which have a Redstone Output on their Facing.
+ */
+ public final boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return manipulatesSidedRedstoneOutputImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * if this Cover should let Pipe Connections look connected even if it is not the case.
+ */
+ public final boolean alwaysLookConnected(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return alwaysLookConnectedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * Called to determine the incoming Redstone Signal of a Machine.
+ * Returns the original Redstone per default.
+ * The Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0.
+ */
+ public final byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return getRedstoneInputImpl(aSide, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * Gets the Tick Rate for doCoverThings of the Cover
+ * <p/>
+ * 0 = No Ticks! Yes, 0 is Default, you have to override this
+ */
+ public final int getTickRate(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return getTickRateImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+
+ /**
+ * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then).
+ */
+ public final byte getLensColor(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return getLensColorImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+
+ /**
+ * @return the ItemStack dropped by this Cover
+ */
+ public final ItemStack getDrop(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) {
+ return getDropImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity);
+ }
+ // endregion
+
+ // region impl
+
+ protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ return true;
+ }
+
+ /**
+ * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time.
+ */
+ protected T doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ return aCoverVariable;
+ }
+
+ /**
+ * Called when someone rightclicks this Cover.
+ * <p/>
+ * return true, if something actually happens.
+ */
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return false;
+ }
+
+ /**
+ * Called when someone rightclicks this Cover with a Screwdriver. Doesn't call @onCoverRightclick in this Case.
+ * <p/>
+ * return the new Value of the Cover Variable
+ */
+ protected T onCoverScrewdriverClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return aCoverVariable;
+ }
+
+ /**
+ * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case.
+ */
+ protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) {
+ if (hasCoverGUI() && aPlayer instanceof EntityPlayerMP) {
+ lastPlayer = aPlayer;
+ GT_Values.NW.sendToPlayer(new GT_Packet_TileEntityCoverGUI(aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), (EntityPlayerMP) aPlayer);
+ return true;
+ }
+ return false;
+ }
+
+ protected Object getClientGUIImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) {
+ return null;
+ }
+
+ /**
+ * Removes the Cover if this returns true, or if aForced is true.
+ * Doesn't get called when the Machine Block is getting broken, only if you break the Cover away from the Machine.
+ */
+ protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, boolean aForced) {
+ return true;
+ }
+
+ /**
+ * Gives a small Text for the status of the Cover.
+ */
+ protected String getDescriptionImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return E;
+ }
+
+ /**
+ * How Blast Proof the Cover is. 30 is normal.
+ */
+ protected float getBlastProofLevelImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return 10.0F;
+ }
+
+ /**
+ * If it lets RS-Signals into the Block
+ * <p/>
+ * This is just Informative so that Machines know if their Redstone Input is blocked or not
+ */
+ protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets RS-Signals out of the Block
+ */
+ protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Fibre-Signals into the Block
+ * <p/>
+ * This is just Informative so that Machines know if their Redstone Input is blocked or not
+ */
+ protected boolean letsFibreGoInImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Fibre-Signals out of the Block
+ */
+ protected boolean letsFibreGoOutImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Energy into the Block
+ */
+ protected boolean letsEnergyInImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Energy out of the Block
+ */
+ protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not.
+ */
+ protected boolean letsFluidInImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not.
+ */
+ protected boolean letsFluidOutImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Items into the Block, aSlot = -1 means if it is generally accepting Items (return false for no Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each Slot).
+ */
+ protected boolean letsItemsInImpl(byte aSide, int aCoverID, T aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Items out of the Block, aSlot = -1 means if it is generally accepting Items (return false for no Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each Slot).
+ */
+ protected boolean letsItemsOutImpl(byte aSide, int aCoverID, T aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets you rightclick the Machine normally
+ */
+ protected boolean isGUIClickableImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * Needs to return true for Covers, which have a Redstone Output on their Facing.
+ */
+ protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * if this Cover should let Pipe Connections look connected even if it is not the case.
+ */
+ protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * Called to determine the incoming Redstone Signal of a Machine.
+ * Returns the original Redstone per default.
+ * The Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0.
+ */
+ protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return letsRedstoneGoIn(aSide, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0;
+ }
+
+ /**
+ * Gets the Tick Rate for doCoverThings of the Cover
+ * <p/>
+ * 0 = No Ticks! Yes, 0 is Default, you have to override this
+ */
+ protected int getTickRateImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return 0;
+ }
+
+
+ /**
+ * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then).
+ */
+ protected byte getLensColorImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return -1;
+ }
+
+ /**
+ * @return the ItemStack dropped by this Cover
+ */
+ protected ItemStack getDropImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {
+ return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(aSide));
+ }
+
+ //endregion
+
+ // region no data
+
+ /**
+ * Checks if the Cover can be placed on this.
+ */
+ public boolean isCoverPlaceable(byte aSide, GT_ItemStack aStack, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public boolean hasCoverGUI() {
+ return false;
+ }
+
+ /**
+ * Called when someone rightclicks this Cover Client Side
+ * <p/>
+ * return true, if something actually happens.
+ */
+ public boolean onCoverRightclickClient(byte aSide, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return false;
+ }
+
+ /**
+ * If this is a simple Cover, which can also be used on Bronze Machines and similar.
+ */
+ public boolean isSimpleCover() {
+ return false;
+ }
+
+ /**
+ * sets the Cover upon placement.
+ */
+ public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) {
+ aTileEntity.setCoverIDAtSide(aSide, GT_Utility.stackToInt(aCover));
+ }
+
+ public String trans(String aNr, String aEnglish) {
+ return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aNr, aEnglish, false);
+ }
+ // endregion
+}
diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java
index 9faa7b11a6..767c830f79 100644
--- a/src/main/java/gregtech/api/util/GT_LanguageManager.java
+++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java
@@ -335,6 +335,8 @@ public class GT_LanguageManager {
addStringLocalization("Interaction_DESCRIPTION_Index_216", "Deprecated Recipe");
addStringLocalization("Interaction_DESCRIPTION_Index_217", "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly.");
addStringLocalization("Interaction_DESCRIPTION_Index_218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.");
+ addStringLocalization("Interaction_DESCRIPTION_Index_219", "Single recipe locking enabled. Will lock to next recipe.");
+ addStringLocalization("Interaction_DESCRIPTION_Index_220", "Single recipe locking disabled.");
addStringLocalization("Interaction_DESCRIPTION_Index_500", "Fitting: Loose - More Flow");
addStringLocalization("Interaction_DESCRIPTION_Index_501", "Fitting: Tight - More Efficiency");
diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
index a910723069..810a204c40 100644
--- a/src/main/java/gregtech/api/util/GT_ModHandler.java
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -91,7 +91,7 @@ public class GT_ModHandler {
public static volatile int VERSION = 509;
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);
+ public static Object sBoxableWrapper = new GT_IBoxableWrapper();
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<>();
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 96018571e9..c0ea06af07 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -376,115 +376,131 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
return isRecipeInputEqual(aDecreaseStacksizeBySuccess, false, aFluidInputs, aInputs);
}
+ /**
+ * Okay, did some code archeology to figure out what's going on here.
+ *
+ * <p>This variable was added in
+ * <a href=https://github.com/GTNewHorizons/GT5-Unofficial/commit/9959ab7443982a19ad329bca424ab515493432e9>this commit,</a>
+ * in order to fix the issues mentioned in
+ * <a href=https://github.com/GTNewHorizons/GT5-Unofficial/pull/183>the PR</a>.
+ *
+ * <p>It looks like it controls checking NBT. At this point, since we are still using universal
+ * fluid cells which store their fluids in NBT, it probably will not be safe to disable the NBT
+ * checks in the near future. Data sticks may be another case. Anyway, we probably can't get rid
+ * of this without some significant changes to clean up recipe inputs.
+ */
public static boolean GTppRecipeHelper;
+ /**
+ * WARNING: Do not call this method with both {@code aDecreaseStacksizeBySuccess} and {@code aDontCheckStackSizes} set to {@code true}!
+ * You'll get weird behavior.
+ */
public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) {
-
if (mInputs.length > 0 && aInputs == null) return false;
if (mFluidInputs.length > 0 && aFluidInputs == null) return false;
- int amt;
- for (FluidStack tFluid : mFluidInputs)
- if (tFluid != null) {
- boolean temp = true;
- amt = tFluid.amount;
- for (FluidStack aFluid : aFluidInputs)
- if (aFluid != null && aFluid.isFluidEqual(tFluid)) {
- if (aDontCheckStackSizes) {
- temp = false;
- break;
- }
- amt -= aFluid.amount;
- if (amt < 1) {
- temp = false;
- break;
+
+ // We need to handle 0-size recipe inputs. These are for inputs that don't get consumed.
+ boolean inputFound;
+ int remainingCost;
+
+ // Array tracking modified fluid amounts. For efficiency, we will lazily initialize this array.
+ // We use Integer so that we can have null as the default value, meaning unchanged.
+ Integer[] newFluidAmounts = null;
+ if (aFluidInputs != null) {
+ newFluidAmounts = new Integer[aFluidInputs.length];
+
+ for (FluidStack recipeFluidCost : mFluidInputs) {
+ if (recipeFluidCost != null) {
+ inputFound = false;
+ remainingCost = recipeFluidCost.amount;
+
+ for (int i = 0; i < aFluidInputs.length; i++) {
+ FluidStack providedFluid = aFluidInputs[i];
+ if (providedFluid != null && providedFluid.isFluidEqual(recipeFluidCost)) {
+ inputFound = true;
+ if (newFluidAmounts[i] == null) {
+ newFluidAmounts[i] = providedFluid.amount;
+ }
+
+ if (aDontCheckStackSizes || newFluidAmounts[i] >= remainingCost) {
+ newFluidAmounts[i] -= remainingCost;
+ remainingCost = 0;
+ break;
+ } else {
+ remainingCost -= newFluidAmounts[i];
+ newFluidAmounts[i] = 0;
+ }
}
}
- if (temp) return false;
+
+ if (remainingCost > 0 || !inputFound) {
+ // Cost not satisfied, or for non-consumed inputs, input not found.
+ return false;
+ }
+ }
}
+ }
- HashSet<Integer> isVisited = new HashSet<>();
-
- for (ItemStack tStack : mInputs) {
- ItemStack unified_tStack = GT_OreDictUnificator.get_nocopy(true, tStack);
- if (unified_tStack != null) {
- amt = tStack.stackSize;
- boolean temp = true;
- int it = 0;
- for (ItemStack aStack : aInputs) {
- it ++;
- if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack) && !isVisited.contains(it)) {
- isVisited.add(it);
- if (GTppRecipeHelper) {//remove once the fix is out
- if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) {
- if (!GT_Utility.areStacksEqual(aStack, tStack, false))
- continue;
+ // Array tracking modified item stack sizes. For efficiency, we will lazily initialize this array.
+ // We use Integer so that we can have null as the default value, meaning unchanged.
+ Integer[] newItemAmounts = null;
+ if (aInputs != null) {
+ newItemAmounts = new Integer[aInputs.length];
+
+ for (ItemStack recipeItemCost : mInputs) {
+ ItemStack unifiedItemCost = GT_OreDictUnificator.get_nocopy(true, recipeItemCost);
+ if (unifiedItemCost != null) {
+ inputFound = false;
+ remainingCost = recipeItemCost.stackSize;
+
+ for (int i = 0; i < aInputs.length; i++) {
+ ItemStack providedItem = aInputs[i];
+ if (GT_OreDictUnificator.isInputStackEqual(providedItem, unifiedItemCost)) {
+ if (GTppRecipeHelper) { // Please see JavaDoc on GTppRecipeHelper for why this is here.
+ if (GT_Utility.areStacksEqual(providedItem, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(providedItem, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(providedItem, ItemList.Tool_DataOrb.get(1L), true)) {
+ if (!GT_Utility.areStacksEqual(providedItem, recipeItemCost, false))
+ continue;
+ }
+ }
+
+ inputFound = true;
+ if (newItemAmounts[i] == null) {
+ newItemAmounts[i] = providedItem.stackSize;
+ }
+
+ if (aDontCheckStackSizes || newItemAmounts[i] >= remainingCost) {
+ newItemAmounts[i] -= remainingCost;
+ remainingCost = 0;
+ break;
+ } else {
+ remainingCost -= newItemAmounts[i];
+ newItemAmounts[i] = 0;
}
}
- if (aDontCheckStackSizes) {
- temp = false;
- break;
- }
- amt -= aStack.stackSize;
- if (amt < 1) {
- temp = false;
- break;
- }
+ }
+
+ if (remainingCost > 0 || !inputFound) {
+ // Cost not satisfied, or for non-consumed inputs, input not found.
+ return false;
}
}
- if (temp) return false;
}
}
+
if (aDecreaseStacksizeBySuccess) {
+ // Copy modified amounts into the input stacks.
if (aFluidInputs != null) {
- for (FluidStack tFluid : mFluidInputs) {
- if (tFluid != null) {
- amt = tFluid.amount;
- for (FluidStack aFluid : aFluidInputs) {
- if (aFluid != null && aFluid.isFluidEqual(tFluid)) {
- if (aDontCheckStackSizes) {
- aFluid.amount -= amt;
- break;
- }
- if (aFluid.amount < amt) {
- amt -= aFluid.amount;
- aFluid.amount = 0;
- } else {
- aFluid.amount -= amt;
- amt = 0;
- break;
- }
- }
- }
+ for (int i = 0; i < aFluidInputs.length; i++) {
+ if (newFluidAmounts[i] != null) {
+ aFluidInputs[i].amount = newFluidAmounts[i];
}
}
}
if (aInputs != null) {
- for (ItemStack tStack : mInputs) {
- if (tStack != null) {
- amt = tStack.stackSize;
- for (ItemStack aStack : aInputs) {
- if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
- if (GTppRecipeHelper) {
- if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) {
- if (!GT_Utility.areStacksEqual(aStack, tStack, false))
- continue;
- }
- }
- if (aDontCheckStackSizes){
- aStack.stackSize -= amt;
- break;
- }
- if (aStack.stackSize < amt){
- amt -= aStack.stackSize;
- aStack.stackSize = 0;
- }else{
- aStack.stackSize -= amt;
- amt = 0;
- break;
- }
- }
- }
+ for (int i = 0; i < aInputs.length; i++) {
+ if (newItemAmounts[i] != null) {
+ aInputs[i].stackSize = newItemAmounts[i];
}
}
}
@@ -564,6 +580,84 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
mEUt = aEUt;
mOreDictAlt = aAlt;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ GT_ItemStack[] thisInputs = new GT_ItemStack[this.mInputs.length];
+ int totalInputStackSize = 0;
+ for (int i=0;i<this.mInputs.length;i++) {
+ thisInputs[i] = new GT_ItemStack(this.mInputs[i]);
+ totalInputStackSize += thisInputs[i].mStackSize;
+ }
+ int inputHash = Arrays.deepHashCode(thisInputs);
+ int inputFluidHash = Arrays.deepHashCode(this.mFluidInputs);
+ GT_ItemStack thisOutput = new GT_ItemStack(mOutput);
+ GT_ItemStack thisResearch = new GT_ItemStack(mResearchItem);
+ int miscRecipeDataHash = Arrays.deepHashCode(new Object[] {
+ totalInputStackSize,
+ mDuration, mEUt,
+ thisOutput,
+ thisResearch,
+ mResearchTime
+ });
+ result = prime * result + inputFluidHash;
+ result = prime * result + inputHash;
+ result = prime * result + miscRecipeDataHash;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof GT_Recipe_AssemblyLine)) {
+ return false;
+ }
+ GT_Recipe_AssemblyLine other = (GT_Recipe_AssemblyLine) obj;
+ if (this.mInputs.length != other.mInputs.length) {
+ return false;
+ }
+ if (this.mFluidInputs.length != other.mFluidInputs.length) {
+ return false;
+ }
+ // Check Outputs Match
+ GT_ItemStack output1 = new GT_ItemStack(this.mOutput);
+ GT_ItemStack output2 = new GT_ItemStack(other.mOutput);
+ if (!output1.equals(output2)) {
+ return false;
+ }
+ // Check Scanned Item Match
+ GT_ItemStack scan1 = new GT_ItemStack(this.mResearchItem);
+ GT_ItemStack scan2 = new GT_ItemStack(other.mResearchItem);
+ if (!scan1.equals(scan2)) {
+ return false;
+ }
+ // Check Items Match
+ GT_ItemStack[] thisInputs = new GT_ItemStack[this.mInputs.length];
+ GT_ItemStack[] otherInputs = new GT_ItemStack[other.mInputs.length];
+ for (int i=0;i<thisInputs.length;i++) {
+ thisInputs[i] = new GT_ItemStack(this.mInputs[i]);
+ otherInputs[i] = new GT_ItemStack(other.mInputs[i]);
+ }
+ for (int i=0;i<thisInputs.length;i++) {
+ if (!thisInputs[i].equals(otherInputs[i]) || thisInputs[i].mStackSize != otherInputs[i].mStackSize) {
+ return false;
+ }
+ }
+ // Check Fluids Match
+ for (int i=0;i<this.mFluidInputs.length;i++) {
+ if (!this.mFluidInputs[i].isFluidStackIdentical(other.mFluidInputs[i])) {
+ return false;
+ }
+ }
+
+ return this.mDuration == other.mDuration
+ && this.mEUt == other.mEUt
+ && this.mResearchTime == other.mResearchTime;
+ }
}
@@ -599,7 +693,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map(new HashSet<>(105), "gt.recipe.sifter", "Sifter", null, RES_PATH_GUI + "basicmachines/Sifter", 1, 9, 1, 0, 1, E, 1, E, true, true);
public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress(new HashSet<>(300), "gt.recipe.press", "Forming Press", null, RES_PATH_GUI + "basicmachines/Press", 2, 1, 2, 0, 1, E, 1, E, true, true);
public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map(new HashSet<>(810), "gt.recipe.laserengraver", "Precision Laser Engraver", null, RES_PATH_GUI + "basicmachines/LaserEngraver", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer2", 9, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer6", 9, 4, 1, 0, 1, E, 1, E, true, true);
public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.autoclave", "Autoclave", null, RES_PATH_GUI + "basicmachines/Autoclave4", 2, 4, 1, 1, 1, E, 1, E, true, true);
public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.electromagneticseparator", "Electromagnetic Separator", null, RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", 1, 3, 1, 0, 1, E, 1, E, true, true);
public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.polarizer", "Electromagnetic Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true);
@@ -1045,6 +1139,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
tFluid.amount = 0;
mRecipesByFluidInput.put(tFluid.getUnlocalizedName(), aRecipe);
}
+ } else if ((aRecipe.mInputs == null || GT_Utility.getNonnullElementCount(aRecipe.mInputs) == 0) &&
+ aRecipe.mFluidInputs != null && GT_Utility.getNonnullElementCount(aRecipe.mFluidInputs) == 1 &&
+ aRecipe.mFluidInputs[0] != null) {
+ mRecipesByFluidInput.put(aRecipe.mFluidInputs[0].getUnlocalizedName(), aRecipe);
}
return aRecipe;
}
diff --git a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java
new file mode 100644
index 0000000000..469f2d64a1
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java
@@ -0,0 +1,284 @@
+package gregtech.api.util;
+
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+import javax.annotation.Nullable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** Used by machines that are locked to a single recipe, for fast computation. */
+public class GT_Single_Recipe_Check {
+ protected final GT_MetaTileEntity_MultiBlockBase multiBlockBase;
+ protected final GT_Recipe recipe;
+ protected final ImmutableMap<ItemId, Integer> itemCost;
+ protected final ImmutableMap<Fluid, Integer> fluidCost;
+
+ protected final int totalItemCost;
+ protected final int totalFluidCost;
+
+ protected GT_Single_Recipe_Check(
+ GT_MetaTileEntity_MultiBlockBase multiBlockBase,
+ GT_Recipe recipe,
+ ImmutableMap<ItemId, Integer> itemCost,
+ ImmutableMap<Fluid, Integer> fluidCost) {
+ this.multiBlockBase = multiBlockBase;
+ this.recipe = recipe;
+ this.itemCost = itemCost;
+ this.fluidCost = fluidCost;
+
+ this.totalItemCost = itemCost.values().stream().mapToInt(Integer::intValue).sum();
+ this.totalFluidCost = fluidCost.values().stream().mapToInt(Integer::intValue).sum();
+ }
+
+ public GT_Recipe getRecipe() {
+ return recipe;
+ }
+
+ /**
+ * Use this method if recipes cannot require more than a single stack of any item or fluid.
+ * In particular, {@link GT_MetaTileEntity_MultiBlockBase#getCompactedInputs()} and
+ * {@link GT_MetaTileEntity_MultiBlockBase#getCompactedFluids()} both enforce this single-stack
+ * restriction, so any multi-block that calls those can use this method.
+ */
+ public boolean checkRecipeInputsSingleStack(boolean consumeInputs) {
+ Map<ItemId, ItemStack> itemMap = null;
+ if (totalItemCost > 0) {
+ itemMap = new HashMap<>();
+ for (ItemStack itemStack : multiBlockBase.getStoredInputs()) {
+ itemMap.merge(
+ ItemId.createNoCopy(itemStack), itemStack,
+ (a, b) -> a.stackSize >= b.stackSize ? a : b);
+ }
+
+ for (Map.Entry<ItemId, Integer> entry : itemCost.entrySet()) {
+ ItemStack itemStack = itemMap.get(entry.getKey());
+ if (itemStack == null || itemStack.stackSize < entry.getValue()) {
+ return false;
+ }
+ }
+ }
+
+ Map<Fluid, FluidStack> fluidMap = null;
+ if (totalFluidCost > 0) {
+ fluidMap = new HashMap<>();
+ for (FluidStack fluidStack : multiBlockBase.getStoredFluids()) {
+ fluidMap.merge(
+ fluidStack.getFluid(), fluidStack,
+ (a, b) -> a.amount >= b.amount ? a : b);
+ }
+
+ for (Map.Entry<Fluid, Integer> entry : fluidCost.entrySet()) {
+ FluidStack fluidStack = fluidMap.get(entry.getKey());
+ if (fluidStack == null || fluidStack.amount < entry.getValue()) {
+ return false;
+ }
+ }
+ }
+
+ if (consumeInputs) {
+ if (totalItemCost > 0) {
+ for (Map.Entry<ItemId, Integer> entry : itemCost.entrySet()) {
+ itemMap.get(entry.getKey()).stackSize -= entry.getValue();
+ }
+ }
+
+ if (totalFluidCost > 0) {
+ for (Map.Entry<Fluid, Integer> entry : fluidCost.entrySet()) {
+ fluidMap.get(entry.getKey()).amount -= entry.getValue();
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Use this method if recipes can require more than a single stack of any item or fluid.
+ * It is less efficient, though.
+ */
+ public boolean checkRecipeInputs(boolean consumeInputs) {
+ List<ItemStack> items = null;
+ if (totalItemCost > 0) {
+ items = multiBlockBase.getStoredInputs();
+
+ Map<ItemId, Integer> itemMap = new HashMap<>();
+ for (ItemStack itemStack : items) {
+ itemMap.merge(ItemId.createNoCopy(itemStack), itemStack.stackSize, Integer::sum);
+ }
+
+ for (Map.Entry<ItemId, Integer> entry : itemCost.entrySet()) {
+ if (itemMap.getOrDefault(entry.getKey(), 0) < entry.getValue()) {
+ return false;
+ }
+ }
+ }
+
+ List<FluidStack> fluids = null;
+ if (totalFluidCost > 0) {
+ fluids = multiBlockBase.getStoredFluids();
+
+ Map<Fluid, Integer> fluidMap = new HashMap<>();
+ for (FluidStack fluidStack : fluids) {
+ fluidMap.merge(fluidStack.getFluid(), fluidStack.amount, Integer::sum);
+ }
+
+ for (Map.Entry<Fluid, Integer> entry : fluidCost.entrySet()) {
+ if (fluidMap.getOrDefault(entry.getKey(), 0) < entry.getValue()) {
+ return false;
+ }
+ }
+ }
+
+ if (consumeInputs) {
+ if (totalItemCost > 0) {
+ int remainingItemCost = totalItemCost;
+ Map<ItemId, Integer> runningItemCost = Maps.newHashMap(itemCost);
+ for (ItemStack itemStack : items) {
+ ItemId key = ItemId.createNoCopy(itemStack);
+ int runningCost = runningItemCost.getOrDefault(key, 0);
+ int paid = Math.min(itemStack.stackSize, runningCost);
+ itemStack.stackSize -= paid;
+ runningItemCost.put(key, runningCost - paid);
+
+ remainingItemCost -= paid;
+ if (remainingItemCost <= 0) {
+ break;
+ }
+ }
+ }
+
+ if (totalFluidCost > 0) {
+ int remainingFluidCost = totalFluidCost;
+ Map<Fluid, Integer> runningFluidCost = Maps.newHashMap(fluidCost);
+ for (FluidStack fluidStack : fluids) {
+ Fluid key = fluidStack.getFluid();
+ int runningCost = runningFluidCost.getOrDefault(key, 0);
+ int paid = Math.min(fluidStack.amount, runningCost);
+ fluidStack.amount -= paid;
+ runningFluidCost.put(key, runningCost - paid);
+
+ remainingFluidCost -= paid;
+ if (remainingFluidCost <= 0) {
+ break;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ protected static Map<ItemId, Integer> buildItemMap(
+ GT_MetaTileEntity_MultiBlockBase multiBlockBase) {
+ Map<ItemId, Integer> itemMap = new HashMap<>();
+ for (ItemStack itemStack : multiBlockBase.getStoredInputs()) {
+ itemMap.merge(ItemId.create(itemStack), itemStack.stackSize, Integer::sum);
+ }
+ return itemMap;
+ }
+
+ protected static Map<Fluid, Integer> buildFluidMap(
+ GT_MetaTileEntity_MultiBlockBase multiBlockBase) {
+ Map<Fluid, Integer> fluidMap = new HashMap<>();
+ for (FluidStack fluidStack : multiBlockBase.getStoredFluids()) {
+ fluidMap.merge(fluidStack.getFluid(), fluidStack.amount, Integer::sum);
+ }
+ return fluidMap;
+ }
+
+ public static Builder builder(GT_MetaTileEntity_MultiBlockBase multiBlockBase) {
+ return new Builder(multiBlockBase);
+ }
+
+ public static final class Builder {
+ private final GT_MetaTileEntity_MultiBlockBase multiBlockBase;
+
+ // In order to compute which items and fluids are consumed by the recipe, we compare the
+ // multi-block's items and fluids before and after inputs are consumed by the recipe.
+ private Map<ItemId, Integer> beforeItems;
+ private Map<Fluid, Integer> beforeFluids;
+ private Map<ItemId, Integer> afterItems;
+ private Map<Fluid, Integer> afterFluids;
+
+ private GT_Recipe recipe;
+
+ private Builder(GT_MetaTileEntity_MultiBlockBase multiBlockBase) {
+ this.multiBlockBase = multiBlockBase;
+ }
+
+ /** Call this before inputs are consumed by the recipe. */
+ public Builder setBefore() {
+ beforeItems = buildItemMap(multiBlockBase);
+ beforeFluids = buildFluidMap(multiBlockBase);
+ return this;
+ }
+
+ /** Call this after inputs are consumed by the recipe. */
+ public Builder setAfter() {
+ afterItems = buildItemMap(multiBlockBase);
+ afterFluids = buildFluidMap(multiBlockBase);
+ return this;
+ }
+
+ public Builder setRecipe(GT_Recipe recipe) {
+ this.recipe = recipe;
+ return this;
+ }
+
+ public GT_Single_Recipe_Check build() {
+ ImmutableMap.Builder<ItemId, Integer> itemCostBuilder = ImmutableMap.builder();
+ for (Map.Entry<ItemId, Integer> entry : beforeItems.entrySet()) {
+ int cost = entry.getValue() - afterItems.getOrDefault(entry.getKey(), 0);
+ if (cost > 0) {
+ itemCostBuilder.put(entry.getKey(), cost);
+ }
+ }
+
+ ImmutableMap.Builder<Fluid, Integer> fluidCostBuilder = ImmutableMap.builder();
+ for (Map.Entry<Fluid, Integer> entry : beforeFluids.entrySet()) {
+ int cost = entry.getValue() - afterFluids.getOrDefault(entry.getKey(), 0);
+ if (cost > 0) {
+ fluidCostBuilder.put(entry.getKey(), cost);
+ }
+ }
+
+ return new GT_Single_Recipe_Check(
+ multiBlockBase, recipe, itemCostBuilder.build(), fluidCostBuilder.build());
+ }
+ }
+
+ @AutoValue
+ protected abstract static class ItemId {
+ /** This method copies NBT, as it is mutable. */
+ protected static ItemId create(ItemStack itemStack) {
+ NBTTagCompound nbt = itemStack.getTagCompound();
+ if (nbt != null) {
+ nbt = (NBTTagCompound) nbt.copy();
+ }
+
+ return new AutoValue_GT_Single_Recipe_Check_ItemId(
+ itemStack.getItem(), itemStack.getItemDamage(), nbt);
+ }
+
+ /** This method does not copy NBT in order to save time. Make sure not to mutate it! */
+ protected static ItemId createNoCopy(ItemStack itemStack) {
+ return new AutoValue_GT_Single_Recipe_Check_ItemId(
+ itemStack.getItem(), itemStack.getItemDamage(), itemStack.getTagCompound());
+ }
+
+ protected abstract Item item();
+ protected abstract int metaData();
+
+ @Nullable
+ protected abstract NBTTagCompound nbt();
+ }
+}
diff --git a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java
new file mode 100644
index 0000000000..225e0bd723
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java
@@ -0,0 +1,212 @@
+package gregtech.api.util;
+
+import com.google.common.collect.ImmutableMap;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/** Processing Array-specialized version of {@link gregtech.api.util.GT_Single_Recipe_Check}. */
+public class GT_Single_Recipe_Check_Processing_Array extends GT_Single_Recipe_Check {
+ protected final int recipeAmperage;
+
+ /**
+ * The machine type that the locked recipe is for.
+ * We will not allow running with other machines.
+ */
+ protected final ItemStack machineStack;
+
+ protected GT_Single_Recipe_Check_Processing_Array(
+ GT_MetaTileEntity_MultiBlockBase multiBlockBase,
+ GT_Recipe recipe,
+ ImmutableMap<ItemId, Integer> itemCost,
+ ImmutableMap<Fluid, Integer> fluidCost,
+ int recipeAmperage,
+ ItemStack machineStack) {
+ super(multiBlockBase, recipe, itemCost, fluidCost);
+
+ this.recipeAmperage = recipeAmperage;
+ this.machineStack = machineStack;
+ }
+
+ public int getRecipeAmperage() {
+ return recipeAmperage;
+ }
+
+ @Override
+ public boolean checkRecipeInputsSingleStack(boolean consumeInputs) {
+ throw new UnsupportedOperationException("Use checkRecipeInputs(boolean, int) instead.");
+ }
+
+ @Override
+ public boolean checkRecipeInputs(boolean consumeInputs) {
+ throw new UnsupportedOperationException("Use checkRecipeInputs(boolean, int) instead.");
+ }
+
+ /** Returns the number of parallel recipes, or 0 if recipe is not satisfied at all. */
+ public int checkRecipeInputs(boolean consumeInputs, int maxParallel) {
+ if (!GT_Utility.areStacksEqual(machineStack, multiBlockBase.mInventory[1])) {
+ // Machine stack was modified. This is not allowed, so stop processing.
+ return 0;
+ }
+ int parallel = maxParallel;
+
+ List<ItemStack> items = null;
+ if (totalItemCost > 0) {
+ items = multiBlockBase.getStoredInputs();
+
+ Map<ItemId, Integer> itemMap = new HashMap<>();
+ for (ItemStack itemStack : items) {
+ itemMap.merge(ItemId.createNoCopy(itemStack), itemStack.stackSize, Integer::sum);
+ }
+
+ for (Map.Entry<ItemId, Integer> entry : itemCost.entrySet()) {
+ parallel = Math.min(parallel, itemMap.getOrDefault(entry.getKey(), 0) / entry.getValue());
+ if (parallel <= 0) {
+ return 0;
+ }
+ }
+ }
+
+ List<FluidStack> fluids = null;
+ if (totalFluidCost > 0) {
+ fluids = multiBlockBase.getStoredFluids();
+
+ Map<Fluid, Integer> fluidMap = new HashMap<>();
+ for (FluidStack fluidStack : fluids) {
+ fluidMap.merge(fluidStack.getFluid(), fluidStack.amount, Integer::sum);
+ }
+
+ for (Map.Entry<Fluid, Integer> entry : fluidCost.entrySet()) {
+ parallel = Math.min(parallel, fluidMap.getOrDefault(entry.getKey(), 0) / entry.getValue());
+ if (parallel <= 0) {
+ return 0;
+ }
+ }
+ }
+
+ final int finalParallel = parallel;
+ if (consumeInputs) {
+ if (totalItemCost > 0) {
+ int remainingItemCost = totalItemCost * finalParallel;
+ Map<ItemId, Integer> runningItemCost =
+ itemCost.entrySet().stream()
+ .collect(
+ Collectors.toMap(
+ Map.Entry::getKey,
+ entry -> entry.getValue() * finalParallel));
+
+ for (ItemStack itemStack : items) {
+ ItemId key = ItemId.createNoCopy(itemStack);
+ int runningCost = runningItemCost.getOrDefault(key, 0);
+ int paid = Math.min(itemStack.stackSize, runningCost);
+ itemStack.stackSize -= paid;
+ runningItemCost.put(key, runningCost - paid);
+
+ remainingItemCost -= paid;
+ if (remainingItemCost <= 0) {
+ break;
+ }
+ }
+ }
+
+ if (totalFluidCost > 0) {
+ int remainingFluidCost = totalFluidCost * finalParallel;
+ Map<Fluid, Integer> runningFluidCost =
+ fluidCost.entrySet().stream()
+ .collect(
+ Collectors.toMap(
+ Map.Entry::getKey,
+ entry -> entry.getValue() * finalParallel));
+
+ for (FluidStack fluidStack : fluids) {
+ Fluid key = fluidStack.getFluid();
+ int runningCost = runningFluidCost.getOrDefault(key, 0);
+ int paid = Math.min(fluidStack.amount, runningCost);
+ fluidStack.amount -= paid;
+ runningFluidCost.put(key, runningCost - paid);
+
+ remainingFluidCost -= paid;
+ if (remainingFluidCost <= 0) {
+ break;
+ }
+ }
+ }
+ }
+
+ return finalParallel;
+ }
+
+ public static Builder processingArrayBuilder(GT_MetaTileEntity_MultiBlockBase multiBlockBase) {
+ return new Builder(multiBlockBase);
+ }
+
+ public static final class Builder {
+ private final GT_MetaTileEntity_MultiBlockBase multiBlockBase;
+
+ // In order to compute which items and fluids are consumed by the recipe, we compare the
+ // multi-block's items and fluids before and after inputs are consumed by the recipe.
+ private Map<ItemId, Integer> beforeItems;
+ private Map<Fluid, Integer> beforeFluids;
+ private Map<ItemId, Integer> afterItems;
+ private Map<Fluid, Integer> afterFluids;
+
+ private GT_Recipe recipe;
+ private int recipeAmperage;
+
+ private Builder(GT_MetaTileEntity_MultiBlockBase multiBlockBase) {
+ this.multiBlockBase = multiBlockBase;
+ }
+
+ /** Call this before inputs are consumed by the recipe. */
+ public Builder setBefore() {
+ beforeItems = buildItemMap(multiBlockBase);
+ beforeFluids = buildFluidMap(multiBlockBase);
+ return this;
+ }
+
+ /** Call this after inputs are consumed by the recipe. */
+ public Builder setAfter() {
+ afterItems = buildItemMap(multiBlockBase);
+ afterFluids = buildFluidMap(multiBlockBase);
+ return this;
+ }
+
+ public Builder setRecipe(GT_Recipe recipe) {
+ this.recipe = recipe;
+ return this;
+ }
+
+ public Builder setRecipeAmperage(int recipeAmperage) {
+ this.recipeAmperage = recipeAmperage;
+ return this;
+ }
+
+ public GT_Single_Recipe_Check_Processing_Array build() {
+ ImmutableMap.Builder<ItemId, Integer> itemCostBuilder = ImmutableMap.builder();
+ for (Map.Entry<ItemId, Integer> entry : beforeItems.entrySet()) {
+ int cost = entry.getValue() - afterItems.getOrDefault(entry.getKey(), 0);
+ if (cost > 0) {
+ itemCostBuilder.put(entry.getKey(), cost);
+ }
+ }
+
+ ImmutableMap.Builder<Fluid, Integer> fluidCostBuilder = ImmutableMap.builder();
+ for (Map.Entry<Fluid, Integer> entry : beforeFluids.entrySet()) {
+ int cost = entry.getValue() - afterFluids.getOrDefault(entry.getKey(), 0);
+ if (cost > 0) {
+ fluidCostBuilder.put(entry.getKey(), cost);
+ }
+ }
+
+ return new GT_Single_Recipe_Check_Processing_Array(
+ multiBlockBase, recipe, itemCostBuilder.build(), fluidCostBuilder.build(),
+ recipeAmperage, multiBlockBase.mInventory[1].copy());
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 16d22be9ef..a07868ec68 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -12,13 +12,24 @@ import gregtech.api.GregTech_API;
import gregtech.api.damagesources.GT_DamageSources;
import gregtech.api.damagesources.GT_DamageSources.DamageSourceHotItem;
import gregtech.api.enchants.Enchantment_Radioactivity;
-import gregtech.api.enums.*;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.SubTag;
+import gregtech.api.enums.Textures;
+import gregtech.api.enums.ToolDictNames;
import gregtech.api.events.BlockScanningEvent;
import gregtech.api.interfaces.IBlockContainer;
import gregtech.api.interfaces.IDebugableBlock;
import gregtech.api.interfaces.IProjectileItem;
import gregtech.api.interfaces.ITexture;
-import gregtech.api.interfaces.tileentity.*;
+import gregtech.api.interfaces.tileentity.IBasicEnergyContainer;
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.interfaces.tileentity.IMachineProgress;
+import gregtech.api.interfaces.tileentity.IUpgradableMachine;
import gregtech.api.items.GT_EnergyArmor_Item;
import gregtech.api.items.GT_Generic_Item;
import gregtech.api.items.GT_MetaGenerated_Tool;
@@ -28,7 +39,7 @@ import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.ItemData;
import gregtech.api.threads.GT_Runnable_Sound;
import gregtech.api.util.extensions.ArrayExt;
-import gregtech.common.GT_Proxy;
+import gregtech.common.GT_Pollution;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeInputItemStack;
@@ -37,7 +48,11 @@ import ic2.api.recipe.RecipeOutput;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
-import net.minecraft.entity.*;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityList;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -59,9 +74,14 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
-import net.minecraft.util.*;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
+import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot;
@@ -70,8 +90,13 @@ import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.world.BlockEvent;
-import net.minecraftforge.fluids.*;
+import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidContainerItem;
+import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nullable;
@@ -79,16 +104,25 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.NumberFormat;
-import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import static gregtech.GT_Mod.GT_FML_LOGGER;
-import static gregtech.api.enums.GT_Values.*;
-import static gregtech.common.GT_Proxy.GTPOLLUTION;
+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.GT;
+import static gregtech.api.enums.GT_Values.L;
+import static gregtech.api.enums.GT_Values.M;
+import static gregtech.api.enums.GT_Values.NW;
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.enums.GT_Values.W;
import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
/**
@@ -2114,7 +2148,7 @@ public class GT_Utility {
try {
if (tTileEntity instanceof ICoverable) {
rEUAmount += 300;
- String tString = ((ICoverable) tTileEntity).getCoverBehaviorAtSide((byte) aSide).getDescription((byte) aSide, ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide), ((ICoverable) tTileEntity).getCoverDataAtSide((byte) aSide), (ICoverable) tTileEntity);
+ String tString = ((ICoverable) tTileEntity).getCoverBehaviorAtSideNew((byte) aSide).getDescription((byte) aSide, ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide), ((ICoverable) tTileEntity).getComplexCoverDataAtSide((byte) aSide), (ICoverable) tTileEntity);
if (tString != null && !tString.equals(E)) tList.add(tString);
}
} catch (Throwable e) {
@@ -2186,23 +2220,19 @@ public class GT_Utility {
}
}
+ Chunk currentChunk = aWorld.getChunkFromBlockCoords(aX, aZ);
if (aPlayer.capabilities.isCreativeMode) {
- FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ));//-# to only read
+ FluidStack tFluid = undergroundOilReadInformation(currentChunk);//-# to only read
if (tFluid!=null)
tList.add(EnumChatFormatting.GOLD + tFluid.getLocalizedName() + EnumChatFormatting.RESET + ": " + EnumChatFormatting.YELLOW + formatNumbers(tFluid.amount) + EnumChatFormatting.RESET + " L");
else
tList.add(EnumChatFormatting.GOLD + trans("201","Nothing") + EnumChatFormatting.RESET + ": " + EnumChatFormatting.YELLOW + '0' + EnumChatFormatting.RESET + " L");
}
// if(aPlayer.capabilities.isCreativeMode){
- int[] chunkData = GT_Proxy.dimensionWiseChunkData.get(aWorld.provider.dimensionId).get(aWorld.getChunkFromBlockCoords(aX,aZ).getChunkCoordIntPair());
- if(chunkData != null){
- if(chunkData[GTPOLLUTION]>0){
- tList.add(trans("202","Pollution in Chunk: ") + EnumChatFormatting.RED + formatNumbers(chunkData[GTPOLLUTION]) + EnumChatFormatting.RESET + trans("203"," gibbl"));
- }else{
- tList.add(EnumChatFormatting.GREEN+trans("204","No Pollution in Chunk! HAYO!")+EnumChatFormatting.RESET);
- }
- }else{
- tList.add(EnumChatFormatting.GREEN+trans("204","No Pollution in Chunk! HAYO!")+EnumChatFormatting.RESET);
+ if (GT_Pollution.hasPollution(currentChunk)) {
+ tList.add(trans("202", "Pollution in Chunk: ") + EnumChatFormatting.RED + formatNumbers(GT_Pollution.getPollution(currentChunk)) + EnumChatFormatting.RESET + trans("203", " gibbl"));
+ } else {
+ tList.add(EnumChatFormatting.GREEN + trans("204", "No Pollution in Chunk! HAYO!") + EnumChatFormatting.RESET);
}
try {
diff --git a/src/main/java/gregtech/api/util/ISerializableObject.java b/src/main/java/gregtech/api/util/ISerializableObject.java
new file mode 100644
index 0000000000..51fa40e55a
--- /dev/null
+++ b/src/main/java/gregtech/api/util/ISerializableObject.java
@@ -0,0 +1,150 @@
+package gregtech.api.util;
+
+import com.google.common.io.ByteArrayDataInput;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTSizeTracker;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagInt;
+
+import javax.annotation.Nonnull;
+import java.io.IOException;
+
+/**
+ * We could well have used {@link java.io.Serializable}, but that's too slow and should generally be avoided
+ *
+ * @author glease
+ */
+public interface ISerializableObject {
+
+ @Nonnull
+ ISerializableObject copy();
+
+ @Nonnull
+ NBTBase saveDataToNBT();
+
+ /**
+ * Write data to given ByteBuf
+ * The data saved this way is intended to be stored for short amount of time over network.
+ * DO NOT store it to disks.
+ */
+ // the NBT is an unfortunate piece of tech. everything uses it but its API is not as efficient as could be
+ void writeToByteBuf(ByteBuf aBuf);
+
+ void loadDataFromNBT(NBTBase aNBT);
+
+ /**
+ * Read data from given parameter and return this.
+ * The data read this way is intended to be stored for short amount of time over network.
+ */
+ // the NBT is an unfortunate piece of tech. everything uses it but its API is not as efficient as could be
+ @Nonnull
+ ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer);
+
+ /**
+ * Reverse engineered and adapted {@link cpw.mods.fml.common.network.ByteBufUtils#readTag(ByteBuf)}
+ * Given buffer must contain a serialized NBTTagCompound in minecraft encoding
+ */
+ static NBTTagCompound readCompoundTagFromGreggyByteBuf(ByteArrayDataInput aBuf) {
+ short size = aBuf.readShort();
+ if (size < 0)
+ return null;
+ else {
+ byte[] buf = new byte[size]; // this is shit, how many copies have we been doing?
+ aBuf.readFully(buf);
+ try {
+ return CompressedStreamTools.func_152457_a(buf, new NBTSizeTracker(2097152L));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * Reverse engineered and adapted {@link cpw.mods.fml.common.network.ByteBufUtils#readItemStack(ByteBuf)}
+ * Given buffer must contain a serialized ItemStack in minecraft encoding
+ */
+ static ItemStack readItemStackFromGreggyByteBuf(ByteArrayDataInput aBuf) {
+ ItemStack stack = null;
+ short id = aBuf.readShort();
+ if (id >= 0) {
+ byte size = aBuf.readByte();
+ short meta = aBuf.readShort();
+ stack = new ItemStack(Item.getItemById(id), size, meta);
+ stack.stackTagCompound = readCompoundTagFromGreggyByteBuf(aBuf);
+ }
+ return stack;
+ }
+
+ final class LegacyCoverData implements ISerializableObject {
+ private int mData;
+
+ public LegacyCoverData() {
+ }
+
+ public LegacyCoverData(int mData) {
+ this.mData = mData;
+ }
+
+ @Override
+ @Nonnull
+ public ISerializableObject copy() {
+ return new LegacyCoverData(mData);
+ }
+
+ @Override
+ @Nonnull
+ public NBTBase saveDataToNBT() {
+ return new NBTTagInt(mData);
+ }
+
+ @Override
+ public void writeToByteBuf(ByteBuf aBuf) {
+ aBuf.writeInt(mData);
+ }
+
+ @Override
+ public void loadDataFromNBT(NBTBase aNBT) {
+ mData = aNBT instanceof NBTBase.NBTPrimitive ? ((NBTBase.NBTPrimitive) aNBT).func_150287_d() : 0;
+ }
+
+ @Override
+ @Nonnull
+ public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) {
+ mData = aBuf.readInt();
+ return this;
+ }
+
+ public int get() {
+ return mData;
+ }
+
+ public void set(int mData) {
+ this.mData = mData;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ LegacyCoverData that = (LegacyCoverData) o;
+
+ return mData == that.mData;
+ }
+
+ @Override
+ public int hashCode() {
+ return mData;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(mData);
+ }
+ }
+}