Skip to content

Commit 1487171

Browse files
authored
Merge branch '1.21.x' into shape-matcher-api
2 parents 92c3c79 + c093035 commit 1487171

File tree

43 files changed

+395
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+395
-199
lines changed

docs/ADDING_RECIPES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The easiest way to add process conditions is via KubeJS, similarly to how inputs
3838
Here is the list of currently supported conditions:
3939
- `dimension(dimension key)`: Requires the machine to be in the specified dimension.
4040
- `biome(biome key)`: Requires the machine to be in the specified biome.
41+
- `biomeTag(biome tag key)`: Requires the machine to be in a biome of the specified tag.
4142
- `adjacentBlock(block, position)`: Requires a specific block to be next to the machine.
4243
- Position indicates where the block should be.
4344
- For multiblocks, the position is always relative to the controller.

src/client/java/aztech/modern_industrialization/compat/viewer/impl/MachineScreenPredicateTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public static boolean test(ReiMachineRecipes.MachineScreenPredicate predicate, M
3434
case ANY -> true;
3535
case MULTIBLOCK -> {
3636
for (GuiComponentClient client : screen.getMenu().components) {
37-
if (client instanceof CraftingMultiblockGuiClient cmGui) {
38-
if (cmGui.isShapeValid) {
39-
yield true;
40-
}
37+
if (client instanceof CraftingMultiblockGuiClient cmGui && cmGui.isShapeValid) {
38+
yield true;
4139
}
4240
}
4341
yield false;

src/client/java/aztech/modern_industrialization/compat/viewer/usage/MachineCategory.java

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,24 @@
3535
import aztech.modern_industrialization.machines.gui.MachineScreen;
3636
import aztech.modern_industrialization.machines.guicomponents.EnergyBarClient;
3737
import aztech.modern_industrialization.machines.guicomponents.ProgressBarClient;
38-
import aztech.modern_industrialization.machines.init.MIMachineRecipeTypes;
3938
import aztech.modern_industrialization.machines.init.MachineTier;
4039
import aztech.modern_industrialization.machines.recipe.MachineRecipe;
41-
import aztech.modern_industrialization.machines.recipe.RecipeConversions;
4240
import aztech.modern_industrialization.thirdparty.fabrictransfer.api.fluid.FluidVariant;
4341
import aztech.modern_industrialization.util.TextHelper;
4442
import java.util.ArrayList;
4543
import java.util.Comparator;
4644
import java.util.List;
47-
import java.util.Objects;
4845
import java.util.function.Consumer;
4946
import net.minecraft.ChatFormatting;
47+
import net.minecraft.client.Minecraft;
5048
import net.minecraft.core.RegistryAccess;
5149
import net.minecraft.core.registries.BuiltInRegistries;
5250
import net.minecraft.network.chat.Component;
5351
import net.minecraft.network.chat.Style;
5452
import net.minecraft.resources.ResourceLocation;
5553
import net.minecraft.world.item.crafting.RecipeHolder;
5654
import net.minecraft.world.item.crafting.RecipeManager;
57-
import net.minecraft.world.item.crafting.RecipeType;
5855
import net.minecraft.world.level.ItemLike;
59-
import net.minecraft.world.level.block.ComposterBlock;
6056

6157
public class MachineCategory extends ViewerCategory<RecipeHolder<MachineRecipe>> {
6258
public static MachineCategory create(MachineCategoryParams params) {
@@ -96,41 +92,10 @@ public void buildWorkstations(WorkstationConsumer consumer) {
9692

9793
@Override
9894
public void buildRecipes(RecipeManager recipeManager, RegistryAccess registryAccess, Consumer<RecipeHolder<MachineRecipe>> consumer) {
99-
var machineRecipes = recipeManager.getRecipes().stream()
100-
.filter(r -> r.value() instanceof MachineRecipe)
101-
.map(r -> (RecipeHolder<MachineRecipe>) r)
102-
.toList();
103-
104-
// regular recipes
105-
machineRecipes.stream()
106-
.filter(r -> params.recipePredicate.test(r.value()))
95+
params.recipeType.getRecipesWithoutCache(Minecraft.getInstance().level).stream()
96+
.filter(recipe -> params.recipePredicate.test(recipe.value()))
10797
.sorted(Comparator.comparing(RecipeHolder::id))
10898
.forEach(consumer);
109-
110-
// converted recipes
111-
if (params.category.getNamespace().equals(MI.ID)) {
112-
switch (params.category.getPath()) {
113-
case "bronze_furnace" -> {
114-
recipeManager.getAllRecipesFor(RecipeType.SMELTING)
115-
.stream()
116-
.map(r -> RecipeConversions.ofSmelting(r, MIMachineRecipeTypes.FURNACE, registryAccess))
117-
.forEach(consumer);
118-
}
119-
case "bronze_cutting_machine" -> {
120-
recipeManager.getAllRecipesFor(RecipeType.STONECUTTING)
121-
.stream()
122-
.map(r -> RecipeConversions.ofStonecutting(r, MIMachineRecipeTypes.CUTTING_MACHINE, registryAccess))
123-
.forEach(consumer);
124-
}
125-
case "centrifuge" -> {
126-
ComposterBlock.COMPOSTABLES.keySet()
127-
.stream()
128-
.map(RecipeConversions::ofCompostable)
129-
.filter(Objects::nonNull)
130-
.forEach(consumer);
131-
}
132-
}
133-
}
13499
}
135100

136101
@Override

src/client/java/aztech/modern_industrialization/machines/gui/MachineMenuClient.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import aztech.modern_industrialization.inventory.ConfigurableItemStack;
2828
import aztech.modern_industrialization.inventory.MIInventory;
2929
import aztech.modern_industrialization.inventory.SlotPositions;
30+
import aztech.modern_industrialization.machines.ComponentStorage;
3031
import aztech.modern_industrialization.machines.GuiComponentsClient;
3132
import aztech.modern_industrialization.util.NbtHelper;
3233
import java.util.ArrayList;
@@ -52,34 +53,29 @@ public static MachineMenuClient create(int syncId, Inventory playerInventory, Re
5253
SlotPositions fluidPositions = SlotPositions.read(buf);
5354
MIInventory inventory = new MIInventory(itemStacks, fluidStacks, itemPositions, fluidPositions);
5455
// Components
55-
List<GuiComponentClient> components = new ArrayList<>();
56+
ComponentStorage<GuiComponentClient> components = new ComponentStorage<>();
5657
int componentCount = buf.readInt();
5758
for (int i = 0; i < componentCount; ++i) {
5859
ResourceLocation id = buf.readResourceLocation();
59-
components.add(GuiComponentsClient.get(id).createFromInitialData(buf));
60+
components.register(GuiComponentsClient.get(id).createFromInitialData(buf));
6061
}
6162
// GUI params
6263
MachineGuiParameters guiParams = MachineGuiParameters.read(buf);
6364

6465
return new MachineMenuClient(syncId, playerInventory, inventory, components, guiParams);
6566
}
6667

67-
public final List<GuiComponentClient> components;
68+
public final ComponentStorage<GuiComponentClient> components;
6869

69-
private MachineMenuClient(int syncId, Inventory playerInventory, MIInventory inventory, List<GuiComponentClient> components,
70+
private MachineMenuClient(int syncId, Inventory playerInventory, MIInventory inventory, ComponentStorage<GuiComponentClient> components,
7071
MachineGuiParameters guiParams) {
7172
super(syncId, playerInventory, inventory, guiParams, components);
7273
this.components = components;
7374
}
7475

7576
@Nullable
7677
public <T extends GuiComponentClient> T getComponent(Class<T> klass) {
77-
for (GuiComponentClient component : components) {
78-
if (klass.isInstance(component)) {
79-
return (T) component;
80-
}
81-
}
82-
return null;
78+
return components.get(klass);
8379
}
8480

8581
@Override

src/client/java/aztech/modern_industrialization/machines/gui/MachineScreen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,13 @@ protected void renderBg(GuiGraphics guiGraphics, float delta, int mouseX, int mo
212212
private void renderConfigurableSlotBackgrounds(GuiGraphics guiGraphics) {
213213
for (Slot slot : this.menu.slots) {
214214
if (slot instanceof BackgroundRenderedSlot brs) {
215+
var atlas = brs.getBackgroundAtlasLocation();
216+
if (atlas == null) {
217+
continue;
218+
}
215219
int px = leftPos + slot.x - 1;
216220
int py = topPos + slot.y - 1;
217-
guiGraphics.blit(SLOT_ATLAS, px, py, brs.getBackgroundU(), brs.getBackgroundV(), 18, 18);
221+
guiGraphics.blit(atlas, px, py, brs.getBackgroundU(), brs.getBackgroundV(), 18, 18);
218222
}
219223
}
220224
}

src/client/java/aztech/modern_industrialization/machines/multiblocks/MultiblockMachineBER.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public void render(MultiblockMachineBlockEntity be, float tickDelta, PoseStack m
7171
}
7272
if (drawHighlights) {
7373
if (!matcher.matches(pos, be.getLevel(), null)) {
74-
if (be.getLevel().getBlockState(pos).isAir()) {
74+
var existingState = be.getLevel().getBlockState(pos);
75+
if (existingState.isAir() || /* approximate check for e.g. grass and snow */ existingState.canBeReplaced()) {
7576
// Enqueue state preview
7677
MultiblockErrorHighlight.enqueueHighlight(pos, matcher.getSimpleMember(pos).getPreviewState());
7778
} else {

src/generated/resources/data/modern_industrialization/data_maps/item/item_pipe_upgrades.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"values": {
33
"modern_industrialization:advanced_motor": {
4-
"maxExtractedItems": 32
4+
"maxExtractedItems": 64
55
},
66
"modern_industrialization:large_advanced_motor": {
7-
"maxExtractedItems": 64
7+
"maxExtractedItems": 512
88
},
99
"modern_industrialization:large_motor": {
10-
"maxExtractedItems": 8
10+
"maxExtractedItems": 16
1111
},
1212
"modern_industrialization:motor": {
1313
"maxExtractedItems": 2
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2020 Azercoco & Technici4n
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package aztech.modern_industrialization.api.energy;
25+
26+
public interface CableTierHolder {
27+
CableTier getCableTier();
28+
}

src/main/java/aztech/modern_industrialization/compat/kubejs/recipe/ProcessConditionHelper.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
import aztech.modern_industrialization.machines.recipe.condition.CustomProcessCondition;
2929
import aztech.modern_industrialization.machines.recipe.condition.DimensionProcessCondition;
3030
import aztech.modern_industrialization.machines.recipe.condition.MachineProcessCondition;
31+
import com.mojang.datafixers.util.Either;
3132
import net.minecraft.core.registries.Registries;
3233
import net.minecraft.resources.ResourceKey;
3334
import net.minecraft.resources.ResourceLocation;
35+
import net.minecraft.tags.TagKey;
3436
import net.minecraft.world.level.block.Block;
3537

3638
public interface ProcessConditionHelper {
@@ -45,7 +47,11 @@ default ProcessConditionHelper adjacentBlock(Block block, String relativePositio
4547
}
4648

4749
default ProcessConditionHelper biome(ResourceLocation biome) {
48-
return processCondition(new BiomeProcessCondition(ResourceKey.create(Registries.BIOME, biome)));
50+
return processCondition(new BiomeProcessCondition(Either.left(ResourceKey.create(Registries.BIOME, biome))));
51+
}
52+
53+
default ProcessConditionHelper biomeTag(ResourceLocation tag) {
54+
return processCondition(new BiomeProcessCondition(Either.right(TagKey.create(Registries.BIOME, tag))));
4955
}
5056

5157
default ProcessConditionHelper customCondition(String id) {

src/main/java/aztech/modern_industrialization/compat/rei/machines/MachineCategoryParams.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import aztech.modern_industrialization.inventory.SlotPositions;
2727
import aztech.modern_industrialization.machines.guicomponents.ProgressBar;
2828
import aztech.modern_industrialization.machines.recipe.MachineRecipe;
29+
import aztech.modern_industrialization.machines.recipe.MachineRecipeType;
2930
import java.util.ArrayList;
3031
import java.util.List;
3132
import java.util.function.Predicate;
@@ -39,21 +40,23 @@ public class MachineCategoryParams {
3940
public final SlotPositions fluidInputs;
4041
public final SlotPositions fluidOutputs;
4142
public final ProgressBar.Parameters progressBarParams;
43+
public final MachineRecipeType recipeType;
4244
public final Predicate<MachineRecipe> recipePredicate;
4345
public final boolean isMultiblock;
4446
public final SteamMode steamMode;
4547
public final List<ResourceLocation> workstations = new ArrayList<>();
4648

4749
public MachineCategoryParams(String englishName, ResourceLocation category, SlotPositions itemInputs, SlotPositions itemOutputs,
48-
SlotPositions fluidInputs, SlotPositions fluidOutputs, ProgressBar.Parameters progressBarParams, Predicate<MachineRecipe> recipePredicate,
49-
boolean isMultiblock, SteamMode steamMode) {
50+
SlotPositions fluidInputs, SlotPositions fluidOutputs, ProgressBar.Parameters progressBarParams, MachineRecipeType recipeType,
51+
Predicate<MachineRecipe> recipePredicate, boolean isMultiblock, SteamMode steamMode) {
5052
this.englishName = englishName;
5153
this.category = category;
5254
this.itemInputs = itemInputs;
5355
this.itemOutputs = itemOutputs;
5456
this.fluidInputs = fluidInputs;
5557
this.fluidOutputs = fluidOutputs;
5658
this.progressBarParams = progressBarParams;
59+
this.recipeType = recipeType;
5760
this.recipePredicate = recipePredicate;
5861
this.isMultiblock = isMultiblock;
5962
this.steamMode = steamMode;

0 commit comments

Comments
 (0)