Skip to content

Commit

Permalink
调整 Mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Apr 13, 2024
1 parent 22845f9 commit 8296dd0
Show file tree
Hide file tree
Showing 53 changed files with 668 additions and 512 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.tterrag.registrate.util.nullness.NonNullFunction;
import com.tterrag.registrate.util.nullness.NonNullSupplier;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.dubhe.anvilcraft.util.FormattingUtil;
import dev.dubhe.anvilcraft.util.IFormattingUtil;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.CreativeModeTab;
Expand Down Expand Up @@ -42,7 +42,7 @@ public static AnvilCraftRegistrate create(String modId) {
String name,
NonNullFunction<Item.Properties, T> factory
) {
return super.item(name, factory).lang(FormattingUtil.toEnglishName(name.replaceAll("/.", "_")));
return super.item(name, factory).lang(IFormattingUtil.toEnglishName(name.replaceAll("/.", "_")));
}

private RegistryEntry<CreativeModeTab> currentTab;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.tterrag.registrate.providers.RegistrateLangProvider;
import dev.dubhe.anvilcraft.AnvilCraft;
import dev.dubhe.anvilcraft.config.AnvilCraftConfig;
import dev.dubhe.anvilcraft.util.FormattingUtil;
import dev.dubhe.anvilcraft.util.IFormattingUtil;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -36,7 +36,7 @@ private static void readConfigClass(
if (field.isAnnotationPresent(SerializedName.class)) {
name = field.getAnnotation(SerializedName.class).value();
} else {
name = FormattingUtil.toEnglishName(FormattingUtil.toLowerCaseUnder(fieldName));
name = IFormattingUtil.toEnglishName(IFormattingUtil.toLowerCaseUnder(fieldName));
}
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, fieldName), name);
if (field.isAnnotationPresent(Comment.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasBlockIngredient;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasItem;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasItemIngredient;
import dev.dubhe.anvilcraft.util.IItemStackInjector;
import dev.dubhe.anvilcraft.util.IItemStackUtil;
import lombok.Getter;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementRewards;
Expand Down Expand Up @@ -138,7 +138,7 @@ public enum Serializer implements RecipeSerializer<AnvilRecipe> {
public @NotNull AnvilRecipe fromJson(@NotNull ResourceLocation recipeId, @NotNull JsonObject serializedRecipe) {
ItemStack icon = ItemStack.EMPTY;
if (serializedRecipe.has("icon")) {
icon = IItemStackInjector.fromJson(serializedRecipe.get("icon"));
icon = IItemStackUtil.fromJson(serializedRecipe.get("icon"));
}
AnvilRecipe recipe = new AnvilRecipe(recipeId, icon);
JsonArray predicates = GsonHelper.getAsJsonArray(serializedRecipe, "predicates");
Expand Down Expand Up @@ -677,12 +677,11 @@ static class Result implements FinishedRecipe {
}

@Override
@SuppressWarnings("UnreachableCode")
public void serializeRecipeData(@NotNull JsonObject json) {
if (!this.group.isEmpty()) {
json.addProperty("group", this.group);
}
json.add("icon", ((IItemStackInjector) (Object) this.icon).anvilcraft$toJson());
json.add("icon", IItemStackUtil.toJson(this.icon));
JsonArray predicates = new JsonArray();
for (RecipePredicate predicate : this.predicates) {
predicates.add(predicate.toJson());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import dev.dubhe.anvilcraft.AnvilCraft;
import dev.dubhe.anvilcraft.data.recipe.anvil.AnvilCraftingContainer;
import dev.dubhe.anvilcraft.data.recipe.anvil.RecipeOutcome;
import dev.dubhe.anvilcraft.util.IBlockStateInjector;
import dev.dubhe.anvilcraft.util.IBlockStateUtil;
import lombok.Getter;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
Expand Down Expand Up @@ -45,7 +45,7 @@ public SetBlock(Vec3 offset, double chance, BlockState result) {
public SetBlock(@NotNull FriendlyByteBuf buffer) {
this.offset = new Vec3(buffer.readVector3f());
this.chance = buffer.readDouble();
this.result = IBlockStateInjector.fromJson(AnvilCraft.GSON.fromJson(buffer.readUtf(), JsonElement.class));
this.result = IBlockStateUtil.fromJson(AnvilCraft.GSON.fromJson(buffer.readUtf(), JsonElement.class));
}

/**
Expand All @@ -67,7 +67,7 @@ public SetBlock(@NotNull JsonObject serializedRecipe) {
if (serializedRecipe.has("chance")) {
this.chance = GsonHelper.getAsDouble(serializedRecipe, "chance");
} else this.chance = 1.0;
this.result = IBlockStateInjector.fromJson(GsonHelper.getAsJsonObject(serializedRecipe, "result"));
this.result = IBlockStateUtil.fromJson(GsonHelper.getAsJsonObject(serializedRecipe, "result"));
}

@Override
Expand All @@ -86,7 +86,7 @@ public void toNetwork(@NotNull FriendlyByteBuf buffer) {
buffer.writeUtf(this.getType());
buffer.writeVector3f(this.offset.toVector3f());
buffer.writeDouble(this.chance);
buffer.writeUtf(((IBlockStateInjector) this.result).anvilcraft$toJson().toString());
buffer.writeUtf(IBlockStateUtil.toJson(this.result).toString());
}

@Override
Expand All @@ -98,7 +98,7 @@ public JsonElement toJson() {
object.addProperty("type", this.getType());
object.add("offset", offset);
object.addProperty("chance", this.chance);
object.add("result", ((IBlockStateInjector) this.result).anvilcraft$toJson());
object.add("result", IBlockStateUtil.toJson(this.result));
return object;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.google.gson.JsonSyntaxException;
import dev.dubhe.anvilcraft.data.recipe.anvil.AnvilCraftingContainer;
import dev.dubhe.anvilcraft.data.recipe.anvil.RecipeOutcome;
import dev.dubhe.anvilcraft.util.IItemStackInjector;
import dev.dubhe.anvilcraft.util.IItemStackUtil;
import lombok.Getter;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
Expand Down Expand Up @@ -67,7 +67,7 @@ public SpawnItem(@NotNull JsonObject serializedRecipe) {
if (serializedRecipe.has("chance")) {
this.chance = GsonHelper.getAsDouble(serializedRecipe, "chance");
} else this.chance = 1.0;
this.result = IItemStackInjector.fromJson(GsonHelper.getAsJsonObject(serializedRecipe, "result"));
this.result = IItemStackUtil.fromJson(GsonHelper.getAsJsonObject(serializedRecipe, "result"));
}

@Override
Expand Down Expand Up @@ -98,7 +98,7 @@ public JsonElement toJson() {
object.addProperty("type", this.getType());
object.add("offset", offset);
object.addProperty("chance", this.chance);
object.add("result", ((IItemStackInjector) (Object) this.result).anvilcraft$toJson());
object.add("result", IItemStackUtil.toJson(this.result));
return object;
}
}
4 changes: 2 additions & 2 deletions common/src/main/java/dev/dubhe/anvilcraft/item/GeodeItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.dubhe.anvilcraft.item;

import dev.dubhe.anvilcraft.AnvilCraft;
import dev.dubhe.anvilcraft.util.BlockHighlightUtil;
import dev.dubhe.anvilcraft.util.IBlockHighlightUtil;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.ClickEvent;
Expand Down Expand Up @@ -69,7 +69,7 @@ public GeodeItem(Properties properties) {
player.sendSystemMessage(Component.translatable(
"item.anvilcraft.geode.find", component
));
BlockHighlightUtil.highlightBlock(level, offsetPos);
IBlockHighlightUtil.highlightBlock(level, offsetPos);
break block;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import dev.dubhe.anvilcraft.init.ModBlocks;
import dev.dubhe.anvilcraft.util.IBucketPickupInjector;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
Expand All @@ -11,6 +10,7 @@
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.AbstractCauldronBlock;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
Expand All @@ -19,7 +19,7 @@
import java.util.Optional;

@Mixin(AbstractCauldronBlock.class)
abstract class AbstractCauldronBlockMixin implements IBucketPickupInjector {
public abstract class AbstractCauldronBlockMixin implements BucketPickup {
@Override
public @NotNull ItemStack pickupBlock(
@NotNull LevelAccessor level, @NotNull BlockPos pos, @NotNull BlockState state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Optional;

@Mixin(BeaconMenu.class)
public class BeaconMenuMixin {
public abstract class BeaconMenuMixin {
@Shadow
@Final
private BeaconMenu.PaymentSlot paymentSlot;
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8296dd0

Please sign in to comment.