-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from InfernalSuite/develop
Merge from develop
- Loading branch information
Showing
12 changed files
with
215 additions
and
29 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
34 changes: 34 additions & 0 deletions
34
api/src/main/java/com/infernalsuite/aswm/api/world/properties/type/SlimePropertyFloat.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,34 @@ | ||
package com.infernalsuite.aswm.api.world.properties.type; | ||
|
||
import com.flowpowered.nbt.CompoundMap; | ||
import com.flowpowered.nbt.FloatTag; | ||
import com.flowpowered.nbt.Tag; | ||
import com.infernalsuite.aswm.api.world.properties.SlimeProperty; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* A slime property of type float | ||
*/ | ||
public class SlimePropertyFloat extends SlimeProperty<Float> { | ||
|
||
public SlimePropertyFloat(String nbtName, Float defaultValue, Function<Float, Boolean> validator) { | ||
super(nbtName, defaultValue, validator); | ||
} | ||
|
||
public SlimePropertyFloat(String nbtName, Float defaultValue) { | ||
super(nbtName, defaultValue); | ||
} | ||
|
||
@Override | ||
protected void writeValue(CompoundMap compound, Float value) { | ||
compound.put(getNbtName(), new FloatTag(getNbtName(), value)); | ||
} | ||
|
||
@Override | ||
protected Float readValue(Tag<?> compoundTag) { | ||
return compoundTag.getAsFloatTag() | ||
.map(Tag::getValue) | ||
.orElse(getDefaultValue()); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
patches/server/0014-Add-default-spawn-yaw-propagate-CraftWorld-setSpawnL.patch
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,42 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: kyngs <[email protected]> | ||
Date: Sat, 18 May 2024 20:34:06 +0200 | ||
Subject: [PATCH] Add default spawn yaw, propagate CraftWorld#setSpawnLocation | ||
to the SlimeProperties. | ||
|
||
|
||
diff --git a/src/main/java/com/infernalsuite/aswm/level/SlimeLevelInstance.java b/src/main/java/com/infernalsuite/aswm/level/SlimeLevelInstance.java | ||
index a525fa1781535d458c5ecb67e261520692c858ac..1d5547a74042743e388f77f70b9ebbd37be3f1bc 100644 | ||
--- a/src/main/java/com/infernalsuite/aswm/level/SlimeLevelInstance.java | ||
+++ b/src/main/java/com/infernalsuite/aswm/level/SlimeLevelInstance.java | ||
@@ -95,7 +95,11 @@ public class SlimeLevelInstance extends ServerLevel { | ||
SlimePropertyMap propertyMap = slimeBootstrap.initial().getPropertyMap(); | ||
|
||
this.serverLevelData.setDifficulty(Difficulty.valueOf(propertyMap.getValue(SlimeProperties.DIFFICULTY).toUpperCase())); | ||
- this.serverLevelData.setSpawn(new BlockPos(propertyMap.getValue(SlimeProperties.SPAWN_X), propertyMap.getValue(SlimeProperties.SPAWN_Y), propertyMap.getValue(SlimeProperties.SPAWN_Z)), 0); | ||
+ this.serverLevelData.setSpawn(new BlockPos( | ||
+ propertyMap.getValue(SlimeProperties.SPAWN_X), | ||
+ propertyMap.getValue(SlimeProperties.SPAWN_Y), | ||
+ propertyMap.getValue(SlimeProperties.SPAWN_Z)), | ||
+ propertyMap.getValue(SlimeProperties.SPAWN_YAW)); | ||
super.setSpawnSettings(propertyMap.getValue(SlimeProperties.ALLOW_MONSTERS), propertyMap.getValue(SlimeProperties.ALLOW_ANIMALS)); | ||
|
||
this.pvpMode = propertyMap.getValue(SlimeProperties.PVP); | ||
@@ -187,6 +191,17 @@ public class SlimeLevelInstance extends ServerLevel { | ||
} | ||
} | ||
|
||
+ @Override | ||
+ public void setDefaultSpawnPos(BlockPos pos, float angle) { | ||
+ super.setDefaultSpawnPos(pos, angle); | ||
+ | ||
+ SlimePropertyMap propertyMap = this.slimeInstance.getPropertyMap(); | ||
+ propertyMap.setValue(SlimeProperties.SPAWN_X, pos.getX()); | ||
+ propertyMap.setValue(SlimeProperties.SPAWN_Y, pos.getY()); | ||
+ propertyMap.setValue(SlimeProperties.SPAWN_Z, pos.getZ()); | ||
+ propertyMap.setValue(SlimeProperties.SPAWN_YAW, angle); | ||
+ } | ||
+ | ||
// @Override | ||
// public void unload(LevelChunk chunk) { | ||
// this.slimeInstance.unload(chunk); |
46 changes: 46 additions & 0 deletions
46
patches/server/0015-Fix-chunks-not-getting-serialized-when-reloaded.patch
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,46 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: kyngs <[email protected]> | ||
Date: Sun, 19 May 2024 19:17:07 +0200 | ||
Subject: [PATCH] Fix chunks not getting serialized when reloaded. | ||
|
||
|
||
diff --git a/src/main/java/com/infernalsuite/aswm/level/SlimeChunkLevel.java b/src/main/java/com/infernalsuite/aswm/level/SlimeChunkLevel.java | ||
index b159fc8751e9840b311cc1eda01e496e2dbc5f2e..2ebabf20c37d2b5c479de5bb241aa334f92a1104 100644 | ||
--- a/src/main/java/com/infernalsuite/aswm/level/SlimeChunkLevel.java | ||
+++ b/src/main/java/com/infernalsuite/aswm/level/SlimeChunkLevel.java | ||
@@ -24,4 +24,10 @@ public class SlimeChunkLevel extends LevelChunk { | ||
super.unloadCallback(); | ||
this.inMemoryWorld.unload(this); | ||
} | ||
+ | ||
+ @Override | ||
+ public void loadCallback() { | ||
+ super.loadCallback(); | ||
+ this.inMemoryWorld.ensureChunkMarkedAsLoaded(this); | ||
+ } | ||
} | ||
\ No newline at end of file | ||
diff --git a/src/main/java/com/infernalsuite/aswm/level/SlimeInMemoryWorld.java b/src/main/java/com/infernalsuite/aswm/level/SlimeInMemoryWorld.java | ||
index 95133e0ff8a8bdfc84c1dd7ff6b2c7ed7ae9a2f9..b54b231e22967eb0b34e6ba9b7ec9cdf64bad87e 100644 | ||
--- a/src/main/java/com/infernalsuite/aswm/level/SlimeInMemoryWorld.java | ||
+++ b/src/main/java/com/infernalsuite/aswm/level/SlimeInMemoryWorld.java | ||
@@ -219,7 +219,7 @@ public class SlimeInMemoryWorld implements SlimeWorld, SlimeWorldInstance { | ||
} else { | ||
chunk = safeNmsChunkWrapper.getWrapper().getChunk(); | ||
} | ||
- } else if (clonedChunk instanceof NMSSlimeChunk nmsSlimeChunk) { | ||
+ } else if (clonedChunk instanceof NMSSlimeChunk nmsSlimeChunk) { | ||
chunk = nmsSlimeChunk.getChunk(); | ||
} | ||
|
||
@@ -279,4 +279,10 @@ public class SlimeInMemoryWorld implements SlimeWorld, SlimeWorldInstance { | ||
public @NotNull PersistentDataContainer getPersistentDataContainer() { | ||
return this.extraPDC; | ||
} | ||
+ | ||
+ public void ensureChunkMarkedAsLoaded(SlimeChunkLevel chunk) { | ||
+ if (chunkStorage.get(new ChunkPos(chunk.locX, chunk.locZ)) instanceof SlimeChunkSkeleton skeleton) { | ||
+ chunkStorage.put(new ChunkPos(chunk.locX, chunk.locZ), new NMSSlimeChunk(chunk, skeleton)); | ||
+ } | ||
+ } | ||
} |
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
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