Merge pull request 'fix for null-NBT' (#14) from multi-sleep into main
Reviewed-on: #14
This commit is contained in:
commit
d56761cd27
|
@ -32,13 +32,25 @@ public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInter
|
||||||
|
|
||||||
@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
|
@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
|
||||||
public void writeCustomDataToNbt(NbtCompound nbt, CallbackInfo ci) { //Immer wenn eine andere Methode aufruft, dass Daten abgespeichert werden sollen, tun wir das jetzt auch
|
public void writeCustomDataToNbt(NbtCompound nbt, CallbackInfo ci) { //Immer wenn eine andere Methode aufruft, dass Daten abgespeichert werden sollen, tun wir das jetzt auch
|
||||||
|
if (dataSaver != null) { //wenn der dataSaver null ist, wuerde sonst ein Error kommen, weil Minecraft keine leeren NBTs absepeicheern kann :(
|
||||||
|
try {
|
||||||
nbt.put("REServerMod", this.dataSaver);
|
nbt.put("REServerMod", this.dataSaver);
|
||||||
|
} catch (Exception e) {
|
||||||
|
REServerMod.LOGGER.info("Error while saving custom NBt-Data: " + e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REServerMod.LOGGER.info("write failed! This probably means, that the player hasn't set a custom spanpoint yet");
|
||||||
|
}
|
||||||
//REServerMod.LOGGER.info("writeCustomDataToNbt called");
|
//REServerMod.LOGGER.info("writeCustomDataToNbt called");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "readCustomDataFromNbt", at = @At("TAIL"))
|
@Inject(method = "readCustomDataFromNbt", at = @At("TAIL"))
|
||||||
public void readCustomDataFromNbt(NbtCompound nbt, CallbackInfo ci) { //gleiches beim einlesen. Werden NBT-Daten eingelesen, tun wird das auch
|
public void readCustomDataFromNbt(NbtCompound nbt, CallbackInfo ci) { //gleiches beim einlesen. Werden NBT-Daten eingelesen, tun wird das auch
|
||||||
|
try {
|
||||||
dataSaver = (NbtCompound) nbt.get("REServerMod");
|
dataSaver = (NbtCompound) nbt.get("REServerMod");
|
||||||
|
} catch (Exception e) {
|
||||||
|
REServerMod.LOGGER.info("Error while saving custom NBt-Data: " + e);
|
||||||
|
}
|
||||||
//REServerMod.LOGGER.info("readCustomDataFromNbt called with following Data: " + Arrays.toString(nbt.getIntArray("REServerMod.sleep_data")));
|
//REServerMod.LOGGER.info("readCustomDataFromNbt called with following Data: " + Arrays.toString(nbt.getIntArray("REServerMod.sleep_data")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue