mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-21 23:13:28 +01:00
Compare commits
3 commits
9492973a28
...
7a95edfcaa
Author | SHA1 | Date | |
---|---|---|---|
|
7a95edfcaa | ||
|
c8e90aefd7 | ||
|
dd6fb2053c |
5 changed files with 85 additions and 92 deletions
|
@ -10,15 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.data;
|
package de.ellpeck.actuallyadditions.mod.data;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
|
||||||
import net.minecraft.nbt.StringTag;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -54,13 +49,13 @@ public final class PlayerData {
|
||||||
public UUID id;
|
public UUID id;
|
||||||
|
|
||||||
public boolean bookGottenAlready;
|
public boolean bookGottenAlready;
|
||||||
public boolean didBookTutorial;
|
// public boolean didBookTutorial;
|
||||||
public boolean hasBatWings;
|
public boolean hasBatWings;
|
||||||
public boolean shouldDisableBatWings;
|
public boolean shouldDisableBatWings;
|
||||||
public int batWingsFlyTime;
|
public int batWingsFlyTime;
|
||||||
|
|
||||||
public IBookletPage[] bookmarks = new IBookletPage[12];
|
// public IBookletPage[] bookmarks = new IBookletPage[12];
|
||||||
public List<String> completedTrials = new ArrayList<>();
|
// public List<String> completedTrials = new ArrayList<>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// public GuiBooklet lastOpenBooklet;
|
// public GuiBooklet lastOpenBooklet;
|
||||||
|
@ -71,16 +66,16 @@ public final class PlayerData {
|
||||||
|
|
||||||
public void readFromNBT(CompoundTag compound, boolean savingToFile) {
|
public void readFromNBT(CompoundTag compound, boolean savingToFile) {
|
||||||
this.bookGottenAlready = compound.getBoolean("BookGotten");
|
this.bookGottenAlready = compound.getBoolean("BookGotten");
|
||||||
this.didBookTutorial = compound.getBoolean("DidTutorial");
|
// this.didBookTutorial = compound.getBoolean("DidTutorial");
|
||||||
|
|
||||||
this.hasBatWings = compound.getBoolean("HasBatWings");
|
this.hasBatWings = compound.getBoolean("HasBatWings");
|
||||||
this.batWingsFlyTime = compound.getInt("BatWingsFlyTime");
|
this.batWingsFlyTime = compound.getInt("BatWingsFlyTime");
|
||||||
|
|
||||||
ListTag bookmarks = compound.getList("Bookmarks", 8);
|
// ListTag bookmarks = compound.getList("Bookmarks", 8);
|
||||||
this.loadBookmarks(bookmarks);
|
// this.loadBookmarks(bookmarks);
|
||||||
|
//
|
||||||
ListTag trials = compound.getList("Trials", 8);
|
// ListTag trials = compound.getList("Trials", 8);
|
||||||
this.loadTrials(trials);
|
// this.loadTrials(trials);
|
||||||
|
|
||||||
if (!savingToFile) {
|
if (!savingToFile) {
|
||||||
this.shouldDisableBatWings = compound.getBoolean("ShouldDisableWings");
|
this.shouldDisableBatWings = compound.getBoolean("ShouldDisableWings");
|
||||||
|
@ -89,59 +84,59 @@ public final class PlayerData {
|
||||||
|
|
||||||
public void writeToNBT(CompoundTag compound, boolean savingToFile) {
|
public void writeToNBT(CompoundTag compound, boolean savingToFile) {
|
||||||
compound.putBoolean("BookGotten", this.bookGottenAlready);
|
compound.putBoolean("BookGotten", this.bookGottenAlready);
|
||||||
compound.putBoolean("DidTutorial", this.didBookTutorial);
|
// compound.putBoolean("DidTutorial", this.didBookTutorial);
|
||||||
|
|
||||||
compound.putBoolean("HasBatWings", this.hasBatWings);
|
compound.putBoolean("HasBatWings", this.hasBatWings);
|
||||||
compound.putInt("BatWingsFlyTime", this.batWingsFlyTime);
|
compound.putInt("BatWingsFlyTime", this.batWingsFlyTime);
|
||||||
|
|
||||||
compound.put("Bookmarks", this.saveBookmarks());
|
// compound.put("Bookmarks", this.saveBookmarks());
|
||||||
compound.put("Trials", this.saveTrials());
|
// compound.put("Trials", this.saveTrials());
|
||||||
|
|
||||||
if (!savingToFile) {
|
if (!savingToFile) {
|
||||||
compound.putBoolean("ShouldDisableWings", this.shouldDisableBatWings);
|
compound.putBoolean("ShouldDisableWings", this.shouldDisableBatWings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListTag saveBookmarks() {
|
// public ListTag saveBookmarks() {
|
||||||
ListTag bookmarks = new ListTag();
|
// ListTag bookmarks = new ListTag();
|
||||||
for (IBookletPage bookmark : this.bookmarks) {
|
// for (IBookletPage bookmark : this.bookmarks) {
|
||||||
bookmarks.add(StringTag.valueOf(bookmark == null
|
// bookmarks.add(StringTag.valueOf(bookmark == null
|
||||||
? ""
|
// ? ""
|
||||||
: bookmark.getIdentifier()));
|
// : bookmark.getIdentifier()));
|
||||||
}
|
// }
|
||||||
return bookmarks;
|
// return bookmarks;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void loadBookmarks(ListTag bookmarks) {
|
// public void loadBookmarks(ListTag bookmarks) {
|
||||||
for (int i = 0; i < bookmarks.size(); i++) {
|
// for (int i = 0; i < bookmarks.size(); i++) {
|
||||||
String strg = bookmarks.getString(i);
|
// String strg = bookmarks.getString(i);
|
||||||
if (!strg.isEmpty()) {
|
// if (!strg.isEmpty()) {
|
||||||
// IBookletPage page = BookletUtils.getBookletPageById(strg);
|
//// IBookletPage page = BookletUtils.getBookletPageById(strg);
|
||||||
this.bookmarks[i] = null; // page;
|
// this.bookmarks[i] = null; // page;
|
||||||
} else {
|
// } else {
|
||||||
this.bookmarks[i] = null;
|
// this.bookmarks[i] = null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public ListTag saveTrials() {
|
// public ListTag saveTrials() {
|
||||||
ListTag trials = new ListTag();
|
// ListTag trials = new ListTag();
|
||||||
for (String trial : this.completedTrials) {
|
// for (String trial : this.completedTrials) {
|
||||||
trials.add(StringTag.valueOf(trial));
|
// trials.add(StringTag.valueOf(trial));
|
||||||
}
|
// }
|
||||||
return trials;
|
// return trials;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void loadTrials(ListTag trials) {
|
// public void loadTrials(ListTag trials) {
|
||||||
this.completedTrials.clear();
|
// this.completedTrials.clear();
|
||||||
|
//
|
||||||
for (int i = 0; i < trials.size(); i++) {
|
// for (int i = 0; i < trials.size(); i++) {
|
||||||
String strg = trials.getString(i);
|
// String strg = trials.getString(i);
|
||||||
if (!strg.isEmpty()) {
|
// if (!strg.isEmpty()) {
|
||||||
this.completedTrials.add(strg);
|
// this.completedTrials.add(strg);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,6 @@ public record BoolConfigFeatureBiomeModifier(HolderSet<Biome> biomes, HolderSet<
|
||||||
|
|
||||||
private boolean checkConfig() {
|
private boolean checkConfig() {
|
||||||
switch (boolConfig) {
|
switch (boolConfig) {
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
case "generateQuartz":
|
case "generateQuartz":
|
||||||
return CommonConfig.Worldgen.GENERATE_QUARTZ.get();
|
return CommonConfig.Worldgen.GENERATE_QUARTZ.get();
|
||||||
case "generateCanola":
|
case "generateCanola":
|
||||||
|
@ -35,6 +33,8 @@ public record BoolConfigFeatureBiomeModifier(HolderSet<Biome> biomes, HolderSet<
|
||||||
return CommonConfig.Worldgen.GENERATE_FLAX.get();
|
return CommonConfig.Worldgen.GENERATE_FLAX.get();
|
||||||
case "generateCoffee":
|
case "generateCoffee":
|
||||||
return CommonConfig.Worldgen.GENERATE_COFFEE.get();
|
return CommonConfig.Worldgen.GENERATE_COFFEE.get();
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.network;
|
package de.ellpeck.actuallyadditions.mod.network;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
|
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.packet.ButtonToTilePacket;
|
import de.ellpeck.actuallyadditions.mod.network.packet.ButtonToTilePacket;
|
||||||
|
@ -44,24 +42,24 @@ public final class PacketHelperClient {
|
||||||
|
|
||||||
PlayerSave data = PlayerData.getDataFromPlayer(player);
|
PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||||
|
|
||||||
if (type == 0) {
|
// if (type == 0) {
|
||||||
compound.put("Bookmarks", data.saveBookmarks());
|
// compound.put("Bookmarks", data.saveBookmarks());
|
||||||
} else if (type == 1) {
|
// } else if (type == 1) {
|
||||||
compound.putBoolean("DidBookTutorial", data.didBookTutorial);
|
// compound.putBoolean("DidBookTutorial", data.didBookTutorial);
|
||||||
} else if (type == 2) {
|
// } else if (type == 2) {
|
||||||
compound.put("Trials", data.saveTrials());
|
// compound.put("Trials", data.saveTrials());
|
||||||
|
//
|
||||||
int total = 0;
|
// int total = 0;
|
||||||
for (IBookletChapter chapter : ActuallyAdditionsAPI.entryTrials.getAllChapters()) {
|
// for (IBookletChapter chapter : ActuallyAdditionsAPI.entryTrials.getAllChapters()) {
|
||||||
//if (chapter instanceof BookletChapterTrials) {
|
// //if (chapter instanceof BookletChapterTrials) {
|
||||||
// total++;
|
// // total++;
|
||||||
|
// //}
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (data.completedTrials.size() >= total) {
|
||||||
|
// compound.putBoolean("Achievement", true);
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
if (data.completedTrials.size() >= total) {
|
|
||||||
compound.putBoolean("Achievement", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PacketDistributor.sendToServer(new SyncPlayerPacket(compound));
|
PacketDistributor.sendToServer(new SyncPlayerPacket(compound));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public final class PacketHelperServer {
|
||||||
CompoundTag data = new CompoundTag();
|
CompoundTag data = new CompoundTag();
|
||||||
PlayerData.getDataFromPlayer(player).writeToNBT(data, false);
|
PlayerData.getDataFromPlayer(player).writeToNBT(data, false);
|
||||||
compound.put("Data", data);
|
compound.put("Data", data);
|
||||||
ActuallyAdditions.LOGGER.info("Sending data {}", data);
|
ActuallyAdditions.LOGGER.debug("Sending data {}", data);
|
||||||
|
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
serverPlayer.connection.send(new SyncPlayerPacket(data));
|
serverPlayer.connection.send(new SyncPlayerPacket(data));
|
||||||
|
|
|
@ -121,18 +121,18 @@ public class ServerPayloadHandler {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||||
|
|
||||||
int type = tag.getInt("Type");
|
// int type = tag.getInt("Type");
|
||||||
if (type == 0) {
|
// if (type == 0) {
|
||||||
data.loadBookmarks(tag.getList("Bookmarks", 8));
|
// data.loadBookmarks(tag.getList("Bookmarks", 8));
|
||||||
} else if (type == 1) {
|
// } else if (type == 1) {
|
||||||
data.didBookTutorial = tag.getBoolean("DidBookTutorial");
|
// data.didBookTutorial = tag.getBoolean("DidBookTutorial");
|
||||||
} else if (type == 2) {
|
// } else if (type == 2) {
|
||||||
data.loadTrials(tag.getList("Trials", 8));
|
// data.loadTrials(tag.getList("Trials", 8));
|
||||||
|
//
|
||||||
if (tag.getBoolean("Achievement")) {
|
// if (tag.getBoolean("Achievement")) {
|
||||||
//TheAchievements.COMPLETE_TRIALS.get(player);
|
// //TheAchievements.COMPLETE_TRIALS.get(player);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
WorldData.get(level).setDirty();
|
WorldData.get(level).setDirty();
|
||||||
|
|
||||||
if (tag.getBoolean("Log")) {
|
if (tag.getBoolean("Log")) {
|
||||||
|
|
Loading…
Reference in a new issue