Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev/1.20.1fabric' into dev/1.20.…
Browse files Browse the repository at this point in the history
…1fabric

# Conflicts:
#	src/main/java/org/hiedacamellia/mystiasizakaya/core/command/MIDebug.java
#	src/main/java/org/hiedacamellia/mystiasizakaya/core/cooking/BuildTags.java
#	src/main/java/org/hiedacamellia/mystiasizakaya/core/cooking/effects/GiveEffectFromCuisines.java
#	src/main/java/org/hiedacamellia/mystiasizakaya/core/cooking/effects/GiveEffectFromIngredients.java
#	src/main/java/org/hiedacamellia/mystiasizakaya/core/cooking/effects/GiveEffectFromTags.java
#	src/main/java/org/hiedacamellia/mystiasizakaya/core/cooking/get/GetRawsFromSelectedFood.java
  • Loading branch information
Yuqi154 committed Oct 8, 2024
2 parents 1eaf030 + 0ff29ab commit eb883d0
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package org.hiedacamellia.mystiasizakaya.core.command;

import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.hiedacamellia.mystiasizakaya.core.event.MIPlayerEvent;

@Mod.EventBusSubscriber

public class Currency {
@SubscribeEvent
public static void registerCommand(RegisterCommandsEvent event) {
event.getDispatcher().register(Commands.literal("mystiasizakaya").then(Commands.literal("currency")
.requires(s -> s.hasPermission(3)).then(Commands.literal("add")
.then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", IntegerArgumentType.integer(0)).executes(arguments -> {
ServerPlayer player = EntityArgument.getPlayer(arguments, "player");
int change = IntegerArgumentType.getInteger(arguments, "number");
MIPlayerEvent.setBalance(player, MIPlayerEvent.getBalance(player) + change);
MIPlayerEvent.addTurnover(player, "from_command", change);
MIPlayerEvent.deleteOverTurnover(player);
MIPlayerEvent.syncPlayerVariables(player);
return 0;
}))))
.then(Commands.literal("query")
.then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", IntegerArgumentType.integer(0)).executes(arguments -> {
ServerPlayer player = EntityArgument.getPlayer(arguments, "player");
int change = IntegerArgumentType.getInteger(arguments, "number");
MIPlayerEvent.setBalance(player, MIPlayerEvent.getBalance(player) - change);
MIPlayerEvent.addTurnover(player, "from_command", -change);
MIPlayerEvent.deleteOverTurnover(player);
MIPlayerEvent.syncPlayerVariables(player);
return 0;
}))))
.then(Commands.literal("set")
.then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", IntegerArgumentType.integer(0)).executes(arguments -> {
ServerPlayer player = EntityArgument.getPlayer(arguments, "player");
int set = IntegerArgumentType.getInteger(arguments, "number");
int change = (int) (set - MIPlayerEvent.getBalance(player));
MIPlayerEvent.setBalance(player, set);
MIPlayerEvent.addTurnover(player, "from_command", change);
MIPlayerEvent.deleteOverTurnover(player);
MIPlayerEvent.syncPlayerVariables(player);
return 0;
}))))));
public static void registerCommand() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(Commands.literal("mystiasizakaya").then(Commands.literal("currency")
.requires(s -> s.hasPermission(3)).then(Commands.literal("add")
.then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", IntegerArgumentType.integer(0)).executes(arguments -> {
ServerPlayer player = EntityArgument.getPlayer(arguments, "player");
int change = IntegerArgumentType.getInteger(arguments, "number");
MIPlayerEvent.setBalance(player, MIPlayerEvent.getBalance(player) + change);
MIPlayerEvent.addTurnover(player, "from_command", change);
MIPlayerEvent.deleteOverTurnover(player);
MIPlayerEvent.syncPlayerVariables(player);
return 0;
}))))
.then(Commands.literal("query")
.then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", IntegerArgumentType.integer(0)).executes(arguments -> {
ServerPlayer player = EntityArgument.getPlayer(arguments, "player");
int change = IntegerArgumentType.getInteger(arguments, "number");
MIPlayerEvent.setBalance(player, MIPlayerEvent.getBalance(player) - change);
MIPlayerEvent.addTurnover(player, "from_command", -change);
MIPlayerEvent.deleteOverTurnover(player);
MIPlayerEvent.syncPlayerVariables(player);
return 0;
}))))
.then(Commands.literal("set")
.then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("number", IntegerArgumentType.integer(0)).executes(arguments -> {
ServerPlayer player = EntityArgument.getPlayer(arguments, "player");
int set = IntegerArgumentType.getInteger(arguments, "number");
int change = (int) (set - MIPlayerEvent.getBalance(player));
MIPlayerEvent.setBalance(player, set);
MIPlayerEvent.addTurnover(player, "from_command", change);
MIPlayerEvent.deleteOverTurnover(player);
MIPlayerEvent.syncPlayerVariables(player);
return 0;
}))))));
});
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
package org.hiedacamellia.mystiasizakaya.core.command;

import com.mojang.brigadier.arguments.DoubleArgumentType;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.ChatFormatting;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.item.ItemArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
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 org.hiedacamellia.mystiasizakaya.core.debug.Debug;
import org.hiedacamellia.mystiasizakaya.core.event.MIPlayerEvent;

Expand All @@ -25,17 +26,16 @@
import java.util.Locale;
import java.util.Objects;

@Mod.EventBusSubscriber
public class MIDebug {
@SubscribeEvent
public static void registerCommand(RegisterCommandsEvent event) {
event.getDispatcher().register(Commands.literal("mystiasizakaya").then(Commands.literal("debug")

public class MIDebug {
public static void registerCommand() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(Commands.literal("mystiasizakaya").then(Commands.literal("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 = Objects.requireNonNull(BuiltInRegistries.ITEM.get(cuisines.getItem())).toString();
String order = Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(cuisines.getItem())).toString();
Player player = arguments.getSource().getPlayer();
List<String> orders_list;
if (player != null) {
Expand All @@ -59,7 +59,7 @@ public static void registerCommand(RegisterCommandsEvent event) {
}))).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 = Objects.requireNonNull(BuiltInRegistries.ITEM.get(beverages.getItem())).toString();
String order = Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(beverages.getItem())).toString();
Player player = arguments.getSource().getPlayer();
List<String> ordersbeverages_list;
if (player != null) {
Expand Down Expand Up @@ -94,8 +94,8 @@ public static void registerCommand(RegisterCommandsEvent event) {
List<String> menusBeverages =MIPlayerEvent.getMenusBeverages(player);
Component component = Component.empty().append("Menu:[ ");
for(int i=0;i<8;i++){
ItemStack cuisine = ForgeRegistries.ITEMS.getValue(new ResourceLocation((menu.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
ItemStack beverage = ForgeRegistries.ITEMS.getValue(new ResourceLocation((menusBeverages.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
ItemStack cuisine = BuiltInRegistries.ITEM.get(new ResourceLocation((menu.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
ItemStack beverage = BuiltInRegistries.ITEM.get(new ResourceLocation((menusBeverages.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
Component component1 = Component.empty().append(cuisine.getDisplayName()).append(" ").append(beverage.getDisplayName());
component = Component.empty().append(component).append(Component.literal(i+" ").withStyle(style -> style
.withColor(ChatFormatting.GREEN)
Expand All @@ -121,8 +121,8 @@ public static void registerCommand(RegisterCommandsEvent event) {
List<String> ordersBeverages =MIPlayerEvent.getOrdersBeverages(player);
Component component = Component.empty().append("Order:[ ");
for(int i=0;i<orders.size();i++){
ItemStack cuisine = ForgeRegistries.ITEMS.getValue(new ResourceLocation((orders.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
ItemStack beverage = ForgeRegistries.ITEMS.getValue(new ResourceLocation((ordersBeverages.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
ItemStack cuisine = BuiltInRegistries.ITEM.get(new ResourceLocation((orders.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
ItemStack beverage = BuiltInRegistries.ITEM.get(new ResourceLocation((ordersBeverages.get(i).toLowerCase(Locale.ENGLISH)))).getDefaultInstance();
Component component1 = Component.empty().append(cuisine.getDisplayName()).append(" ").append(beverage.getDisplayName());
component = Component.empty().append(component).append(Component.literal(i+" ").withStyle(style -> style
.withColor(ChatFormatting.GREEN)
Expand Down Expand Up @@ -164,6 +164,7 @@ public static void registerCommand(RegisterCommandsEvent event) {
return 0;
})))
)
);
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@
package org.hiedacamellia.mystiasizakaya.core.command;

import com.mojang.brigadier.arguments.BoolArgumentType;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.hiedacamellia.mystiasizakaya.core.config.ClientConfig;

@Mod.EventBusSubscriber
public class Showbalance {
@SubscribeEvent
public static void registerCommand(RegisterCommandsEvent event) {
event.getDispatcher().register(Commands.literal("mystiasizakaya").then(Commands.literal("showbalance")
public static void registerCommands() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(Commands.literal("mystiasizakaya")
.then(Commands.literal("showbalance")
.then(Commands.argument("logic", BoolArgumentType.bool())
.executes(context -> {
Level world = context.getSource().getLevel();
Entity entity = context.getSource().getEntity();

.then(Commands.argument("logic", BoolArgumentType.bool()).executes(arguments -> {
Level world = arguments.getSource().getUnsidedLevel();
Entity entity = arguments.getSource().getEntity();
if (entity == null && world instanceof ServerLevel _servLevel)
entity = FakePlayerFactory.getMinecraft(_servLevel);
if (entity == null)
return 0;
{
boolean set = BoolArgumentType.getBool(arguments, "logic");
if (entity == null && world instanceof ServerLevel _servLevel) {
entity = FakePlayerFactory.getMinecraft(_servLevel);
}
if (entity == null) {
return 0;
}

ClientConfig.SHOW_BALANCE.set(set);
{
boolean set = BoolArgumentType.getBool(context, "logic");
ClientConfig.SHOW_BALANCE.set(set);
}

}
return 0;
}))));
return 0; // 命令成功执行
}))));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.ItemStack;
import org.hiedacamellia.mystiasizakaya.MystiasIzakaya;
import org.hiedacamellia.mystiasizakaya.core.cooking.get.GetTagFromItemStacks;
import org.hiedacamellia.mystiasizakaya.core.debug.Debug;
import org.hiedacamellia.mystiasizakaya.registries.MIItem;
Expand All @@ -29,7 +28,7 @@ public static ItemStack execute(ItemStack target, ItemStack Kitchenware, List<It
try {
targettags.sort(Comparator.naturalOrder());
}catch (Exception e){
Debug.getLogger().atTrace().log("Failed to sort targettags for {}", Objects.requireNonNull(BuiltInRegistries.ITEM.get(target.getItem())));
Debug.getLogger().atTrace().log("Failed to sort targettags for {}", Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(target.getItem())));
}
//烧香!本来这是有问题的,但是改了后再回滚,它就好了
set.addAll(targettags);
Expand All @@ -39,7 +38,7 @@ public static ItemStack execute(ItemStack target, ItemStack Kitchenware, List<It

ArrayList<String> rawslist = new ArrayList<>();
for (int i = 0; i < 5; i++) {
rawslist.add(Objects.requireNonNull(BuiltInRegistries.ITEM.get(ingredients.get(i).getItem())).toString());
rawslist.add(Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(ingredients.get(i).getItem())).toString());
}
rawslist.sort(Comparator.naturalOrder());

Expand Down Expand Up @@ -79,7 +78,7 @@ public static ItemStack check(ItemStack cuisine){
Set<String> seti = new HashSet<>(List.of(tags));
for (String str : ntags) {
if (seti.contains(str)&& !Objects.equals(str, "")) {
return new ItemStack(MIItem.HEI_AN_WU_ZHI.get());
return new ItemStack(MIItem.HEI_AN_WU_ZHI);
}
}
return cuisine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void execute(LevelAccessor world, double x, double y, double z) {
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putDouble("timeleft", 0);
_blockEntity.getCustomData().putDouble("timeleft", 0);
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
Expand All @@ -23,7 +23,7 @@ public static void execute(LevelAccessor world, double x, double y, double z) {
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putBoolean("breaking", false);
_blockEntity.getCustomData().putBoolean("breaking", false);
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;


public class GiveEffectFromCuisines {
public static void execute(LevelAccessor world, ItemStack itemstack, LivingEntity entity) {
String s = BuiltInRegistries.ITEM.getKey(itemstack.getItem()).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;


import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;


import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.ItemStack;

import org.hiedacamellia.mystiasizakaya.integration.youkaihomecoming.IngredientsCompact;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

public class GetTargets {
public static List<String> getTargets(List<String> raws, ItemStack util) {
if (util.getItem() == MIItem.CUTTING_BOARD.get()) {
if (util.getItem() == MIItem.CUTTING_BOARD) {
return CuttingBoard.get(raws);
}
if (util.getItem() == MIItem.GRILL.get()) {
if (util.getItem() == MIItem.GRILL) {
return Grill.get(raws);
}
if (util.getItem() == MIItem.FRYING_PAN.get()) {
if (util.getItem() == MIItem.FRYING_PAN) {
return FryingPan.get(raws);
}
if (util.getItem() == MIItem.STEAMER.get()) {
if (util.getItem() == MIItem.STEAMER) {
return Steamer.get(raws);
}
if (util.getItem() == MIItem.BOILING_POT.get()) {
if (util.getItem() == MIItem.BOILING_POT) {
return BoilingPot.get(raws);
}
return new ArrayList<>();
Expand Down

0 comments on commit eb883d0

Please sign in to comment.