Skip to content

Commit 73a9ccd

Browse files
committed
3.3.0
1 parent b7ca78a commit 73a9ccd

7 files changed

Lines changed: 99 additions & 17 deletions

File tree

changelog.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
Atmospheric API 3.2.3
2-
- Fix trying to create an identifier of an identifier for block item registration
1+
Atmospheric API 3.3.0
2+
- Allow `AutoSendPayload#send` to accept a sync predicate
3+
- Create `FunctionOperations`
4+
- Custom Trident API
5+
- Create `AtmosphericTridentRegistry` (1.21.1)
6+
- Create `AtmosphericTridentModelRenderer` (1.21.4+) which can be accessed in json via `atmospheric_api:trident`
7+
- Allow `CreativeTabEnchantmentAdder` to accept a key of the enchantment
8+
- Make `CreativeTabEnchantmentAdder` final and add a private constructor
9+
- Prepare for porting to 26+
10+
- Add spotless
11+
- Fix issue.yml typos
12+
- Add `DynamicRegistrant`s
13+
- Deprecate `RegistryEntryLookupContainer`
14+
- Add `AtmosphericCodecs$RCB` which provides `tuple` methods to create `MapCodec`s in a similar structure to `PacketCodec.tuple`/`StreamCodec.composite`
15+
- Currently, this provides up to `Function4`

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
33
org.gradle.parallel=true
44

55
# Mod Properties
6-
mod_version=3.2.3
6+
mod_version=3.3.0
77
maven_group=survivalblock.atmosphere
88
archives_base_name=atmospheric_api
99

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/datafixer/AtmosphericCodecs.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55
*/
66
package survivalblock.atmosphere.atmospheric_api.not_mixin.datafixer;
77

8+
import com.mojang.datafixers.util.Function3;
9+
import com.mojang.datafixers.util.Function4;
810
import com.mojang.serialization.Codec;
11+
import com.mojang.serialization.MapCodec;
12+
import com.mojang.serialization.codecs.RecordCodecBuilder;
913
import net.minecraft.world.phys.AABB;
1014
import net.minecraft.world.phys.Vec3;
15+
import org.jetbrains.annotations.ApiStatus;
1116
import survivalblock.atmosphere.atmospheric_api.not_mixin.funny.BadAtProgramming;
1217
import survivalblock.atmosphere.atmospheric_api.not_mixin.util.Duo;
1318

1419
import java.util.List;
20+
import java.util.function.BiFunction;
21+
import java.util.function.Function;
1522

1623
@SuppressWarnings("unused")
1724
public interface AtmosphericCodecs {
@@ -25,4 +32,60 @@ public interface AtmosphericCodecs {
2532
static <E> Codec<Duo<E>> duo(Codec<E> codec) {
2633
return codec.listOf(2, 2).xmap(Duo::new, List::copyOf);
2734
}
35+
36+
@ApiStatus.Experimental
37+
interface RCB {
38+
static <O, F1> MapCodec<O> tuple(MapCodec<F1> codec, Function<O, F1> from, Function<F1, O> to) {
39+
return RecordCodecBuilder.mapCodec(
40+
instance -> instance.group(
41+
codec.forGetter(from)
42+
).apply(instance, to)
43+
);
44+
}
45+
46+
static <O, F1, F2> MapCodec<O> tuple(
47+
MapCodec<F1> codec1, Function<O, F1> from1,
48+
MapCodec<F2> codec2, Function<O, F2> from2,
49+
BiFunction<F1, F2, O> to
50+
) {
51+
return RecordCodecBuilder.mapCodec(
52+
instance -> instance.group(
53+
codec1.forGetter(from1),
54+
codec2.forGetter(from2)
55+
).apply(instance, to)
56+
);
57+
}
58+
59+
static <O, F1, F2, F3> MapCodec<O> tuple(
60+
MapCodec<F1> codec1, Function<O, F1> from1,
61+
MapCodec<F2> codec2, Function<O, F2> from2,
62+
MapCodec<F3> codec3, Function<O, F3> from3,
63+
Function3<F1, F2, F3, O> to
64+
) {
65+
return RecordCodecBuilder.mapCodec(
66+
instance -> instance.group(
67+
codec1.forGetter(from1),
68+
codec2.forGetter(from2),
69+
codec3.forGetter(from3)
70+
).apply(instance, to)
71+
);
72+
}
73+
74+
static <O, F1, F2, F3, F4> MapCodec<O> tuple(
75+
MapCodec<F1> codec1, Function<O, F1> from1,
76+
MapCodec<F2> codec2, Function<O, F2> from2,
77+
MapCodec<F3> codec3, Function<O, F3> from3,
78+
MapCodec<F4> codec4, Function<O, F4> from4,
79+
Function4<F1, F2, F3, F4, O> to
80+
) {
81+
return RecordCodecBuilder.mapCodec(
82+
instance -> instance.group(
83+
codec1.forGetter(from1),
84+
codec2.forGetter(from2),
85+
codec3.forGetter(from3),
86+
codec4.forGetter(from4)
87+
).apply(instance, to)
88+
);
89+
}
90+
}
2891
}

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/datagen/RegistryEntryLookupContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.jetbrains.annotations.Nullable;
1515
import survivalblock.atmosphere.atmospheric_api.not_mixin.funny.IsThisEvenNecessary;
1616

17+
@Deprecated(since = "3.3.0")
1718
@IsThisEvenNecessary(IsThisEvenNecessary.Levels.PROBABLY_NOT)
1819
@SuppressWarnings("unused")
1920
public class RegistryEntryLookupContainer {

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/item/CreativeTabEnchantmentAdder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import java.util.function.Supplier;
2424

2525
@SuppressWarnings("unused")
26-
public class CreativeTabEnchantmentAdder {
26+
public final class CreativeTabEnchantmentAdder {
27+
private CreativeTabEnchantmentAdder() {
28+
}
2729

2830
public static void addEnchantedStack(Item item, CreativeModeTab.ItemDisplayParameters displayContext, String enchantment, CreativeModeTab.Output entries) {
2931
addEnchantedStack(item, displayContext, enchantment, entries, null);

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/item/client/AtmosphericTridentModelRenderer.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.minecraft.world.item.ItemDisplayContext;
3030
import org.joml.Vector3f;
3131
import survivalblock.atmosphere.atmospheric_api.not_mixin.AtmosphericAPI;
32+
import survivalblock.atmosphere.atmospheric_api.not_mixin.datafixer.AtmosphericCodecs;
3233

3334
import java.util.Set;
3435

@@ -66,19 +67,15 @@ public void getExtents(Set<Vector3f> output) {
6667

6768
@Environment(EnvType.CLIENT)
6869
public record Unbaked(ResourceLocation texture, ModelLayerLocation entityModelLayer) implements SpecialModelRenderer.Unbaked {
69-
public static final Codec<ModelLayerLocation> MODEL_LAYER_CODEC = RecordCodecBuilder.create(
70-
instance -> instance.group(
71-
ResourceLocation.CODEC.fieldOf("model").forGetter(ModelLayerLocation::model),
72-
Codec.STRING.optionalFieldOf("layer", "main").forGetter(ModelLayerLocation::layer)
73-
)
74-
.apply(instance, ModelLayerLocation::new)
75-
);
76-
public static final MapCodec<Unbaked> MAP_CODEC = RecordCodecBuilder.mapCodec(
77-
instance -> instance.group(
78-
ResourceLocation.CODEC.fieldOf("texture").forGetter(unbaked -> unbaked.texture),
79-
MODEL_LAYER_CODEC.optionalFieldOf("entityModelLayer", ModelLayers.TRIDENT).forGetter(unbaked -> unbaked.entityModelLayer)
80-
)
81-
.apply(instance, Unbaked::new)
70+
public static final Codec<ModelLayerLocation> MODEL_LAYER_CODEC = AtmosphericCodecs.RCB.tuple(
71+
ResourceLocation.CODEC.fieldOf("model"), ModelLayerLocation::model,
72+
Codec.STRING.optionalFieldOf("layer", "main"), ModelLayerLocation::layer,
73+
ModelLayerLocation::new
74+
).codec();
75+
public static final MapCodec<Unbaked> MAP_CODEC = AtmosphericCodecs.RCB.tuple(
76+
ResourceLocation.CODEC.fieldOf("texture"), unbaked -> unbaked.texture,
77+
MODEL_LAYER_CODEC.optionalFieldOf("entityModelLayer", ModelLayers.TRIDENT), unbaked -> unbaked.entityModelLayer,
78+
Unbaked::new
8279
);
8380

8481
public MapCodec<Unbaked> type() {

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/util/FunctionOperations.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraft.world.entity.SpawnPlacements.SpawnPredicate;
1010

1111
import java.util.function.BiFunction;
12+
import java.util.function.Consumer;
1213
import java.util.function.Predicate;
1314

1415
@SuppressWarnings("unused")
@@ -42,4 +43,9 @@ public static <T extends Entity> SpawnPredicate<T> combine(SpawnPredicate<T> one
4243
return (type, world, spawnReason, blockPos, random) ->
4344
operator.apply(one.test(type, world, spawnReason, blockPos, random), two.test(type, world, spawnReason, blockPos, random));
4445
}
46+
47+
public static <T> T consumeAndReturn(T obj, Consumer<T> consumer) {
48+
consumer.accept(obj);
49+
return obj;
50+
}
4551
}

0 commit comments

Comments
 (0)