-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flesh-mound): make mound shapes persist across unloaded chunks a…
…nd store mound shape seed in primordial cradle block/item
- Loading branch information
1 parent
bdfa12f
commit 32c2efd
Showing
28 changed files
with
1,125 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/github/elenterius/biomancy/util/Bit32Set.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...us/biomancy/util/IntegerSerializable.java → ...il/serialization/IntegerSerializable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/com/github/elenterius/biomancy/util/serialization/NBTSerializable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.github.elenterius.biomancy.util.serialization; | ||
|
||
public interface NBTSerializable<T> { | ||
NBTSerializer<T> getNBTSerializer(); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/github/elenterius/biomancy/util/serialization/NBTSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.github.elenterius.biomancy.util.serialization; | ||
|
||
import net.minecraft.nbt.CompoundTag; | ||
|
||
public interface NBTSerializer<T> { | ||
String id(); | ||
|
||
CompoundTag serializeNBT(T t); | ||
|
||
T deserializeNBT(CompoundTag tag); | ||
|
||
@FunctionalInterface | ||
interface Factory<T> { | ||
NBTSerializer<T> create(String id); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/github/elenterius/biomancy/util/serialization/NBTSerializers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.github.elenterius.biomancy.util.serialization; | ||
|
||
import com.github.elenterius.biomancy.util.shape.OctantEllipsoidShape; | ||
import com.github.elenterius.biomancy.util.shape.Shape; | ||
import com.github.elenterius.biomancy.util.shape.SphereShape; | ||
import com.github.elenterius.biomancy.world.Region; | ||
import com.github.elenterius.biomancy.world.ShapeRegion; | ||
import com.github.elenterius.biomancy.world.mound.MoundShape; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public final class NBTSerializers { | ||
private static final Map<String, NBTSerializer<?>> SERIALIZERS = new HashMap<>(); | ||
public static final NBTSerializer<Shape> SPHERE_SERIALIZER = registerShape("sphere", SphereShape.Serializer::new); | ||
public static final NBTSerializer<Shape> OCTANT_ELLIPSOID_SERIALIZER = registerShape("octant_ellipsoid", OctantEllipsoidShape.Serializer::new); | ||
public static final NBTSerializer<Shape> MOUND_SERIALIZER = registerShape("mound", MoundShape.Serializer::new); | ||
public static final NBTSerializer<Region> SHAPE_REGION_SERIALIZER = registerRegion("shape_region", ShapeRegion.Serializer::new); | ||
|
||
private NBTSerializers() {} | ||
|
||
public static <T> NBTSerializer<T> register(String id, NBTSerializer.Factory<T> factory) { | ||
NBTSerializer<T> serializer = factory.create(id); | ||
SERIALIZERS.put(id, serializer); | ||
return serializer; | ||
} | ||
|
||
public static <T extends Shape> NBTSerializer<Shape> registerShape(String id, NBTSerializer.Factory<T> factory) { | ||
NBTSerializer<T> serializer = factory.create(id); | ||
SERIALIZERS.put(id, serializer); | ||
//noinspection unchecked | ||
return (NBTSerializer<Shape>) serializer; | ||
} | ||
|
||
public static <T extends Region> NBTSerializer<Region> registerRegion(String id, NBTSerializer.Factory<T> factory) { | ||
NBTSerializer<T> serializer = factory.create(id); | ||
SERIALIZERS.put(id, serializer); | ||
//noinspection unchecked | ||
return (NBTSerializer<Region>) serializer; | ||
} | ||
|
||
public static @Nullable NBTSerializer<?> get(String id) { | ||
return SERIALIZERS.get(id); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/github/elenterius/biomancy/util/serialization/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package com.github.elenterius.biomancy.util.serialization; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.