Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正代码风格问题 #425

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@
import net.minecraft.world.item.crafting.Ingredient;

public class SmithingRecipesLoader {
/**
* 初始化
*
* @param provider 提供器
*/
public static void init(RegistrateRecipeProvider provider) {
SmithingTransformRecipeBuilder
.smithing(
Ingredient.of(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE),
Ingredient.of(ModItems.ANVIL_HAMMER),
Ingredient.of(ModBlocks.ROYAL_STEEL_BLOCK),
RecipeCategory.TOOLS,
ModItems.ROYAL_ANVIL_HAMMER.asItem()
).unlocks(
AnvilCraftDatagen.hasItem(ModItems.ANVIL_HAMMER),
AnvilCraftDatagen.has(ModItems.ANVIL_HAMMER)
).unlocks(
AnvilCraftDatagen.hasItem(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE),
AnvilCraftDatagen.has(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE)
).save(
provider,
new ResourceLocation("anvilcraft", "anvil_hammer_upgrade")
);
.smithing(
Ingredient.of(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE),
Ingredient.of(ModItems.ANVIL_HAMMER),
Ingredient.of(ModBlocks.ROYAL_STEEL_BLOCK),
RecipeCategory.TOOLS,
ModItems.ROYAL_ANVIL_HAMMER.asItem()
)
.unlocks(
AnvilCraftDatagen.hasItem(ModItems.ANVIL_HAMMER),
AnvilCraftDatagen.has(ModItems.ANVIL_HAMMER)
)
.unlocks(
AnvilCraftDatagen.hasItem(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE),
AnvilCraftDatagen.has(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE)
)
.save(
provider,
new ResourceLocation("anvilcraft", "anvil_hammer_upgrade")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class FinishedMobTransformRecipe implements FinishedRecipe {
private final Advancement.Builder advancement;
private final ResourceLocation advancementId;

/**
* 生物转化配方
*/
public FinishedMobTransformRecipe(
MobTransformRecipe recipe,
Advancement.Builder advancement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class MobTransformContainer implements Container {
private final Entity entity;
private final RandomSource random;

/**
* 生物转化容器
*/
public MobTransformContainer(Level level, BlockPos pos, Entity entity) {
this.level = level;
this.random = this.level.getRandom();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class MobTransformRecipe implements Recipe<MobTransformContainer> {
private List<TransformResult> results;
private final ItemStack iconSrc;

/**
* 生物转化配方
*/
public MobTransformRecipe(
ResourceLocation id,
ItemStack iconSrc,
Expand Down Expand Up @@ -79,6 +82,9 @@ public boolean matches(@NotNull MobTransformContainer container, @NotNull Level
return ItemStack.EMPTY;
}

/**
* 结果
*/
public EntityType<?> result(RandomSource randomSource) {
if (results.size() == 1) return results.get(0).resultEntityType();
List<TransformResult> sorted = new ArrayList<>(results.stream()
Expand Down Expand Up @@ -207,13 +213,19 @@ public Builder icon(ItemStack iconSrc) {
return this;
}

/**
* 构造
*/
public MobTransformRecipe build() {
MobTransformRecipe r = new MobTransformRecipe(id, iconSrc);
r.inputEntityType = inputEntityType;
r.results = results;
return r;
}

/**
* 完成
*/
public FinishedMobTransformRecipe finish() {
this.advancement
.parent(ROOT_RECIPE_ADVANCEMENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ public AnvilCraftRecipeJs icon(OutputItem outputItem) {
RecipeKey<OutputItem> ICON =
ItemComponents.OUTPUT.key("icon").optional(OutputItem.of(ModItems.ROYAL_STEEL_NUGGET));

RecipeSchema SCHEMA = new RecipeSchema(AnvilCraftRecipeJs.class, AnvilCraftRecipeJs::new, OUTCOMES, PREDICATES, ICON)
.constructor(((recipe, schemaType, keys, from) -> recipe.id(from.getValue(recipe, ID))), ID);
RecipeSchema SCHEMA = new RecipeSchema(
AnvilCraftRecipeJs.class, AnvilCraftRecipeJs::new, OUTCOMES, PREDICATES, ICON
).constructor(((recipe, schemaType, keys, from) -> recipe.id(from.getValue(recipe, ID))), ID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ public SelectOneBuilder spawnItem(Vec3 offset, double chance, ItemStack result)
return addOutcome(spawnItem);
}

/**
* KubeJS
*/
public SelectOne build() {
SelectOne selectOne = new SelectOne();
outcomes.forEach(selectOne::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public JsonElement write(RecipeJS recipe, ResourceLocation value) {

@Override
public ResourceLocation read(RecipeJS recipe, Object from) {
return from instanceof CharSequence c ? ResourceLocation.tryParse(c.toString()) : ResourceLocation.tryParse(String.valueOf(from));
return from instanceof CharSequence c
? ResourceLocation.tryParse(c.toString())
: ResourceLocation.tryParse(String.valueOf(from));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class RoyalUpgradeTemplateItem extends SmithingTemplateItem {
"item/empty_slot_block"
);

/**
* @param properties 物品属性
*/
public RoyalUpgradeTemplateItem(@SuppressWarnings("unused") Properties properties) {
super(APPLIES_TO,
UPGRADE_INGREDIENTS,
Expand Down
Loading