aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/loaders
diff options
context:
space:
mode:
authorNotAPenguin <michiel.vandeginste@gmail.com>2024-08-24 15:12:00 +0200
committerGitHub <noreply@github.com>2024-08-24 15:12:00 +0200
commitc2e8f2754f8b5868e7b2110c6442410ce686ff0a (patch)
tree3c5b2b33065fdb0578abaebc6384662bb496d8fe /src/main/java/gregtech/loaders
parentf89d122ce4492281981140fd9e1612cea08313cf (diff)
downloadGT5-Unofficial-c2e8f2754f8b5868e7b2110c6442410ce686ff0a.tar.gz
GT5-Unofficial-c2e8f2754f8b5868e7b2110c6442410ce686ff0a.tar.bz2
GT5-Unofficial-c2e8f2754f8b5868e7b2110c6442410ce686ff0a.zip
Make frame boxes no longer TileEntities (#2799)
* fiddling around with frame boxes * more fiddling * am trying * frames exist * fix frame rendering in inventory * Fix in world frame rendering * Apply cover to dumb frame * continue work on frames * apply covers to correct side and fix crash on load * Test permissions * fix oredict for new frames and create recipes * fix waila names and drops (kind of) * fix drops * mostly all working * remove old comment * fix structurecheck using new frames * create the TE transformer * it didnt work * dont modify tes we dont want to modify (needs future postea update) * it works! * item transformer works too * spotless * add more method overrides from generic gt block? * update postea * fix postea transforming items in reserved frame range that were not frame boxes * fix tesla tower structurecheck + capacitor hatch crash * Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com> * Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com> * Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com> * Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com> * Spotless apply for branch dumb-frames for #2799 (#2953) spotlessApply Co-authored-by: GitHub GTNH Actions <> * remove extra null check * Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com> * remove more messy instanceof checks * Spotless apply for branch dumb-frames for #2799 (#2954) spotlessApply Co-authored-by: GitHub GTNH Actions <> * remove unnecessary null check * try fixing facade color * Update src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com> * small cleanup in framebox gen code * swap material for frame box block * fix description * make getMaterial static and add fix AE cover color * nicer casts + localize tooltip in frame block instead of stealing old localization * draw grid on cover hover * add a null check in getTexture() that hopefully fixes crash in full pack when interacting with frame boxes * also draw grid when hovering with wrench * add chemical element back to tooltip * fix breaking frame not causing structure update --------- Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/loaders')
-rw-r--r--src/main/java/gregtech/loaders/postload/PosteaTransformers.java76
-rw-r--r--src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java2
-rw-r--r--src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java53
3 files changed, 119 insertions, 12 deletions
diff --git a/src/main/java/gregtech/loaders/postload/PosteaTransformers.java b/src/main/java/gregtech/loaders/postload/PosteaTransformers.java
new file mode 100644
index 0000000000..ae24de26e8
--- /dev/null
+++ b/src/main/java/gregtech/loaders/postload/PosteaTransformers.java
@@ -0,0 +1,76 @@
+package gregtech.loaders.postload;
+
+import net.minecraft.item.Item;
+import net.minecraft.nbt.NBTTagCompound;
+
+import com.gtnewhorizons.postea.api.ItemStackReplacementManager;
+import com.gtnewhorizons.postea.api.TileEntityReplacementManager;
+import com.gtnewhorizons.postea.utility.BlockInfo;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
+import vexatos.tgregworks.reference.Mods;
+
+public class PosteaTransformers implements Runnable {
+
+ @Override
+ public void run() {
+ registerFrameboxTransformers();
+ }
+
+ private static NBTTagCompound passthrough(NBTTagCompound tag) {
+ return tag;
+ }
+
+ private void registerFrameboxTransformers() {
+ // These are used to convert old TileEntity frame boxes into the new system
+ // that does not use TEs by default
+
+ TileEntityReplacementManager.tileEntityTransformer("BaseMetaPipeEntity", (tag, world) -> {
+ // Read the MTE ID from the NBT data and try to figure out if this is a frame box
+ int id = tag.getInteger("mID");
+ // Framebox IDs start at 4096
+ int indexInMaterialList = id - 4096;
+ // The offset from 4096 is the index in the material list, so if this is outside the valid range then this
+ // is not a valid frame box, and we don't want to modify it
+ if (indexInMaterialList < 0 || indexInMaterialList >= GregTech_API.sGeneratedMaterials.length) {
+ // Do not modify this TE, so return null
+ return null;
+ }
+
+ // Now we know for sure that the tileentity is a frame box
+ // If this frame has a cover on it, we need to keep it, but we still need to make sure the block
+ // is the new frame block. We can make sure to keep the TE using a pass-through transformer.
+ // This works because between the old and new frame systems, the TileEntity used for covered frames
+ // is still the same
+ if (tag.hasKey(GT_Values.NBT.COVERS)) {
+ return new BlockInfo(GregTech_API.sBlockFrames, indexInMaterialList, PosteaTransformers::passthrough);
+ }
+
+ // If this frame has no covers, simply return a block and delete the TileEntity
+ return new BlockInfo(GregTech_API.sBlockFrames, indexInMaterialList);
+ });
+
+ ItemStackReplacementManager.addItemReplacement("gregtech:gt.blockmachines", (tag) -> {
+ // Get item meta id and see if this is a frame box, this works pretty much identically to the TE transformer
+ int id = tag.getInteger("Damage");
+ int indexInMaterialList = id - 4096;
+ // Not a frame box
+ if (indexInMaterialList < 0 || indexInMaterialList >= GregTech_API.sGeneratedMaterials.length) {
+ return tag;
+ }
+ // Not a frame box if the material for this id does not have a frame box associated with it.
+ // Apparently the DEFC ID overlaps with the material ID for a Bastnasite frame box for example
+ if ((GregTech_API.sGeneratedMaterials[indexInMaterialList].mTypes & 0x2) == 0) {
+ return tag;
+ }
+ Item frameItem = GameRegistry.findItem(Mods.GregTech, "gt.blockframes");
+ int itemId = Item.getIdFromItem(frameItem);
+ // Change this item into the correct frame item (make sure to keep amount)
+ tag.setInteger("id", itemId);
+ tag.setInteger("Damage", indexInMaterialList);
+ return tag;
+ });
+ }
+}
diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java
index ecede7ebb9..ce69a4fa27 100644
--- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java
+++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java
@@ -64,6 +64,7 @@ import gregtech.common.blocks.GT_Block_Casings8;
import gregtech.common.blocks.GT_Block_Casings9;
import gregtech.common.blocks.GT_Block_Concretes;
import gregtech.common.blocks.GT_Block_Drone;
+import gregtech.common.blocks.GT_Block_FrameBox;
import gregtech.common.blocks.GT_Block_Glass1;
import gregtech.common.blocks.GT_Block_Granites;
import gregtech.common.blocks.GT_Block_Laser;
@@ -554,6 +555,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable {
GregTech_API.sBlockConcretes = new GT_Block_Concretes();
GregTech_API.sBlockStones = new GT_Block_Stones();
GregTech_API.sBlockOres1 = new GT_Block_Ores();
+ GregTech_API.sBlockFrames = new GT_Block_FrameBox();
GregTech_API.sDroneRender = new GT_Block_Drone();
GregTech_API.sBlockGlass1 = new GT_Block_Glass1();
GregTech_API.sBlockTintedGlass = new GT_Block_TintedIndustrialGlass();
diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java
index bbfe7538b2..918251d265 100644
--- a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java
+++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java
@@ -43,6 +43,9 @@ import static gregtech.api.recipe.RecipeMaps.sifterRecipes;
import static gregtech.api.recipe.RecipeMaps.slicerRecipes;
import static gregtech.api.recipe.RecipeMaps.thermalCentrifugeRecipes;
import static gregtech.api.recipe.RecipeMaps.wiremillRecipes;
+import static gregtech.api.util.GT_RecipeBuilder.SECONDS;
+import static gregtech.api.util.GT_RecipeBuilder.TICKS;
+import static gregtech.api.util.GT_Utility.calculateRecipeEU;
import net.minecraft.util.EnumChatFormatting;
@@ -54,6 +57,8 @@ import gregtech.api.enums.Materials;
import gregtech.api.enums.MaterialsUEVplus;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.SoundResource;
+import gregtech.api.enums.SubTag;
+import gregtech.api.enums.TierEU;
import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable;
import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid;
import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame;
@@ -80,7 +85,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Wireless_Ha
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.util.GT_LanguageManager;
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.common.blocks.GT_Block_FrameBox;
import gregtech.common.tileentities.automation.GT_MetaTileEntity_ChestBuffer;
import gregtech.common.tileentities.automation.GT_MetaTileEntity_Filter;
import gregtech.common.tileentities.automation.GT_MetaTileEntity_ItemDistributor;
@@ -11886,19 +11894,40 @@ public class GT_Loader_MetaTileEntities implements Runnable { // TODO CHECK CIRC
}
private static void generateWiresAndPipes() {
- for (int i = 0; i < GregTech_API.sGeneratedMaterials.length; i++) {
- if (((GregTech_API.sGeneratedMaterials[i] != null)
- && ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x2) != 0))
- || (GregTech_API.sGeneratedMaterials[i] == Materials.Wood)) {
+ for (int meta = 0; meta < GregTech_API.sGeneratedMaterials.length; meta++) {
+ Materials material = GregTech_API.sGeneratedMaterials[meta];
+ // This check is separated out because IntelliJ thinks Materials.Wood can be null.
+ if (material == null) continue;
+ if ((material.mTypes & 0x2) != 0 || material == Materials.Wood) {
new GT_MetaPipeEntity_Frame(
- 4096 + i,
- "GT_Frame_" + GregTech_API.sGeneratedMaterials[i],
- (GT_LanguageManager.i18nPlaceholder ? "%material"
- : GregTech_API.sGeneratedMaterials[i] != null
- ? GregTech_API.sGeneratedMaterials[i].mDefaultLocalName
- : "")
- + " Frame Box",
- GregTech_API.sGeneratedMaterials[i]);
+ 4096 + meta,
+ "GT_Frame_" + material,
+ (GT_LanguageManager.i18nPlaceholder ? "%material" : material.mDefaultLocalName)
+ + " Frame Box (TileEntity)",
+ material);
+
+ // Generate recipes for frame box
+ GT_Block_FrameBox block = (GT_Block_FrameBox) GregTech_API.sBlockFrames;
+ GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, material, block.getStackForm(1, meta));
+ if (material.getProcessingMaterialTierEU() < TierEU.IV) {
+ GT_ModHandler.addCraftingRecipe(
+ block.getStackForm(2, meta),
+ GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED,
+ new Object[] { "SSS", "SwS", "SSS", 'S', OrePrefixes.stick.get(material) });
+ }
+
+ if (!material.contains(SubTag.NO_RECIPES)
+ && GT_OreDictUnificator.get(OrePrefixes.stick, material, 1) != null) {
+ // Auto generate frame box recipe in an assembler.
+ GT_Values.RA.stdBuilder()
+ .itemInputs(
+ GT_OreDictUnificator.get(OrePrefixes.stick, material, 4),
+ GT_Utility.getIntegratedCircuit(4))
+ .itemOutputs(block.getStackForm(1, meta))
+ .duration(3 * SECONDS + 4 * TICKS)
+ .eut(calculateRecipeEU(material, 7))
+ .addTo(assemblerRecipes);
+ }
}
}