Skip to content

Commit

Permalink
Merge pull request #494 from Gu-ZT/releases/1.20.1
Browse files Browse the repository at this point in the history
修复代码风格问题
  • Loading branch information
Gu-ZT authored Apr 29, 2024
2 parents 7b055f9 + 1505b37 commit 9cdfae8
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 58 deletions.
18 changes: 12 additions & 6 deletions common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,16 @@ public static class SimplePowerGrid {

private final Map<BlockPos, PowerComponentInfo> mappedPowerComponentInfo = new HashMap<>();

/**
* 简单电网
*/
public SimplePowerGrid(
int hash,
String level,
BlockPos pos,
List<PowerComponentInfo> powerComponentInfoList,
int generate,
int consume
int hash,
String level,
BlockPos pos,
@NotNull List<PowerComponentInfo> powerComponentInfoList,
int generate,
int consume
) {
this.pos = pos;
this.level = level;
Expand Down Expand Up @@ -471,6 +474,9 @@ public VoxelShape getShape() {
return pos.subtract(this.pos);
}

/**
* 寻找电网
*/
public static List<SimplePowerGrid> findPowerGrid(BlockPos pos) {
return PowerGridRenderer.getGrids()
.values().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockPos> blocks) {
/**
* 活塞移动方块
*/
public static void onPistonMoveBlocks(@NotNull Level level, @NotNull List<BlockPos> blocks) {
RandomSource random = level.random;
for (BlockPos pos : blocks) {
if (!level.getBlockState(pos).is(ModBlocks.MAGNET_BLOCK.get())) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
88 changes: 44 additions & 44 deletions common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -824,40 +824,40 @@ public class ModItems {
})
.register();

// public static final ItemEntry<Item> 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<Item> 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<Item> 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)
Expand Down Expand Up @@ -906,26 +906,26 @@ public class ModItems {
})
.register();

// public static final ItemEntry<Item> 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<Item> 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<Item> AMULET_BOX = REGISTRATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Component> lines, int x, int y) {
private static void anvilCraft$renderInfo(
GuiGraphics thiz, Font font, ItemStack itemStack, @NotNull List<Component> lines, int x, int y
) {
ClientTooltipPositioner tooltipPositioner = DefaultTooltipPositioner.INSTANCE;
List<ClientTooltipComponent> components = lines.stream()
.map(Component::getVisualOrderText)
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEnergyStorage> capability = blockEntity.getCapability(ForgeCapabilities.ENERGY, direction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import java.util.List;

/**
* Mixin
*/
@Mixin(PistonStructureResolver.class)
public interface PistonStructorResolverAccessor {
@Accessor
Expand Down

0 comments on commit 9cdfae8

Please sign in to comment.