Update to 1.21
This commit is contained in:
parent
48479c9a88
commit
3727cf7a5b
@ -3,17 +3,19 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
|
||||
minecraft_version=1.20.6
|
||||
yarn_mappings=1.20.6+build.3
|
||||
minecraft_version=1.21
|
||||
yarn_mappings=1.21+build.1
|
||||
loader_version=0.15.11
|
||||
|
||||
# Fabric API
|
||||
fabric_version=0.100.1+1.21
|
||||
|
||||
# Mod Properties
|
||||
mod_version=2.4
|
||||
mod_version=2.5
|
||||
maven_group=systems.brn
|
||||
archives_base_name=Server_storage
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.99.0+1.20.6
|
||||
polymer_version=0.8.0+1.20.6
|
||||
server_translations_api_version=2.3.0+1.20.5-rc2
|
||||
servergui_version=1.5.1+1.20.5
|
||||
polymer_version=0.8.4+1.20.6
|
||||
server_translations_api_version=2.3.1+1.21-pre2
|
||||
servergui_version=1.6.0+1.21
|
@ -2,7 +2,10 @@ package systems.brn.server_storage;
|
||||
|
||||
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
|
||||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.GameRules;
|
||||
import systems.brn.server_storage.blockentities.StorageBlockEntity;
|
||||
import systems.brn.server_storage.blocks.StorageBlock;
|
||||
import systems.brn.server_storage.items.StorageBlockItem;
|
||||
@ -13,6 +16,9 @@ public class ServerStorage implements ModInitializer {
|
||||
public static StorageBlock STORAGE_BLOCK;
|
||||
public static BlockEntityType<StorageBlockEntity> STORAGE_BLOCK_ENTITY;
|
||||
|
||||
public static final GameRules.Key<GameRules.BooleanRule> ServerStorage_Crafting_Enable =
|
||||
GameRuleRegistry.register("enableserverstoragecrafting", GameRules.Category.MISC, GameRuleFactory.createBooleanRule(false));
|
||||
|
||||
@Override
|
||||
public void onInitialize()
|
||||
{
|
||||
|
@ -95,6 +95,8 @@ public class CraftingScreen extends PagedGui {
|
||||
return true; //stop
|
||||
}
|
||||
|
||||
ArrayList<ItemStack> stacksToRemove = new ArrayList<>();
|
||||
|
||||
// Check and remove ingredients
|
||||
for (Ingredient ingredient : recipeEntry.value().getIngredients()) {
|
||||
ItemStack stackToRemove = findMatchingStack(ingredient);
|
||||
@ -106,10 +108,14 @@ public class CraftingScreen extends PagedGui {
|
||||
if (requiredCount > 0 && canRemoveCount(stackToRemove, this.storageScreen.getPlayer().getInventory()) < requiredCount) {
|
||||
return true;
|
||||
} else {
|
||||
removeItems(stackToRemove, requiredCount);
|
||||
stacksToRemove.add(stackToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack stack : stacksToRemove) {
|
||||
removeItems(stack);
|
||||
}
|
||||
|
||||
// Add the result to the appropriate inventory
|
||||
ItemStack outputStack = recipeEntry.value().getResult(storageScreen.getPlayer().getRegistryManager());
|
||||
if (toPlayerInventory) {
|
||||
@ -132,7 +138,7 @@ public class CraftingScreen extends PagedGui {
|
||||
if (stackToRemove == null){
|
||||
return false;
|
||||
}
|
||||
removeItems(stackToRemove, stackToRemove.getCount());
|
||||
removeItems(stackToRemove);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -161,11 +167,9 @@ public class CraftingScreen extends PagedGui {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void removeItems(ItemStack stack, int count) {
|
||||
private void removeItems(ItemStack stack) {
|
||||
// Logic to remove items from the storage
|
||||
ItemStack stackRemove = stack.copy();
|
||||
stackRemove.setCount(count);
|
||||
ItemStack fromPlayer = this.storageScreen.blockEntity.chests.removeItemStack(stackRemove);
|
||||
ItemStack fromPlayer = this.storageScreen.blockEntity.chests.removeItemStack(stack);
|
||||
if (fromPlayer != null && fromPlayer.getCount() > 0) {
|
||||
Inventory playerInventory = player.getInventory();
|
||||
for (int i = 0; i < playerInventory.size(); i++) {
|
||||
|
@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import systems.brn.server_storage.blockentities.StorageBlockEntity;
|
||||
import systems.brn.server_storage.lib.PagedGui;
|
||||
|
||||
import static systems.brn.server_storage.ServerStorage.ServerStorage_Crafting_Enable;
|
||||
import static systems.brn.server_storage.lib.StorageOperations.*;
|
||||
import static systems.brn.server_storage.lib.Util.addCountToLore;
|
||||
import static systems.brn.server_storage.lib.Util.removeCountFromLore;
|
||||
@ -183,6 +184,9 @@ public class StorageScreen extends PagedGui {
|
||||
|
||||
@Override
|
||||
protected DisplayElement crafting() {
|
||||
if (!this.getPlayer().getWorld().getGameRules().getBoolean(ServerStorage_Crafting_Enable)){
|
||||
return DisplayElement.filler();
|
||||
}
|
||||
return DisplayElement.of(
|
||||
new GuiElementBuilder(Items.PLAYER_HEAD)
|
||||
.setName(Text.translatable("container.crafting").formatted(Formatting.WHITE))
|
||||
|
Loading…
Reference in New Issue
Block a user