Skip to content

Commit 6d69a3f

Browse files
committed
Tags
1 parent ae87abc commit 6d69a3f

23 files changed

+622
-85
lines changed

gradle.properties

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

4-
version = b12.0.3
4+
version = b12.0.4
55
maven_group = net.ludocrypt
66
archives_base_name = limlib

src/main/java/net/ludocrypt/limlib/api/effects/post/PostEffect.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public abstract class PostEffect {
2424

2525
public abstract Codec<? extends PostEffect> getCodec();
2626

27+
public static void init() {
28+
Registry.register(PostEffect.POST_EFFECT_CODEC, new Identifier("limlib", "static"), StaticPostEffect.CODEC);
29+
Registry.register(PostEffect.POST_EFFECT_CODEC, new Identifier("limlib", "empty"), EmptyPostEffect.CODEC);
30+
}
31+
2732
public abstract boolean shouldRender();
2833

2934
public abstract void beforeRender();

src/main/java/net/ludocrypt/limlib/api/effects/sky/DimensionEffects.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.concurrent.atomic.AtomicReference;
44
import java.util.function.Function;
55

6+
import org.quiltmc.loader.api.ModInternal;
67
import org.quiltmc.loader.api.minecraft.ClientOnly;
78

89
import com.mojang.serialization.Codec;
@@ -30,10 +31,20 @@ public abstract class DimensionEffects {
3031
public static final RegistryKey<Registry<DimensionEffects>> DIMENSION_EFFECTS_KEY = RegistryKey
3132
.ofRegistry(new Identifier("limlib/dimension_effects"));
3233

34+
@ModInternal
3335
public static final AtomicReference<HolderLookup<DimensionEffects>> MIXIN_WORLD_LOOKUP = new AtomicReference<HolderLookup<DimensionEffects>>();
3436

3537
public abstract Codec<? extends DimensionEffects> getCodec();
3638

39+
public static void init() {
40+
Registry
41+
.register(DimensionEffects.DIMENSION_EFFECTS_CODEC, new Identifier("limlib", "static"),
42+
StaticDimensionEffects.CODEC);
43+
Registry
44+
.register(DimensionEffects.DIMENSION_EFFECTS_CODEC, new Identifier("limlib", "empty"),
45+
EmptyDimensionEffects.CODEC);
46+
}
47+
3748
@ClientOnly
3849
public abstract DimensionVisualEffects getDimensionEffects();
3950

src/main/java/net/ludocrypt/limlib/api/effects/sound/distortion/DistortionEffect.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ public abstract class DistortionEffect {
2727

2828
public abstract Codec<? extends DistortionEffect> getCodec();
2929

30+
public static void init() {
31+
Registry
32+
.register(DistortionEffect.DISTORTION_EFFECT_CODEC, new Identifier("limlib", "static"),
33+
StaticDistortionEffect.CODEC);
34+
}
35+
3036
/**
3137
* Whether or not a Sound Event should be ignored
3238
*

src/main/java/net/ludocrypt/limlib/api/effects/sound/reverb/ReverbEffect.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public abstract class ReverbEffect {
2727

2828
public abstract Codec<? extends ReverbEffect> getCodec();
2929

30+
public static void init() {
31+
Registry.register(ReverbEffect.REVERB_EFFECT_CODEC, new Identifier("limlib", "static"), StaticReverbEffect.CODEC);
32+
}
33+
3034
/**
3135
* Whether or not a Sound Event should be ignored
3236
*

src/main/java/net/ludocrypt/limlib/api/skybox/Skybox.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public abstract class Skybox {
2727

2828
public abstract Codec<? extends Skybox> getCodec();
2929

30+
public static void init() {
31+
Registry.register(Skybox.SKYBOX_CODEC, new Identifier("limlib", "empty"), EmptySkybox.CODEC);
32+
Registry.register(Skybox.SKYBOX_CODEC, new Identifier("limlib", "textured"), TexturedSkybox.CODEC);
33+
}
34+
3035
@ClientOnly
3136
public abstract void renderSky(WorldRenderer worldRenderer, MinecraftClient client, MatrixStack matrices,
3237
Matrix4f projectionMatrix, float tickDelta);

src/main/java/net/ludocrypt/limlib/api/world/chunk/AbstractNbtChunkGenerator.java

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

33
import java.util.Optional;
44

5-
import net.ludocrypt.limlib.api.world.FunctionMap;
65
import net.ludocrypt.limlib.api.world.LimlibHelper;
76
import net.ludocrypt.limlib.api.world.Manipulation;
8-
import net.ludocrypt.limlib.api.world.NbtGroup;
9-
import net.ludocrypt.limlib.api.world.NbtPlacerUtil;
7+
import net.ludocrypt.limlib.api.world.nbt.FunctionMap;
8+
import net.ludocrypt.limlib.api.world.nbt.NbtGroup;
9+
import net.ludocrypt.limlib.api.world.nbt.NbtPlacerUtil;
10+
import net.ludocrypt.limlib.api.world.nbt.NbtTags;
1011
import net.minecraft.block.Block;
1112
import net.minecraft.block.BlockState;
1213
import net.minecraft.block.Blocks;
@@ -15,6 +16,7 @@
1516
import net.minecraft.loot.LootTables;
1617
import net.minecraft.nbt.NbtCompound;
1718
import net.minecraft.resource.ResourceManager;
19+
import net.minecraft.server.world.ServerWorld;
1820
import net.minecraft.util.Identifier;
1921
import net.minecraft.util.math.BlockPos;
2022
import net.minecraft.world.ChunkRegion;
@@ -24,6 +26,7 @@ public abstract class AbstractNbtChunkGenerator extends LiminalChunkGenerator {
2426

2527
public final NbtGroup nbtGroup;
2628
public final FunctionMap<Identifier, NbtPlacerUtil, ResourceManager> structures;
29+
public NbtTags tags;
2730

2831
public AbstractNbtChunkGenerator(BiomeSource biomeSource, NbtGroup nbtGroup) {
2932
this(biomeSource, nbtGroup, new FunctionMap<Identifier, NbtPlacerUtil, ResourceManager>(NbtPlacerUtil::load));
@@ -37,6 +40,14 @@ public AbstractNbtChunkGenerator(BiomeSource biomeSource, NbtGroup nbtGroup,
3740
this.nbtGroup.fill(structures);
3841
}
3942

43+
public void loadTags(ServerWorld world) {
44+
45+
if (this.tags == null) {
46+
this.tags = NbtTags.parse(this.nbtGroup, world.getServer().getResourceManager());
47+
}
48+
49+
}
50+
4051
public void generateNbt(ChunkRegion region, BlockPos at, Identifier id) {
4152
generateNbt(region, at, id, Manipulation.NONE);
4253
}
@@ -78,36 +89,32 @@ public void generateNbt(ChunkRegion region, BlockPos offset, BlockPos from, Bloc
7889

7990
protected void modifyStructure(ChunkRegion region, BlockPos pos, BlockState state,
8091
Optional<NbtCompound> blockEntityNbt) {
81-
this.modifyStructure(region, pos, state, blockEntityNbt, Block.NOTIFY_ALL);
92+
this.modifyStructure(region, pos, state, blockEntityNbt, Block.NOTIFY_ALL, 1);
8293
}
8394

8495
protected void modifyStructure(ChunkRegion region, BlockPos pos, BlockState state, Optional<NbtCompound> blockEntityNbt,
85-
int update) {
96+
int update, int depth) {
8697

87-
if (!state.isAir()) {
88-
89-
if (state.isOf(Blocks.BARRIER)) {
90-
region.setBlockState(pos, Blocks.AIR.getDefaultState(), update, 1);
91-
} else {
92-
region.setBlockState(pos, state, update, 1);
93-
}
98+
if (state.isOf(Blocks.STRUCTURE_VOID)) {
99+
return;
100+
}
94101

95-
if (blockEntityNbt.isPresent()) {
96-
BlockEntity blockEntity = region.getBlockEntity(pos);
102+
region.setBlockState(pos, state, update, depth);
97103

98-
if (blockEntity != null) {
104+
if (blockEntityNbt.isPresent()) {
105+
BlockEntity blockEntity = region.getBlockEntity(pos);
99106

100-
if (state.isOf(blockEntity.getCachedState().getBlock())) {
101-
blockEntity.readNbt(blockEntityNbt.get());
102-
}
107+
if (blockEntity != null) {
103108

109+
if (state.isOf(blockEntity.getCachedState().getBlock())) {
110+
blockEntity.readNbt(blockEntityNbt.get());
104111
}
105112

106-
if (blockEntity instanceof LootableContainerBlockEntity lootTable) {
107-
lootTable
108-
.setLootTable(this.getContainerLootTable(lootTable), region.getSeed() + LimlibHelper.blockSeed(pos));
109-
}
113+
}
110114

115+
if (blockEntity instanceof LootableContainerBlockEntity lootTable) {
116+
lootTable
117+
.setLootTable(this.getContainerLootTable(lootTable), region.getSeed() + LimlibHelper.blockSeed(pos));
111118
}
112119

113120
}

src/main/java/net/ludocrypt/limlib/api/world/maze/MazeComponent.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import com.google.common.collect.Maps;
88

9-
import net.ludocrypt.limlib.api.world.maze.storage.NbtSerializer;
9+
import net.ludocrypt.limlib.api.world.nbt.ImmutableNbtCompound;
10+
import net.ludocrypt.limlib.api.world.nbt.NbtSerializer;
1011
import net.minecraft.nbt.NbtCompound;
1112
import net.minecraft.util.math.BlockPos;
1213
import net.minecraft.util.math.Vec3i;
@@ -56,7 +57,6 @@ public String toString() {
5657

5758
for (int y = 0; y < height; y++) {
5859
row.append(cellState(width - x, y).toString());
59-
6060
}
6161

6262
row.append("\n");
@@ -66,21 +66,22 @@ public String toString() {
6666
}
6767

6868
@Override
69-
public NbtCompound write(NbtCompound nbt) {
69+
public ImmutableNbtCompound write() {
70+
NbtCompound nbt = new NbtCompound();
7071

7172
for (int x = 0; x < width; x++) {
7273

7374
for (int y = 0; y < height; y++) {
74-
nbt.put(x + "." + y, this.cellState(x, y).write(new NbtCompound()));
75+
nbt.put(x + "." + y, this.cellState(x, y).write());
7576
}
7677

7778
}
7879

79-
return nbt;
80+
return new ImmutableNbtCompound(nbt);
8081
}
8182

8283
@Override
83-
public MazeComponent read(NbtCompound nbt) {
84+
public MazeComponent read(ImmutableNbtCompound nbt) {
8485

8586
for (int x = 0; x < width; x++) {
8687

@@ -264,12 +265,14 @@ public String toString() {
264265
}
265266

266267
@Override
267-
public NbtCompound write(NbtCompound nbt) {
268+
public ImmutableNbtCompound write() {
269+
NbtCompound nbt = new NbtCompound();
270+
268271
nbt.putBoolean("up", up);
269272
nbt.putBoolean("down", down);
270273
nbt.putBoolean("left", left);
271274
nbt.putBoolean("right", right);
272-
nbt.put("pos", this.position.write(new NbtCompound()));
275+
nbt.put("pos", this.position.write());
273276

274277
NbtCompound extraData = new NbtCompound();
275278

@@ -279,11 +282,11 @@ public NbtCompound write(NbtCompound nbt) {
279282

280283
nbt.put("extra", extraData);
281284

282-
return nbt;
285+
return new ImmutableNbtCompound(nbt);
283286
}
284287

285288
@Override
286-
public CellState read(NbtCompound nbt) {
289+
public CellState read(ImmutableNbtCompound nbt) {
287290
this.up = nbt.getBoolean("up");
288291
this.down = nbt.getBoolean("down");
289292
this.left = nbt.getBoolean("left");
@@ -425,15 +428,17 @@ public String toString() {
425428
}
426429

427430
@Override
428-
public NbtCompound write(NbtCompound nbt) {
431+
public ImmutableNbtCompound write() {
432+
NbtCompound nbt = new NbtCompound();
433+
429434
nbt.putInt("x", x);
430435
nbt.putInt("y", y);
431436

432-
return nbt;
437+
return new ImmutableNbtCompound(nbt);
433438
}
434439

435440
@Override
436-
public Vec2i read(NbtCompound nbt) {
441+
public Vec2i read(ImmutableNbtCompound nbt) {
437442
this.x = nbt.getInt("x");
438443
this.y = nbt.getInt("y");
439444

src/main/java/net/ludocrypt/limlib/api/world/maze/storage/MazeStorage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.ludocrypt.limlib.api.world.maze.MazeComponent;
1616
import net.ludocrypt.limlib.api.world.maze.MazeComponent.Vec2i;
1717
import net.ludocrypt.limlib.api.world.maze.MazeGenerator;
18+
import net.ludocrypt.limlib.api.world.nbt.ImmutableNbtCompound;
1819
import net.minecraft.nbt.NbtCompound;
1920
import net.minecraft.nbt.NbtIo;
2021
import net.minecraft.util.math.MathHelper;
@@ -64,7 +65,7 @@ public void read() {
6465
.get(id)
6566
.getMazes()
6667
.put(regionPos.add(pos), new MazeComponent(mazeRaw.getInt("width"), mazeRaw.getInt("height"))
67-
.read(mazeRaw.getCompound("maze")));
68+
.read(new ImmutableNbtCompound(mazeRaw.getCompound("maze"))));
6869
}
6970

7071
} catch (IOException | NullPointerException e) {
@@ -99,7 +100,7 @@ public void serialize(String mazeId, Vec2i pos, MazeComponent maze) {
99100
}
100101

101102
NbtCompound compound = new NbtCompound();
102-
NbtCompound mazeCompound = maze.write(new NbtCompound());
103+
NbtCompound mazeCompound = maze.write();
103104

104105
compound.put("maze", mazeCompound);
105106
compound.putInt("width", maze.width);

src/main/java/net/ludocrypt/limlib/api/world/maze/storage/NbtSerializer.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)