Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/migrate-coremod-casings' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Dec 30, 2024
2 parents 91ddcb4 + d9b5d0a commit 2d7c5cb
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 160 deletions.
13 changes: 13 additions & 0 deletions src/main/java/gregtech/GTMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLModIdMappingEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import galacticgreg.SpaceDimRegisterer;
import gregtech.api.GregTechAPI;
import gregtech.api.enchants.EnchantmentEnderDamage;
Expand Down Expand Up @@ -828,6 +830,17 @@ public void onServerStopping(FMLServerStoppingEvent aEvent) {
RunnableMachineUpdate.shutdownExecutorService();
}

@Mod.EventHandler
public void onMissingMappings(FMLMissingMappingsEvent event) {
for (FMLMissingMappingsEvent.MissingMapping mapping : event.getAll()) {
if (mapping.type == GameRegistry.Type.BLOCK) {
if ("dreamcraft:gt.blockcasingsNH".equals(mapping.name)) {
mapping.remap(GregTechAPI.sBlockCasingsNH);
}
}
}
}

public static void logStackTrace(Throwable t) {
final StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gregtech/api/GregTechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public class GregTechAPI {
sBlockMetal9, sBlockGem1, sBlockGem2, sBlockGem3, sBlockReinforced;
public static Block sBlockGranites, sBlockConcretes, sBlockStones;
public static Block sBlockCasings1, sBlockCasings2, sBlockCasings3, sBlockCasings4, sBlockCasings5, sBlockCasings6,
sBlockCasings8, sBlockCasings9, sBlockCasings10, sBlockCasings11, sSolenoidCoilCasings;
sBlockCasings8, sBlockCasings9, sBlockCasings10, sBlockCasings11, sSolenoidCoilCasings, sBlockCasingsNH;
public static Block sBlockLongDistancePipes;
public static Block sDroneRender;
public static Block sBlockFrames;
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/gregtech/api/enums/ItemList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,6 @@ public enum ItemList implements IItemContainer {
Hull_UMV,
Hull_UXV,
Hull_MAXV,
// todo: move them from gt.blockcasingsNH in NHCore to here
Casing_UEV,
Casing_UIV,
Casing_UMV,
Expand Down Expand Up @@ -2593,6 +2592,13 @@ public enum ItemList implements IItemContainer {
ResearchCompleter,
SpaceElevatorController, // Populated in GTNH-Intergalactic
Spray_Color_Infinite,
Casing_AirFilter_Turbine_T1,
Casing_AirFilter_Vent_T1,
Casing_AirFilter_Turbine_T2,
Casing_AirFilter_Vent_T2,
Casing_AirFilter_Turbine_T3,
Casing_AirFilter_Vent_T3,
Casing_Pyrolyse,
// semicolon after the comment to reduce merge conflicts
;

Expand Down
81 changes: 81 additions & 0 deletions src/main/java/gregtech/common/blocks/BlockCasingsNH.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package gregtech.common.blocks;

import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.util.GTLanguageManager;

public class BlockCasingsNH extends BlockCasingsAbstract {

public BlockCasingsNH() {
super(ItemCasingsNH.class, "gt.blockcasingsNH", MaterialCasings.INSTANCE, 16);

GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Air Filter Turbine Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Air Filter Vent Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Pyrolyse Oven Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Advanced Air Filter Turbine Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Advanced Air Filter Vent Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Super Air Filter Turbine Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Super Air Filter Vent Casing");

GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "UEV Machine Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "UIV Machine Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "UMV Machine Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "UXV Machine Casing");
GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "MAX Machine Casing");

ItemList.Casing_AirFilter_Turbine_T1.set(new ItemStack(this, 1, 0));
ItemList.Casing_AirFilter_Vent_T1.set(new ItemStack(this, 1, 1));
ItemList.Casing_Pyrolyse.set(new ItemStack(this, 1, 2));
ItemList.Casing_AirFilter_Turbine_T2.set(new ItemStack(this, 1, 3));
ItemList.Casing_AirFilter_Vent_T2.set(new ItemStack(this, 1, 4));
ItemList.Casing_AirFilter_Turbine_T3.set(new ItemStack(this, 1, 5));
ItemList.Casing_AirFilter_Vent_T3.set(new ItemStack(this, 1, 6));

ItemList.Casing_UEV.set(new ItemStack(this, 1, 10));
ItemList.Casing_UIV.set(new ItemStack(this, 1, 11));
ItemList.Casing_UMV.set(new ItemStack(this, 1, 12));
ItemList.Casing_UXV.set(new ItemStack(this, 1, 13));
ItemList.Casing_MAXV.set(new ItemStack(this, 1, 14));
}

@Override
public int getTextureIndex(int aMeta) {
return (8 << 7) | (aMeta + 64);
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int aSide, int aMeta) {
return switch (aMeta) {
case 0 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_STEEL.getIcon();
case 1 -> Textures.BlockIcons.MACHINE_CASING_PIPE_STEEL.getIcon();
case 2 -> Textures.BlockIcons.MACHINE_8V_SIDE.getIcon();
case 3 -> Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon();
case 4 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TITANIUM.getIcon();
case 5 -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon();
case 6 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TUNGSTENSTEEL.getIcon();
default -> {
if (aSide == 0) {
yield Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon();
}
if (aSide == 1) {
yield Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon();
}
yield Textures.BlockIcons.MACHINECASINGS_SIDE[aMeta].getIcon();
}
};
}

@Override
public int colorMultiplier(IBlockAccess aWorld, int aX, int aY, int aZ) {
return aWorld.getBlockMetadata(aX, aY, aZ) <= 9 ? super.colorMultiplier(aWorld, aX, aY, aZ)
: Dyes.MACHINE_METAL.mRGBa[0] << 16 | Dyes.MACHINE_METAL.mRGBa[1] << 8 | Dyes.MACHINE_METAL.mRGBa[2];
}
}
10 changes: 10 additions & 0 deletions src/main/java/gregtech/common/blocks/ItemCasingsNH.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gregtech.common.blocks;

import net.minecraft.block.Block;

public class ItemCasingsNH extends ItemCasingsAbstract {

public ItemCasingsNH(Block block) {
super(block);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gregtech.common.tileentities.machines.multi;

import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockUnlocalizedName;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.enums.HatchElement.Energy;
Expand All @@ -11,7 +10,6 @@
import static gregtech.api.enums.HatchElement.Muffler;
import static gregtech.api.enums.HatchElement.OutputBus;
import static gregtech.api.enums.HatchElement.OutputHatch;
import static gregtech.api.enums.Mods.NewHorizonsCoreMod;
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;
Expand All @@ -26,14 +24,12 @@

import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.IStructureElement;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;

import gregtech.GTMod;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.Textures;
import gregtech.api.enums.Textures.BlockIcons;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
Expand All @@ -50,37 +46,29 @@ public class MTEPyrolyseOven extends MTEEnhancedMultiBlockBase<MTEPyrolyseOven>

private HeatingCoilLevel coilHeat;
private static final int CASING_INDEX = 1090;
private static final IStructureDefinition<MTEPyrolyseOven> STRUCTURE_DEFINITION = createStructureDefinition();

private static IStructureDefinition<MTEPyrolyseOven> createStructureDefinition() {
IStructureElement<MTEPyrolyseOven> tCasingElement = NewHorizonsCoreMod.isModLoaded()
? ofBlockUnlocalizedName(NewHorizonsCoreMod.ID, "gt.blockcasingsNH", 2)
: ofBlock(GregTechAPI.sBlockCasings1, 0);

return StructureDefinition.<MTEPyrolyseOven>builder()
.addShape(
"main",
transpose(
new String[][] { { "ccccc", "ctttc", "ctttc", "ctttc", "ccccc" },
{ "ccccc", "c---c", "c---c", "c---c", "ccccc" },
{ "ccccc", "c---c", "c---c", "c---c", "ccccc" },
{ "bb~bb", "bCCCb", "bCCCb", "bCCCb", "bbbbb" }, }))
.addElement('c', onElementPass(MTEPyrolyseOven::onCasingAdded, tCasingElement))
.addElement('C', ofCoil(MTEPyrolyseOven::setCoilLevel, MTEPyrolyseOven::getCoilLevel))
.addElement(
'b',
buildHatchAdder(MTEPyrolyseOven.class).atLeast(OutputBus, OutputHatch, Energy, Maintenance)
.casingIndex(CASING_INDEX)
.dot(1)
.buildAndChain(onElementPass(MTEPyrolyseOven::onCasingAdded, tCasingElement)))
.addElement(
't',
buildHatchAdder(MTEPyrolyseOven.class).atLeast(InputBus, InputHatch, Muffler)
.casingIndex(CASING_INDEX)
.dot(1)
.buildAndChain(onElementPass(MTEPyrolyseOven::onCasingAdded, tCasingElement)))
.build();
}
private static final IStructureDefinition<MTEPyrolyseOven> STRUCTURE_DEFINITION = StructureDefinition
.<MTEPyrolyseOven>builder()
.addShape(
"main",
transpose(
new String[][] { { "ccccc", "ctttc", "ctttc", "ctttc", "ccccc" },
{ "ccccc", "c---c", "c---c", "c---c", "ccccc" }, { "ccccc", "c---c", "c---c", "c---c", "ccccc" },
{ "bb~bb", "bCCCb", "bCCCb", "bCCCb", "bbbbb" }, }))
.addElement('c', onElementPass(MTEPyrolyseOven::onCasingAdded, ofBlock(GregTechAPI.sBlockCasingsNH, 2)))
.addElement('C', ofCoil(MTEPyrolyseOven::setCoilLevel, MTEPyrolyseOven::getCoilLevel))
.addElement(
'b',
buildHatchAdder(MTEPyrolyseOven.class).atLeast(OutputBus, OutputHatch, Energy, Maintenance)
.casingIndex(CASING_INDEX)
.dot(1)
.buildAndChain(onElementPass(MTEPyrolyseOven::onCasingAdded, ofBlock(GregTechAPI.sBlockCasingsNH, 2))))
.addElement(
't',
buildHatchAdder(MTEPyrolyseOven.class).atLeast(InputBus, InputHatch, Muffler)
.casingIndex(CASING_INDEX)
.dot(1)
.buildAndChain(onElementPass(MTEPyrolyseOven::onCasingAdded, ofBlock(GregTechAPI.sBlockCasingsNH, 2))))
.build();

private int mCasingAmount;

Expand Down Expand Up @@ -120,7 +108,7 @@ protected MultiblockTooltipBuilder createTooltip() {
public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection,
ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) {
if (sideDirection == facingDirection) {
if (active) return new ITexture[] { BlockIcons.casingTexturePages[0][0], TextureFactory.builder()
if (active) return new ITexture[] { BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder()
.addIcon(OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE)
.extFacing()
.build(),
Expand All @@ -129,7 +117,7 @@ public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirect
.extFacing()
.glow()
.build() };
return new ITexture[] { BlockIcons.casingTexturePages[0][0], TextureFactory.builder()
return new ITexture[] { BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder()
.addIcon(OVERLAY_FRONT_PYROLYSE_OVEN)
.extFacing()
.build(),
Expand All @@ -139,7 +127,7 @@ public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirect
.glow()
.build() };
}
return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][0] };
return new ITexture[] { BlockIcons.getCasingTextureForId(CASING_INDEX) };
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import gregtech.common.blocks.BlockCasings6;
import gregtech.common.blocks.BlockCasings8;
import gregtech.common.blocks.BlockCasings9;
import gregtech.common.blocks.BlockCasingsNH;
import gregtech.common.blocks.BlockConcretes;
import gregtech.common.blocks.BlockCyclotronCoils;
import gregtech.common.blocks.BlockDrone;
Expand Down Expand Up @@ -544,6 +545,7 @@ public void run() {
GregTechAPI.sBlockCasings9 = new BlockCasings9();
GregTechAPI.sBlockCasings10 = new BlockCasings10();
GregTechAPI.sBlockCasings11 = new BlockCasings11();
GregTechAPI.sBlockCasingsNH = new BlockCasingsNH();
GregTechAPI.sBlockGranites = new BlockGranites();
GregTechAPI.sBlockLongDistancePipes = new BlockLongDistancePipe();
GregTechAPI.sBlockConcretes = new BlockConcretes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import ic2.core.init.BlocksItems;
import ic2.core.init.InternalName;
import tectech.thing.casing.TTCasingsContainer;

public class MTEAlgaePondBase extends GTPPMultiBlockBase<MTEAlgaePondBase> implements ISurvivalConstructable {

Expand Down Expand Up @@ -155,7 +154,7 @@ public IStructureDefinition<MTEAlgaePondBase> getStructureDefinition() {
onElementPass(
x -> ++x.mCasing,
addTieredBlock(
TTCasingsContainer.sBlockCasingsNH,
GregTechAPI.sBlockCasingsNH,
MTEAlgaePondBase::setMeta,
MTEAlgaePondBase::getMeta,
10,
Expand Down Expand Up @@ -377,7 +376,7 @@ private int getCasingTier() {
aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir);
aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir);
if (aInitStructureCheck == GregTechAPI.sBlockCasings1
|| aInitStructureCheck == TTCasingsContainer.sBlockCasingsNH) {
|| aInitStructureCheck == GregTechAPI.sBlockCasingsNH) {
return aInitStructureCheckMeta;
}
return 0;
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/tectech/loader/MainLoader.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package tectech.loader;

import static gregtech.api.enums.Mods.NewHorizonsCoreMod;
import static tectech.TecTech.LOGGER;
import static tectech.TecTech.creativeTabTecTech;
import static tectech.TecTech.proxy;

import net.minecraft.block.Block;
import net.minecraft.util.DamageSource;

import cpw.mods.fml.common.ProgressManager;
Expand All @@ -16,7 +14,6 @@
import tectech.loader.thing.CoverLoader;
import tectech.loader.thing.MachineLoader;
import tectech.loader.thing.ThingsLoader;
import tectech.thing.casing.TTCasingsContainer;
import tectech.thing.metaTileEntity.Textures;

@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -72,24 +69,6 @@ public static void load() {
}

public static void postLoad() {
ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 2);

progressBarPostLoad.step("Dreamcraft Compatibility");
if (NewHorizonsCoreMod.isModLoaded()) {
try {
Class<?> clazz = Class.forName("com.dreammaster.gthandler.casings.GT_Container_CasingsNH");
TTCasingsContainer.sBlockCasingsNH = (Block) clazz.getField("sBlockCasingsNH")
.get(null);

if (TTCasingsContainer.sBlockCasingsNH == null) {
throw new NullPointerException("sBlockCasingsNH Is not set at this time");
}
} catch (Exception e) {
throw new Error("Unable to get NH casings", e);
}
}

progressBarPostLoad.step("Recipes");
new BaseRecipeLoader().run();
TecTech.LOGGER.info("Recipe Init Done");
}
Expand Down
Loading

0 comments on commit 2d7c5cb

Please sign in to comment.