diff --git a/src/main/java/net/touhou/mystiasizakaya/block/CookingRangeBlock.java b/src/main/java/net/touhou/mystiasizakaya/block/CookingRangeBlock.java index 4ecabfbc..801016a2 100644 --- a/src/main/java/net/touhou/mystiasizakaya/block/CookingRangeBlock.java +++ b/src/main/java/net/touhou/mystiasizakaya/block/CookingRangeBlock.java @@ -4,7 +4,7 @@ import net.touhou.mystiasizakaya.world.inventory.CookingRangeUiMenu; import net.touhou.mystiasizakaya.procedures.ReProcedure; import net.touhou.mystiasizakaya.cooking.Main; -import net.touhou.mystiasizakaya.procedures.InitialCookProcedure; +import net.touhou.mystiasizakaya.cooking.Init; import net.touhou.mystiasizakaya.procedures.CleanProcedure; import net.touhou.mystiasizakaya.block.entity.CookingRangeBlockEntity; @@ -100,7 +100,7 @@ public List getDrops(BlockState state, LootParams.Builder builder) { public void onPlace(BlockState blockstate, Level world, BlockPos pos, BlockState oldState, boolean moving) { super.onPlace(blockstate, world, pos, oldState, moving); world.scheduleTick(pos, this, 1); - InitialCookProcedure.execute(world, pos.getX(), pos.getY(), pos.getZ()); + Init.execute(world, pos.getX(), pos.getY(), pos.getZ()); } @Override diff --git a/src/main/java/net/touhou/mystiasizakaya/client/screens/BalanceOverlay.java b/src/main/java/net/touhou/mystiasizakaya/client/screens/BalanceOverlay.java index cd9c7fc3..ff3e9a97 100644 --- a/src/main/java/net/touhou/mystiasizakaya/client/screens/BalanceOverlay.java +++ b/src/main/java/net/touhou/mystiasizakaya/client/screens/BalanceOverlay.java @@ -1,8 +1,8 @@ package net.touhou.mystiasizakaya.client.screens; +import net.touhou.mystiasizakaya.network.Variables; import net.touhou.mystiasizakaya.procedures.ShowbalanceLProcedure; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -23,8 +23,8 @@ public static void eventHandler(RenderGuiEvent.Pre event) { Player entity = Minecraft.getInstance().player; String text = Component.translatable("gui.mystias_izakaya.balance").getString() + "" + new java.text.DecimalFormat("#######") - .format((entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null) - .orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance) + .format((entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null) + .orElse(new Variables.PlayerVariables())).balance) + "\u5186"; int strlength = Minecraft.getInstance().font.width(text); diff --git a/src/main/java/net/touhou/mystiasizakaya/client/screens/OrdersOverlay.java b/src/main/java/net/touhou/mystiasizakaya/client/screens/OrdersOverlay.java index f30a4ff3..2cc9acb3 100644 --- a/src/main/java/net/touhou/mystiasizakaya/client/screens/OrdersOverlay.java +++ b/src/main/java/net/touhou/mystiasizakaya/client/screens/OrdersOverlay.java @@ -1,10 +1,8 @@ package net.touhou.mystiasizakaya.client.screens; -import org.checkerframework.checker.units.qual.h; - -import net.touhou.mystiasizakaya.procedures.GetCuisinesTextureProcedure; -import net.touhou.mystiasizakaya.procedures.GetBeveragesTextureProcedure; +import net.touhou.mystiasizakaya.orders.GetCuisinesTexture; +import net.touhou.mystiasizakaya.orders.GetBeveragesTexture; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -15,7 +13,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.entity.player.Player; import net.minecraft.resources.ResourceLocation; -import net.minecraft.network.chat.Component; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.Minecraft; @@ -51,8 +48,8 @@ public static void eventHandler(RenderGuiEvent.Pre event) { String fmb = ""; int reali = 0; for (int i = 0; i < 7; i++) { - fm = GetCuisinesTextureProcedure.execute(i); - fmb = GetBeveragesTextureProcedure.execute(i); + fm = GetCuisinesTexture.execute(i, entity); + fmb = GetBeveragesTexture.execute(i, entity); if (fm != "" || fmb != "") { event.getGuiGraphics().blit(new ResourceLocation("mystias_izakaya:textures/screens/page.png"), diff --git a/src/main/java/net/touhou/mystiasizakaya/command/Addcurrency.java b/src/main/java/net/touhou/mystiasizakaya/command/Addcurrency.java new file mode 100644 index 00000000..e90a7c24 --- /dev/null +++ b/src/main/java/net/touhou/mystiasizakaya/command/Addcurrency.java @@ -0,0 +1,95 @@ + +package net.touhou.mystiasizakaya.command; + +import net.touhou.mystiasizakaya.command.sub.Set; +import net.touhou.mystiasizakaya.command.sub.Add; +import net.touhou.mystiasizakaya.command.sub.Qurey; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.event.RegisterCommandsEvent; + +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.commands.Commands; + +import java.util.HashMap; + +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.arguments.DoubleArgumentType; + +@Mod.EventBusSubscriber +public class Addcurrency { + @SubscribeEvent + public static void registerCommand(RegisterCommandsEvent event) { + event.getDispatcher().register(Commands.literal("mi_currency").requires(s -> s.hasPermission(3)).then(Commands.literal("add") + .then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", DoubleArgumentType.doubleArg(0)).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> { + HashMap cmdparams = new HashMap<>(); + int index = -1; + for (String param : arguments.getInput().split("\\s+")) { + if (index >= 0) + cmdparams.put(Integer.toString(index), param); + index++; + } + + Add.execute(arguments); + return 0; + })).executes(arguments -> { + HashMap cmdparams = new HashMap<>(); + int index = -1; + for (String param : arguments.getInput().split("\\s+")) { + if (index >= 0) + cmdparams.put(Integer.toString(index), param); + index++; + } + Add.execute(arguments); + return 0; + })))).then(Commands.literal("query") + .then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", DoubleArgumentType.doubleArg(0)).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> { + HashMap cmdparams = new HashMap<>(); + int index = -1; + for (String param : arguments.getInput().split("\\s+")) { + if (index >= 0) + cmdparams.put(Integer.toString(index), param); + index++; + } + + Qurey.execute(arguments); + return 0; + })).executes(arguments -> { + HashMap cmdparams = new HashMap<>(); + int index = -1; + for (String param : arguments.getInput().split("\\s+")) { + if (index >= 0) + cmdparams.put(Integer.toString(index), param); + index++; + } + + Qurey.execute(arguments); + return 0; + })))) + .then(Commands.literal("set") + .then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", DoubleArgumentType.doubleArg(0)).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> { + HashMap cmdparams = new HashMap<>(); + int index = -1; + for (String param : arguments.getInput().split("\\s+")) { + if (index >= 0) + cmdparams.put(Integer.toString(index), param); + index++; + } + + Set.execute(arguments); + return 0; + })).executes(arguments -> { + HashMap cmdparams = new HashMap<>(); + int index = -1; + for (String param : arguments.getInput().split("\\s+")) { + if (index >= 0) + cmdparams.put(Integer.toString(index), param); + index++; + } + + Set.execute(arguments); + return 0; + }))))); + } +} diff --git a/src/main/java/net/touhou/mystiasizakaya/command/AddcurrencycommandCommand.java b/src/main/java/net/touhou/mystiasizakaya/command/AddcurrencycommandCommand.java deleted file mode 100644 index f66933d2..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/command/AddcurrencycommandCommand.java +++ /dev/null @@ -1,163 +0,0 @@ - -package net.touhou.mystiasizakaya.command; - -import org.checkerframework.checker.units.qual.s; - -import net.touhou.mystiasizakaya.procedures.CommandPSProcedure; -import net.touhou.mystiasizakaya.procedures.CommandPProcedure; -import net.touhou.mystiasizakaya.procedures.CommandPMProcedure; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.common.util.FakePlayerFactory; - -import net.minecraft.world.level.Level; -import net.minecraft.world.entity.Entity; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.core.Direction; -import net.minecraft.commands.arguments.EntityArgument; -import net.minecraft.commands.Commands; - -import java.util.HashMap; - -import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.arguments.DoubleArgumentType; - -@Mod.EventBusSubscriber -public class AddcurrencycommandCommand { - @SubscribeEvent - public static void registerCommand(RegisterCommandsEvent event) { - event.getDispatcher().register(Commands.literal("mi_currency").requires(s -> s.hasPermission(3)).then(Commands.literal("add") - .then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", DoubleArgumentType.doubleArg(0)).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - HashMap cmdparams = new HashMap<>(); - int index = -1; - for (String param : arguments.getInput().split("\\s+")) { - if (index >= 0) - cmdparams.put(Integer.toString(index), param); - index++; - } - - CommandPProcedure.execute(arguments); - return 0; - })).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - HashMap cmdparams = new HashMap<>(); - int index = -1; - for (String param : arguments.getInput().split("\\s+")) { - if (index >= 0) - cmdparams.put(Integer.toString(index), param); - index++; - } - - CommandPProcedure.execute(arguments); - return 0; - })))).then(Commands.literal("query") - .then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", DoubleArgumentType.doubleArg(0)).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - HashMap cmdparams = new HashMap<>(); - int index = -1; - for (String param : arguments.getInput().split("\\s+")) { - if (index >= 0) - cmdparams.put(Integer.toString(index), param); - index++; - } - - CommandPMProcedure.execute(arguments); - return 0; - })).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - HashMap cmdparams = new HashMap<>(); - int index = -1; - for (String param : arguments.getInput().split("\\s+")) { - if (index >= 0) - cmdparams.put(Integer.toString(index), param); - index++; - } - - CommandPMProcedure.execute(arguments); - return 0; - })))) - .then(Commands.literal("set") - .then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", DoubleArgumentType.doubleArg(0)).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - HashMap cmdparams = new HashMap<>(); - int index = -1; - for (String param : arguments.getInput().split("\\s+")) { - if (index >= 0) - cmdparams.put(Integer.toString(index), param); - index++; - } - - CommandPSProcedure.execute(arguments); - return 0; - })).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - HashMap cmdparams = new HashMap<>(); - int index = -1; - for (String param : arguments.getInput().split("\\s+")) { - if (index >= 0) - cmdparams.put(Integer.toString(index), param); - index++; - } - - CommandPSProcedure.execute(arguments); - return 0; - }))))); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/command/CommandTESTCommand.java b/src/main/java/net/touhou/mystiasizakaya/command/CommandTESTCommand.java deleted file mode 100644 index 6dc4af65..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/command/CommandTESTCommand.java +++ /dev/null @@ -1,88 +0,0 @@ - -package net.touhou.mystiasizakaya.command; - -import net.touhou.mystiasizakaya.procedures.CommandDebug4Procedure; -import net.touhou.mystiasizakaya.procedures.CommandDebug3Procedure; -import net.touhou.mystiasizakaya.procedures.CommandDebug2Procedure; -import net.touhou.mystiasizakaya.procedures.CommandDebug1Procedure; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.common.util.FakePlayerFactory; - -import net.minecraft.world.level.Level; -import net.minecraft.world.entity.Entity; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.core.Direction; -import net.minecraft.commands.arguments.item.ItemArgument; -import net.minecraft.commands.Commands; - -import com.mojang.brigadier.arguments.DoubleArgumentType; - -@Mod.EventBusSubscriber -public class CommandTESTCommand { - @SubscribeEvent - public static void registerCommand(RegisterCommandsEvent event) { - event.getDispatcher().register(Commands.literal("mi_debug") - - .then(Commands.literal("orders").then( - Commands.argument("id", DoubleArgumentType.doubleArg()).then(Commands.literal("cuisines").then(Commands.literal("replace").then(Commands.argument("cuisines", ItemArgument.item(event.getBuildContext())).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - - CommandDebug1Procedure.execute(arguments); - return 0; - }))).then(Commands.literal("clean").executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - - CommandDebug2Procedure.execute(arguments); - return 0; - }))).then(Commands.literal("beverages").then(Commands.literal("replace").then(Commands.argument("beverages", ItemArgument.item(event.getBuildContext())).executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - - CommandDebug3Procedure.execute(arguments); - return 0; - }))).then(Commands.literal("clean").executes(arguments -> { - Level world = arguments.getSource().getUnsidedLevel(); - double x = arguments.getSource().getPosition().x(); - double y = arguments.getSource().getPosition().y(); - double z = arguments.getSource().getPosition().z(); - Entity entity = arguments.getSource().getEntity(); - if (entity == null && world instanceof ServerLevel _servLevel) - entity = FakePlayerFactory.getMinecraft(_servLevel); - Direction direction = Direction.DOWN; - if (entity != null) - direction = entity.getDirection(); - - CommandDebug4Procedure.execute(arguments); - return 0; - })))))); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/command/Debug.java b/src/main/java/net/touhou/mystiasizakaya/command/Debug.java new file mode 100644 index 00000000..4101e9d9 --- /dev/null +++ b/src/main/java/net/touhou/mystiasizakaya/command/Debug.java @@ -0,0 +1,70 @@ + +package net.touhou.mystiasizakaya.command; + +import com.mojang.brigadier.arguments.DoubleArgumentType; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.item.ItemArgument; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.event.RegisterCommandsEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.registries.ForgeRegistries; +import net.touhou.mystiasizakaya.network.Variables; + +import java.util.List; + +@Mod.EventBusSubscriber +public class Debug { + @SubscribeEvent + public static void registerCommand(RegisterCommandsEvent event) { + event.getDispatcher().register(Commands.literal("mi_debug") + + .then(Commands.literal("orders").then( + Commands.argument("id", DoubleArgumentType.doubleArg()).then(Commands.literal("cuisines").then(Commands.literal("replace").then(Commands.argument("cuisines", ItemArgument.item(event.getBuildContext())).executes(arguments -> { + int id = (int) DoubleArgumentType.getDouble(arguments, "id"); + ItemStack cuisines = ItemArgument.getItem(arguments, "cuisines").getItem().getDefaultInstance(); + String order = ForgeRegistries.ITEMS.getKey(cuisines.getItem()).toString(); + Player player = arguments.getSource().getPlayer(); + List orders_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables()).orders; + orders_list.set(id, order); + player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + capability.orders = orders_list; + capability.syncPlayerVariables(player); + }); + return 0; + }))).then(Commands.literal("clean").executes(arguments -> { + int id = (int) DoubleArgumentType.getDouble(arguments, "id"); + Player player = arguments.getSource().getPlayer(); + List orders_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables()).orders; + orders_list.set(id, ""); + player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + capability.orders = orders_list; + capability.syncPlayerVariables(player); + }); + return 0; + }))).then(Commands.literal("beverages").then(Commands.literal("replace").then(Commands.argument("beverages", ItemArgument.item(event.getBuildContext())).executes(arguments -> { + int id = (int) DoubleArgumentType.getDouble(arguments, "id"); + ItemStack beverages = ItemArgument.getItem(arguments, "beverages").getItem().getDefaultInstance(); + String order = ForgeRegistries.ITEMS.getKey(beverages.getItem()).toString(); + Player player = arguments.getSource().getPlayer(); + List ordersbeverages_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables()).ordersbeverages; + ordersbeverages_list.set(id, order); + player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + capability.ordersbeverages = ordersbeverages_list; + capability.syncPlayerVariables(player); + }); + return 0; + }))).then(Commands.literal("clean").executes(arguments -> { + int id = (int) DoubleArgumentType.getDouble(arguments, "id"); + Player player = arguments.getSource().getPlayer(); + List ordersbeverages_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables()).ordersbeverages; + ordersbeverages_list.set(id, ""); + player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + capability.ordersbeverages = ordersbeverages_list; + capability.syncPlayerVariables(player); + }); + return 0; + })))))); + } +} diff --git a/src/main/java/net/touhou/mystiasizakaya/command/ShowbalanceCCommand.java b/src/main/java/net/touhou/mystiasizakaya/command/Showbalance.java similarity index 98% rename from src/main/java/net/touhou/mystiasizakaya/command/ShowbalanceCCommand.java rename to src/main/java/net/touhou/mystiasizakaya/command/Showbalance.java index 229eed2e..97d8c411 100644 --- a/src/main/java/net/touhou/mystiasizakaya/command/ShowbalanceCCommand.java +++ b/src/main/java/net/touhou/mystiasizakaya/command/Showbalance.java @@ -20,7 +20,7 @@ import com.mojang.brigadier.arguments.BoolArgumentType; @Mod.EventBusSubscriber -public class ShowbalanceCCommand { +public class Showbalance { @SubscribeEvent public static void registerCommand(RegisterCommandsEvent event) { event.getDispatcher().register(Commands.literal("mi_showbalance") diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandPProcedure.java b/src/main/java/net/touhou/mystiasizakaya/command/sub/Add.java similarity index 71% rename from src/main/java/net/touhou/mystiasizakaya/procedures/CommandPProcedure.java rename to src/main/java/net/touhou/mystiasizakaya/command/sub/Add.java index 7becb442..cc90715d 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandPProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/command/sub/Add.java @@ -1,6 +1,6 @@ -package net.touhou.mystiasizakaya.procedures; +package net.touhou.mystiasizakaya.command.sub; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.entity.Entity; import net.minecraft.commands.arguments.EntityArgument; @@ -10,7 +10,7 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.arguments.DoubleArgumentType; -public class CommandPProcedure { +public class Add { public static void execute(CommandContext arguments) { { double _setval = ((new Object() { @@ -22,7 +22,7 @@ public Entity getEntity() { return null; } } - }.getEntity()).getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance + DoubleArgumentType.getDouble(arguments, "number"); + }.getEntity()).getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance + DoubleArgumentType.getDouble(arguments, "number"); (new Object() { public Entity getEntity() { try { @@ -32,7 +32,7 @@ public Entity getEntity() { return null; } } - }.getEntity()).getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + }.getEntity()).getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables((new Object() { public Entity getEntity() { diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandPMProcedure.java b/src/main/java/net/touhou/mystiasizakaya/command/sub/Qurey.java similarity index 71% rename from src/main/java/net/touhou/mystiasizakaya/procedures/CommandPMProcedure.java rename to src/main/java/net/touhou/mystiasizakaya/command/sub/Qurey.java index 8b229914..a435d2c9 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandPMProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/command/sub/Qurey.java @@ -1,6 +1,6 @@ -package net.touhou.mystiasizakaya.procedures; +package net.touhou.mystiasizakaya.command.sub; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.entity.Entity; import net.minecraft.commands.arguments.EntityArgument; @@ -10,7 +10,7 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.arguments.DoubleArgumentType; -public class CommandPMProcedure { +public class Qurey { public static void execute(CommandContext arguments) { { double _setval = ((new Object() { @@ -22,7 +22,7 @@ public Entity getEntity() { return null; } } - }.getEntity()).getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance - DoubleArgumentType.getDouble(arguments, "number"); + }.getEntity()).getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance - DoubleArgumentType.getDouble(arguments, "number"); (new Object() { public Entity getEntity() { try { @@ -32,7 +32,7 @@ public Entity getEntity() { return null; } } - }.getEntity()).getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + }.getEntity()).getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables((new Object() { public Entity getEntity() { diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandPSProcedure.java b/src/main/java/net/touhou/mystiasizakaya/command/sub/Set.java similarity index 79% rename from src/main/java/net/touhou/mystiasizakaya/procedures/CommandPSProcedure.java rename to src/main/java/net/touhou/mystiasizakaya/command/sub/Set.java index 4acd17cb..392a5999 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandPSProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/command/sub/Set.java @@ -1,6 +1,6 @@ -package net.touhou.mystiasizakaya.procedures; +package net.touhou.mystiasizakaya.command.sub; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.entity.Entity; import net.minecraft.commands.arguments.EntityArgument; @@ -10,7 +10,7 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.arguments.DoubleArgumentType; -public class CommandPSProcedure { +public class Set { public static void execute(CommandContext arguments) { { double _setval = DoubleArgumentType.getDouble(arguments, "number"); @@ -23,7 +23,7 @@ public Entity getEntity() { return null; } } - }.getEntity()).getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + }.getEntity()).getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables((new Object() { public Entity getEntity() { diff --git a/src/main/java/net/touhou/mystiasizakaya/cooking/Confirm.java b/src/main/java/net/touhou/mystiasizakaya/cooking/Confirm.java index 1aa5935a..3f8a46cb 100644 --- a/src/main/java/net/touhou/mystiasizakaya/cooking/Confirm.java +++ b/src/main/java/net/touhou/mystiasizakaya/cooking/Confirm.java @@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.core.BlockPos; -import net.touhou.mystiasizakaya.procedures.GetKitchenwareTagProcedure; +import net.touhou.mystiasizakaya.cooking.get.GetKitchenwareTag; import net.touhou.mystiasizakaya.cooking.get.GetTagFromItemStacks; import net.touhou.mystiasizakaya.cooking.get.GetTargetNagetivetags; import net.touhou.mystiasizakaya.cooking.get.GetTargetTags; @@ -66,7 +66,7 @@ public static void execute(LevelAccessor world, double x, double y, double z) { && resultList.contains("tag.mystias_izakaya.Refreshing")) { resultList.remove("tag.mystias_izakaya.Refreshing"); } - resultList.add(GetKitchenwareTagProcedure.execute(Kitchenware)); + resultList.add(GetKitchenwareTag.execute(Kitchenware)); String resultString = String.join(",", resultList); Set seti = new HashSet<>(resultList); for (String str : targetntags) { diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/InitialCookProcedure.java b/src/main/java/net/touhou/mystiasizakaya/cooking/Init.java similarity index 92% rename from src/main/java/net/touhou/mystiasizakaya/procedures/InitialCookProcedure.java rename to src/main/java/net/touhou/mystiasizakaya/cooking/Init.java index 4f0c04ce..5de6926b 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/InitialCookProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/cooking/Init.java @@ -1,4 +1,4 @@ -package net.touhou.mystiasizakaya.procedures; +package net.touhou.mystiasizakaya.cooking; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.entity.BlockEntity; @@ -6,7 +6,7 @@ import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; -public class InitialCookProcedure { +public class Init { public static void execute(LevelAccessor world, double x, double y, double z) { double time = 0; if (!world.isClientSide()) { diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/GetKitchenwareTagProcedure.java b/src/main/java/net/touhou/mystiasizakaya/cooking/get/GetKitchenwareTag.java similarity index 90% rename from src/main/java/net/touhou/mystiasizakaya/procedures/GetKitchenwareTagProcedure.java rename to src/main/java/net/touhou/mystiasizakaya/cooking/get/GetKitchenwareTag.java index 085d8471..2cfad69a 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/GetKitchenwareTagProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/cooking/get/GetKitchenwareTag.java @@ -1,10 +1,10 @@ -package net.touhou.mystiasizakaya.procedures; +package net.touhou.mystiasizakaya.cooking.get; import net.touhou.mystiasizakaya.init.MystiasIzakayaModItems; import net.minecraft.world.item.ItemStack; -public class GetKitchenwareTagProcedure { +public class GetKitchenwareTag { public static String execute(ItemStack Kitchenware) { ItemStack util = ItemStack.EMPTY; String tag = ""; diff --git a/src/main/java/net/touhou/mystiasizakaya/item/currency/En10Item.java b/src/main/java/net/touhou/mystiasizakaya/item/currency/En10Item.java index abea1f2e..5d6ce048 100644 --- a/src/main/java/net/touhou/mystiasizakaya/item/currency/En10Item.java +++ b/src/main/java/net/touhou/mystiasizakaya/item/currency/En10Item.java @@ -1,7 +1,7 @@ package net.touhou.mystiasizakaya.item.currency; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.level.Level; import net.minecraft.world.item.UseAnim; @@ -46,8 +46,8 @@ public void appendHoverText(ItemStack itemstack, Level world, List li @Override public InteractionResultHolder use(Level world, Player entity, InteractionHand hand) { InteractionResultHolder ar = super.use(world, entity, hand); - double _setval = 10 * ar.getObject().getCount() + (entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance; - entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + double _setval = 10 * ar.getObject().getCount() + (entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance; + entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables(entity); }); diff --git a/src/main/java/net/touhou/mystiasizakaya/item/currency/En10kItem.java b/src/main/java/net/touhou/mystiasizakaya/item/currency/En10kItem.java index 6c19e967..c21e6387 100644 --- a/src/main/java/net/touhou/mystiasizakaya/item/currency/En10kItem.java +++ b/src/main/java/net/touhou/mystiasizakaya/item/currency/En10kItem.java @@ -1,7 +1,7 @@ package net.touhou.mystiasizakaya.item.currency; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.level.Level; import net.minecraft.world.item.UseAnim; @@ -46,8 +46,8 @@ public void appendHoverText(ItemStack itemstack, Level world, List li @Override public InteractionResultHolder use(Level world, Player entity, InteractionHand hand) { InteractionResultHolder ar = super.use(world, entity, hand); - double _setval = 10000 * ar.getObject().getCount() + (entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance; - entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + double _setval = 10000 * ar.getObject().getCount() + (entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance; + entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables(entity); }); diff --git a/src/main/java/net/touhou/mystiasizakaya/item/currency/En1Item.java b/src/main/java/net/touhou/mystiasizakaya/item/currency/En1Item.java index bea882ab..1d556c73 100644 --- a/src/main/java/net/touhou/mystiasizakaya/item/currency/En1Item.java +++ b/src/main/java/net/touhou/mystiasizakaya/item/currency/En1Item.java @@ -1,7 +1,7 @@ package net.touhou.mystiasizakaya.item.currency; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.level.Level; import net.minecraft.world.item.UseAnim; @@ -46,8 +46,8 @@ public void appendHoverText(ItemStack itemstack, Level world, List li @Override public InteractionResultHolder use(Level world, Player entity, InteractionHand hand) { InteractionResultHolder ar = super.use(world, entity, hand); - double _setval = ar.getObject().getCount() + (entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance; - entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + double _setval = ar.getObject().getCount() + (entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance; + entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables(entity); }); diff --git a/src/main/java/net/touhou/mystiasizakaya/item/currency/En5Item.java b/src/main/java/net/touhou/mystiasizakaya/item/currency/En5Item.java index 25e3cf4b..34824937 100644 --- a/src/main/java/net/touhou/mystiasizakaya/item/currency/En5Item.java +++ b/src/main/java/net/touhou/mystiasizakaya/item/currency/En5Item.java @@ -1,7 +1,7 @@ package net.touhou.mystiasizakaya.item.currency; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.level.Level; import net.minecraft.world.item.UseAnim; @@ -46,8 +46,8 @@ public void appendHoverText(ItemStack itemstack, Level world, List li @Override public InteractionResultHolder use(Level world, Player entity, InteractionHand hand) { InteractionResultHolder ar = super.use(world, entity, hand); - double _setval = 5 * ar.getObject().getCount() + (entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance; - entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + double _setval = 5 * ar.getObject().getCount() + (entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance; + entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables(entity); }); diff --git a/src/main/java/net/touhou/mystiasizakaya/network/MystiasIzakayaModVariables.java b/src/main/java/net/touhou/mystiasizakaya/network/Variables.java similarity index 88% rename from src/main/java/net/touhou/mystiasizakaya/network/MystiasIzakayaModVariables.java rename to src/main/java/net/touhou/mystiasizakaya/network/Variables.java index 4911ab6b..32d16e51 100644 --- a/src/main/java/net/touhou/mystiasizakaya/network/MystiasIzakayaModVariables.java +++ b/src/main/java/net/touhou/mystiasizakaya/network/Variables.java @@ -32,7 +32,7 @@ import java.util.ArrayList; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) -public class MystiasIzakayaModVariables { +public class Variables { public static List orders = new ArrayList<>(); public static List ordersbeverages = new ArrayList<>(); @@ -73,6 +73,8 @@ public static void clonePlayer(PlayerEvent.Clone event) { PlayerVariables clone = ((PlayerVariables) event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())); clone.balance = original.balance; clone.showbalance = original.showbalance; + clone.orders = original.orders; + clone.ordersbeverages = original.ordersbeverages; if (!event.isWasDeath()) { } } @@ -111,6 +113,8 @@ public void deserializeNBT(Tag nbt) { public static class PlayerVariables { public double balance = 0; public boolean showbalance = true; + public List orders = new ArrayList<>(); + public List ordersbeverages = new ArrayList<>(); public void syncPlayerVariables(Entity entity) { if (entity instanceof ServerPlayer serverPlayer) @@ -121,6 +125,10 @@ public Tag writeNBT() { CompoundTag nbt = new CompoundTag(); nbt.putDouble("balance", balance); nbt.putBoolean("showbalance", showbalance); + String orders_string = String.join(",", orders); + String ordersbeverages_string = String.join(",", ordersbeverages); + nbt.putString("orders", orders_string); + nbt.putString("ordersbeverages", ordersbeverages_string); return nbt; } @@ -128,6 +136,10 @@ public void readNBT(Tag Tag) { CompoundTag nbt = (CompoundTag) Tag; balance = nbt.getDouble("balance"); showbalance = nbt.getBoolean("showbalance"); + String orders_string = nbt.getString("orders"); + String ordersbeverages_string = nbt.getString("ordersbeverages"); + orders = new ArrayList<>(List.of(orders_string.split(","))); + ordersbeverages = new ArrayList<>(List.of(ordersbeverages_string.split(","))); } } @@ -154,6 +166,8 @@ public static void handler(PlayerVariablesSyncMessage message, Supplier orders_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables()).ordersbeverages; + if(orders_list.size()<=id) return ""; + String order = orders_list.get((int) id); + TagKey tag = ItemTags.create(new ResourceLocation("mystiasizakaya:beverages")); + if (!new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(order))).is(tag)) { + return ""; + } + return GetTextureProcedure.get(order); + } +} diff --git a/src/main/java/net/touhou/mystiasizakaya/orders/GetCuisinesTexture.java b/src/main/java/net/touhou/mystiasizakaya/orders/GetCuisinesTexture.java new file mode 100644 index 00000000..f05562f5 --- /dev/null +++ b/src/main/java/net/touhou/mystiasizakaya/orders/GetCuisinesTexture.java @@ -0,0 +1,29 @@ +package net.touhou.mystiasizakaya.orders; + +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraftforge.registries.ForgeRegistries; +import net.touhou.mystiasizakaya.network.Variables; +import net.touhou.mystiasizakaya.network.Variables.PlayerVariables; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.tags.ItemTags; +import net.minecraft.resources.ResourceLocation; +import net.touhou.mystiasizakaya.procedures.GetTextureProcedure; + +import java.util.List; + +public class GetCuisinesTexture { + public static String execute(double id, Player player) { + Initorders.init(player); + List orders_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).orders; + if(orders_list.size()<=id) return ""; + String order = orders_list.get((int) id); + TagKey tag = ItemTags.create(new ResourceLocation("mystiasizakaya:cuisines")); + if (!new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(order))).is(tag)) { + return ""; + } + return GetTextureProcedure.get(order); + } +} diff --git a/src/main/java/net/touhou/mystiasizakaya/orders/Initorders.java b/src/main/java/net/touhou/mystiasizakaya/orders/Initorders.java new file mode 100644 index 00000000..837b0b5f --- /dev/null +++ b/src/main/java/net/touhou/mystiasizakaya/orders/Initorders.java @@ -0,0 +1,30 @@ +package net.touhou.mystiasizakaya.orders; + +import net.minecraft.world.entity.player.Player; +import net.touhou.mystiasizakaya.network.Variables; + +import net.minecraft.world.item.ItemStack; + +import java.util.List; + +public class Initorders { + public static void init(Player player) { + List orders_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables()).orders; + List ordersbeverages_list = player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables()).ordersbeverages; + if (orders_list.size() == 0) { + for (int i = 0; i < 10; i++) { + orders_list.add(""); + } + } + if (ordersbeverages_list.size() == 0) { + for (int i = 0; i < 10; i++) { + ordersbeverages_list.add(""); + } + } + player.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + capability.orders = orders_list; + capability.ordersbeverages = ordersbeverages_list; + capability.syncPlayerVariables(player); + }); + } +} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/AddordersProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/AddordersProcedure.java index 1f128f7b..1b559f33 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/AddordersProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/procedures/AddordersProcedure.java @@ -1,12 +1,12 @@ package net.touhou.mystiasizakaya.procedures; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.item.ItemStack; public class AddordersProcedure { public static void execute(ItemStack beverages, ItemStack cuisines, double id) { - MystiasIzakayaModVariables.orders.set((int) id, cuisines); - MystiasIzakayaModVariables.ordersbeverages.set((int) id, beverages); + Variables.orders.set((int) id, cuisines); + Variables.ordersbeverages.set((int) id, beverages); } } diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/BankPProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/BankPProcedure.java index 59a5e60d..ba79e61a 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/BankPProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/procedures/BankPProcedure.java @@ -1,8 +1,7 @@ package net.touhou.mystiasizakaya.procedures; -import org.checkerframework.checker.units.qual.s; +import net.touhou.mystiasizakaya.network.Variables; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; import net.touhou.mystiasizakaya.init.MystiasIzakayaModItems; import net.minecraftforge.items.ItemHandlerHelper; @@ -29,10 +28,10 @@ public static void execute(Entity entity, HashMap guistate) { return 0; } }.convert(guistate.containsKey("text:input") ? ((EditBox) guistate.get("text:input")).getValue() : ""); - if (!(i < 0) && (entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance >= i) { + if (!(i < 0) && (entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance >= i) { { - double _setval = (entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).balance - i; - entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + double _setval = (entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).balance - i; + entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.balance = _setval; capability.syncPlayerVariables(entity); }); diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug1Procedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug1Procedure.java deleted file mode 100644 index b0be5cf2..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug1Procedure.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.touhou.mystiasizakaya.procedures; - -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; - -import net.minecraft.commands.arguments.item.ItemArgument; -import net.minecraft.commands.CommandSourceStack; - -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.arguments.DoubleArgumentType; - -public class CommandDebug1Procedure { - public static void execute(CommandContext arguments) { - MystiasIzakayaModVariables.orders.set((int) DoubleArgumentType.getDouble(arguments, "id"), (ItemArgument.getItem(arguments, "cuisines").getItem().getDefaultInstance())); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug2Procedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug2Procedure.java deleted file mode 100644 index 41ddcba6..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug2Procedure.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.touhou.mystiasizakaya.procedures; - -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.commands.CommandSourceStack; - -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.arguments.DoubleArgumentType; - -public class CommandDebug2Procedure { - public static void execute(CommandContext arguments) { - MystiasIzakayaModVariables.orders.set((int) DoubleArgumentType.getDouble(arguments, "id"), ItemStack.EMPTY); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug3Procedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug3Procedure.java deleted file mode 100644 index 02c218d3..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug3Procedure.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.touhou.mystiasizakaya.procedures; - -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; - -import net.minecraft.commands.arguments.item.ItemArgument; -import net.minecraft.commands.CommandSourceStack; - -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.arguments.DoubleArgumentType; - -public class CommandDebug3Procedure { - public static void execute(CommandContext arguments) { - MystiasIzakayaModVariables.ordersbeverages.set((int) DoubleArgumentType.getDouble(arguments, "id"), (ItemArgument.getItem(arguments, "beverages").getItem().getDefaultInstance())); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug4Procedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug4Procedure.java deleted file mode 100644 index 90e23ab3..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/CommandDebug4Procedure.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.touhou.mystiasizakaya.procedures; - -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.commands.CommandSourceStack; - -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.arguments.DoubleArgumentType; - -public class CommandDebug4Procedure { - public static void execute(CommandContext arguments) { - MystiasIzakayaModVariables.ordersbeverages.set((int) DoubleArgumentType.getDouble(arguments, "id"), ItemStack.EMPTY); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/DeleteordersProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/DeleteordersProcedure.java index 7585beff..cef4fb88 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/DeleteordersProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/procedures/DeleteordersProcedure.java @@ -1,12 +1,12 @@ package net.touhou.mystiasizakaya.procedures; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.item.ItemStack; public class DeleteordersProcedure { public static void execute(double id) { - MystiasIzakayaModVariables.orders.set((int) id, ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.set((int) id, ItemStack.EMPTY); + Variables.orders.set((int) id, ItemStack.EMPTY); + Variables.ordersbeverages.set((int) id, ItemStack.EMPTY); } } diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/GetBeveragesTextureProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/GetBeveragesTextureProcedure.java deleted file mode 100644 index 2940c029..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/GetBeveragesTextureProcedure.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.touhou.mystiasizakaya.procedures; - -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.tags.ItemTags; -import net.minecraft.resources.ResourceLocation; - -public class GetBeveragesTextureProcedure { - public static String execute(double id) { - ItemStack i = ItemStack.EMPTY; - ItemStack target = ItemStack.EMPTY; - String fm = ""; - InitordersProcedure.execute(); - target = (MystiasIzakayaModVariables.ordersbeverages.get((int) id) instanceof ItemStack _bs ? _bs : ItemStack.EMPTY); - if (!target.is(ItemTags.create(new ResourceLocation("mystiasizakaya:beverages")))) { - return ""; - } - return GetTextureProcedure.execute(target); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/GetCuisinesTextureProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/GetCuisinesTextureProcedure.java deleted file mode 100644 index f130e544..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/GetCuisinesTextureProcedure.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.touhou.mystiasizakaya.procedures; - -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.tags.ItemTags; -import net.minecraft.resources.ResourceLocation; - -public class GetCuisinesTextureProcedure { - public static String execute(double id) { - ItemStack i = ItemStack.EMPTY; - ItemStack target = ItemStack.EMPTY; - String fm = ""; - InitordersProcedure.execute(); - target = (MystiasIzakayaModVariables.orders.get((int) id) instanceof ItemStack _bs ? _bs : ItemStack.EMPTY); - if (!target.is(ItemTags.create(new ResourceLocation("mystiasizakaya:cuisines")))) { - return ""; - } - return GetTextureProcedure.execute(target); - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/GetTextureProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/GetTextureProcedure.java index 3f1927e0..4b88aa02 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/GetTextureProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/procedures/GetTextureProcedure.java @@ -19,4 +19,12 @@ public static String execute(ItemStack itemstack) { fm += "_"; return fm; } + public static String get(String Reg) { + String fm = ""; + fm = Reg; + fm = fm.split(":")[1]; + fm += "_"; + return fm; + } + } diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/InitordersProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/InitordersProcedure.java deleted file mode 100644 index 20bfbbba..00000000 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/InitordersProcedure.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.touhou.mystiasizakaya.procedures; - -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; - -import net.minecraft.world.item.ItemStack; - -public class InitordersProcedure { - public static void execute() { - if (MystiasIzakayaModVariables.orders.isEmpty()) { - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.orders.add(ItemStack.EMPTY); - } - if (MystiasIzakayaModVariables.ordersbeverages.isEmpty()) { - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - MystiasIzakayaModVariables.ordersbeverages.add(ItemStack.EMPTY); - } - } -} diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalanceLProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalanceLProcedure.java index f1fb15f4..a2bc9f3e 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalanceLProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalanceLProcedure.java @@ -1,6 +1,6 @@ package net.touhou.mystiasizakaya.procedures; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.entity.Entity; @@ -8,6 +8,6 @@ public class ShowbalanceLProcedure { public static boolean execute(Entity entity) { if (entity == null) return false; - return (entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new MystiasIzakayaModVariables.PlayerVariables())).showbalance; + return (entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new Variables.PlayerVariables())).showbalance; } } diff --git a/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalancePProcedure.java b/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalancePProcedure.java index 1b731201..024505e0 100644 --- a/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalancePProcedure.java +++ b/src/main/java/net/touhou/mystiasizakaya/procedures/ShowbalancePProcedure.java @@ -1,6 +1,6 @@ package net.touhou.mystiasizakaya.procedures; -import net.touhou.mystiasizakaya.network.MystiasIzakayaModVariables; +import net.touhou.mystiasizakaya.network.Variables; import net.minecraft.world.entity.Entity; import net.minecraft.commands.CommandSourceStack; @@ -14,7 +14,7 @@ public static void execute(CommandContext arguments, Entity return; { boolean _setval = BoolArgumentType.getBool(arguments, "logic"); - entity.getCapability(MystiasIzakayaModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + entity.getCapability(Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.showbalance = _setval; capability.syncPlayerVariables(entity); });