Skip to content

Commit 92417d8

Browse files
committed
update vtil to 0.6.0
1 parent bdfb659 commit 92417d8

File tree

7 files changed

+86
-96
lines changed

7 files changed

+86
-96
lines changed

common/src/main/java/com/github/litermc/vschunkloader/VSCApi.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.litermc.vschunkloader;
22

33
import com.github.litermc.vschunkloader.attachment.AmmoShipAttachment;
4-
import com.github.litermc.vschunkloader.attachment.ForceLoadAttachment;
4+
import com.github.litermc.vschunkloader.attachment.ForceLoadStorage;
55
import com.github.litermc.vschunkloader.config.Config;
66

77
import net.minecraft.resources.ResourceLocation;
@@ -45,7 +45,7 @@ public static boolean forceLoad(final MinecraftServer server, final long id, fin
4545
if (ship == null) {
4646
return false;
4747
}
48-
final ForceLoadAttachment attachment = ForceLoadAttachment.get(ship);
48+
final ForceLoadStorage attachment = ForceLoadStorage.get(ship);
4949
if (load) {
5050
attachment.addForceLoad(token);
5151
} else {
@@ -68,7 +68,7 @@ public static boolean clearForceLoadTokens(final MinecraftServer server, final l
6868
if (ship == null) {
6969
return false;
7070
}
71-
final ForceLoadAttachment attachment = ForceLoadAttachment.get(ship);
71+
final ForceLoadStorage attachment = ForceLoadStorage.get(ship);
7272
attachment.removeAllForceLoadTokens();
7373
return true;
7474
}
@@ -86,7 +86,7 @@ public static Set<ResourceLocation> getForceLoadTokens(final MinecraftServer ser
8686
if (ship == null) {
8787
return null;
8888
}
89-
final ForceLoadAttachment attachment = ForceLoadAttachment.get(ship);
89+
final ForceLoadStorage attachment = ForceLoadStorage.get(ship);
9090
return attachment.getAllForceLoadTokens();
9191
}
9292

@@ -102,7 +102,7 @@ public static boolean isForceLoaded(final MinecraftServer server, final long id)
102102
if (ship == null) {
103103
return false;
104104
}
105-
return ForceLoadAttachment.get(ship).isForceLoaded();
105+
return ForceLoadStorage.get(ship).isForceLoaded();
106106
}
107107

108108
/**
@@ -118,7 +118,7 @@ public static boolean isForceLoadedBy(final MinecraftServer server, final long i
118118
if (ship == null) {
119119
return false;
120120
}
121-
return ForceLoadAttachment.get(ship).isForceLoadedBy(token);
121+
return ForceLoadStorage.get(ship).isForceLoadedBy(token);
122122
}
123123

124124
private static ServerShip getShip(final MinecraftServer server, final long id) {

common/src/main/java/com/github/litermc/vschunkloader/VSCListeners.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.litermc.vschunkloader;
22

33
import com.github.litermc.vschunkloader.attachment.AmmoShipAttachment;
4-
import com.github.litermc.vschunkloader.attachment.ForceLoadAttachment;
54
import com.github.litermc.vschunkloader.config.Config;
65
import com.github.litermc.vschunkloader.util.ChunkLoaderManager;
76
import com.github.litermc.vschunkloader.util.ChunkSensor;
@@ -33,7 +32,6 @@ public static void onModSetup() {
3332

3433
private static void registerAttachments() {
3534
ValkyrienSkiesMod.getApi().registerAttachment(AmmoShipAttachment.class);
36-
ValkyrienSkiesMod.getApi().registerAttachment(ForceLoadAttachment.class);
3735
}
3836

3937
public static void onServerLevelLoad(final ServerLevel level) {

common/src/main/java/com/github/litermc/vschunkloader/attachment/ForceLoadAttachment.java

Lines changed: 0 additions & 86 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.github.litermc.vschunkloader.attachment;
2+
3+
import com.github.litermc.vschunkloader.platform.PlatformHelper;
4+
import com.github.litermc.vtil.api.storage.IShipAdditionalData;
5+
import com.github.litermc.vtil.api.storage.ShipDataStorage;
6+
7+
import net.minecraft.nbt.CompoundTag;
8+
import net.minecraft.nbt.ListTag;
9+
import net.minecraft.nbt.StringTag;
10+
import net.minecraft.nbt.Tag;
11+
import net.minecraft.resources.ResourceLocation;
12+
13+
import org.valkyrienskies.core.api.ships.LoadedServerShip;
14+
import org.valkyrienskies.core.api.ships.ServerShip;
15+
import org.valkyrienskies.core.impl.game.ships.ShipData;
16+
17+
import java.util.Collection;
18+
import java.util.Collections;
19+
import java.util.HashSet;
20+
import java.util.Set;
21+
22+
public final class ForceLoadStorage implements IShipAdditionalData {
23+
private Set<ResourceLocation> forceLoadTokens = new HashSet<>();
24+
25+
public ForceLoadStorage() {}
26+
27+
public static ForceLoadStorage get(final ServerShip ship) {
28+
return ShipDataStorage.get(ship).getOrCreate(ForceLoadStorage.class);
29+
}
30+
31+
@Override
32+
public void load(final CompoundTag data) {
33+
data.getList("forceLoadTokens", Tag.TAG_STRING)
34+
.forEach((tag) -> this.forceLoadTokens.add(new ResourceLocation(tag.getAsString())));
35+
}
36+
37+
@Override
38+
public void save(final CompoundTag data) {
39+
final ListTag forceLoadTokens = new ListTag();
40+
for (final ResourceLocation token : this.forceLoadTokens) {
41+
forceLoadTokens.add(StringTag.valueOf(token.toString()));
42+
}
43+
data.put("forceLoadTokens", forceLoadTokens);
44+
}
45+
46+
public boolean isForceLoaded() {
47+
final PlatformHelper platform = PlatformHelper.get();
48+
for (final ResourceLocation id : this.forceLoadTokens) {
49+
if (platform.isModLoaded(id.getNamespace())) {
50+
return true;
51+
}
52+
}
53+
return false;
54+
}
55+
56+
public boolean isForceLoadedBy(final ResourceLocation token) {
57+
return this.forceLoadTokens.contains(token);
58+
}
59+
60+
public void addForceLoad(final ResourceLocation token) {
61+
this.forceLoadTokens.add(token);
62+
}
63+
64+
public void removeForceLoad(final ResourceLocation token) {
65+
this.forceLoadTokens.remove(token);
66+
}
67+
68+
public void removeAllForceLoadTokens() {
69+
this.forceLoadTokens.clear();
70+
}
71+
72+
public Set<ResourceLocation> getAllForceLoadTokens() {
73+
return Collections.unmodifiableSet(this.forceLoadTokens);
74+
}
75+
}

common/src/main/java/com/github/litermc/vschunkloader/mixin/MixinShipObjectServerWorld.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public ArrayList<org.valkyrienskies.core.impl.shadow.Er.b> getVoxelShapeUpdatesL
8787

8888
@Inject(method = "onDisconnect", at = @At("RETURN"), remap = false)
8989
public void onDisconnect(final VsiPlayer player, final CallbackInfo ci) {
90+
if (!(((Object) (player)) instanceof VsiPlayer)) {
91+
throw new RuntimeException("VsiPlayer verify failed on " + player);
92+
}
9093
this.disconnectedPlayers.add(player);
9194
}
9295

forge/src/main/resources/META-INF/mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ side = "BOTH"
3131
modId = "valkyrienskies"
3232
mandatory = true
3333
versionRange = "[2.4,2.5)"
34-
ordering = "BEFORE"
34+
ordering = "AFTER"
3535
side = "BOTH"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cloth_config_version=6.4.90
3737
kff_version=4.10.0
3838
vs2_version=2.4.5
3939
vs_core_version=1.1.0+3d898dfd55
40-
vtil_version=0.5.9
40+
vtil_version=0.6.0
4141

4242
# Soft dependencies
4343
jade_version=11.13.1

0 commit comments

Comments
 (0)