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