Skip to content

Commit 6ad5e61

Browse files
authored
Merge branch 'master' into toolbelt
2 parents ee3d959 + 7141fcf commit 6ad5e61

File tree

23 files changed

+302
-67
lines changed

23 files changed

+302
-67
lines changed

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies {
4141
// Published dependencies
4242
api("codechicken:codechickenlib:3.2.3.358")
4343
api("com.cleanroommc:modularui:2.5.0-rc1") { transitive = false }
44-
api("com.cleanroommc:groovyscript:1.1.1") { transitive = false }
44+
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
4545
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
4646
api("appeng:ae2-uel:v0.56.4") { transitive = false }
4747
api rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31
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/GregTechMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
dependencies = "required:forge@[14.23.5.2847,);" + "required-after:codechickenlib@[3.2.3,);" +
3434
"required-after:modularui@[2.3,);" + "required-after:mixinbooter@[8.0,);" + "after:appliedenergistics2;" +
3535
"after:forestry;" + "after:extrabees;" + "after:extratrees;" + "after:genetics;" + "after:magicbees;" +
36-
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.1.0,);" +
36+
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.2.0,);" +
3737
"after:theoneprobe;" + "after:hwyla;")
3838
public class GregTechMod {
3939

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

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import net.minecraft.block.Block;
3636
import net.minecraft.item.Item;
3737
import net.minecraft.item.ItemStack;
38+
import net.minecraft.util.ResourceLocation;
3839
import net.minecraftforge.fluids.Fluid;
3940
import net.minecraftforge.fluids.FluidStack;
4041
import net.minecraftforge.fml.common.Optional;
@@ -44,6 +45,7 @@
4445
import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient;
4546
import crafttweaker.CraftTweakerAPI;
4647
import it.unimi.dsi.fastutil.ints.IntList;
48+
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
4749
import org.apache.commons.lang3.builder.ToStringBuilder;
4850
import org.jetbrains.annotations.ApiStatus;
4951
import org.jetbrains.annotations.MustBeInvokedByOverriders;
@@ -53,6 +55,7 @@
5355
import java.util.ArrayList;
5456
import java.util.Arrays;
5557
import java.util.Collection;
58+
import java.util.Collections;
5659
import java.util.List;
5760
import java.util.Map;
5861

@@ -86,6 +89,9 @@ public class RecipeBuilder<R extends RecipeBuilder<R>> {
8689
protected RecipePropertyStorage recipePropertyStorage = RecipePropertyStorage.EMPTY;
8790
protected boolean recipePropertyStorageErrored = false;
8891

92+
protected boolean ignoreAllBuildActions = false;
93+
protected Map<ResourceLocation, RecipeBuildAction<R>> ignoredBuildActions;
94+
8995
protected RecipeBuilder() {
9096
this.inputs = new ArrayList<>();
9197
this.outputs = new ArrayList<>();
@@ -126,6 +132,10 @@ protected RecipeBuilder(RecipeBuilder<R> recipeBuilder) {
126132
this.hidden = recipeBuilder.hidden;
127133
this.category = recipeBuilder.category;
128134
this.recipePropertyStorage = recipeBuilder.recipePropertyStorage.copy();
135+
this.ignoreAllBuildActions = recipeBuilder.ignoreAllBuildActions;
136+
if (recipeBuilder.ignoredBuildActions != null) {
137+
this.ignoredBuildActions = new Object2ObjectOpenHashMap<>(recipeBuilder.ignoredBuildActions);
138+
}
129139
}
130140

131141
public R cleanroom(@Nullable CleanroomType cleanroom) {
@@ -818,15 +828,15 @@ protected static void multiplyInputsAndOutputs(List<GTRecipeInput> newRecipeInpu
818828
if (ri.isNonConsumable()) {
819829
newRecipeInputs.add(ri);
820830
} else {
821-
newRecipeInputs.add(ri.withAmount(ri.getAmount() * numberOfOperations));
831+
newRecipeInputs.add(ri.copyWithAmount(ri.getAmount() * numberOfOperations));
822832
}
823833
});
824834

825835
recipe.getFluidInputs().forEach(fi -> {
826836
if (fi.isNonConsumable()) {
827837
newFluidInputs.add(fi);
828838
} else {
829-
newFluidInputs.add(fi.withAmount(fi.getAmount() * numberOfOperations));
839+
newFluidInputs.add(fi.copyWithAmount(fi.getAmount() * numberOfOperations));
830840
}
831841
});
832842

@@ -887,6 +897,31 @@ public R copy() {
887897
return (R) new RecipeBuilder<>(this);
888898
}
889899

900+
/**
901+
* Only use if you absolutely don't want the recipe to be run through any build actions.
902+
* Instead, you should blacklist specific actions with {@link #ignoreBuildAction(ResourceLocation)}
903+
*/
904+
public R ignoreAllBuildActions() {
905+
this.ignoreAllBuildActions = true;
906+
return (R) this;
907+
}
908+
909+
public R ignoreBuildAction(ResourceLocation buildActionName) {
910+
if (ignoredBuildActions == null) {
911+
ignoredBuildActions = new Object2ObjectOpenHashMap<>();
912+
} else if (!recipeMap.getBuildActions().containsKey(buildActionName)) {
913+
GTLog.logger.error("Recipe map {} does not contain build action {}!", recipeMap, buildActionName,
914+
new Throwable());
915+
return (R) this;
916+
} else if (ignoredBuildActions.containsKey(buildActionName)) {
917+
return (R) this;
918+
}
919+
920+
ignoredBuildActions.put(buildActionName, recipeMap.getBuildActions().get(buildActionName));
921+
922+
return (R) this;
923+
}
924+
890925
public ValidationResult<Recipe> build() {
891926
EnumValidationResult result = recipePropertyStorageErrored ? EnumValidationResult.INVALID : validate();
892927
return ValidationResult.newResult(result, new Recipe(inputs, outputs,
@@ -985,8 +1020,14 @@ protected R invalidateOnBuildAction() {
9851020
*/
9861021
@MustBeInvokedByOverriders
9871022
public void buildAndRegister() {
988-
for (RecipeBuildAction<R> action : recipeMap.getBuildActions()) {
989-
action.accept((R) this);
1023+
if (!ignoreAllBuildActions) {
1024+
for (Map.Entry<ResourceLocation, RecipeBuildAction<R>> buildAction : recipeMap.getBuildActions()
1025+
.entrySet()) {
1026+
if (ignoredBuildActions != null && ignoredBuildActions.containsKey(buildAction.getKey())) {
1027+
continue;
1028+
}
1029+
buildAction.getValue().accept((R) this);
1030+
}
9901031
}
9911032
ValidationResult<Recipe> validationResult = build();
9921033
recipeMap.addRecipe(validationResult);
@@ -1047,6 +1088,27 @@ public int getDuration() {
10471088
return this.recipePropertyStorage.get(CleanroomProperty.getInstance(), null);
10481089
}
10491090

1091+
public boolean ignoresAllBuildActions() {
1092+
return ignoreAllBuildActions;
1093+
}
1094+
1095+
/**
1096+
* Get all ignored build actions for the recipe map.
1097+
*
1098+
* @return A map of ignored build actions.
1099+
*/
1100+
public @NotNull Map<ResourceLocation, RecipeBuildAction<R>> getIgnoredBuildActions() {
1101+
if (ignoreAllBuildActions) {
1102+
return recipeMap.getBuildActions();
1103+
}
1104+
1105+
if (ignoredBuildActions == null) {
1106+
return Collections.emptyMap();
1107+
}
1108+
1109+
return ignoredBuildActions;
1110+
}
1111+
10501112
@Override
10511113
public String toString() {
10521114
return new ToStringBuilder(this)
@@ -1064,6 +1126,8 @@ public String toString() {
10641126
.append("dimensions", getDimensionIDs().toString())
10651127
.append("dimensions_blocked", getBlockedDimensionIDs().toString())
10661128
.append("recipeStatus", recipeStatus)
1129+
.append("ignoresBuildActions", ignoresAllBuildActions())
1130+
.append("ignoredBuildActions", getIgnoredBuildActions())
10671131
.toString();
10681132
}
10691133
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ protected void onRecipeBuild(@NotNull Map<ResourceLocation, RecipeBuildAction<R>
347347
* @return the build actions for this RecipeMap's default RecipeBuilder
348348
*/
349349
@ApiStatus.Internal
350-
protected @UnmodifiableView @NotNull Collection<@NotNull RecipeBuildAction<R>> getBuildActions() {
351-
return this.recipeBuildActions.values();
350+
protected @UnmodifiableView @NotNull Map<ResourceLocation, RecipeBuildAction<R>> getBuildActions() {
351+
return this.recipeBuildActions;
352352
}
353353

354354
public RecipeMap<R> allowEmptyOutput() {

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/unification/material/materials/FirstDegreeMaterials.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ public static void register() {
241241
Galena = new Material.Builder(279, gregtechId("galena"))
242242
.dust(3).ore()
243243
.color(0x643C64)
244-
.flags(NO_SMELTING)
245244
.components(Lead, 1, Sulfur, 1)
246245
.build();
247246

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ public static ItemStack insertItem(IItemHandler handler, ItemStack stack, boolea
175175
if (handler == null || stack.isEmpty()) {
176176
return stack;
177177
}
178-
if (!stack.isStackable()) {
179-
return insertToEmpty(handler, stack, simulate);
180-
}
181178

182179
IntList emptySlots = new IntArrayList();
183180
int slots = handler.getSlots();

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

0 commit comments

Comments
 (0)