Skip to content

Commit

Permalink
Make gt multiblocks able to better modify their preview (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
  • Loading branch information
3 people authored Jan 13, 2025
1 parent 4eee810 commit 6e0c104
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
dependencies {
api('com.github.GTNewHorizons:StructureLib:1.4.2:dev')
api('com.github.GTNewHorizons:GTNHLib:0.6.1:dev')
implementation("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.67:dev")
implementation("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.70:dev")
compileOnly("com.github.GTNewHorizons:NotEnoughEnergistics:1.6.4:dev")

runtimeOnlyNonPublishable("com.github.GTNewHorizons:StructureCompat:0.6.5:dev")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import blockrenderer6343.BlockRenderer6343;
import blockrenderer6343.client.utils.BRUtil;
import gregtech.api.interfaces.INEIPreviewModifier;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.threads.RunnableMachineUpdate;
Expand Down Expand Up @@ -177,6 +178,9 @@ private int estimateTier(IConstructable multi) {
do {
holo.stackSize = tier + 1;
hasChanged = false;
if (BlockRenderer6343.isGTLoaded && multi instanceof INEIPreviewModifier modifier) {
modifier.onPreviewConstruct(holo);
}
multi.construct(holo, false);

} while (tier++ < MAX_TRIES && hasChanged);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import blockrenderer6343.integration.nei.GuiMultiblockHandler;
import blockrenderer6343.integration.nei.StructureHacks;
import cpw.mods.fml.relauncher.ReflectionHelper;
import gregtech.api.interfaces.INEIPreviewModifier;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.interfaces.tileentity.ITurnable;
Expand Down Expand Up @@ -173,6 +174,10 @@ protected void placeMultiblock() {
((ITurnable) tTileEntity).setFrontFacing(ForgeDirection.SOUTH);
IMetaTileEntity mte = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();

if (mte instanceof INEIPreviewModifier modifier) {
modifier.onPreviewConstruct(getBuildTriggerStack());
}

if (mte instanceof ISurvivalConstructable survivalConstructable) {
int iterations = 0;
do {
Expand All @@ -187,10 +192,15 @@ protected void placeMultiblock() {
} else if (tTileEntity instanceof IConstructable iConstructable) {
constructable = iConstructable;
}

if (constructable != null) {
constructable.construct(getBuildTriggerStack(), false);
}

if (mte instanceof INEIPreviewModifier modifier) {
modifier.onPreviewStructureComplete(getBuildTriggerStack());
}

if (!RunnableMachineUpdate.isCurrentThreadEnabled()) {
RunnableMachineUpdate.setCurrentThreadEnabled(true);
}
Expand Down

0 comments on commit 6e0c104

Please sign in to comment.