aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/gregtech/api/util/GT_StructureUtility.java37
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java26
2 files changed, 45 insertions, 18 deletions
diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java
index 5067c698ab..7e39a0d838 100644
--- a/src/main/java/gregtech/api/util/GT_StructureUtility.java
+++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java
@@ -3,6 +3,7 @@ package gregtech.api.util;
import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.structure.IStructureElement;
import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement;
+import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.interfaces.IHeatingCoil;
@@ -12,13 +13,12 @@ import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
+import org.apache.commons.lang3.StringUtils;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.function.Function;
-import static com.gtnewhorizon.structurelib.StructureLibAPI.HINT_BLOCK_META_GENERIC_11;
-
public class GT_StructureUtility {
private GT_StructureUtility() {
throw new AssertionError("Not instantiable");
@@ -133,4 +133,37 @@ public class GT_StructureUtility {
}
};
}
+
+ public static <T> IStructureElement<T> ofBlockUnlocalizedName(String modid, String unlocalizedName, int meta) {
+ if (StringUtils.isBlank(unlocalizedName)) throw new IllegalArgumentException();
+ if (meta < 0) throw new IllegalArgumentException();
+ if (meta > 15) throw new IllegalArgumentException();
+ if (StringUtils.isBlank(modid)) throw new IllegalArgumentException();
+ return new IStructureElement<T>() {
+ private Block block;
+
+ private Block getBlock() {
+ if (block == null)
+ block = GameRegistry.findBlock(modid, unlocalizedName);
+ return block;
+ }
+
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ return world.getBlock(x, y, z) != getBlock() && world.getBlockMetadata(x, y, z) == meta;
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI.hintParticle(world, x, y, z, getBlock(), meta);
+ return true;
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
+ world.setBlock(x, y, z, getBlock(), meta, 2);
+ return true;
+ }
+ };
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
index 76bdb8423a..3db096eca3 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
@@ -1,9 +1,9 @@
package gregtech.common.tileentities.machines.multi;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import cpw.mods.fml.common.Loader;
-import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.Textures;
@@ -17,12 +17,10 @@ import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
-import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.oredict.OreDictionary;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
@@ -32,6 +30,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_GLOW;
+import static gregtech.api.util.GT_StructureUtility.ofBlockUnlocalizedName;
import static gregtech.api.util.GT_StructureUtility.ofCoil;
import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
@@ -43,16 +42,11 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu
private static final IStructureDefinition<GT_MetaTileEntity_PyrolyseOven> STRUCTURE_DEFINITION = createStructureDefinition();
private static IStructureDefinition<GT_MetaTileEntity_PyrolyseOven> createStructureDefinition() {
- Block casingBlock;
- int casingMeta;
-
- if (Loader.isModLoaded("dreamcraft")) {
- casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH");
- casingMeta = 2;
- } else {
- casingBlock = GregTech_API.sBlockCasings1;
- casingMeta = 0;
- }
+ IStructureElement<GT_MetaTileEntity_PyrolyseOven> tCasingElement =
+ Loader.isModLoaded("dreamcraft") ?
+ ofBlockUnlocalizedName("dreamcraft", "gt.blockcasingsNH", 2) :
+ ofBlock(GregTech_API.sBlockCasings1, 0);
+
return StructureDefinition.<GT_MetaTileEntity_PyrolyseOven>builder()
.addShape("main", transpose(new String[][]{
{"ccccc", "ctttc", "ctttc", "ctttc", "ccccc"},
@@ -60,18 +54,18 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu
{"ccccc", "c---c", "c---c", "c---c", "ccccc"},
{"bb~bb", "bCCCb", "bCCCb", "bCCCb", "bbbbb"},
}))
- .addElement('c', onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta)))
+ .addElement('c', onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement))
.addElement('C', ofCoil(GT_MetaTileEntity_PyrolyseOven::setCoilLevel, GT_MetaTileEntity_PyrolyseOven::getCoilLevel))
.addElement('b', ofChain(
ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMaintenanceToMachineList, CASING_INDEX, 1),
ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addOutputToMachineList, CASING_INDEX, 1),
ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addEnergyInputToMachineList, CASING_INDEX, 1),
- onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta))
+ onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement)
))
.addElement('t', ofChain(
ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addInputToMachineList, CASING_INDEX, 1),
ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMufflerToMachineList, CASING_INDEX, 1),
- onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta))
+ onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement)
))
.build();
}