From 1505b37e2c62bf343562f76986026c4f5c613590 Mon Sep 17 00:00:00 2001 From: Gugle Date: Tue, 30 Apr 2024 03:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dubhe/anvilcraft/api/power/PowerGrid.java | 18 ++-- .../block/BasePowerConverterBlock.java | 3 + .../entity/PowerConverterBlockEntity.java | 5 +- .../recipe/TimeWarpRecipesLoader.java | 3 + .../event/PistonMoveBlockListener.java | 6 +- .../dubhe/anvilcraft/init/ModItemGroups.java | 4 +- .../dev/dubhe/anvilcraft/init/ModItems.java | 88 +++++++++---------- .../PowerGridInformationRenderMixin.java | 5 +- .../api/energy/fabric/EnergyHelperImpl.java | 8 +- .../api/energy/fabric/EnergyInsert.java | 3 + .../api/energy/forge/EnergyHelperImpl.java | 6 +- .../PistonStructorResolverAccessor.java | 3 + 12 files changed, 94 insertions(+), 58 deletions(-) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java index 3eaed3d83..91836854b 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java @@ -346,13 +346,16 @@ public static class SimplePowerGrid { private final Map mappedPowerComponentInfo = new HashMap<>(); + /** + * 简单电网 + */ public SimplePowerGrid( - int hash, - String level, - BlockPos pos, - List powerComponentInfoList, - int generate, - int consume + int hash, + String level, + BlockPos pos, + @NotNull List powerComponentInfoList, + int generate, + int consume ) { this.pos = pos; this.level = level; @@ -471,6 +474,9 @@ public VoxelShape getShape() { return pos.subtract(this.pos); } + /** + * 寻找电网 + */ public static List findPowerGrid(BlockPos pos) { return PowerGridRenderer.getGrids() .values().stream() diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/BasePowerConverterBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/BasePowerConverterBlock.java index 796a839f9..f9a3c97ee 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/BasePowerConverterBlock.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/BasePowerConverterBlock.java @@ -33,6 +33,9 @@ public abstract class BasePowerConverterBlock extends BaseEntityBlock { public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final BooleanProperty OVERLOAD = IPowerComponent.OVERLOAD; + /** + * 基本电源转换器模块 + */ public BasePowerConverterBlock(Properties properties, int inputPower) { super(properties); registerDefaultState(stateDefinition.any() diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/PowerConverterBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/PowerConverterBlockEntity.java index 6b0322d13..184446f83 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/PowerConverterBlockEntity.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/PowerConverterBlockEntity.java @@ -47,8 +47,11 @@ public void load(CompoundTag tag) { inputPower = tag.getInt("InputPower"); } + /** + * tick + */ public void tick() { - flushState(getLevel(), getBlockPos()); + if (this.level != null) flushState(this.level, getBlockPos()); if (getBlockState().getValue(BasePowerConverterBlock.OVERLOAD)) return; int amount = (int) (inputPower * 60 * (1 - AnvilCraft.config.powerLoss)); Direction face = getBlockState().getValue(BasePowerConverterBlock.FACING); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/TimeWarpRecipesLoader.java b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/TimeWarpRecipesLoader.java index db24925d3..7549732ca 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/TimeWarpRecipesLoader.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/TimeWarpRecipesLoader.java @@ -78,6 +78,9 @@ public static void timeWarpWithWater(ItemLike item, ItemLike item1, RegistrateRe .save(provider, AnvilCraft.of("timewarp/" + BuiltInRegistries.ITEM.getKey(item1.asItem()).getPath())); } + /** + * 需要熔融宝石的时移配方 + */ public static void timeWarpWithMeltGem(ItemLike item, ItemLike item1, RegistrateRecipeProvider provider) { AnvilRecipe.Builder.create(RecipeCategory.MISC) .icon(item1) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java b/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java index e8b14a64b..94554f9ea 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java @@ -8,13 +8,17 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; +import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.List; import java.util.Map; public class PistonMoveBlockListener { - public static void onPistonMoveBlocks(Level level, List blocks) { + /** + * 活塞移动方块 + */ + public static void onPistonMoveBlocks(@NotNull Level level, @NotNull List blocks) { RandomSource random = level.random; for (BlockPos pos : blocks) { if (!level.getBlockState(pos).is(ModBlocks.MAGNET_BLOCK.get())) continue; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java index b3f3f1b51..28924c063 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java @@ -59,9 +59,9 @@ public class ModItemGroups { entries.accept(ModItems.TUNGSTEN_INGOT.get().getDefaultInstance()); entries.accept(ModItems.TUNGSTEN_NUGGET.get().getDefaultInstance()); entries.accept(ModItems.BRONZE_INGOT.get().getDefaultInstance()); -// entries.accept(ModItems.BRONZE_NUGGET.get().getDefaultInstance()); + // entries.accept(ModItems.BRONZE_NUGGET.get().getDefaultInstance()); entries.accept(ModItems.BRASS_INGOT.get().getDefaultInstance()); -// entries.accept(ModItems.BRASS_NUGGET.get().getDefaultInstance()); + // entries.accept(ModItems.BRASS_NUGGET.get().getDefaultInstance()); entries.accept(ModItems.TOPAZ.get().getDefaultInstance()); entries.accept(ModItems.RUBY.get().getDefaultInstance()); entries.accept(ModItems.SAPPHIRE.get().getDefaultInstance()); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java index 15a449335..11d861ee8 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java @@ -768,14 +768,14 @@ public class ModItems { .tag(ModItemTags.BRONZE_INGOTS, ModItemTags.BRONZE_INGOTS_FORGE) .recipe((ctx, provider) -> { ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get()) - .requires(Ingredient.of(ModItemTags.BRONZE_NUGGETS),9) + .requires(Ingredient.of(ModItemTags.BRONZE_NUGGETS), 9) .unlockedBy( AnvilCraftDatagen.hasItem(ModItemTags.BRONZE_NUGGETS), AnvilCraftDatagen.has(ModItemTags.BRONZE_NUGGETS) ) .save(provider); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get()) - .requires(Ingredient.of(ModItemTags.BRONZE_NUGGETS_FORGE),9) + .requires(Ingredient.of(ModItemTags.BRONZE_NUGGETS_FORGE), 9) .unlockedBy( AnvilCraftDatagen.hasItem(ModItemTags.BRONZE_NUGGETS_FORGE), AnvilCraftDatagen.has(ModItemTags.BRONZE_NUGGETS_FORGE) @@ -824,40 +824,40 @@ public class ModItems { }) .register(); -// public static final ItemEntry BRONZE_NUGGET = REGISTRATE -// .item("bronze_nugget", Item::new) -// .tag(ModItemTags.BRONZE_NUGGETS, ModItemTags.BRONZE_NUGGETS_FORGE) -// .recipe((ctx, provider) -> { -// ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) -// .requires(ModItemTags.BRONZE_INGOTS) -// .unlockedBy( -// AnvilCraftDatagen.hasItem(ModItemTags.BRONZE_INGOTS), -// AnvilCraftDatagen.has(ModItemTags.BRONZE_INGOTS) -// ) -// .save(provider); -// ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) -// .requires(ModItemTags.BRONZE_INGOTS_FORGE) -// .unlockedBy( -// AnvilCraftDatagen.hasItem(ModItemTags.BRONZE_INGOTS_FORGE), -// AnvilCraftDatagen.has(ModItemTags.BRONZE_INGOTS_FORGE) -// ) -// .save(provider, BuiltInRegistries.ITEM.getKey(ctx.get()).getPath() + "_forge"); -// }) -// .register(); + // public static final ItemEntry BRONZE_NUGGET = REGISTRATE + // .item("bronze_nugget", Item::new) + // .tag(ModItemTags.BRONZE_NUGGETS, ModItemTags.BRONZE_NUGGETS_FORGE) + // .recipe((ctx, provider) -> { + // ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) + // .requires(ModItemTags.BRONZE_INGOTS) + // .unlockedBy( + // AnvilCraftDatagen.hasItem(ModItemTags.BRONZE_INGOTS), + // AnvilCraftDatagen.has(ModItemTags.BRONZE_INGOTS) + // ) + // .save(provider); + // ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) + // .requires(ModItemTags.BRONZE_INGOTS_FORGE) + // .unlockedBy( + // AnvilCraftDatagen.hasItem(ModItemTags.BRONZE_INGOTS_FORGE), + // AnvilCraftDatagen.has(ModItemTags.BRONZE_INGOTS_FORGE) + // ) + // .save(provider, BuiltInRegistries.ITEM.getKey(ctx.get()).getPath() + "_forge"); + // }) + // .register(); public static final ItemEntry BRASS_INGOT = REGISTRATE .item("brass_ingot", Item::new) .tag(ModItemTags.BRASS_INGOTS, ModItemTags.BRASS_INGOTS_FORGE) .recipe((ctx, provider) -> { ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get()) - .requires(Ingredient.of(ModItemTags.BRASS_NUGGETS),9) + .requires(Ingredient.of(ModItemTags.BRASS_NUGGETS), 9) .unlockedBy( AnvilCraftDatagen.hasItem(ModItemTags.BRASS_NUGGETS), AnvilCraftDatagen.has(ModItemTags.BRASS_NUGGETS) ) .save(provider); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get()) - .requires(Ingredient.of(ModItemTags.BRASS_NUGGETS_FORGE),9) + .requires(Ingredient.of(ModItemTags.BRASS_NUGGETS_FORGE), 9) .unlockedBy( AnvilCraftDatagen.hasItem(ModItemTags.BRASS_NUGGETS_FORGE), AnvilCraftDatagen.has(ModItemTags.BRASS_NUGGETS_FORGE) @@ -906,26 +906,26 @@ public class ModItems { }) .register(); -// public static final ItemEntry BRASS_NUGGET = REGISTRATE -// .item("brass_nugget", Item::new) -// .tag(ModItemTags.BRASS_NUGGETS, ModItemTags.BRASS_NUGGETS_FORGE) -// .recipe((ctx, provider) -> { -// ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) -// .requires(ModItemTags.BRASS_INGOTS) -// .unlockedBy( -// AnvilCraftDatagen.hasItem(ModItemTags.BRASS_INGOTS), -// AnvilCraftDatagen.has(ModItemTags.BRASS_INGOTS) -// ) -// .save(provider); -// ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) -// .requires(ModItemTags.BRASS_INGOTS_FORGE) -// .unlockedBy( -// AnvilCraftDatagen.hasItem(ModItemTags.BRASS_INGOTS_FORGE), -// AnvilCraftDatagen.has(ModItemTags.BRASS_INGOTS_FORGE) -// ) -// .save(provider, BuiltInRegistries.ITEM.getKey(ctx.get()).getPath() + "_forge"); -// }) -// .register(); + // public static final ItemEntry BRASS_NUGGET = REGISTRATE + // .item("brass_nugget", Item::new) + // .tag(ModItemTags.BRASS_NUGGETS, ModItemTags.BRASS_NUGGETS_FORGE) + // .recipe((ctx, provider) -> { + // ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) + // .requires(ModItemTags.BRASS_INGOTS) + // .unlockedBy( + // AnvilCraftDatagen.hasItem(ModItemTags.BRASS_INGOTS), + // AnvilCraftDatagen.has(ModItemTags.BRASS_INGOTS) + // ) + // .save(provider); + // ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9) + // .requires(ModItemTags.BRASS_INGOTS_FORGE) + // .unlockedBy( + // AnvilCraftDatagen.hasItem(ModItemTags.BRASS_INGOTS_FORGE), + // AnvilCraftDatagen.has(ModItemTags.BRASS_INGOTS_FORGE) + // ) + // .save(provider, BuiltInRegistries.ITEM.getKey(ctx.get()).getPath() + "_forge"); + // }) + // .register(); public static final ItemEntry AMULET_BOX = REGISTRATE diff --git a/common/src/main/java/dev/dubhe/anvilcraft/mixin/PowerGridInformationRenderMixin.java b/common/src/main/java/dev/dubhe/anvilcraft/mixin/PowerGridInformationRenderMixin.java index 2660e1e14..11efa7250 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/mixin/PowerGridInformationRenderMixin.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/mixin/PowerGridInformationRenderMixin.java @@ -25,6 +25,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; +import org.jetbrains.annotations.NotNull; import org.joml.Vector2ic; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -152,7 +153,9 @@ void onHudRender(GuiGraphics guiGraphics, float partialTick, CallbackInfo ci) { } @Unique - private static void anvilCraft$renderInfo(GuiGraphics thiz, Font font, ItemStack itemStack, List lines, int x, int y) { + private static void anvilCraft$renderInfo( + GuiGraphics thiz, Font font, ItemStack itemStack, @NotNull List lines, int x, int y + ) { ClientTooltipPositioner tooltipPositioner = DefaultTooltipPositioner.INSTANCE; List components = lines.stream() .map(Component::getVisualOrderText) diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyHelperImpl.java b/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyHelperImpl.java index ae39b91df..832c89464 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyHelperImpl.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyHelperImpl.java @@ -1,16 +1,20 @@ package dev.dubhe.anvilcraft.api.energy.fabric; +import dev.dubhe.anvilcraft.AnvilCraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.Level; public class EnergyHelperImpl { + /** + * 插入能量 + */ public static void insertEnergy(Level level, BlockPos pos, Direction direction, int amount) { try { Class.forName("team.reborn.energy.api.EnergyStorage"); EnergyInsert.insertEnergy(level, pos, direction, amount); - } catch (ClassNotFoundException ignore) { - + } catch (ClassNotFoundException exception) { + AnvilCraft.LOGGER.debug(exception.getMessage()); } } } diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyInsert.java b/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyInsert.java index ade6ed17b..ef8776fe5 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyInsert.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/api/energy/fabric/EnergyInsert.java @@ -7,6 +7,9 @@ import team.reborn.energy.api.EnergyStorage; public class EnergyInsert { + /** + * 能量插入 + */ @SuppressWarnings("UnstableApiUsage") public static void insertEnergy(Level level, BlockPos pos, Direction direction, int amount) { EnergyStorage maybeStorage = EnergyStorage.SIDED.find(level, pos, direction); diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/api/energy/forge/EnergyHelperImpl.java b/forge/src/main/java/dev/dubhe/anvilcraft/api/energy/forge/EnergyHelperImpl.java index 3a4c3f4d1..a333aabab 100644 --- a/forge/src/main/java/dev/dubhe/anvilcraft/api/energy/forge/EnergyHelperImpl.java +++ b/forge/src/main/java/dev/dubhe/anvilcraft/api/energy/forge/EnergyHelperImpl.java @@ -7,9 +7,13 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; +import org.jetbrains.annotations.NotNull; public class EnergyHelperImpl { - public static void insertEnergy(Level level, BlockPos pos, Direction direction, int amount) { + /** + * 插入能量 + */ + public static void insertEnergy(@NotNull Level level, BlockPos pos, Direction direction, int amount) { BlockEntity blockEntity = level.getBlockEntity(pos); if (blockEntity != null) { LazyOptional capability = blockEntity.getCapability(ForgeCapabilities.ENERGY, direction); diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/accessor/PistonStructorResolverAccessor.java b/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/accessor/PistonStructorResolverAccessor.java index 53819cd90..590839c14 100644 --- a/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/accessor/PistonStructorResolverAccessor.java +++ b/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/accessor/PistonStructorResolverAccessor.java @@ -8,6 +8,9 @@ import java.util.List; +/** + * Mixin + */ @Mixin(PistonStructureResolver.class) public interface PistonStructorResolverAccessor { @Accessor