Update to 1.21.5
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.8-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.10-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
@@ -3,19 +3,19 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
|
||||
minecraft_version=1.21.4
|
||||
yarn_mappings=1.21.4+build.8
|
||||
loader_version=0.16.10
|
||||
minecraft_version=1.21.5
|
||||
yarn_mappings=1.21.5+build.1
|
||||
loader_version=0.16.13
|
||||
|
||||
# Fabric API
|
||||
fabric_version=0.118.0+1.21.4
|
||||
fabric_version=0.120.0+1.21.5
|
||||
|
||||
# Mod Properties
|
||||
mod_version=3.3.4
|
||||
mod_version=3.3.5
|
||||
maven_group=systems.brn
|
||||
archives_base_name=Serverstorage
|
||||
|
||||
# Dependencies
|
||||
polymer_version=0.11.7+1.21.4
|
||||
server_translations_api_version=2.4.0+1.21.2-rc1
|
||||
servergui_version=1.8.2+1.21.4
|
||||
polymer_version=0.12.3+1.21.5
|
||||
server_translations_api_version=2.5.0+1.21.5-rc1
|
||||
servergui_version=1.9.0+1.21.5
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
@@ -59,8 +59,8 @@ public class InventoryInterfaceBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void nextDirection() {
|
||||
int newId = (direction.getId() + 1) % 6;
|
||||
direction = Direction.byId(newId);
|
||||
int newId = (direction.getIndex() + 1) % 6;
|
||||
direction = Direction.byIndex(newId);
|
||||
}
|
||||
|
||||
// Serialize the BlockEntity
|
||||
@@ -68,7 +68,7 @@ public class InventoryInterfaceBlockEntity extends BlockEntity {
|
||||
public void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
// Save the current value of the number to the nbt
|
||||
nbt.putBoolean("isOutput", isOutput);
|
||||
nbt.putInt("direction", direction.getId());
|
||||
nbt.putInt("direction", direction.getIndex());
|
||||
nbt.putInt("tickCounter", tickCounter);
|
||||
nbt.putString("query", query);
|
||||
super.writeNbt(nbt, wrapperLookup);
|
||||
@@ -78,10 +78,10 @@ public class InventoryInterfaceBlockEntity extends BlockEntity {
|
||||
@Override
|
||||
public void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
super.readNbt(nbt, wrapperLookup);
|
||||
isOutput = nbt.getBoolean("isOutput");
|
||||
direction = Direction.byId(nbt.getInt("direction"));
|
||||
tickCounter = nbt.getInt("tickCounter");
|
||||
query = nbt.getString("query");
|
||||
isOutput = nbt.getBoolean("isOutput", false);
|
||||
direction = Direction.byIndex(nbt.getInt("direction", Direction.NORTH.getIndex()));
|
||||
tickCounter = nbt.getInt("tickCounter", 0);
|
||||
query = nbt.getString("query", "");
|
||||
}
|
||||
|
||||
private static int processIncomingInternal(ItemStack stack, int count, InventoryInterfaceBlockEntity blockEntity, Inventory targetedBlockEntityInventory) {
|
||||
|
@@ -18,6 +18,7 @@ import systems.brn.serverstorage.lib.Session;
|
||||
import systems.brn.serverstorage.screenhandlers.RadioInterfaceScreenHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static systems.brn.serverstorage.ServerStorage.ANTENNA_RANGES;
|
||||
@@ -98,17 +99,22 @@ public class RadioInterfaceBlockEntity extends LootableContainerBlockEntity {
|
||||
protected void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
|
||||
super.readNbt(nbt, registryLookup);
|
||||
this.inventory = DefaultedList.ofSize(this.size(), ItemStack.EMPTY);
|
||||
this.antennaRange = nbt.getInt("AntennaRange");
|
||||
this.antennaRange = nbt.getInt("AntennaRange", 0);
|
||||
if (!this.readLootTable(nbt)) {
|
||||
Inventories.readNbt(nbt, this.inventory, registryLookup);
|
||||
}
|
||||
updateAntenna();
|
||||
// Deserialize sessions list
|
||||
this.sessions.clear();
|
||||
NbtList sessionsNbtList = nbt.getList("Sessions", 10); // 10 = NbtCompound type
|
||||
NbtList sessionsNbtList = nbt.getListOrEmpty("Sessions"); // 10 = NbtCompound type
|
||||
for (int i = 0; i < sessionsNbtList.size(); i++) {
|
||||
NbtCompound sessionNbt = sessionsNbtList.getCompound(i);
|
||||
this.sessions.add(Session.fromNbt(sessionNbt));
|
||||
Optional<NbtCompound> sessionNbt = sessionsNbtList.getCompound(i);
|
||||
if (sessionNbt.isPresent()) {
|
||||
Session session = Session.fromNbt(sessionNbt.get());
|
||||
if (session != null) {
|
||||
this.sessions.add(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -77,9 +77,9 @@ public class StorageInterfaceBlockEntity extends BlockEntity {
|
||||
public void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
super.readNbt(nbt, wrapperLookup);
|
||||
|
||||
page = nbt.getInt("page");
|
||||
sortAlphabetically = SortMode.fromId(nbt.getInt("sortAlphabetically"));
|
||||
searchString = nbt.getString("searchString");
|
||||
groupSimilar = nbt.getBoolean("groupSimilar");
|
||||
page = nbt.getInt("page", 0);
|
||||
sortAlphabetically = SortMode.fromId(nbt.getInt("sortAlphabetically", SortMode.NUMERICALLY_REVERSE.getId()));
|
||||
searchString = nbt.getString("searchString", "");
|
||||
groupSimilar = nbt.getBoolean("groupSimilar", false);
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@@ -110,8 +111,8 @@ public class HardDriveContainerBlock extends ConnectedBlock implements PolymerTe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
ItemScatterer.onStateReplaced(state, newState, world, pos);
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
protected void onStateReplaced(BlockState state, ServerWorld world, BlockPos pos, boolean moved) {
|
||||
ItemScatterer.onStateReplaced(state, world, pos);
|
||||
super.onStateReplaced(state, world, pos, moved);
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@@ -148,8 +149,8 @@ public class RadioInterfaceBlock extends ConnectedBlock implements PolymerTextur
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
ItemScatterer.onStateReplaced(state, newState, world, pos);
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
protected void onStateReplaced(BlockState state, ServerWorld world, BlockPos pos, boolean moved) {
|
||||
ItemScatterer.onStateReplaced(state, world, pos);
|
||||
super.onStateReplaced(state, world, pos, moved);
|
||||
}
|
||||
}
|
||||
|
@@ -2,22 +2,29 @@ package systems.brn.serverstorage.lib;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static systems.brn.serverstorage.lib.Util.getUUID;
|
||||
import static systems.brn.serverstorage.lib.Util.putUUID;
|
||||
|
||||
public record Session(UUID sessionKey, UUID playerUUID) {
|
||||
|
||||
// Serialize to NBT
|
||||
public NbtCompound toNbt() {
|
||||
NbtCompound nbt = new NbtCompound();
|
||||
nbt.putUuid("SessionKey", this.sessionKey);
|
||||
nbt.putUuid("PlayerUUID", this.playerUUID);
|
||||
putUUID(nbt, "SessionKey", this.sessionKey);
|
||||
putUUID(nbt, "PlayerUUID", this.playerUUID);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
// Deserialize from NBT
|
||||
public static Session fromNbt(NbtCompound nbt) {
|
||||
UUID sessionKey = nbt.getUuid("SessionKey");
|
||||
UUID playerUUID = nbt.getUuid("PlayerUUID");
|
||||
return new Session(sessionKey, playerUUID);
|
||||
Optional<UUID> sessionKey = getUUID(nbt, "SessionKey");
|
||||
Optional<UUID> playerUUID = getUUID(nbt, "PlayerUUID");
|
||||
if (sessionKey.isPresent() && playerUUID.isPresent()) {
|
||||
return new Session(sessionKey.get(), playerUUID.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -219,8 +219,8 @@ public class StorageOperations {
|
||||
|
||||
if (inventory instanceof PlayerInventory playerInventory) {
|
||||
// Iterate through the slots in the player's inventory
|
||||
for (int i = 0; i < playerInventory.main.size(); i++) {
|
||||
ItemStack slotStack = playerInventory.main.get(i);
|
||||
for (int i = 0; i < playerInventory.getMainStacks().size(); i++) {
|
||||
ItemStack slotStack = playerInventory.getMainStacks().get(i);
|
||||
maxInsert = canInsertToStack(slotStack, itemStack, maxInsert);
|
||||
}
|
||||
} else {
|
||||
|
@@ -5,6 +5,7 @@ import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.LoreComponent;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.recipe.CraftingRecipe;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeEntry;
|
||||
@@ -19,6 +20,7 @@ import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.UserCache;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -141,7 +143,7 @@ public class Util {
|
||||
ArrayList<CraftingEntry> craftingEntries = new ArrayList<>();
|
||||
|
||||
for (RecipeEntry<?> recipex : allRecipes) {
|
||||
if (! (recipex.value() instanceof CraftingRecipe)) {
|
||||
if (!(recipex.value() instanceof CraftingRecipe)) {
|
||||
continue;
|
||||
}
|
||||
RecipeEntry<CraftingRecipe> recipe = (RecipeEntry<CraftingRecipe>) recipex;
|
||||
@@ -205,4 +207,35 @@ public class Util {
|
||||
}
|
||||
return craftingEntries;
|
||||
}
|
||||
|
||||
public static void putUUID(NbtCompound nbtCompound, String name, UUID uuid) {
|
||||
Objects.requireNonNull(uuid, "UUID cannot be null");
|
||||
ByteBuffer buffer = ByteBuffer.allocate(16);
|
||||
buffer.putLong(uuid.getMostSignificantBits());
|
||||
buffer.putLong(uuid.getLeastSignificantBits());
|
||||
nbtCompound.putByteArray(name, buffer.array());
|
||||
}
|
||||
|
||||
public static Optional<UUID> getUUID(NbtCompound nbtCompound, String name) {
|
||||
Optional<byte[]> bytesOpt = nbtCompound.getByteArray(name);
|
||||
if (bytesOpt.isPresent()) {
|
||||
byte[] bytes = bytesOpt.get();
|
||||
if (bytes.length == 16) {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(bytes);
|
||||
long mostSigBits = buffer.getLong();
|
||||
long leastSigBits = buffer.getLong();
|
||||
return Optional.of(new UUID(mostSigBits, leastSigBits));
|
||||
}
|
||||
} else {
|
||||
Optional<int[]> intsOpt = nbtCompound.getIntArray(name);
|
||||
if (intsOpt.isPresent() && intsOpt.get().length == 4) {
|
||||
int[] ints = intsOpt.get();
|
||||
long mostSigBits = ((long) ints[0] << 32) | (ints[1] & 0xFFFFFFFFL);
|
||||
long leastSigBits = ((long) ints[2] << 32) | (ints[3] & 0xFFFFFFFFL);
|
||||
return Optional.of(new UUID(mostSigBits, leastSigBits));
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -232,8 +232,8 @@ public class StorageScreen extends PagedGui implements Searchable {
|
||||
if (!type.shift) {
|
||||
noLoreStack.setCount(Math.min(noLoreStack.getMaxCount(), noLoreStack.getCount() / 2)); //half stack
|
||||
} else {
|
||||
for (int i = 0; i < player.getInventory().main.size(); i++) {
|
||||
ItemStack stack = player.getInventory().main.get(i);
|
||||
for (int i = 0; i < player.getInventory().getMainStacks().size(); i++) {
|
||||
ItemStack stack = player.getInventory().getMainStacks().get(i);
|
||||
if (ItemStack.areItemsAndComponentsEqual(stack, noLoreStack)) {
|
||||
insertItem(stack, 0, getVirtualSize(), false);
|
||||
}
|
||||
@@ -382,8 +382,8 @@ public class StorageScreen extends PagedGui implements Searchable {
|
||||
playClickSound(player);
|
||||
if (checkDistance()) {
|
||||
if (y.isLeft) {
|
||||
for (int i = y.shift ? 0 : 8; i < player.getInventory().main.size(); i++) {
|
||||
ItemStack stack = player.getInventory().main.get(i);
|
||||
for (int i = y.shift ? 0 : 8; i < player.getInventory().getMainStacks().size(); i++) {
|
||||
ItemStack stack = player.getInventory().getMainStacks().get(i);
|
||||
insertItem(stack, 0, getVirtualSize(), false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user