Skip to content

Commit c7f8c59

Browse files
Merge branch '1.21.1-release' into 1.21.1-release-DataGen&FluidInit
Signed-off-by: Real Ant Engineer <[email protected]>
2 parents 761266e + 72680bc commit c7f8c59

File tree

10 files changed

+181
-120
lines changed

10 files changed

+181
-120
lines changed

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mod_version=1.21.1_1.7.10
4040
create_version = 6.0.6-98
4141
flywheel_version = 1.0.4
4242
ponder_version = 1.0.56
43+
4344
registrate_version = MC1.21-1.3.0+62
4445
jei_version=19.10.0.126
4546

src/main/java/com/rae/creatingspace/content/recipes/air_liquefying/AirLiquefyingRecipe.java

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
package com.rae.creatingspace.content.recipes.air_liquefying;
22

3-
import com.google.gson.JsonObject;
3+
import com.mojang.serialization.MapCodec;
44
import com.rae.creatingspace.init.RecipeInit;
5+
import com.simibubi.create.content.kinetics.deployer.ItemApplicationRecipe;
6+
import com.simibubi.create.content.kinetics.deployer.ItemApplicationRecipeParams;
57
import com.simibubi.create.content.processing.recipe.ProcessingRecipe;
6-
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder.ProcessingRecipeParams;
8+
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
9+
import com.simibubi.create.content.processing.recipe.ProcessingRecipeParams;
710
import com.simibubi.create.foundation.item.SmartInventory;
811
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
912
import net.createmod.catnip.data.Iterate;
1013
import net.minecraft.core.registries.BuiltInRegistries;
11-
import net.minecraft.network.FriendlyByteBuf;
14+
import net.minecraft.network.RegistryFriendlyByteBuf;
15+
import net.minecraft.network.codec.StreamCodec;
1216
import net.minecraft.resources.ResourceLocation;
1317
import net.minecraft.world.item.crafting.Recipe;
18+
import net.minecraft.world.item.crafting.RecipeSerializer;
1419
import net.minecraft.world.level.Level;
1520
import net.minecraft.world.level.block.Block;
1621
import net.minecraft.world.level.block.state.BlockState;
1722
import net.neoforged.neoforge.fluids.FluidStack;
23+
import net.neoforged.neoforge.items.wrapper.RecipeWrapper;
1824
import org.jetbrains.annotations.NotNull;
1925

20-
import javax.annotation.Nonnull;
2126
import java.util.ArrayList;
2227
import java.util.List;
2328

24-
public class AirLiquefyingRecipe extends ProcessingRecipe<SmartInventory> {
29+
public class AirLiquefyingRecipe extends ProcessingRecipe<RecipeWrapper, AirLiquefyingRecipeParam> {
2530

26-
private ResourceLocation blockInFront;
27-
private ResourceLocation dimension;
31+
private final ResourceLocation blockInFront;
32+
private final ResourceLocation dimension;
2833

2934
public static boolean match(AirLiquefierBlockEntity airLiquefierBlockEntity, Recipe<?> recipe) {
3035
return apply(airLiquefierBlockEntity, recipe, true);
@@ -40,7 +45,7 @@ private static boolean apply(AirLiquefierBlockEntity airLiquefierBlockEntity, Re
4045
BlockState state = airLiquefierBlockEntity.getBlockState();
4146
BlockState targetedState = airLiquefierBlockEntity.getLevel().getBlockState(airLiquefierBlockEntity.getBlockPos().relative(state.getValue(AirLiquefierBlock.FACING)));
4247
Block block = BuiltInRegistries.BLOCK.get(airLiquefyingRecipe.getBlockInFront());
43-
if (block != null && !targetedState.is(block)) {
48+
if (!targetedState.is(block)) {
4449
return false;
4550
}
4651
ResourceLocation currentDimension = airLiquefierBlockEntity.getLevel().dimension().location();
@@ -69,9 +74,13 @@ private static boolean apply(AirLiquefierBlockEntity airLiquefierBlockEntity, Re
6974

7075
return true;
7176
}
72-
73-
protected AirLiquefyingRecipe(IRecipeTypeInfo type, ProcessingRecipeParams params) {
77+
public AirLiquefyingRecipe(AirLiquefyingRecipeParam params) {
78+
this(RecipeInit.AIR_LIQUEFYING, params);
79+
}
80+
protected AirLiquefyingRecipe(IRecipeTypeInfo type, AirLiquefyingRecipeParam params) {
7481
super(type, params);
82+
blockInFront = params.blockInFront;
83+
dimension = params.dimension;
7584
}
7685

7786
public ResourceLocation getBlockInFront() {
@@ -92,9 +101,7 @@ protected int getMaxOutputCount() {
92101
return 0;
93102
}
94103

95-
public AirLiquefyingRecipe(ProcessingRecipeParams params) {
96-
this(RecipeInit.AIR_LIQUEFYING, params);
97-
}
104+
98105

99106
@Override
100107
protected int getMaxFluidOutputCount() {
@@ -107,37 +114,51 @@ protected boolean canSpecifyDuration() {
107114
}
108115

109116
@Override
110-
public boolean matches(SmartInventory inv, @Nonnull Level worldIn) {
117+
public boolean matches(@NotNull RecipeWrapper smartInventory, @NotNull Level level) {
111118
return false;
112119
}
120+
@FunctionalInterface
121+
public interface Factory<R extends AirLiquefyingRecipe> extends ProcessingRecipe.Factory<AirLiquefyingRecipeParam, R> {
122+
R create(AirLiquefyingRecipeParam params);
123+
}
113124

125+
public static class Builder<R extends AirLiquefyingRecipe> extends ProcessingRecipeBuilder<AirLiquefyingRecipeParam, R, AirLiquefyingRecipe.Builder<R>> {
126+
public Builder(AirLiquefyingRecipe.Factory<R> factory, ResourceLocation recipeId) {
127+
super(factory, recipeId);
128+
}
114129

115-
116-
@Override
117-
public void readAdditional(@NotNull FriendlyByteBuf buffer) {
118-
super.readAdditional(buffer);
119-
blockInFront = buffer.readResourceLocation();
120-
if (blockInFront.equals(ResourceLocation.parse("minecraft:_"))) {
121-
blockInFront = null;
130+
@Override
131+
protected AirLiquefyingRecipeParam createParams() {
132+
return new AirLiquefyingRecipeParam();
122133
}
123-
dimension = buffer.readResourceLocation();
124-
if (dimension.equals(ResourceLocation.parse("minecraft:_"))) {
125-
dimension = null;
134+
135+
@Override
136+
public AirLiquefyingRecipe.Builder<R> self() {
137+
return this;
126138
}
139+
127140
}
128141

129-
@Override
130-
public void writeAdditional(@NotNull FriendlyByteBuf buffer) {
131-
super.writeAdditional(buffer);
132-
if (blockInFront != null)
133-
buffer.writeResourceLocation(blockInFront);
134-
else {
135-
buffer.writeResourceLocation(ResourceLocation.parse("minecraft:_"));
142+
public static class Serializer<R extends AirLiquefyingRecipe> implements RecipeSerializer<R> {
143+
private final MapCodec<R> codec;
144+
private final StreamCodec<RegistryFriendlyByteBuf, R> streamCodec;
145+
146+
public Serializer(ProcessingRecipe.Factory<AirLiquefyingRecipeParam, R> factory) {
147+
this.codec = ProcessingRecipe.codec(factory, AirLiquefyingRecipeParam.CODEC);
148+
this.streamCodec = ProcessingRecipe.streamCodec(factory, AirLiquefyingRecipeParam.STREAM_CODEC);
149+
}
150+
151+
@Override
152+
public MapCodec<R> codec() {
153+
return codec;
136154
}
137-
if (dimension != null)
138-
buffer.writeResourceLocation(dimension);
139-
else {
140-
buffer.writeResourceLocation(ResourceLocation.parse("minecraft:_"));
155+
156+
@Override
157+
public StreamCodec<RegistryFriendlyByteBuf, R> streamCodec() {
158+
return streamCodec;
141159
}
160+
142161
}
162+
163+
143164
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.rae.creatingspace.content.recipes.air_liquefying;
2+
3+
import com.mojang.serialization.MapCodec;
4+
import com.mojang.serialization.codecs.RecordCodecBuilder;
5+
import com.simibubi.create.content.kinetics.deployer.ItemApplicationRecipeParams;
6+
import com.simibubi.create.content.processing.recipe.ProcessingRecipeParams;
7+
import net.minecraft.network.RegistryFriendlyByteBuf;
8+
import net.minecraft.network.codec.StreamCodec;
9+
import net.minecraft.resources.ResourceLocation;
10+
import org.jetbrains.annotations.NotNull;
11+
12+
import java.util.function.Function;
13+
14+
public class AirLiquefyingRecipeParam extends ProcessingRecipeParams {
15+
private static final ResourceLocation DEFAULT_EMPTY = ResourceLocation.fromNamespaceAndPath("minecraft", "empy");
16+
public static MapCodec<AirLiquefyingRecipeParam> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
17+
codec(AirLiquefyingRecipeParam::new).forGetter(Function.identity()),
18+
ResourceLocation.CODEC.optionalFieldOf("blockInFront", DEFAULT_EMPTY)
19+
.forGetter( r -> r.blockInFront!=null?r.blockInFront: DEFAULT_EMPTY),
20+
ResourceLocation.CODEC.optionalFieldOf("dimension", DEFAULT_EMPTY)
21+
.forGetter( r -> r.dimension!=null?r.blockInFront: DEFAULT_EMPTY)
22+
).apply(instance, (params, blockInFront, dimension) -> {
23+
params.blockInFront = blockInFront;
24+
params.dimension = dimension;
25+
return params;
26+
}));
27+
public static StreamCodec<RegistryFriendlyByteBuf, AirLiquefyingRecipeParam> STREAM_CODEC = streamCodec(AirLiquefyingRecipeParam::new);
28+
29+
ResourceLocation blockInFront;
30+
ResourceLocation dimension;
31+
32+
@Override
33+
public void decode(@NotNull RegistryFriendlyByteBuf buffer) {
34+
super.decode(buffer);
35+
blockInFront = buffer.readResourceLocation();
36+
if (blockInFront.equals(DEFAULT_EMPTY)) {
37+
blockInFront = null;
38+
}
39+
dimension = buffer.readResourceLocation();
40+
if (dimension.equals(DEFAULT_EMPTY)) {
41+
dimension = null;
42+
}
43+
}
44+
45+
@Override
46+
public void encode(@NotNull RegistryFriendlyByteBuf buffer) {
47+
super.encode(buffer);
48+
if (blockInFront != null)
49+
buffer.writeResourceLocation(blockInFront);
50+
else {
51+
buffer.writeResourceLocation(ResourceLocation.parse("minecraft:empty"));
52+
}
53+
if (dimension != null)
54+
buffer.writeResourceLocation(dimension);
55+
else {
56+
buffer.writeResourceLocation(ResourceLocation.parse("minecraft:empty"));
57+
}
58+
}
59+
}

src/main/java/com/rae/creatingspace/content/recipes/chemical_synthesis/CatalystCarrierBlockEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void tick() {
113113
if (processingTicks < 0) {
114114
float recipeSpeed = 1;
115115
if (currentRecipe instanceof ProcessingRecipe) {
116-
int t = ((ProcessingRecipe<?>) currentRecipe).getProcessingDuration();
116+
int t = ((ProcessingRecipe<?,?>) currentRecipe).getProcessingDuration();
117117
if (t != 0)
118118
recipeSpeed = t / 100f;
119119
}
Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,14 @@
11
package com.rae.creatingspace.content.recipes.chemical_synthesis;
22

3-
import com.google.gson.JsonObject;
4-
import com.mojang.serialization.JsonOps;
53
import com.rae.creatingspace.init.RecipeInit;
64
import com.simibubi.create.content.processing.basin.BasinRecipe;
7-
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder.ProcessingRecipeParams;
8-
import net.minecraft.nbt.NbtOps;
9-
import net.minecraft.network.FriendlyByteBuf;
10-
import net.minecraft.world.item.crafting.Ingredient;
5+
import com.simibubi.create.content.processing.recipe.ProcessingRecipeParams;
6+
117

128
public class ChemicalSynthesisRecipe extends BasinRecipe {
13-
Ingredient catalyst;
9+
1410
public ChemicalSynthesisRecipe(ProcessingRecipeParams params) {
1511
super(RecipeInit.CHEMICAL_SYNTHESIS, params);
1612
}
1713

18-
/*@Override
19-
public void readAdditional(JsonObject json) {
20-
super.readAdditional(json);
21-
if (json.get("catalyst") == null)
22-
catalyst = Ingredient.EMPTY;
23-
else
24-
catalyst = Ingredient.CODEC.parse(JsonOps.INSTANCE,json.get("catalyst")).resultOrPartial().orElse(Ingredient.EMPTY);
25-
}*/
26-
27-
@Override
28-
public void readAdditional(FriendlyByteBuf buffer) {
29-
super.readAdditional(buffer);
30-
catalyst = buffer.readJsonWithCodec(Ingredient.CODEC);
31-
}
32-
33-
@Override
34-
public void writeAdditional(FriendlyByteBuf buffer) {
35-
super.writeAdditional(buffer);
36-
if (catalyst != null)
37-
buffer.writeJsonWithCodec(Ingredient.CODEC,catalyst);
38-
}
3914
}

src/main/java/com/rae/creatingspace/content/recipes/electrolysis/MechanicalElectrolysisRecipe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.rae.creatingspace.init.RecipeInit;
44
import com.simibubi.create.content.processing.basin.BasinRecipe;
5-
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder.ProcessingRecipeParams;
5+
import com.simibubi.create.content.processing.recipe.ProcessingRecipeParams;
66

77
public class MechanicalElectrolysisRecipe extends BasinRecipe {
88
public MechanicalElectrolysisRecipe(ProcessingRecipeParams params) {

src/main/java/com/rae/creatingspace/content/recipes/electrolysis/MechanicalElectrolyzerBlockEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void tick() {
110110
if (processingTicks < 0) {
111111
float recipeSpeed = 1;
112112
if (currentRecipe instanceof ProcessingRecipe) {
113-
int t = ((ProcessingRecipe<?>) currentRecipe).getProcessingDuration();
113+
int t = ((ProcessingRecipe<?,?>) currentRecipe).getProcessingDuration();
114114
if (t != 0)
115115
recipeSpeed = t / 100f;
116116
}

src/main/java/com/rae/creatingspace/init/RecipeInit.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import com.rae.creatingspace.CreatingSpace;
44
import com.rae.creatingspace.content.recipes.air_liquefying.AirLiquefyingRecipe;
5+
import com.rae.creatingspace.content.recipes.air_liquefying.AirLiquefyingRecipeParam;
56
import com.rae.creatingspace.content.recipes.chemical_synthesis.ChemicalSynthesisRecipe;
67
import com.rae.creatingspace.content.recipes.electrolysis.MechanicalElectrolysisRecipe;
78
import com.simibubi.create.AllTags;
8-
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
9-
import com.simibubi.create.content.processing.recipe.ProcessingRecipeSerializer;
9+
import com.simibubi.create.content.kinetics.deployer.ItemApplicationRecipe;
10+
import com.simibubi.create.content.kinetics.deployer.ItemApplicationRecipeParams;
11+
import com.simibubi.create.content.processing.recipe.ProcessingRecipe;
12+
import com.simibubi.create.content.processing.recipe.StandardProcessingRecipe;
1013
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
1114
import net.createmod.catnip.lang.Lang;
1215
import net.minecraft.core.registries.BuiltInRegistries;
@@ -58,10 +61,13 @@ public enum RecipeInit implements IRecipeTypeInfo , StringRepresentable {
5861
type = typeObject;
5962
}
6063

61-
RecipeInit(ProcessingRecipeBuilder.ProcessingRecipeFactory<?> processingFactory) {
62-
this(() -> new ProcessingRecipeSerializer<>(processingFactory));
63-
}
64+
RecipeInit(StandardProcessingRecipe.Factory<?> processingFactory) {
65+
this(() -> new StandardProcessingRecipe.Serializer<>(processingFactory));
6466

67+
}
68+
RecipeInit(ProcessingRecipe.Factory<AirLiquefyingRecipeParam, ? extends AirLiquefyingRecipe> liquefyingRecipeParamFactory) {
69+
this(() -> new AirLiquefyingRecipe.Serializer<>(liquefyingRecipeParamFactory));
70+
}
6571
@ApiStatus.Internal
6672
public static void register(IEventBus modEventBus) {
6773
ShapedRecipePattern.setCraftingSize(9, 9);

0 commit comments

Comments
 (0)