Compare commits

14 Commits
main ... main

Author SHA1 Message Date
1e38561f5e test 2025-07-21 20:10:20 +02:00
0c7094f01d Hopefully fix everything 2025-07-20 23:15:53 +02:00
fc5b5470b8 Update to 1.21.8
Start adding the display block(@sternschnaube) - still needs work
Add the shift to move to last and first page(@sternschnaube)
2025-07-20 21:56:40 +02:00
f87a0c6c14 Fix component 2025-04-17 20:50:03 +02:00
d8c4773424 Update to 1.21.5 2025-04-16 22:30:44 +02:00
5a45506bd9 Update 2025-02-22 15:41:08 +01:00
a0f12ed4b1 Update 2024-12-23 08:49:03 +01:00
00fef620d5 Update to 1.21.4 2024-12-05 14:12:37 +01:00
fb52a6580f Try to fix crafting 2024-11-04 15:31:36 +01:00
c1648f1e13 Merge pull request 'Block name fix' (#12) from Gagooby/Server_storage:name-fix into main
Reviewed-on: BRNSystems/Server_storage#12
Reviewed-by: Bruno Rybársky <bruno@brn.systems>
2024-11-04 15:14:03 +01:00
92838e6c50 Merge branch 'main' into name-fix 2024-11-04 15:13:29 +01:00
998a6b7b04 Merge pull request 'Recipe unlock fix' (#11) from Gagooby/Server_storage:recipe-unlock into main
Reviewed-on: BRNSystems/Server_storage#11
Reviewed-by: Bruno Rybársky <bruno@brn.systems>
2024-11-04 15:13:13 +01:00
Gagooby
61428a1c9c Updated en_us.json so that the blocks name shows up properly in both item and block form 2024-11-04 03:39:08 -05:00
Gagooby
31a7fc9d03 Added recipe advancements 2024-11-04 01:41:17 -05:00
111 changed files with 1907 additions and 247 deletions

Binary file not shown.

View File

@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'maven-publish'
}

View File

@@ -3,19 +3,19 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.8
minecraft_version=1.21.8
yarn_mappings=1.21.8+build.1
loader_version=0.16.14
# Fabric API
fabric_version=0.107.0+1.21.3
fabric_version=0.129.0+1.21.8
# Mod Properties
mod_version=3.3.0
mod_version=3.3.7
maven_group=systems.brn
archives_base_name=Serverstorage
# Dependencies
polymer_version=0.10.1+1.21.3
server_translations_api_version=2.4.0+1.21.2-rc1
servergui_version=1.7.2+1.21.2
polymer_version=0.13.7+1.21.8
server_translations_api_version=2.5.1+1.21.5
servergui_version=1.10.2+1.21.8

View File

@@ -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.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@@ -10,10 +10,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.util.Identifier;
import net.minecraft.world.GameRules;
import systems.brn.serverstorage.blockentities.HardDriveContainerBlockEntity;
import systems.brn.serverstorage.blockentities.InventoryInterfaceBlockEntity;
import systems.brn.serverstorage.blockentities.RadioInterfaceBlockEntity;
import systems.brn.serverstorage.blockentities.StorageInterfaceBlockEntity;
import systems.brn.serverstorage.blockentities.*;
import systems.brn.serverstorage.blocks.*;
import systems.brn.serverstorage.items.HardDriveItem;
import systems.brn.serverstorage.items.SimpleBlockItem;
@@ -30,12 +27,18 @@ import java.util.List;
public class ServerStorage implements ModInitializer {
public static final List<String> moduleList = Arrays.asList("bus", "configuration", "container", "display", "drive", "filtering", "inventory", "pagination", "pcb", "transport", "antenna", "radio", "antenna_connector", "modem", "netherite_upgrade");
public static final List<String> tiers = Arrays.asList("iron", "golden", "diamond", "netherite");
public static final List<String> tiersAntenna = Arrays.asList("iron", "golden", "diamond", "netherite", "ender");
public static final List<String> tiersDrive = Arrays.asList("iron", "golden", "diamond", "netherite", "creative");
public static final List<String> materialList = Arrays.asList("pcb", "pcb_substrate", "cpu", "cpu_substrate", "drive_controller", "drive_casing");
public static final String MOD_ID = "serverstorage";
public static final String WIRELESS_TERMINAL_ID = "wireless_terminal";
public static final String DISPLAY_BLOCK_MODEL_ID = "display_block";
public static DisplayBlock DISPLAY_BLOCK;
public static BlockEntityType<DisplayBlockEntity> DISPLAY_BLOCK_ENTITY;
public static final String BUS_CONNECTOR_MODEL_ID = "bus_connector";
public static BusConnectorBlock BUS_CONNECTOR_BLOCK;
@@ -56,7 +59,7 @@ public class ServerStorage implements ModInitializer {
public static BlockEntityType<InventoryInterfaceBlockEntity> INVENTORY_INTERFACE_BLOCK_ENTITY;
public static final GameRules.Key<GameRules.BooleanRule> ServerStorage_Crafting_Enable =
GameRuleRegistry.register("serverstorage_crafting_module", GameRules.Category.MISC, GameRuleFactory.createBooleanRule(false));
GameRuleRegistry.register("serverstorage_crafting_module", GameRules.Category.MISC, GameRuleFactory.createBooleanRule(true));
public static final GameRules.Key<GameRules.BooleanRule> ServerStorage_Terminal_Enable =
GameRuleRegistry.register("serverstorage_terminal_module", GameRules.Category.MISC, GameRuleFactory.createBooleanRule(true));
@@ -97,18 +100,22 @@ public class ServerStorage implements ModInitializer {
RadioInterfaceBlock.register();
SimpleBlockItem.register(RADIO_INTERFACE_BLOCK);
DisplayBlock.register();
SimpleBlockItem.register(DISPLAY_BLOCK);
MATERIALS = SimpleItem.register("material", materialList, false, ItemGroups.INGREDIENTS);
MODULES = SimpleItem.register("module", moduleList, false, ItemGroups.INGREDIENTS);
HEADS = SimpleItem.register("head", tiers, ItemGroups.INGREDIENTS);
PLATTERS = SimpleItem.register("platter", tiers, ItemGroups.INGREDIENTS);
DRIVES = HardDriveItem.register(tiers);
DRIVES = HardDriveItem.register(tiersDrive);
ANTENNA_LIST = Antenna.register(tiers);
ANTENNA_LIST = Antenna.register(tiersAntenna);
WIRELESS_TERMINAL = WirelessTerminalItem.register();
UseItemCallback.EVENT.register(EventHandler::onItemUse);
systems.brn.serverstorage.lib.ItemGroups.register();

View File

@@ -0,0 +1,143 @@
package systems.brn.serverstorage.blockentities;
import eu.pb4.polymer.virtualentity.api.ElementHolder;
import eu.pb4.polymer.virtualentity.api.attachment.ChunkAttachment;
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
import eu.pb4.polymer.virtualentity.api.elements.TextDisplayElement;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.storage.ReadView;
import net.minecraft.storage.WriteView;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.joml.Vector3f;
import systems.brn.serverstorage.lib.SortMode;
import systems.brn.serverstorage.lib.StorageNetwork;
import java.util.Map;
import static systems.brn.serverstorage.ServerStorage.DISPLAY_BLOCK_ENTITY;
import static systems.brn.serverstorage.blocks.DisplayBlock.FACING;
public class DisplayBlockEntity extends BlockEntity {
public ItemStack targetItem;
public int itemCount;
public StorageNetwork network;
private final ElementHolder holder = new ElementHolder();
public final ItemDisplayElement itemElement = new ItemDisplayElement();
public final TextDisplayElement textDisplayElement = new TextDisplayElement();
private boolean attached = false;
public void reindexDrives() {
if (this.network != null) {
this.network.searchString = "*";
this.network.reindexNetwork();
} else {
this.network = new StorageNetwork(world, this.pos, SortMode.NUMERICALLY_REVERSE, "*", false);
}
}
public DisplayBlockEntity(BlockPos pos, BlockState state) {
super(DISPLAY_BLOCK_ENTITY, pos, state);
targetItem = ItemStack.EMPTY;
itemCount = 1;
itemElement.setItem(targetItem);
textDisplayElement.setText(Text.of(String.valueOf(itemCount)));
// You can offset to make it float in front of the block
Vector3f vec = new Vector3f(0.5f, 0.5f, 0.5f); // mutable
// Get the block's facing direction as a Vec3d
Vec3d facingVec = state.get(FACING).getDoubleVector(); // Example: NORTH = (0, 0, -1)
// Calculate outward offset for the item
Vec3d itemOffset = facingVec.multiply(0.5);
itemElement.setOffset(itemOffset);
// Define global "up"
Vec3d up = new Vec3d(0, 1, 0);
// Compute perpendicular "down" relative to the block face
Vec3d down = facingVec.crossProduct(up).normalize().multiply(0.3);
// Final text offset: outward from face + downward relative to face
Vec3d textOffset = facingVec.normalize().multiply(0.5).add(down);
textDisplayElement.setOffset(textOffset.add(0,0.25,0));
switch (state.get(FACING)) {
case NORTH -> textDisplayElement.setRotation(0, 180);
case SOUTH -> textDisplayElement.setRotation(0, 0);
case WEST -> textDisplayElement.setRotation(0, 90);
case EAST -> textDisplayElement.setRotation(0, 270);
case UP -> textDisplayElement.setRotation(-90, 0); // text points down
case DOWN -> textDisplayElement.setRotation(90, 0); // text points up
}
// assign to const interface
itemElement.setScale(vec); // Optional
holder.addElement(itemElement);
holder.addElement(textDisplayElement);
}
@Override
protected void readData(ReadView view) {
super.readData(view);
this.targetItem = ItemStack.EMPTY;
this.itemCount = 0;
view.read("TargetItem", ItemStack.CODEC).ifPresent(itemStack -> this.targetItem = itemStack.copy());
this.itemCount = view.getInt("TargetItemCount", 0);
}
@Override
public NbtCompound toInitialChunkDataNbt(RegistryWrapper.WrapperLookup registries) {
return createNbt(registries);
}
@Override
public void markRemoved() {
textDisplayElement.setText(Text.of(""));
itemElement.setItem(Items.AIR.getDefaultStack());
super.markRemoved();
}
@Override
protected void writeData(WriteView view) {
super.writeData(view);
view.putInt("TargetItemCount", itemCount);
view.putNullable("TargetItem", ItemStack.CODEC, targetItem.copy());
}
public static <T extends BlockEntity> void tick(World world, BlockPos blockPos, BlockState blockState, T t) {
if (t instanceof DisplayBlockEntity displayBlockEntity) {
if (!world.isClient()) {
if (displayBlockEntity.network == null) {
displayBlockEntity.reindexDrives();
displayBlockEntity.itemCount = 0;
for(Map.Entry<ItemStack, Integer> entry : displayBlockEntity.network.itemStackMap.entrySet()) {
ItemStack key = entry.getKey();
Integer value = entry.getValue();
if (ItemStack.areItemsAndComponentsEqual(key, displayBlockEntity.targetItem)) {
displayBlockEntity.itemCount = value;
break;
}
}
displayBlockEntity.itemElement.setItem(displayBlockEntity.targetItem);
displayBlockEntity.textDisplayElement.setText(Text.of(String.valueOf(displayBlockEntity.itemCount)));
}
if (!displayBlockEntity.attached) {
displayBlockEntity.attached = true;
ChunkAttachment.ofTicking(displayBlockEntity.holder, (ServerWorld) world, blockPos.toCenterPos());
}
}
}
}
}

View File

@@ -5,9 +5,9 @@ import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.storage.ReadView;
import net.minecraft.storage.WriteView;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
@@ -61,19 +61,19 @@ public class HardDriveContainerBlockEntity extends LootableContainerBlockEntity
}
@Override
protected void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
super.readNbt(nbt, registryLookup);
protected void readData(ReadView view) {
super.readData(view);
this.inventory = DefaultedList.ofSize(this.size(), ItemStack.EMPTY);
if (!this.readLootTable(nbt)) {
Inventories.readNbt(nbt, this.inventory, registryLookup);
if (!this.readLootTable(view)) {
Inventories.readData(view, this.inventory);
}
}
@Override
protected void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
super.writeNbt(nbt, registryLookup);
if (!this.writeLootTable(nbt)) {
Inventories.writeNbt(nbt, this.inventory, registryLookup);
protected void writeData(WriteView view) {
super.writeData(view);
if (!this.writeLootTable(view)) {
Inventories.writeData(view, this.inventory);
}
}

View File

@@ -4,14 +4,15 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.storage.ReadView;
import net.minecraft.storage.WriteView;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import systems.brn.serverstorage.lib.ConnectionType;
import systems.brn.serverstorage.lib.SortMode;
import systems.brn.serverstorage.lib.StorageNetwork;
import systems.brn.serverstorage.screens.SettingsScreen;
@@ -47,7 +48,7 @@ public class InventoryInterfaceBlockEntity extends BlockEntity {
this.network.searchString = query;
this.network.reindexNetwork();
} else {
this.network = new StorageNetwork(world, this.pos, false, query);
this.network = new StorageNetwork(world, this.pos, SortMode.NUMERICALLY_REVERSE, query, false);
}
}
@@ -58,29 +59,29 @@ 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
@Override
public void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
public void writeData(WriteView view) {
// Save the current value of the number to the nbt
nbt.putBoolean("isOutput", isOutput);
nbt.putInt("direction", direction.getId());
nbt.putInt("tickCounter", tickCounter);
nbt.putString("query", query);
super.writeNbt(nbt, wrapperLookup);
view.putBoolean("isOutput", isOutput);
view.putInt("direction", direction.getIndex());
view.putInt("tickCounter", tickCounter);
view.putString("query", query);
super.writeData(view);
}
// Deserialize the 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");
public void readData(ReadView view) {
super.readData(view);
isOutput = view.getBoolean("isOutput", false);
direction = Direction.byIndex(view.getInt("direction", Direction.NORTH.getIndex()));
tickCounter = view.getInt("tickCounter", 0);
query = view.getString("query", "");
}
private static int processIncomingInternal(ItemStack stack, int count, InventoryInterfaceBlockEntity blockEntity, Inventory targetedBlockEntityInventory) {
@@ -95,7 +96,7 @@ public class InventoryInterfaceBlockEntity extends BlockEntity {
ItemStack cappedStack = insertedStack.copy();
cappedStack.setCount(Math.min(insertedStack.getMaxCount(), remainingToInsert));
ItemStack remaining = insertStackIntoInventory(targetedBlockEntityInventory, cappedStack.copy());
ItemStack remaining = insertStackIntoInventory(targetedBlockEntityInventory, cappedStack.copy(), false);
if (!remaining.isEmpty()) {
ItemStack reverseStack = stack.copy();
reverseStack.setCount(remaining.getCount() + remainingToInsert);
@@ -150,7 +151,7 @@ public class InventoryInterfaceBlockEntity extends BlockEntity {
} else {
Map<ItemStack, Integer> targetedBlockInventoryMap = new HashMap<>();
addInventoryToMap(targetedBlockEntityInventory, targetedBlockInventoryMap);
targetedBlockInventoryMap = sortAndFilterMap(targetedBlockInventoryMap, false, blockEntity.query);
targetedBlockInventoryMap = sortAndFilterMap(targetedBlockInventoryMap, SortMode.NUMERICALLY_REVERSE, blockEntity.query, false);
for (Map.Entry<ItemStack, Integer> entry : targetedBlockInventoryMap.entrySet()) {
ItemStack stack = entry.getKey();
int count = entry.getValue();

View File

@@ -6,11 +6,10 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.storage.ReadView;
import net.minecraft.storage.WriteView;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
@@ -18,10 +17,13 @@ import systems.brn.serverstorage.lib.Session;
import systems.brn.serverstorage.screenhandlers.RadioInterfaceScreenHandler;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import static systems.brn.serverstorage.ServerStorage.ANTENNA_RANGES;
import static systems.brn.serverstorage.ServerStorage.RADIO_INTERFACE_BLOCK_ENTITY;
import static systems.brn.serverstorage.lib.Session.SESSION_LIST_CODEC;
public class RadioInterfaceBlockEntity extends LootableContainerBlockEntity {
public DefaultedList<ItemStack> inventory;
@@ -95,35 +97,28 @@ public class RadioInterfaceBlockEntity extends LootableContainerBlockEntity {
}
@Override
protected void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
super.readNbt(nbt, registryLookup);
protected void readData(ReadView view) {
super.readData(view);
this.inventory = DefaultedList.ofSize(this.size(), ItemStack.EMPTY);
this.antennaRange = nbt.getInt("AntennaRange");
if (!this.readLootTable(nbt)) {
Inventories.readNbt(nbt, this.inventory, registryLookup);
this.antennaRange = view.getInt("AntennaRange", 0);
if (!this.readLootTable(view)) {
Inventories.readData(view, this.inventory);
}
updateAntenna();
// Deserialize sessions list
this.sessions.clear();
NbtList sessionsNbtList = nbt.getList("Sessions", 10); // 10 = NbtCompound type
for (int i = 0; i < sessionsNbtList.size(); i++) {
NbtCompound sessionNbt = sessionsNbtList.getCompound(i);
this.sessions.add(Session.fromNbt(sessionNbt));
}
Optional<List<Session>> sessionsTmp = view.read("Sessions", SESSION_LIST_CODEC);
sessionsTmp.ifPresent(this.sessions::addAll);
}
@Override
protected void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
super.writeNbt(nbt, registryLookup);
nbt.putInt("AntennaRange", antennaRange);
if (!this.writeLootTable(nbt)) {
Inventories.writeNbt(nbt, this.inventory, registryLookup);
protected void writeData(WriteView view) {
super.writeData(view);
view.putInt("AntennaRange", antennaRange);
if (!this.writeLootTable(view)) {
Inventories.writeData(view, this.inventory);
}
// Serialize sessions list
NbtList sessionsNbtList = new NbtList();
for (Session session : sessions) {
sessionsNbtList.add(session.toNbt());
}
nbt.put("Sessions", sessionsNbtList);
view.put("Sessions", SESSION_LIST_CODEC, sessions);
}
}

View File

@@ -2,9 +2,10 @@ package systems.brn.serverstorage.blockentities;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.storage.ReadView;
import net.minecraft.storage.WriteView;
import net.minecraft.util.math.BlockPos;
import systems.brn.serverstorage.lib.SortMode;
import systems.brn.serverstorage.lib.StorageNetwork;
import systems.brn.serverstorage.screens.CraftingScreen;
import systems.brn.serverstorage.screens.StorageScreen;
@@ -15,8 +16,9 @@ import static systems.brn.serverstorage.ServerStorage.STORAGE_INTERFACE_BLOCK_EN
public class StorageInterfaceBlockEntity extends BlockEntity {
public Boolean sortAlphabetically = false;
public SortMode sortAlphabetically = SortMode.NUMERICALLY_REVERSE;
public String searchString = "";
public Boolean groupSimilar = false;
public int page = 0;
public StorageNetwork network;
@@ -30,16 +32,17 @@ public class StorageInterfaceBlockEntity extends BlockEntity {
public void reindexDrives() {
if (this.network != null) {
this.network.searchString = searchString;
this.network.sortAlphabetically = sortAlphabetically;
this.network.sortMode = sortAlphabetically;
this.network.groupSimilar = groupSimilar;
this.network.reindexNetwork();
} else {
this.network = new StorageNetwork(world, this.pos, sortAlphabetically, searchString);
this.network = new StorageNetwork(world, this.pos, sortAlphabetically, searchString, groupSimilar);
}
}
public void enforceNetwork() {
if (this.network == null) {
this.network = new StorageNetwork(world, this.pos, sortAlphabetically, searchString);
this.network = new StorageNetwork(world, this.pos, sortAlphabetically, searchString, groupSimilar);
}
}
@@ -59,22 +62,24 @@ public class StorageInterfaceBlockEntity extends BlockEntity {
// Serialize the BlockEntity
@Override
public void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
public void writeData(WriteView view) {
// Save the current value of the number to the nbt
nbt.putInt("page", page);
nbt.putBoolean("sortAlphabetically", sortAlphabetically);
nbt.putString("searchString", searchString);
view.putInt("page", page);
view.putInt("sortAlphabetically", sortAlphabetically.getId());
view.putString("searchString", searchString);
view.putBoolean("groupSimilar", groupSimilar);
super.writeNbt(nbt, wrapperLookup);
super.writeData(view);
}
// Deserialize the BlockEntity
@Override
public void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
super.readNbt(nbt, wrapperLookup);
public void readData(ReadView view) {
super.readData(view);
page = nbt.getInt("page");
sortAlphabetically = nbt.getBoolean("sortAlphabetically");
searchString = nbt.getString("searchString");
page = view.getInt("page", 0);
sortAlphabetically = SortMode.fromId(view.getInt("sortAlphabetically", SortMode.NUMERICALLY_REVERSE.getId()));
searchString = view.getString("searchString", "");
groupSimilar = view.getBoolean("groupSimilar", false);
}
}

View File

@@ -0,0 +1,221 @@
package systems.brn.serverstorage.blocks;
import eu.pb4.polymer.blocks.api.PolymerTexturedBlock;
import eu.pb4.polymer.core.api.block.PolymerBlockUtils;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
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.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import systems.brn.serverstorage.blockentities.DisplayBlockEntity;
import systems.brn.serverstorage.screens.DisplayBlockMangementScreen;
import xyz.nucleoid.packettweaker.PacketContext;
import java.util.HashMap;
import java.util.Map;
import static systems.brn.serverstorage.ServerStorage.*;
import static systems.brn.serverstorage.lib.StorageOperations.*;
public class DisplayBlock extends ConnectedBlock implements PolymerTexturedBlock, BlockEntityProvider {
final Identifier identifier;
public static final EnumProperty<Direction> FACING = FacingBlock.FACING;
private final HashMap<Direction, BlockState> rotations;
public DisplayBlock(Settings settings, Identifier identifier) {
super(settings, Blocks.NOTE_BLOCK);
this.setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH));
this.rotations = generateRotations(identifier);
this.identifier = identifier;
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.getDefaultState().with(FACING, ctx.getPlayerLookDirection().getOpposite());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(FACING);
}
@Override
public BlockState getPolymerBlockState(BlockState state, PacketContext packetContext) {
Direction direction = state.get(FACING);
return rotations.get(direction);
}
public static void register() {
var modId = id(DISPLAY_BLOCK_MODEL_ID);
DISPLAY_BLOCK = Registry.register(Registries.BLOCK, modId,
new DisplayBlock(Settings.copy(Blocks.WHITE_WOOL).registryKey(RegistryKey.of(RegistryKeys.BLOCK, modId)), modId));
UseBlockCallback.EVENT.register(DisplayBlock::onUse);
DISPLAY_BLOCK.setDefaultState();
DISPLAY_BLOCK_ENTITY = Registry.register(
Registries.BLOCK_ENTITY_TYPE,
modId,
FabricBlockEntityTypeBuilder.create(DisplayBlockEntity::new, DISPLAY_BLOCK).build(null)
);
DISPLAY_BLOCK_ENTITY.addSupportedBlock(DISPLAY_BLOCK);
AttackBlockCallback.EVENT.register(DisplayBlock::onAttack);
PolymerBlockUtils.registerBlockEntity(DISPLAY_BLOCK_ENTITY);
}
private static ActionResult onAttack(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction) {
BlockEntity storageBlockEntity = world.getBlockEntity(pos);
if (storageBlockEntity instanceof DisplayBlockEntity displayBlockEntity) {
displayBlockEntity.reindexDrives();
int maxFit = howMuchFits(displayBlockEntity.targetItem, player.getInventory());
int finalCount = Math.min(player.isSneaking() ? displayBlockEntity.targetItem.getMaxCount() : 1, maxFit);
ItemStack insertedStack = displayBlockEntity.targetItem.copy();
insertedStack.setCount(finalCount);
displayBlockEntity.itemCount = 0;
for (Map.Entry<ItemStack, Integer> entry : displayBlockEntity.network.itemStackMap.entrySet()) {
ItemStack key = entry.getKey();
Integer value = entry.getValue();
if (ItemStack.areItemsAndComponentsEqual(key, displayBlockEntity.targetItem)) {
displayBlockEntity.itemCount = value;
break;
}
}
finalCount -= displayBlockEntity.network.removeItemStack(insertedStack).getCount();
displayBlockEntity.network.updateDisplays();
displayBlockEntity.itemCount -= finalCount;
displayBlockEntity.itemElement.setItem(displayBlockEntity.targetItem);
displayBlockEntity.textDisplayElement.setText(Text.of(String.valueOf(displayBlockEntity.itemCount)));
int remainingToInsert = finalCount;
for (int i = 0; i < Math.ceilDivExact(finalCount, displayBlockEntity.targetItem.getMaxCount()); i++) {
ItemStack cappedStack = insertedStack.copy();
cappedStack.setCount(Math.min(insertedStack.getMaxCount(), remainingToInsert));
ItemStack remaining = insertStackIntoInventory(player.getInventory(), cappedStack.copy(), true);
if (!remaining.isEmpty()) {
ItemStack reverseStack = displayBlockEntity.targetItem.copy();
reverseStack.setCount(remaining.getCount() + remainingToInsert);
displayBlockEntity.network.putItemStackRemainder(reverseStack);
break;
}
remainingToInsert -= cappedStack.getCount();
}
displayBlockEntity.itemCount += remainingToInsert;
displayBlockEntity.itemElement.setItem(displayBlockEntity.targetItem);
displayBlockEntity.textDisplayElement.setText(Text.of(String.valueOf(displayBlockEntity.itemCount)));
}
return ActionResult.PASS;
}
private static ActionResult onUse(PlayerEntity plr, World world, Hand hand, BlockHitResult hitResult) {
BlockPos pos = hitResult.getBlockPos();
BlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block instanceof DisplayBlock) {
if (!world.isClient && !plr.isSpectator() && plr instanceof ServerPlayerEntity player && hand == Hand.MAIN_HAND) {
BlockEntity storageBlockEntity = world.getBlockEntity(pos);
if (storageBlockEntity instanceof DisplayBlockEntity displayBlockEntity) {
displayBlockEntity.reindexDrives();
displayBlockEntity.itemCount = 0;
for (Map.Entry<ItemStack, Integer> entry : displayBlockEntity.network.itemStackMap.entrySet()) {
ItemStack key = entry.getKey();
Integer value = entry.getValue();
if (ItemStack.areItemsAndComponentsEqual(key, displayBlockEntity.targetItem)) {
displayBlockEntity.itemCount = value;
break;
}
}
ItemStack stack = player.getStackInHand(hand);
if (stack.isEmpty() && !player.isSneaking()) {
DisplayBlockMangementScreen displayBlockMangementScreen = new DisplayBlockMangementScreen(player, displayBlockEntity);
displayBlockMangementScreen.updateDisplay();
displayBlockMangementScreen.open();
} else {
ItemStack stack1;
boolean wasEmpty = false;
if (!stack.isEmpty()) {
stack1 = stack.copy();
} else {
stack1 = displayBlockEntity.targetItem.copy();
wasEmpty = true;
}
int canPutInTemp = 0;
if (wasEmpty) {
for (int i = 9; i < 45; i++) {
ItemStack stack2 = player.getInventory().getStack(i);
if (!ItemStack.areItemsAndComponentsEqual(stack1, stack2)) {
continue;
}
stack1.setCount(player.isSneaking() ? (stack1.getCount() == 0 ? stack1.getMaxCount() : stack1.getCount()) : 1);
int canPutIn = stack1.getCount() - displayBlockEntity.network.putItemStackRemainder(stack1);
if (canPutIn > 0) {
removeFromInventory(player.getInventory(), stack2, canPutIn);
}
canPutInTemp += canPutIn;
}
} else {
if (ItemStack.areItemsAndComponentsEqual(stack1, stack)) {
stack1.setCount(player.isSneaking() ? (stack1.getCount() == 0 ? stack1.getMaxCount() : stack1.getCount()) : 1);
int canPutIn = stack1.getCount() - displayBlockEntity.network.putItemStackRemainder(stack1);
if (canPutIn > 0) {
removeFromInventory(player.getInventory(), stack, canPutIn);
}
canPutInTemp += canPutIn;
}
}
displayBlockEntity.itemElement.setItem(displayBlockEntity.targetItem);
displayBlockEntity.itemCount += canPutInTemp;
displayBlockEntity.textDisplayElement.setText(Text.of(String.valueOf(displayBlockEntity.itemCount)));
}
}
}
return ActionResult.SUCCESS;
}
return ActionResult.PASS;
}
@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new DisplayBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
// Make sure to check world.isClient if you only want to tick only on serverside.
return world instanceof ServerWorld && type == DISPLAY_BLOCK_ENTITY ? DisplayBlockEntity::tick : null;
}
}

View File

@@ -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;
@@ -24,6 +25,7 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import systems.brn.serverstorage.blockentities.HardDriveContainerBlockEntity;
import systems.brn.serverstorage.lib.SortMode;
import systems.brn.serverstorage.lib.StorageNetwork;
import xyz.nucleoid.packettweaker.PacketContext;
@@ -88,7 +90,7 @@ public class HardDriveContainerBlock extends ConnectedBlock implements PolymerTe
BlockEntity storageBlockEntity = world.getBlockEntity(pos);
if (storageBlockEntity instanceof HardDriveContainerBlockEntity driveContainerBlockEntity) {
if (driveContainerBlockEntity.network == null){
driveContainerBlockEntity.network = new StorageNetwork(world, pos, false, "");
driveContainerBlockEntity.network = new StorageNetwork(world, pos, SortMode.NUMERICALLY_REVERSE, "", false);
}
player.openHandledScreen(driveContainerBlockEntity);
}
@@ -109,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);
}
}

View File

@@ -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;
@@ -122,7 +123,7 @@ public class RadioInterfaceBlock extends ConnectedBlock implements PolymerTextur
}
}
if (sessionStorageClass == null || !sessionStorageClass.getPlayerUUID().equals(player.getUuid())) {
sessionStorageClass = new SessionStorageClass(player.getUuid(), player.getServerWorld(), pos);
sessionStorageClass = new SessionStorageClass(player.getUuid(), player.getWorld(), pos);
wirelessTerminalSessions.add(sessionStorageClass);
}
stack.set(WirelessTerminalComponents.SESSIONS, wirelessTerminalSessions);
@@ -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);
}
}

View File

@@ -52,6 +52,10 @@ public class HardDrive {
tier = 3;
maxItems = 131072;
break;
case "creative_drive":
tier = 4;
maxItems = Integer.MAX_VALUE;
break;
default:
tier = -1;
maxItems = 0;

View File

@@ -2,7 +2,6 @@ package systems.brn.serverstorage.items;
import eu.pb4.polymer.core.api.item.PolymerBlockItem;
import eu.pb4.polymer.core.api.item.PolymerItem;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
@@ -23,7 +22,7 @@ public class SimpleBlockItem extends PolymerBlockItem implements PolymerItem {
public SimpleBlockItem(Item.Settings settings, Block block, Identifier identifier) {
super(block, settings, Items.BARRIER);
this.polymerModel = PolymerResourcePackUtils.getBridgedModelId(identifier.withPath("item/" + identifier.getPath()));
this.polymerModel = identifier;
}
@Override

View File

@@ -2,7 +2,6 @@ package systems.brn.serverstorage.items;
import eu.pb4.polymer.core.api.item.PolymerItem;
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
@@ -25,7 +24,7 @@ public class SimpleItem extends SimplePolymerItem implements PolymerItem {
public SimpleItem(Settings settings, Identifier identifier) {
super(settings, Items.STICK);
this.polymerModel = PolymerResourcePackUtils.getBridgedModelId(identifier.withPath("item/" + identifier.getPath()));
this.polymerModel = identifier;
}
@Override

View File

@@ -44,7 +44,8 @@ public class WirelessTerminalItem extends SimpleItem {
.component(WirelessTerminalComponents.SESSION_KEY, null)
.component(WirelessTerminalComponents.SESSIONS, new ArrayList<>())
.component(WirelessTerminalComponents.SELECTED_POSITION, -1)
.component(WirelessTerminalComponents.SORT_ALPHABETICALLY, false)
.component(WirelessTerminalComponents.SORT_MODE, SortMode.NUMERICALLY_REVERSE)
.component(WirelessTerminalComponents.GROUP_SIMILAR, false)
.component(WirelessTerminalComponents.QUERY_STRING, "")
.component(WirelessTerminalComponents.PAGE, 0)
.registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier))
@@ -64,23 +65,20 @@ public class WirelessTerminalItem extends SimpleItem {
Vec3d playerTempPos = player.getPos();
BlockPos playerPos = player.getBlockPos();
BlockPos pos = radioInterfaceBlockEntity.getPos();
ServerWorld playerWorld = player.getServerWorld();
ServerWorld playerWorld = player.getWorld();
ServerWorld terminalWorld = playerWorld;
int finalDistance = 0;
int actualDistance = 0;
if (radioInterfaceBlockEntity.getWorld() instanceof ServerWorld terminalWorldTemp) {
double distanceCoefficient = 1;
terminalWorld = terminalWorldTemp;
if (playerWorld.getRegistryKey() != terminalWorld.getRegistryKey()) {
int playerWorldScale = (int) playerWorld.getDimension().coordinateScale();
int terminalWorldScale = (int) terminalWorld.getDimension().coordinateScale();
playerTempPos = new Vec3d(playerTempPos.getX() * playerWorldScale, playerTempPos.getY(), playerTempPos.getZ() * terminalWorldScale);
playerTempPos = new Vec3d(playerTempPos.getX() / terminalWorldScale, playerTempPos.getY(), playerTempPos.getZ() / terminalWorldScale);
distanceCoefficient = 0.4;
}
playerPos = BlockPos.ofFloored(playerTempPos);
finalDistance = (int) (radioInterfaceBlockEntity.antennaRange * distanceCoefficient);
finalDistance = Math.max(finalDistance, 1);
finalDistance = Math.max(radioInterfaceBlockEntity.antennaRange, 1);
actualDistance = (int) Math.sqrt(playerPos.getSquaredDistance(pos));
}
return new RadioDistance(radioInterfaceBlockEntity, finalDistance, actualDistance, playerPos, pos, playerWorld, terminalWorld);
@@ -88,20 +86,21 @@ public class WirelessTerminalItem extends SimpleItem {
public static boolean openTerminal(BlockPos pos, ServerPlayerEntity player, ItemStack stack, ServerWorld world) {
ServerWorld playerWorld = player.getServerWorld();
ServerWorld playerWorld = player.getWorld();
String playerWorldName = playerWorld.getRegistryKey().getValue().toString();
String terminalWorldName = world.getRegistryKey().getValue().toString();
if (stack.getItem() == WIRELESS_TERMINAL) {
RadioInterfaceBlockEntity radioInterfaceBlockEntity = WirelessTerminalItem.getRadioInterface(pos, world);
if (radioInterfaceBlockEntity != null) {
RadioDistance radioDistance = getDistance(player, radioInterfaceBlockEntity);
if (radioInterfaceBlockEntity.antennaRange > 0 && radioDistance.actualDistance() <= radioDistance.finalDistance()) {
if (radioInterfaceBlockEntity.antennaRange < 0 || (radioInterfaceBlockEntity.antennaRange > 0 && radioDistance.actualDistance() <= radioDistance.finalDistance())) {
player.sendMessage(Text.translatable("gui.serverstorage.radio_connected", pos.toShortString(), terminalWorldName, radioDistance.playerPos().toShortString(), playerWorldName, radioDistance.actualDistance(), radioDistance.finalDistance()), true);
UUID wirelessTerminalSession = stack.getOrDefault(WirelessTerminalComponents.SESSION_KEY, null);
if (radioInterfaceBlockEntity.isSessionAuthorized(wirelessTerminalSession, player.getUuid())) {
boolean sortAlphabetically = stack.getOrDefault(WirelessTerminalComponents.SORT_ALPHABETICALLY, false);
SortMode sortMode = stack.getOrDefault(WirelessTerminalComponents.SORT_MODE, SortMode.NUMERICALLY_REVERSE);
boolean groupSimilar = stack.getOrDefault(WirelessTerminalComponents.GROUP_SIMILAR, false);
String searchQuery = stack.getOrDefault(WirelessTerminalComponents.QUERY_STRING, "");
StorageNetwork storageNetwork = new StorageNetwork(world, pos, sortAlphabetically, searchQuery);
StorageNetwork storageNetwork = new StorageNetwork(world, pos, sortMode, searchQuery, groupSimilar);
StorageScreen storageScreen = new StorageScreen(player, stack, storageNetwork, radioInterfaceBlockEntity);
storageScreen.updateDisplay();
storageScreen.open();
@@ -159,7 +158,8 @@ public class WirelessTerminalItem extends SimpleItem {
ownedBy = Text.translatable("gui.serverstorage.player_management_session_owner", ownerName);
}
int page = stack.getOrDefault(WirelessTerminalComponents.PAGE, 0);
boolean sortingAlphabetically = stack.getOrDefault(WirelessTerminalComponents.SORT_ALPHABETICALLY, false);
SortMode sortMode = stack.getOrDefault(WirelessTerminalComponents.SORT_MODE, SortMode.NUMERICALLY_REVERSE);
boolean groupSimilar = stack.getOrDefault(WirelessTerminalComponents.GROUP_SIMILAR, false);
String searchQuery = stack.getOrDefault(WirelessTerminalComponents.QUERY_STRING, "*");
if (selectedPositionIndex < 0 && !sessions.isEmpty()) {
selectedPositionIndex = sessions.size() - 1;
@@ -172,7 +172,8 @@ public class WirelessTerminalItem extends SimpleItem {
Text.translatable("gui.serverstorage.wireless_terminal_link_index", selectedPositionIndex),
Text.translatable("gui.serverstorage.wireless_terminal_page", page),
Text.translatable("gui.serverstorage.wireless_terminal_search_query", searchQuery),
Text.translatable(sortingAlphabetically ? "gui.serverstorage.wireless_terminal_sorting_alphabetically" : "gui.serverstorage.wireless_terminal_sorting_numerically"),
sortMode.getSortingText(),
Text.translatable(groupSimilar ? "gui.serverstorage.group_similar" : "gui.serverstorage.dont_group_similar"),
radioPlacedAt
)));
}
@@ -202,24 +203,23 @@ public class WirelessTerminalItem extends SimpleItem {
}
}
public static boolean useItem(ServerWorld world, ServerPlayerEntity playerEntity, ItemStack stackTemp) {
public static boolean useItem(ServerWorld world, ServerPlayerEntity playerEntity, ItemStack stack) {
MinecraftServer server = world.getServer();
ensureUUID(stackTemp, server);
updateLore(stackTemp, server);
ensureUUID(stack, server);
updateLore(stack, server);
if (!playerEntity.isSneaking()) {
ItemStack stack = stackTemp.copy();
List<SessionStorageClass> wirelessTerminalPositions = new ArrayList<>(stack.getOrDefault(WirelessTerminalComponents.SESSIONS, new ArrayList<>()));
int selectedPosition = stack.getOrDefault(WirelessTerminalComponents.SELECTED_POSITION, -1);
if (selectedPosition < 0 && !wirelessTerminalPositions.isEmpty()) {
selectedPosition = wirelessTerminalPositions.size() - 1;
stack.set(WirelessTerminalComponents.SELECTED_POSITION, selectedPosition);
saveStack(stack, stackTemp, playerEntity);
saveStack(stack, stack, playerEntity);
}
if (wirelessTerminalPositions.isEmpty()) {
stack.remove(WirelessTerminalComponents.SELECTED_POSITION);
saveStack(stack, stackTemp, playerEntity);
saveStack(stack, stack, playerEntity);
selectedPosition = -1;
}
@@ -236,12 +236,12 @@ public class WirelessTerminalItem extends SimpleItem {
boolean success = openTerminal(selectedPos, playerEntity, stack, sessionStorageClass.getWorld(server));
if (!success) {
removePosition(selectedPos, stack);
saveStack(stack, stackTemp, playerEntity);
saveStack(stack, stack, playerEntity);
}
return true;
} else {
removePosition(selectedPos, stack);
saveStack(stack, stackTemp, playerEntity);
saveStack(stack, stack, playerEntity);
playerEntity.playSoundToPlayer(SoundEvents.BLOCK_NOTE_BLOCK_BASS.value(), SoundCategory.PLAYERS, 1f, 1f);
WirelessTerminalSelectorScreen wirelessTerminalSelectorScreen = new WirelessTerminalSelectorScreen(playerEntity, null);
wirelessTerminalSelectorScreen.open();

View File

@@ -15,6 +15,7 @@ import systems.brn.serverstorage.items.SimpleItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static systems.brn.serverstorage.ServerStorage.ANTENNA_RANGES;
import static systems.brn.serverstorage.ServerStorage.id;
@@ -32,7 +33,7 @@ public class Antenna extends SimpleItem {
public static List<Item> register(List<String> tiers) {
ArrayList<Item> items = new ArrayList<>();
int range = 16;
int range = 150;
for (String tier : tiers) {
Identifier identifier = id(tier + "_antenna");
Item item = Registry.register(Registries.ITEM, identifier, new Antenna(new Settings()
@@ -40,7 +41,11 @@ public class Antenna extends SimpleItem {
, identifier, range));
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(content -> content.add(item));
items.add(item);
ANTENNA_RANGES.put(item, range);
if (Objects.equals(tier, "ender")) {
ANTENNA_RANGES.put(item, Integer.MAX_VALUE);
} else {
ANTENNA_RANGES.put(item, range);
}
range *= 3;
}
return items;

View File

@@ -3,6 +3,7 @@ package systems.brn.serverstorage.lib;
import com.mojang.authlib.GameProfile;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import net.minecraft.item.Items;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -45,7 +46,11 @@ public class GenericPlayerListGui extends PagedGui {
}
protected DisplayElement getPlayerElement(UUID uuid) {
UserCache userCache = this.player.server.getUserCache();
MinecraftServer srv = this.player.getServer();
if (srv == null) {
return DisplayElement.empty();
}
UserCache userCache = srv.getUserCache();
GameProfile gameProfile = null;
Optional<GameProfile> gameProfileTemp;
boolean exists = false;

View File

@@ -17,6 +17,7 @@ public class ItemGroups {
entries.add(BUS_CONNECTOR_BLOCK);
entries.add(INVENTORY_INTERFACE_BLOCK);
entries.add(RADIO_INTERFACE_BLOCK);
entries.add(DISPLAY_BLOCK);
}))
.build();

View File

@@ -28,8 +28,18 @@ public abstract class PagedGui extends SimpleGui {
public static final String GUI_NEXT_PAGE_BLOCKED = "ewogICJ0aW1lc3RhbXAiIDogMTY0MDYxNjExMDQ4OCwKICAicHJvZmlsZUlkIiA6ICIxZjEyNTNhYTVkYTQ0ZjU5YWU1YWI1NmFhZjRlNTYxNyIsCiAgInByb2ZpbGVOYW1lIiA6ICJOb3RNaUt5IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzdlNTc3MjBhNDg3OGM4YmNhYjBlOWM5YzQ3ZDllNTUxMjhjY2Q3N2JhMzQ0NWE1NGE5MWUzZTFlMWEyNzM1NmUiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==";
public static final String GUI_QUESTION_MARK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmM4ZWExZjUxZjI1M2ZmNTE0MmNhMTFhZTQ1MTkzYTRhZDhjM2FiNWU5YzZlZWM4YmE3YTRmY2I3YmFjNDAifX19";
public static final String GUI_REFRESH = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc1ZDNkYjAzZGMyMWU1NjNiMDM0MTk3ZGE0MzViNzllY2ZlZjRiOGUyZWNkYjczMGUzNzBjMzE2NjI5ZDM2ZiJ9fX0=";
public static final String GUI_A = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGU0MTc0ODEyMTYyNmYyMmFlMTZhNGM2NjRjNzMwMWE5ZjhlYTU5MWJmNGQyOTg4ODk1NzY4MmE5ZmRhZiJ9fX0=";
public static final String GUI_1 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2E1MTZmYmFlMTYwNThmMjUxYWVmOWE2OGQzMDc4NTQ5ZjQ4ZjZkNWI2ODNmMTljZjVhMTc0NTIxN2Q3MmNjIn19fQ==";
public static final String GUI_Z = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzBkNDRmZWUwMzAzZjZkMzdmYWNhN2U5YzMxNTMwOTU1NmZhM2RmMzc5YmRkNTgyMzE3YWEzNjhhYTg0M2UifX19";
public static final String GUI_9 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDZhYmM2MWRjYWVmYmQ1MmQ5Njg5YzA2OTdjMjRjN2VjNGJjMWFmYjU2YjhiMzc1NWU2MTU0YjI0YTVkOGJhIn19fQ==";
public static final String GUI_A_B = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTdkZDM0OTI0ZDJiNmEyMTNhNWVkNDZhZTU3ODNmOTUzNzNhOWVmNWNlNWM4OGY5ZDczNjcwNTk4M2I5NyJ9fX0=";
public static final String GUI_1_B = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDJhNmYwZTg0ZGFlZmM4YjIxYWE5OTQxNWIxNmVkNWZkYWE2ZDhkYzBjM2NkNTkxZjQ5Y2E4MzJiNTc1In19fQ==";
public static final String GUI_Z_B = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzk5MmM3NTNiZjljNjI1ODUzY2UyYTBiN2IxNzRiODlhNmVjMjZiYjVjM2NjYjQ3M2I2YTIwMTI0OTYzMTIifX19";
public static final String GUI_9_B = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWY3YWEwZDk3OTgzY2Q2N2RmYjY3YjdkOWQ5YzY0MWJjOWFhMzRkOTY2MzJmMzcyZDI2ZmVlMTlmNzFmOGI3In19fQ==";
public static final String GUI_STORE_ALL = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWFkNmM4MWY4OTlhNzg1ZWNmMjZiZTFkYzQ4ZWFlMmJjZmU3NzdhODYyMzkwZjU3ODVlOTViZDgzYmQxNGQifX19";
public static final String GUI_SETTINGS = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTRkNDliYWU5NWM3OTBjM2IxZmY1YjJmMDEwNTJhNzE0ZDYxODU0ODFkNWIxYzg1OTMwYjNmOTlkMjMyMTY3NCJ9fX0=";
public static final String GUI_CRAFTING = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWQyYzBjZWRmYzMyZTNiZWVlOTU1Y2FiZDY2ZmQ0ZDc2NWVlZGEzYWRjYzg0YmM0NTFjOWZkYmVjZjNjYjdjMiJ9fX0=";
@@ -61,8 +71,12 @@ public abstract class PagedGui extends SimpleGui {
}
}
protected void nextPage() {
this.page = Math.min(this.getPageAmount() - 1, this.page + 1);
protected void nextPage(boolean allTheWay) {
if (allTheWay) {
this.page = this.getPageAmount() - 1;
} else {
this.page = Math.min(this.getPageAmount() - 1, this.page + 1);
}
this.updateDisplay();
}
@@ -70,8 +84,12 @@ public abstract class PagedGui extends SimpleGui {
return this.getPageAmount() > this.page + 1;
}
protected void previousPage() {
this.page = Math.max(0, this.page - 1);
protected void previousPage(boolean allTheWay) {
if (allTheWay) {
this.page = 0;
} else {
this.page = Math.max(0, this.page - 1);
}
this.updateDisplay();
}
@@ -146,19 +164,19 @@ public abstract class PagedGui extends SimpleGui {
return DisplayElement.filler();
}
protected DisplayElement search(){
protected DisplayElement search() {
return DisplayElement.filler();
}
protected DisplayElement sorting(){
protected DisplayElement sorting() {
return DisplayElement.filler();
}
protected DisplayElement storeAll(){
protected DisplayElement storeAll() {
return DisplayElement.filler();
}
protected DisplayElement settings(){
protected DisplayElement settings() {
return DisplayElement.filler();
}
@@ -192,7 +210,7 @@ public abstract class PagedGui extends SimpleGui {
.setSkullOwner(GUI_NEXT_PAGE)
.setCallback((x, y, z) -> {
playClickSound(gui.player);
gui.nextPage();
gui.nextPage(y.shift);
})
);
} else {
@@ -214,7 +232,7 @@ public abstract class PagedGui extends SimpleGui {
.setSkullOwner(GUI_PREVIOUS_PAGE)
.setCallback((x, y, z) -> {
playClickSound(gui.player);
gui.previousPage();
gui.previousPage(y.shift);
})
);
} else {

View File

@@ -1,23 +1,43 @@
package systems.brn.serverstorage.lib;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Uuids;
import java.util.List;
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;
}
public static final Codec<Session> SESSION_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Uuids.CODEC.fieldOf("SessionKey").forGetter(Session::sessionKey),
Uuids.CODEC.fieldOf("PlayerUUID").forGetter(Session::playerUUID)
).apply(instance, Session::new));
public static final Codec<List<Session>> SESSION_LIST_CODEC = SESSION_CODEC.listOf();
}

View File

@@ -0,0 +1,65 @@
package systems.brn.serverstorage.lib;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import static systems.brn.serverstorage.lib.PagedGui.*;
public enum SortMode {
ALPHABETICALLY(0),
ALPHABETICALLY_REVERSE(1),
NUMERICALLY(2),
NUMERICALLY_REVERSE(3);
private final int id;
SortMode(int id) {
this.id = id;
}
public int getId() {
return id;
}
public static SortMode fromId(int id) {
for (SortMode mode : values()) {
if (mode.getId() == id) {
return mode;
}
}
throw new IllegalArgumentException("Unknown SortMode id: " + id);
}
public SortMode nextSort() {
int nextOrdinal = (this.ordinal() + 1) % SortMode.values().length;
return SortMode.values()[nextOrdinal];
}
public MutableText getSortingText() {
return switch (this) {
case ALPHABETICALLY -> Text.translatable("gui.serverstorage.sorting_alphabetically");
case ALPHABETICALLY_REVERSE -> Text.translatable("gui.serverstorage.sorting_alphabetically_reversed");
case NUMERICALLY -> Text.translatable("gui.serverstorage.sorting_numerically");
case NUMERICALLY_REVERSE -> Text.translatable("gui.serverstorage.sorting_numerically_reversed");
};
}
public String getSortingIcon(boolean groupSimilar) {
if (groupSimilar) {
return switch (this) {
case ALPHABETICALLY -> GUI_A_B;
case ALPHABETICALLY_REVERSE -> GUI_Z_B;
case NUMERICALLY -> GUI_1_B;
case NUMERICALLY_REVERSE -> GUI_9_B;
};
}
return switch (this) {
case ALPHABETICALLY -> GUI_A;
case ALPHABETICALLY_REVERSE -> GUI_Z;
case NUMERICALLY -> GUI_1;
case NUMERICALLY_REVERSE -> GUI_9;
};
}
}

View File

@@ -32,7 +32,8 @@ public class StorageNetwork {
public final World world;
public final BlockPos startPos;
public boolean sortAlphabetically;
public SortMode sortMode;
public boolean groupSimilar;
public String searchString;
public int driveContainerCount;
@@ -41,11 +42,12 @@ public class StorageNetwork {
public int driveUsedSlots;
public int driveFreeSlots;
public StorageNetwork(World world, BlockPos startPos, boolean sortAlphabetically, String searchString) {
public StorageNetwork(World world, BlockPos startPos, SortMode sortMode, String searchString, boolean groupSimilar) {
this.world = world;
this.startPos = startPos;
this.sortAlphabetically = sortAlphabetically;
this.sortMode = sortMode;
this.searchString = searchString;
this.groupSimilar = groupSimilar;
reindexNetwork();
}
@@ -65,7 +67,7 @@ public class StorageNetwork {
countStuff();
filteredItemStackMap = getCombinedMap(sortAlphabetically, searchString);
filteredItemStackMap = getCombinedMap(sortMode, searchString, groupSimilar);
}
private void countStuff() {
@@ -163,12 +165,12 @@ public class StorageNetwork {
}
// Modify getCombinedInventoryFromChests to include item metadata and combine stacks
private TreeMap<ItemStack, Integer> getCombinedMap(boolean sortAlphabetically, String query) {
private TreeMap<ItemStack, Integer> getCombinedMap(SortMode sortAlphabetically, String query, boolean groupSimilar) {
itemStackMap = new HashMap<>();
for (HardDrive drive : drives) {
itemStackMap = drive.addToMap(itemStackMap);
}
return sortAndFilterMap(itemStackMap, sortAlphabetically, query);
return sortAndFilterMap(itemStackMap, sortAlphabetically, query, groupSimilar);
}

View File

@@ -10,8 +10,8 @@ import java.util.*;
public class StorageOperations {
// Modify getSimpleInventory to include item metadata and sort conditionally
public static TreeMap<ItemStack, Integer> sortAndFilterMap(Map<ItemStack, Integer> itemStackMap, boolean sortAlphabetically, String query) {
TreeMap<ItemStack, Integer> sortedMap = getItemStackIntegerTreeMap(itemStackMap, sortAlphabetically);
public static TreeMap<ItemStack, Integer> sortAndFilterMap(Map<ItemStack, Integer> itemStackMap, SortMode sortAlphabetically, String query, boolean groupSimilar) {
TreeMap<ItemStack, Integer> sortedMap = getItemStackIntegerTreeMap(itemStackMap, sortAlphabetically, groupSimilar);
if (query == null || query.isEmpty() || query.equals("*")) {
sortedMap.putAll(itemStackMap);
@@ -29,7 +29,7 @@ public class StorageOperations {
return sortedMap;
}
public static TreeSet<CraftingEntry> sortAndFilterEntries(ArrayList<CraftingEntry> craftingEntries, boolean sortAlphabetically, String query) {
public static TreeSet<CraftingEntry> sortAndFilterEntries(ArrayList<CraftingEntry> craftingEntries, SortMode sortAlphabetically, String query) {
TreeSet<CraftingEntry> sortedSet = getTreeSetCraftingEntries(sortAlphabetically);
if (query == null || query.isEmpty() || query.equals("*")) {
@@ -54,67 +54,153 @@ public class StorageOperations {
return false;
}
private static @NotNull TreeMap<ItemStack, Integer> getItemStackIntegerTreeMap(Map<ItemStack, Integer> itemStackMap, boolean sortAlphabetically) {
private static @NotNull TreeMap<ItemStack, Integer> getItemStackIntegerTreeMap(Map<ItemStack, Integer> itemStackMap, SortMode sortMode, boolean groupSimilar) {
TreeMap<ItemStack, Integer> sortedMap;
if (sortAlphabetically) {
// Sort alphabetically by item name
sortedMap = new TreeMap<>((o1, o2) -> {
String name1 = String.valueOf(o1.getItem());
String name2 = String.valueOf(o2.getItem());
return name1.compareToIgnoreCase(name2);
});
} else {
// Sort by count in descending order
sortedMap = new TreeMap<>((o1, o2) -> {
int count1 = itemStackMap.get(o1);
int count2 = itemStackMap.get(o2);
int countCompare = Integer.compare(count2, count1);
// If counts are equal, compare items alphabetically by name
return countCompare == 0 ? String.valueOf(o1.getItem()).compareToIgnoreCase(String.valueOf(o2.getItem())) : countCompare;
});
switch (sortMode) {
case ALPHABETICALLY:
// Sort alphabetically by item name
sortedMap = new TreeMap<>((o1, o2) -> sortAlpha(groupSimilar, o1, o2));
break;
case ALPHABETICALLY_REVERSE:
// Sort alphabetically by item name in reverse order
sortedMap = new TreeMap<>((o1, o2) -> sortAlpha(groupSimilar, o2, o1)); // Reverse comparison
break;
case NUMERICALLY:
// Sort by count in descending order
sortedMap = new TreeMap<>((o1, o2) -> {
int count1 = itemStackMap.get(o1);
int count2 = itemStackMap.get(o2);
int countCompare = Integer.compare(count2, count1);
// If counts are equal, compare items alphabetically by name
if (countCompare != 0) {
return countCompare;
}
return sortAlpha(groupSimilar, o1, o2);
});
break;
case NUMERICALLY_REVERSE:
// Sort by count in ascending order
sortedMap = new TreeMap<>((o1, o2) -> {
int count1 = itemStackMap.get(o1);
int count2 = itemStackMap.get(o2);
int countCompare = Integer.compare(count1, count2); // Reverse comparison
// If counts are equal, compare items alphabetically by name
if (countCompare != 0) {
return countCompare;
}
return sortAlpha(groupSimilar, o1, o2);
});
break;
default:
throw new IllegalArgumentException("Invalid sort mode: " + sortMode);
}
// Populate the sorted map with entries from the original map
sortedMap.putAll(itemStackMap);
return sortedMap;
}
private static @NotNull TreeSet<CraftingEntry> getTreeSetCraftingEntries(boolean sortAlphabetically) {
private static int sortAlpha(boolean groupSimilar, ItemStack o1, ItemStack o2) {
String name1, name2;
if (groupSimilar) {
name1 = String.valueOf(o1.getItem());
name2 = String.valueOf(o2.getItem());
} else {
name1 = o1.getItem() + o1.getComponents().toString();
name2 = o2.getItem() + o2.getComponents().toString();
}
return name1.compareToIgnoreCase(name2);
}
private static @NotNull TreeSet<CraftingEntry> getTreeSetCraftingEntries(SortMode sortMode) {
TreeSet<CraftingEntry> sortedSet;
if (sortAlphabetically) {
// Sort alphabetically by item name
sortedSet = new TreeSet<>((o1, o2) -> {
if (o1.outputStacks.isEmpty()) {
return 1;
} else if (o2.outputStacks.isEmpty()) {
return -1;
}
String name1 = String.valueOf(o1.outputStacks.getFirst().getItem());
String name2 = String.valueOf(o2.outputStacks.getFirst().getItem());
return name1.compareToIgnoreCase(name2);
});
} else {
// Sort by count in descending order
sortedSet = new TreeSet<>((o1, o2) -> {
if (o1.outputStacks.isEmpty()) {
return 1;
} else if (o2.outputStacks.isEmpty()) {
return -1;
}
int count1 = o1.totalMax;
int count2 = o2.totalMax;
int countCompare = Integer.compare(count2, count1);
// If counts are equal, compare items alphabetically by name
if (countCompare == 0) {
switch (sortMode) {
case ALPHABETICALLY:
// Sort alphabetically by item name
sortedSet = new TreeSet<>((o1, o2) -> {
if (o1.outputStacks.isEmpty()) {
return 1;
} else if (o2.outputStacks.isEmpty()) {
return -1;
}
String name1 = String.valueOf(o1.outputStacks.getFirst().getItem());
String name2 = String.valueOf(o2.outputStacks.getFirst().getItem());
return name1.compareToIgnoreCase(name2);
}
return countCompare;
});
});
break;
case ALPHABETICALLY_REVERSE:
// Sort alphabetically by item name in reverse order
sortedSet = new TreeSet<>((o1, o2) -> {
if (o1.outputStacks.isEmpty()) {
return 1;
} else if (o2.outputStacks.isEmpty()) {
return -1;
}
String name1 = String.valueOf(o1.outputStacks.getFirst().getItem());
String name2 = String.valueOf(o2.outputStacks.getFirst().getItem());
return name2.compareToIgnoreCase(name1); // Reverse comparison
});
break;
case NUMERICALLY:
// Sort by count in descending order
sortedSet = new TreeSet<>((o1, o2) -> {
if (o1.outputStacks.isEmpty()) {
return 1;
} else if (o2.outputStacks.isEmpty()) {
return -1;
}
int count1 = o1.totalMax;
int count2 = o2.totalMax;
int countCompare = Integer.compare(count2, count1);
// If counts are equal, compare items alphabetically by name
if (countCompare == 0) {
String name1 = String.valueOf(o1.outputStacks.getFirst().getItem());
String name2 = String.valueOf(o2.outputStacks.getFirst().getItem());
return name1.compareToIgnoreCase(name2);
}
return countCompare;
});
break;
case NUMERICALLY_REVERSE:
// Sort by count in ascending order
sortedSet = new TreeSet<>((o1, o2) -> {
if (o1.outputStacks.isEmpty()) {
return 1;
} else if (o2.outputStacks.isEmpty()) {
return -1;
}
int count1 = o1.totalMax;
int count2 = o2.totalMax;
int countCompare = Integer.compare(count1, count2); // Reverse comparison
// If counts are equal, compare items alphabetically by name
if (countCompare == 0) {
String name1 = String.valueOf(o1.outputStacks.getFirst().getItem());
String name2 = String.valueOf(o2.outputStacks.getFirst().getItem());
return name1.compareToIgnoreCase(name2);
}
return countCompare;
});
break;
default:
throw new IllegalArgumentException("Invalid sort mode: " + sortMode);
}
return sortedSet;
}
public static int canInsertToStack(ItemStack stack1, ItemStack stack2, int maxInsert) {
if (stack1.isEmpty() || ItemStack.areItemsEqual(stack1, stack2)) {
int remainingSpace = stack1.isEmpty() ? stack2.getMaxCount() : stack1.getMaxCount() - stack1.getCount();
@@ -133,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 {
@@ -147,9 +233,15 @@ public class StorageOperations {
return maxInsert; // Return the maximum insertion count
}
public static ItemStack insertStackIntoInventory(Inventory inventory, ItemStack stack) {
public static ItemStack insertStackIntoInventory(Inventory inventory, ItemStack stack, boolean mainOnly) {
int startSlot = 0;
int endSlot = inventory.size();
if (mainOnly) {
startSlot = 9;
endSlot = 45;
}
// First, try to merge with existing stacks
for (int i = 0; i < inventory.size(); i++) {
for (int i = startSlot; i < endSlot; i++) {
ItemStack slotStack = inventory.getStack(i);
if (canCombine(slotStack, stack)) {
int transferAmount = Math.min(stack.getCount(), slotStack.getMaxCount() - slotStack.getCount());
@@ -165,7 +257,7 @@ public class StorageOperations {
}
// Next, try to find an empty slot
for (int i = 0; i < inventory.size(); i++) {
for (int i = startSlot; i < endSlot; i++) {
ItemStack slotStack = inventory.getStack(i);
if (slotStack.isEmpty()) {
inventory.setStack(i, stack.copy());

View File

@@ -3,8 +3,10 @@ package systems.brn.serverstorage.lib;
import com.mojang.authlib.GameProfile;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.LoreComponent;
import net.minecraft.component.type.TooltipDisplayComponent;
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 +21,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;
@@ -127,7 +130,9 @@ public class Util {
LoreComponent newLore = new LoreComponent(filteredLines);
newStack.set(DataComponentTypes.LORE, newLore);
newStack.set(DataComponentTypes.TOOLTIP_DISPLAY, TooltipDisplayComponent.DEFAULT);
return newStack;
} else {
return stack;
@@ -141,7 +146,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;
@@ -152,7 +157,7 @@ public class Util {
// Count the occurrences of each ingredient in the recipe
for (Ingredient ingredient : recipe.value().getIngredientPlacement().getIngredients()) {
for (RegistryEntry<Item> item : ingredient.getMatchingItems()) {
for (RegistryEntry<Item> item : ingredient.getMatchingItems().toList()) {
ingredientCounts.put(item.value(), ingredientCounts.getOrDefault(item.value(), 0) + 1);
}
}
@@ -163,7 +168,7 @@ public class Util {
int totalAvailable = 0;
HashMap<ItemStack, Integer> inputsTemp = new HashMap<>();
for (RegistryEntry<Item> item : ingredient.getMatchingItems()) {
for (RegistryEntry<Item> item : ingredient.getMatchingItems().toList()) {
for (Map.Entry<ItemStack, Integer> entry : itemStackMap.entrySet()) {
ItemStack inventoryStack = entry.getKey();
int inventoryCount = entry.getValue();
@@ -180,12 +185,13 @@ public class Util {
canMake = false;
break;
}
int occurrences = ingredientCounts.getOrDefault(ingredient.getMatchingItems().getFirst(),0);
if (occurrences == 0) {
canMake = false;
break;
}
maxAmount = Math.min(maxAmount, totalAvailable / occurrences);
// int occurrences = ingredientCounts.getOrDefault(ingredient.getMatchingItems().getFirst(),0);
// if (occurrences == 0) {
// canMake = false;
// break;
// }
// maxAmount = Math.min(maxAmount, totalAvailable / occurrences);
maxAmount = Math.min(maxAmount, totalAvailable);
for (Map.Entry<ItemStack, Integer> entry : inputsTemp.entrySet()) {
ItemStack stackIn = entry.getKey();
@@ -204,4 +210,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();
}
}

View File

@@ -48,8 +48,13 @@ public class WirelessTerminalComponents {
);
public static final ComponentType<Boolean> SORT_ALPHABETICALLY = register(
"sort_alphabetically",
public static final ComponentType<SortMode> SORT_MODE = register(
"sort_mode",
builder -> builder.codec(Codec.INT.xmap(SortMode::fromId, SortMode::getId)) // No packetCodec needed for this example
);
public static final ComponentType<Boolean> GROUP_SIMILAR = register(
"group_similar",
builder -> builder.codec(Codec.BOOL) // No packetCodec needed for this example
);

View File

@@ -1,5 +1,6 @@
package systems.brn.serverstorage.screens;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
@@ -15,10 +16,7 @@ import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import systems.brn.serverstorage.blockentities.StorageInterfaceBlockEntity;
import systems.brn.serverstorage.lib.CraftingEntry;
import systems.brn.serverstorage.lib.PagedGui;
import systems.brn.serverstorage.lib.Searchable;
import systems.brn.serverstorage.lib.WirelessTerminalComponents;
import systems.brn.serverstorage.lib.*;
import java.util.*;
@@ -31,7 +29,6 @@ public class CraftingScreen extends PagedGui implements Searchable {
private final StorageInterfaceBlockEntity blockEntity;
private ArrayList<DisplayElement> recipesList;
public String searchQuery;
public boolean sortAlphabetically = false;
public CraftingScreen(StorageScreen storageScreen) {
super(storageScreen.getPlayer(), null);
@@ -55,7 +52,7 @@ public class CraftingScreen extends PagedGui implements Searchable {
Map<ItemStack, Integer> itemStackMap = new HashMap<>();
addInventoryToMap(storageScreen.getPlayer().getInventory(), itemStackMap);
itemStackMap.putAll(storageScreen.getNetwork().itemStackMap);
Map<ItemStack, Integer> items = sortAndFilterMap(itemStackMap, false, null);
Map<ItemStack, Integer> items = sortAndFilterMap(itemStackMap, SortMode.NUMERICALLY_REVERSE, null, getGroupSimilar());
this.craftingEntries = getCraftableRecipes(items, Objects.requireNonNull(player.getServer()));
this.recipesList = getAvailableRecipes();
super.updateDisplay();
@@ -63,7 +60,7 @@ public class CraftingScreen extends PagedGui implements Searchable {
private ArrayList<DisplayElement> getAvailableRecipes() {
ArrayList<DisplayElement> recipes = new ArrayList<>();
TreeSet<CraftingEntry> filteredCraftingEntries = sortAndFilterEntries(craftingEntries, getAlphabeticalSorting(), getQueryString());
TreeSet<CraftingEntry> filteredCraftingEntries = sortAndFilterEntries(craftingEntries, getSorting(), getQueryString());
for (CraftingEntry craftingEntry : filteredCraftingEntries) {
ItemStack stackWithCount = craftingEntry.outputStacks.getFirst().copy();
if (stackWithCount.getCount() > stackWithCount.getMaxCount()) {
@@ -167,7 +164,7 @@ public class CraftingScreen extends PagedGui implements Searchable {
ItemStack playerStack = playerInventory.getStack(i);
if (ingredient.test(playerStack)) {
ItemStack stackToRemove = playerStack.copy();
for (RegistryEntry<Item> matchingItemx : ingredient.getMatchingItems()) {
for (RegistryEntry<Item> matchingItemx : ingredient.getMatchingItems().toList()) {
Item matchingItem = matchingItemx.value();
if (matchingItem == stackToRemove.getItem()) {
stackToRemove.setCount(1); // Set count to ingredient requirement
@@ -179,7 +176,7 @@ public class CraftingScreen extends PagedGui implements Searchable {
}
// Check storage network
for (RegistryEntry<Item> itemx : ingredient.getMatchingItems()) {
for (RegistryEntry<Item> itemx : ingredient.getMatchingItems().toList()) {
Item item = itemx.value();
if (this.storageScreen.getNetwork().canRemove(item.getDefaultStack())) {
ItemStack stackToRemove = item.getDefaultStack();
@@ -219,33 +216,55 @@ public class CraftingScreen extends PagedGui implements Searchable {
}
}
public boolean getAlphabeticalSorting() {
public SortMode getSorting() {
if (blockEntity == null) {
return storageScreen.itemStack.getOrDefault(WirelessTerminalComponents.SORT_ALPHABETICALLY, false);
return storageScreen.itemStack.getOrDefault(WirelessTerminalComponents.SORT_MODE, SortMode.NUMERICALLY_REVERSE);
} else {
return blockEntity.sortAlphabetically;
}
}
public void setAlphabeticalSorting(boolean sorting) {
public void setSorting(SortMode sorting) {
if (blockEntity == null) {
storageScreen.itemStack.set(WirelessTerminalComponents.SORT_ALPHABETICALLY, sorting);
storageScreen.itemStack.set(WirelessTerminalComponents.SORT_MODE, sorting);
} else {
blockEntity.sortAlphabetically = sorting;
}
}
public boolean getGroupSimilar() {
if (blockEntity == null) {
return storageScreen.itemStack.getOrDefault(WirelessTerminalComponents.GROUP_SIMILAR, false);
} else {
return blockEntity.groupSimilar;
}
}
public void setGroupSimilar(boolean groupSimilar) {
if (blockEntity == null) {
storageScreen.itemStack.set(WirelessTerminalComponents.GROUP_SIMILAR, groupSimilar);
} else {
blockEntity.groupSimilar = groupSimilar;
}
}
@Override
protected DisplayElement sorting() {
return DisplayElement.of(
new GuiElementBuilder(Items.PLAYER_HEAD)
.setName(Text.translatable(getAlphabeticalSorting() ? "A->Z" : "9->1").formatted(Formatting.WHITE))
.setName(getSorting().getSortingText().formatted(Formatting.WHITE))
.setLore(List.of(Text.translatable(getGroupSimilar() ? "gui.serverstorage.group_similar" : "gui.serverstorage.dont_group_similar").formatted(Formatting.DARK_PURPLE)))
.hideDefaultTooltip().noDefaults()
.setSkullOwner(getAlphabeticalSorting() ? GUI_A : GUI_1)
.setCallback((x, y, z) -> {
.setSkullOwner(getSorting().getSortingIcon(getGroupSimilar()))
.setCallback((x, clickType, z) -> {
playClickSound(getPlayer());
if (storageScreen.checkDistance()) {
setAlphabeticalSorting(!getAlphabeticalSorting());
if (clickType == ClickType.MOUSE_LEFT) {
setSorting(getSorting().nextSort());
} else if (clickType == ClickType.MOUSE_RIGHT) {
setGroupSimilar(!getGroupSimilar());
}
updateDisplay();
}
})

View File

@@ -0,0 +1,54 @@
package systems.brn.serverstorage.screens;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import systems.brn.serverstorage.blockentities.DisplayBlockEntity;
import systems.brn.serverstorage.lib.PagedGui;
import java.util.Map;
public class DisplayBlockMangementScreen extends PagedGui {
public final DisplayBlockEntity displayBlockEntity;
public DisplayBlockMangementScreen(ServerPlayerEntity player, DisplayBlockEntity displayBlockEntity) {
super(player, null);
this.displayBlockEntity = displayBlockEntity;
this.setTitle(Text.translatable("gui.serverstorage.display_block_title"));
}
@Override
protected int getPageAmount() {
return 1;
}
@Override
protected DisplayElement getElement(int id) {
var builder = new GuiElementBuilder(displayBlockEntity.targetItem.getCount() > 0 ? displayBlockEntity.targetItem.getItem() : Items.AIR)
.setName(displayBlockEntity.targetItem.getItemName())
.setCallback((clickIndex, clickType, slotActionType) -> {
displayBlockEntity.targetItem = getPlayer().currentScreenHandler.getCursorStack().copy();
displayBlockEntity.reindexDrives();
displayBlockEntity.itemCount = 0;
for(Map.Entry<ItemStack, Integer> entry : displayBlockEntity.network.itemStackMap.entrySet()) {
ItemStack key = entry.getKey();
Integer value = entry.getValue();
if (ItemStack.areItemsAndComponentsEqual(key, displayBlockEntity.targetItem)) {
displayBlockEntity.itemCount = value;
break;
}
}
displayBlockEntity.itemElement.setItem(displayBlockEntity.targetItem.copy());
displayBlockEntity.textDisplayElement.setText(Text.of(String.valueOf(displayBlockEntity.itemCount)));
displayBlockEntity.markDirty();
playClickSound(getPlayer());
updateDisplay();
});
return DisplayElement.of(builder);
}
}

View File

@@ -19,6 +19,7 @@ import systems.brn.serverstorage.blockentities.RadioInterfaceBlockEntity;
import systems.brn.serverstorage.blockentities.StorageInterfaceBlockEntity;
import systems.brn.serverstorage.lib.*;
import java.util.List;
import java.util.Map;
import static systems.brn.serverstorage.ServerStorage.ServerStorage_Crafting_Enable;
@@ -60,7 +61,7 @@ public class StorageScreen extends PagedGui implements Searchable {
assert blockEntity != null;
this.network = null;
this.itemStack = ItemStack.EMPTY;
this.world = player.getServerWorld();
this.world = player.getWorld();
this.radioInterfaceBlockEntity = null;
}
@@ -71,7 +72,7 @@ public class StorageScreen extends PagedGui implements Searchable {
this.setLockPlayerInventory(false);
this.network = storageNetwork;
this.itemStack = itemStack;
this.world = player.getServerWorld();
this.world = player.getWorld();
this.radioInterfaceBlockEntity = radioInterfaceBlockEntity;
}
@@ -83,17 +84,33 @@ public class StorageScreen extends PagedGui implements Searchable {
return network;
}
public boolean getAlphabeticalSorting() {
public SortMode getSorting() {
if (blockEntity == null) {
return itemStack.getOrDefault(WirelessTerminalComponents.SORT_ALPHABETICALLY, false);
return itemStack.getOrDefault(WirelessTerminalComponents.SORT_MODE, SortMode.NUMERICALLY_REVERSE);
} else {
return blockEntity.sortAlphabetically;
}
}
public void setAlphabeticalSorting(boolean sorting) {
public boolean getGroupSimilar() {
if (blockEntity == null) {
itemStack.set(WirelessTerminalComponents.SORT_ALPHABETICALLY, sorting);
return itemStack.getOrDefault(WirelessTerminalComponents.GROUP_SIMILAR, false);
} else {
return blockEntity.groupSimilar;
}
}
public void setGroupSimilar(boolean groupSimilar) {
if (blockEntity == null) {
itemStack.set(WirelessTerminalComponents.GROUP_SIMILAR, groupSimilar);
} else {
blockEntity.groupSimilar = groupSimilar;
}
}
public void setSorting(SortMode sorting) {
if (blockEntity == null) {
itemStack.set(WirelessTerminalComponents.SORT_MODE, sorting);
} else {
blockEntity.sortAlphabetically = sorting;
}
@@ -136,7 +153,8 @@ public class StorageScreen extends PagedGui implements Searchable {
public void refreshTerminals() {
if (blockEntity == null) {
this.network.sortAlphabetically = getAlphabeticalSorting();
this.network.sortMode = getSorting();
this.network.groupSimilar = getGroupSimilar();
this.network.searchString = getQueryString();
getNetwork().reindexNetwork();
getNetwork().updateDisplays();
@@ -155,6 +173,7 @@ public class StorageScreen extends PagedGui implements Searchable {
return false;
}
} else {
blockEntity.reindexDrives();
blockEntity.openStorageScreens.add(this);
blockEntity.updateDisplays();
}
@@ -214,8 +233,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);
}
@@ -309,13 +328,18 @@ public class StorageScreen extends PagedGui implements Searchable {
protected DisplayElement sorting() {
return DisplayElement.of(
new GuiElementBuilder(Items.PLAYER_HEAD)
.setName(Text.translatable(getAlphabeticalSorting() ? "A->Z" : "9->1").formatted(Formatting.WHITE))
.setName(getSorting().getSortingText().formatted(Formatting.WHITE))
.setLore(List.of(Text.translatable(getGroupSimilar() ? "gui.serverstorage.group_similar" : "gui.serverstorage.dont_group_similar").formatted(Formatting.DARK_PURPLE)))
.hideDefaultTooltip().noDefaults()
.setSkullOwner(getAlphabeticalSorting() ? GUI_A : GUI_1)
.setCallback((x, y, z) -> {
.setSkullOwner(getSorting().getSortingIcon(getGroupSimilar()))
.setCallback((x, clickType, z) -> {
playClickSound(getPlayer());
if (checkDistance()) {
setAlphabeticalSorting(!getAlphabeticalSorting());
if (clickType == ClickType.MOUSE_LEFT) {
setSorting(getSorting().nextSort());
} else if (clickType == ClickType.MOUSE_RIGHT) {
setGroupSimilar(!getGroupSimilar());
}
this.refreshTerminals();
}
})
@@ -335,7 +359,7 @@ public class StorageScreen extends PagedGui implements Searchable {
ItemStack cappedStack = insertedStack.copy();
cappedStack.setCount(Math.min(insertedStack.getMaxCount(), remainingToInsert));
ItemStack remaining = insertStackIntoInventory(playerInventory, cappedStack.copy());
ItemStack remaining = insertStackIntoInventory(playerInventory, cappedStack.copy(), true);
if (!remaining.isEmpty()) {
ItemStack reverseStack = stack.copy();
reverseStack.setCount(remaining.getCount() + remainingToInsert);
@@ -351,15 +375,16 @@ public class StorageScreen extends PagedGui implements Searchable {
protected DisplayElement storeAll() {
return DisplayElement.of(
new GuiElementBuilder(Items.PLAYER_HEAD)
.setName(Text.translatable("gui.all").formatted(Formatting.WHITE))
.setName(Text.translatable("gui.serverstorage.store_all").formatted(Formatting.WHITE))
.setLore(List.of(Text.translatable("gui.serverstorage.store_all.lore").formatted(Formatting.DARK_PURPLE)))
.hideDefaultTooltip().noDefaults()
.setSkullOwner(GUI_STORE_ALL)
.setCallback((x, y, z) -> {
playClickSound(player);
if (checkDistance()) {
if (y.isLeft) {
for (int i = 0; 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);
}
}
@@ -379,7 +404,7 @@ public class StorageScreen extends PagedGui implements Searchable {
@Override
protected DisplayElement crafting() {
if (world != null && ((ServerWorld) world).getGameRules().getBoolean(ServerStorage_Crafting_Enable)) {
if (world != null && world.getGameRules().getBoolean(ServerStorage_Crafting_Enable)) {
return DisplayElement.of(
new GuiElementBuilder(Items.PLAYER_HEAD)
.setName(Text.translatable("container.crafting").formatted(Formatting.WHITE))

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:block/bus_connector"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/creative_drive"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/diamond_antenna"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/diamond_drive"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/diamond_head"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/diamond_platter"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:block/display_block"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:block/drive_container"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/ender_antenna"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/golden_antenna"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/golden_drive"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/golden_head"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/golden_platter"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:block/inventory_interface"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/iron_antenna"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/iron_drive"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/iron_head"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/iron_platter"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/material_cpu"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/material_cpu_substrate"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/material_drive_casing"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/material_drive_controller"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/material_pcb"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/material_pcb_substrate"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_antenna"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_antenna_connector"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_bus"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_configuration"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_container"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_display"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_drive"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_filtering"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_inventory"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_modem"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_netherite_upgrade"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_pagination"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_pcb"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_radio"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/module_transport"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/netherite_antenna"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/netherite_drive"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/netherite_head"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/netherite_platter"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:block/radio_interface"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:block/storage"
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "serverstorage:item/wireless_terminal"
}
}

View File

@@ -1,13 +1,21 @@
{
"block.serverstorage.storage": "Networked Storage Interface",
"item.serverstorage.storage": "Networked Storage Interface",
"block.serverstorage.display_block": "Networked Display",
"item.serverstorage.display_block": "Networked Display",
"block.serverstorage.inventory_interface": "Networked Inventory Interface",
"item.serverstorage.inventory_interface": "Networked Inventory Interface",
"block.serverstorage.drive_container": "Hard Drive Container",
"item.serverstorage.drive_container": "Hard Drive Container",
"block.serverstorage.bus_connector": "Storage Network Connector",
"item.serverstorage.bus_connector": "Storage Network Connector",
"block.serverstorage.radio_interface": "Networked Radio Interface",
"item.serverstorage.radio_interface": "Networked Radio Interface",
"item.serverstorage.iron_drive": "Iron Hard Drive",
"item.serverstorage.iron_head": "Iron Hard Drive Head",
@@ -25,6 +33,8 @@
"item.serverstorage.netherite_head": "Netherite Hard Drive Head",
"item.serverstorage.netherite_platter": "Netherite Hard Drive Platter",
"item.serverstorage.creative_drive": "Creative Hard Drive",
"item.serverstorage.module_bus": "Bus Module",
"item.serverstorage.module_configuration": "Configuration Module",
"item.serverstorage.module_container": "Container Module",
@@ -54,22 +64,29 @@
"item.serverstorage.golden_antenna": "Golden Antenna",
"item.serverstorage.diamond_antenna": "Diamond Antenna",
"item.serverstorage.netherite_antenna": "Netherite Antenna",
"item.serverstorage.ender_antenna": "Ender Antenna",
"item.serverstorage.wireless_terminal": "Wireless terminal",
"item.serverstorage.wireless_terminal": "Wireless Terminal",
"gui.serverstorage.store_all": "Store all items from inventory",
"gui.serverstorage.store_all.lore": "Holding shift includes your hotbar",
"gui.serverstorage.player_management": "Player management",
"gui.serverstorage.player_management_session": "Session %d",
"gui.serverstorage.player_management_session_owner": "Owned by: %s",
"gui.serverstorage.player_management_session_owner_error": "Not owned",
"gui.serverstorage.player_management_session_key": "Session key: %s",
"gui.serverstorage.display_block_title": "Display block",
"gui.serverstorage.display_block_item": "Target item: %s",
"gui.serverstorage.wireless_terminal_link_count": "Linked to %d devices",
"gui.serverstorage.wireless_terminal_link_index": "Current link index is %d",
"gui.serverstorage.wireless_terminal_page": "Page: %d",
"gui.serverstorage.wireless_terminal_search_query": "Search query: %s",
"gui.serverstorage.wireless_terminal_sorting_alphabetically": "Sorting alphabetically",
"gui.serverstorage.wireless_terminal_sorting_numerically": "Sorting numerically",
"gui.serverstorage.sorting_alphabetically": "Sorting alphabetically",
"gui.serverstorage.sorting_alphabetically_reversed": "Sorting alphabetically reversed",
"gui.serverstorage.sorting_numerically": "Sorting numerically",
"gui.serverstorage.sorting_numerically_reversed": "Sorting numerically reversed",
"gui.serverstorage.antenna_range": "Range: %d blocks",
"gui.serverstorage.player_management_session_click_deauthorize": "Click to deauthorize",
"gui.serverstorage.radio_selector": "Radio selector",
@@ -95,6 +112,9 @@
"gui.serverstorage.direction_up": "Up",
"gui.serverstorage.direction_down": "Down",
"gui.serverstorage.group_similar": "Group Similar",
"gui.serverstorage.dont_group_similar": "Don't Group Similar",
"serverstorage.groups.blocks" : "Serverstorage Blocks",
"serverstorage.groups.materials" : "Serverstorage Materials",
"serverstorage.groups.drives" : "Serverstorage Drives",

View File

@@ -0,0 +1,12 @@
{
"parent": "block/orientable_with_bottom",
"textures": {
"front": "serverstorage:block/display_front",
"side": "serverstorage:block/drive_container_side",
"top": "serverstorage:block/drive_container_side",
"bottom": "serverstorage:block/drive_container_side",
"east": "serverstorage:block/drive_container_side",
"south": "serverstorage:block/drive_container_side",
"west": "serverstorage:block/drive_container_side"
}
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "serverstorage:item/creative_drive"
}
}

View File

@@ -0,0 +1,3 @@
{
"parent": "serverstorage:block/display_block"
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "serverstorage:item/ender_antenna"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

View File

@@ -0,0 +1,26 @@
{
"criteria": {
"has_cpu": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "serverstorage:material_cpu"
}
]
}
}
},
"requirements": [
[
"has_cpu"
]
],
"rewards": {
"recipes": [
"serverstorage:bus_connector"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_substrate": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "serverstorage:material_cpu_substrate"
}
]
}
}
},
"requirements": [
[
"has_substrate"
]
],
"rewards": {
"recipes": [
"serverstorage:cpu"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_amethyst_shard": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:amethyst_shard"
}
]
}
}
},
"requirements": [
[
"has_amethyst_shard"
]
],
"rewards": {
"recipes": [
"serverstorage:cpu_substrate"
]
}
}

View File

@@ -0,0 +1,30 @@
{
"criteria": {
"has_cpu": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "serverstorage:material_cpu"
}
]
}
}
},
"requirements": [
[
"has_cpu"
]
],
"rewards": {
"recipes": [
"serverstorage:material_drive_controller",
"serverstorage:storage",
"serverstorage:inventory_interface",
"serverstorage:radio_interface",
"serverstorage:wireless_terminal",
"serverstorage:drive_container",
"serverstorage:display_block"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_diamond": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:diamond"
}
]
}
}
},
"requirements": [
[
"has_diamond"
]
],
"rewards": {
"recipes": [
"serverstorage:diamond_antenna"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_diamond_platter": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "serverstorage:diamond_platter"
}
]
}
}
},
"requirements": [
[
"has_diamond_platter"
]
],
"rewards": {
"recipes": [
"serverstorage:diamond_drive"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_diamond": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:diamond"
}
]
}
}
},
"requirements": [
[
"has_diamond"
]
],
"rewards": {
"recipes": [
"serverstorage:diamond_head"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_diamond": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:diamond"
}
]
}
}
},
"requirements": [
[
"has_diamond"
]
],
"rewards": {
"recipes": [
"serverstorage:diamond_platter"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_iron_ingot": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:iron_ingot"
}
]
}
}
},
"requirements": [
[
"has_iron_ingot"
]
],
"rewards": {
"recipes": [
"serverstorage:drive_casing"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_gold_ingot": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:gold_ingot"
}
]
}
}
},
"requirements": [
[
"has_gold_ingot"
]
],
"rewards": {
"recipes": [
"serverstorage:golden_antenna"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_golden_platter": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "serverstorage:golden_platter"
}
]
}
}
},
"requirements": [
[
"has_golden_platter"
]
],
"rewards": {
"recipes": [
"serverstorage:golden_drive"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_gold_ingot": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:gold_ingot"
}
]
}
}
},
"requirements": [
[
"has_gold_ingot"
]
],
"rewards": {
"recipes": [
"serverstorage:golden_head"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_gold_ingot": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:gold_ingot"
}
]
}
}
},
"requirements": [
[
"has_gold_ingot"
]
],
"rewards": {
"recipes": [
"serverstorage:golden_platter"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_iron_ingot": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:iron_ingot"
}
]
}
}
},
"requirements": [
[
"has_iron_ingot"
]
],
"rewards": {
"recipes": [
"serverstorage:iron_antenna"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_iron_platter": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "serverstorage:iron_platter"
}
]
}
}
},
"requirements": [
[
"has_iron_platter"
]
],
"rewards": {
"recipes": [
"serverstorage:iron_drive"
]
}
}

View File

@@ -0,0 +1,24 @@
{
"criteria": {
"has_iron_ingot": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:iron_ingot"
}
]
}
}
},
"requirements": [
[
"has_iron_ingot"
]
],
"rewards": {
"recipes": [
"serverstorage:iron_head"
]
}
}

Some files were not shown because too many files have changed in this diff Show More