Skip to content

Commit cf9db08

Browse files
authored
Merge branch 'master' into deterministic-ore-processing
2 parents 6537c31 + 7141fcf commit cf9db08

File tree

16 files changed

+226
-51
lines changed

16 files changed

+226
-51
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package meldexun.nothirium.api.renderer.chunk;
2+
3+
/**
4+
* Adapted and minimized from <a
5+
* href="https://github.com/Meldexun/Nothirium/blob/main/src/main/java/meldexun/nothirium/api/renderer/chunk/ChunkRenderPass.java">ChunkRenderPass.java</a>
6+
*/
7+
public enum ChunkRenderPass {
8+
;
9+
10+
public static final ChunkRenderPass[] ALL = ChunkRenderPass.values();
11+
12+
}

src/main/java/gregtech/api/recipes/RecipeBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,15 +828,15 @@ protected static void multiplyInputsAndOutputs(List<GTRecipeInput> newRecipeInpu
828828
if (ri.isNonConsumable()) {
829829
newRecipeInputs.add(ri);
830830
} else {
831-
newRecipeInputs.add(ri.withAmount(ri.getAmount() * numberOfOperations));
831+
newRecipeInputs.add(ri.copyWithAmount(ri.getAmount() * numberOfOperations));
832832
}
833833
});
834834

835835
recipe.getFluidInputs().forEach(fi -> {
836836
if (fi.isNonConsumable()) {
837837
newFluidInputs.add(fi);
838838
} else {
839-
newFluidInputs.add(fi.withAmount(fi.getAmount() * numberOfOperations));
839+
newFluidInputs.add(fi.copyWithAmount(fi.getAmount() * numberOfOperations));
840840
}
841841
});
842842

src/main/java/gregtech/api/unification/material/Material.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@
1010
import gregtech.api.unification.material.info.MaterialFlag;
1111
import gregtech.api.unification.material.info.MaterialFlags;
1212
import gregtech.api.unification.material.info.MaterialIconSet;
13-
import gregtech.api.unification.material.properties.*;
13+
import gregtech.api.unification.material.properties.BlastProperty;
14+
import gregtech.api.unification.material.properties.DustProperty;
15+
import gregtech.api.unification.material.properties.FluidPipeProperties;
16+
import gregtech.api.unification.material.properties.FluidProperty;
17+
import gregtech.api.unification.material.properties.GemProperty;
18+
import gregtech.api.unification.material.properties.IMaterialProperty;
19+
import gregtech.api.unification.material.properties.IngotProperty;
20+
import gregtech.api.unification.material.properties.ItemPipeProperties;
21+
import gregtech.api.unification.material.properties.MaterialProperties;
22+
import gregtech.api.unification.material.properties.OreProperty;
23+
import gregtech.api.unification.material.properties.PolymerProperty;
24+
import gregtech.api.unification.material.properties.PropertyKey;
25+
import gregtech.api.unification.material.properties.RotorProperty;
26+
import gregtech.api.unification.material.properties.ToolProperty;
27+
import gregtech.api.unification.material.properties.WireProperties;
28+
import gregtech.api.unification.material.properties.WoodProperty;
1429
import gregtech.api.unification.material.registry.MaterialRegistry;
1530
import gregtech.api.unification.stack.MaterialStack;
1631
import gregtech.api.util.FluidTooltipUtil;
@@ -35,7 +50,11 @@
3550
import stanhebben.zenscript.annotations.ZenMethod;
3651
import stanhebben.zenscript.annotations.ZenOperator;
3752

38-
import java.util.*;
53+
import java.util.ArrayList;
54+
import java.util.Arrays;
55+
import java.util.Collection;
56+
import java.util.List;
57+
import java.util.Objects;
3958
import java.util.function.Consumer;
4059
import java.util.function.UnaryOperator;
4160

@@ -110,6 +129,14 @@ public Material setFormula(String formula, boolean withFormatting) {
110129
return this;
111130
}
112131

132+
@ZenMethod
133+
public Material setComponents(MaterialStack... components) {
134+
this.materialInfo.setComponents(components);
135+
this.chemicalFormula = null;
136+
this.chemicalFormula = calculateChemicalFormula();
137+
return this;
138+
}
139+
113140
public ImmutableList<MaterialStack> getMaterialComponents() {
114141
return materialInfo.componentList;
115142
}
@@ -1172,5 +1199,10 @@ private void verifyInfo(MaterialProperties p, boolean averageRGB) {
11721199
}
11731200
}
11741201
}
1202+
1203+
public MaterialInfo setComponents(MaterialStack... components) {
1204+
this.componentList = ImmutableList.copyOf(Arrays.asList(components));
1205+
return this;
1206+
}
11751207
}
11761208
}

src/main/java/gregtech/api/util/OverlayedItemHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public int insertStackedItemStack(@NotNull ItemStack stack, int amountToInsert)
5858
ItemStack slotKey = this.slots[i].getItemStack();
5959
if (slotKey.isEmpty() || ItemStackHashStrategy.comparingAllButCount().equals(slotKey, stack)) {
6060
// if the slot is not full
61-
int canInsertUpTo = this.slots[i].getSlotLimit() - this.slots[i].getCount();
61+
int canInsertUpTo = Math.min(this.slots[i].getSlotLimit() - this.slots[i].getCount(),
62+
stack.getMaxStackSize());
6263
if (canInsertUpTo > 0) {
6364
int insertedAmount = Math.min(canInsertUpTo, amountToInsert);
6465
this.slots[i].setItemStack(stack.copy()); // this copy may not be need, needs further tests

src/main/java/gregtech/client/utils/BloomEffectUtil.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,19 @@
1818
import net.minecraft.client.renderer.texture.TextureMap;
1919
import net.minecraft.client.shader.Framebuffer;
2020
import net.minecraft.entity.Entity;
21-
import net.minecraft.launchwrapper.Launch;
2221
import net.minecraft.util.BlockRenderLayer;
2322
import net.minecraft.world.World;
24-
import net.minecraftforge.common.util.EnumHelper;
2523
import net.minecraftforge.fml.relauncher.Side;
2624
import net.minecraftforge.fml.relauncher.SideOnly;
2725

2826
import com.github.bsideup.jabel.Desugar;
2927
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
30-
import org.apache.commons.lang3.reflect.FieldUtils;
3128
import org.jetbrains.annotations.ApiStatus;
3229
import org.jetbrains.annotations.Contract;
3330
import org.jetbrains.annotations.NotNull;
3431
import org.jetbrains.annotations.Nullable;
3532
import org.lwjgl.opengl.GL11;
3633

37-
import java.lang.reflect.Field;
3834
import java.util.ArrayList;
3935
import java.util.List;
4036
import java.util.Map;
@@ -336,24 +332,9 @@ public boolean test(BloomRenderTicket bloomRenderTicket) {
336332
}, validityChecker);
337333
}
338334

339-
@SuppressWarnings({ "rawtypes", "unchecked" })
340335
public static void init() {
341-
bloom = EnumHelper.addEnum(BlockRenderLayer.class, "BLOOM", new Class[] { String.class }, "Bloom");
336+
bloom = BlockRenderLayer.valueOf("BLOOM");
342337
BLOOM = bloom;
343-
if (Mods.Nothirium.isModLoaded()) {
344-
try {
345-
// Nothirium hard copies the BlockRenderLayer enum into a ChunkRenderPass enum. Add our BLOOM layer to
346-
// that too.
347-
Class crp = Class.forName("meldexun.nothirium.api.renderer.chunk.ChunkRenderPass", false,
348-
Launch.classLoader);
349-
EnumHelper.addEnum(crp, "BLOOM", new Class[] {});
350-
Field all = FieldUtils.getField(crp, "ALL", false);
351-
FieldUtils.removeFinalModifier(all);
352-
FieldUtils.writeStaticField(all, crp.getEnumConstants());
353-
} catch (ClassNotFoundException | IllegalAccessException e) {
354-
throw new RuntimeException(e);
355-
}
356-
}
357338
}
358339

359340
// Calls injected via ASM

src/main/java/gregtech/client/utils/BloomEffectVintagiumUtil.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
@SideOnly(Side.CLIENT)
1212
public class BloomEffectVintagiumUtil {
1313

14-
public static BlockRenderPass bloom;
15-
1614
/**
1715
* @return {@link BlockRenderPass} instance for the bloom render layer.
1816
*/
1917
@NotNull
2018
@SuppressWarnings("unused")
2119
public static BlockRenderPass getBloomPass() {
22-
return Objects.requireNonNull(bloom, "Bloom effect is not initialized yet");
20+
return Objects.requireNonNull(BlockRenderPass.valueOf("BLOOM"), "Bloom effect is not initialized yet");
2321
}
2422
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityAEHostablePart.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public abstract class MetaTileEntityAEHostablePart<T extends IAEStack<T>> extend
4545
private int meUpdateTick;
4646
protected boolean isOnline;
4747
private boolean allowExtraConnections;
48+
protected boolean meStatusChanged = false;
4849

4950
public MetaTileEntityAEHostablePart(ResourceLocation metaTileEntityId, int tier, boolean isExportHatch,
5051
Class<? extends IStorageChannel<T>> storageChannel) {
@@ -158,6 +159,9 @@ public boolean updateMEStatus() {
158159
if (this.isOnline != isOnline) {
159160
writeCustomData(UPDATE_ONLINE_STATUS, buf -> buf.writeBoolean(isOnline));
160161
this.isOnline = isOnline;
162+
this.meStatusChanged = true;
163+
} else {
164+
this.meStatusChanged = false;
161165
}
162166
}
163167
return this.isOnline;

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEStockingBus.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,22 @@ protected ExportOnlyAEStockingItemList getAEItemHandler() {
6464
@Override
6565
public void update() {
6666
super.update();
67-
if (!getWorld().isRemote && isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
68-
refreshList();
69-
syncME();
67+
if (!getWorld().isRemote) {
68+
if (isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
69+
refreshList();
70+
syncME();
71+
}
72+
73+
// Immediately clear cached items if the status changed, to prevent running recipes while offline
74+
if (this.meStatusChanged && !this.isOnline) {
75+
if (autoPull) {
76+
clearInventory(0);
77+
} else {
78+
for (int i = 0; i < CONFIG_SIZE; i++) {
79+
getAEItemHandler().getInventory()[i].setStack(null);
80+
}
81+
}
82+
}
7083
}
7184
}
7285

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEStockingHatch.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,22 @@ protected ExportOnlyAEStockingFluidList getAEFluidHandler() {
6464
@Override
6565
public void update() {
6666
super.update();
67-
if (!getWorld().isRemote && isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
68-
refreshList();
69-
syncME();
67+
if (!getWorld().isRemote) {
68+
if (isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
69+
refreshList();
70+
syncME();
71+
}
72+
73+
// Immediately clear cached fluids if the status changed, to prevent running recipes while offline
74+
if (this.meStatusChanged && !this.isOnline) {
75+
if (autoPull) {
76+
this.getAEFluidHandler().clearConfig();
77+
} else {
78+
for (int i = 0; i < CONFIG_SIZE; i++) {
79+
getAEFluidHandler().getInventory()[i].setStack(null);
80+
}
81+
}
82+
}
7083
}
7184
}
7285

src/main/java/gregtech/mixins/GregTechLateMixinLoadingPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public List<String> getMixinConfigs() {
1919
configs.add("mixins.gregtech.ccl.json");
2020
configs.add("mixins.gregtech.littletiles.json");
2121
configs.add("mixins.gregtech.vintagium.json");
22+
configs.add("mixins.gregtech.nothirium.json");
2223

2324
return configs;
2425
}
@@ -31,6 +32,7 @@ public boolean shouldMixinConfigQueue(String mixinConfig) {
3132
case "mixin.gregtech.ctm.json" -> Mods.CTM.isModLoaded();
3233
case "mixins.gregtech.littletiles.json" -> Mods.LittleTiles.isModLoaded();
3334
case "mixins.gregtech.vintagium.json" -> Mods.Vintagium.isModLoaded();
35+
case "mixins.gregtech.nothirium.json" -> Mods.Nothirium.isModLoaded();
3436
default -> true;
3537
};
3638
}

0 commit comments

Comments
 (0)