Skip to content

Commit

Permalink
Update to pre 4
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueZeeKing committed Nov 28, 2023
1 parent 7eb5c1f commit 458922e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
org.gradle.jvmargs=-Xmx2G

# Fabric Properties
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
minecraft_version=1.20.3-pre4
yarn_mappings=1.20.3-pre4+build.1
loader_version=0.14.25

# Mod Properties
mod_version = 2.5.2
mod_version = 2.6.0
maven_group = io.icker
archives_base_name = factions

# Dependencies
fabric_version=0.89.0+1.20.2
fabric_version=0.91.1+1.20.3
lucko_permissions_version=0.3-SNAPSHOT
dynmap_api_version=3.7-SNAPSHOT
papi_version=2.1.3+1.20.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public SimpleInventory getSafe() {
}

public DefaultedList<ItemStack> clearSafe() {
DefaultedList<ItemStack> stacks = this.safe.stacks;
DefaultedList<ItemStack> stacks = this.safe.heldStacks;
this.safe = new SimpleInventory(54);
return stacks;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/icker/factions/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -15,6 +16,7 @@
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtTagSizeTracker;

public class Database {
private static final File BASE_PATH =
Expand Down Expand Up @@ -44,7 +46,7 @@ public static <T, E> HashMap<E, T> load(Class<T> clazz, Function<T, E> getStoreK
}

try {
NbtList list = (NbtList) NbtIo.readCompressed(file).get(KEY);
NbtList list = (NbtList) NbtIo.readCompressed(Path.of(file.getPath()), NbtTagSizeTracker.ofUnlimitedBytes()).get(KEY);
for (T item : deserializeList(clazz, list)) {
store.put(getStoreKey.apply(item), item);
}
Expand Down Expand Up @@ -107,7 +109,7 @@ public static <T> void save(Class<T> clazz, List<T> items) {
try {
NbtCompound fileData = new NbtCompound();
fileData.put(KEY, serializeList(clazz, items));
NbtIo.writeCompressed(fileData, file);
NbtIo.writeCompressed(fileData, Path.of(file.getPath()));
} catch (IOException | ReflectiveOperationException e) {
FactionsMod.LOGGER.error("Failed to write NBT data ({})", file, e);
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/io/icker/factions/util/PlaceholdersWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public static void init() {
int red = mapBoundRange(faction.calculateMaxPower(), 0, 170, 255, faction.getPower());
int green = mapBoundRange(0, faction.calculateMaxPower(), 170, 255, faction.getPower());
return Text.literal(String.valueOf(faction.getPower()))
.setStyle(Style.EMPTY.withColor(TextColor.parse(
"#" + Integer.toHexString(red) + Integer.toHexString(green) + "AA")));
.setStyle(Style.EMPTY.withColor(rgbToInt(red, green, 170)));
});

register("max_power", (member) -> {
Expand Down Expand Up @@ -131,10 +130,14 @@ public static void init() {
int reqPower = faction.getClaims().size() * FactionsMod.CONFIG.POWER.CLAIM_WEIGHT;
int red = mapBoundRange(0, faction.getPower(), 85, 255, reqPower);
return Text.literal(String.valueOf(reqPower)).setStyle(Style.EMPTY
.withColor(TextColor.parse("#" + Integer.toHexString(red) + "5555")));
.withColor(rgbToInt(red, 85, 85)));
});
}

private static int rgbToInt(int red, int green, int blue) {
return (red & 255 << 16) | (green & 255 << 8) | (blue & 255);
}

private static int mapBoundRange(int from_min, int from_max, int to_min, int to_max,
int value) {
return Math.min(to_max, Math.max(to_min,
Expand Down

0 comments on commit 458922e

Please sign in to comment.