Changed Aeternium crafts
This commit is contained in:
parent
2a2641eea3
commit
22b10fe134
15 changed files with 576 additions and 360 deletions
|
@ -15,6 +15,7 @@ import ru.betterend.recipe.CraftingRecipes;
|
||||||
import ru.betterend.recipe.FurnaceRecipes;
|
import ru.betterend.recipe.FurnaceRecipes;
|
||||||
import ru.betterend.recipe.InfusionRecipes;
|
import ru.betterend.recipe.InfusionRecipes;
|
||||||
import ru.betterend.recipe.SmithingRecipes;
|
import ru.betterend.recipe.SmithingRecipes;
|
||||||
|
import ru.betterend.recipe.AnvilRecipes;
|
||||||
import ru.betterend.registry.EndBiomes;
|
import ru.betterend.registry.EndBiomes;
|
||||||
import ru.betterend.registry.EndBlockEntities;
|
import ru.betterend.registry.EndBlockEntities;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -51,6 +52,7 @@ public class BetterEnd implements ModInitializer {
|
||||||
CraftingRecipes.register();
|
CraftingRecipes.register();
|
||||||
FurnaceRecipes.register();
|
FurnaceRecipes.register();
|
||||||
AlloyingRecipes.register();
|
AlloyingRecipes.register();
|
||||||
|
AnvilRecipes.register();
|
||||||
SmithingRecipes.register();
|
SmithingRecipes.register();
|
||||||
InfusionRecipes.register();
|
InfusionRecipes.register();
|
||||||
EndStructures.register();
|
EndStructures.register();
|
||||||
|
|
|
@ -52,8 +52,8 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
||||||
widgets.add(Widgets.createArrow(new Point(x + 24, y + 3)));
|
widgets.add(Widgets.createArrow(new Point(x + 24, y + 3)));
|
||||||
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + bounds.height - 12),
|
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + bounds.height - 12),
|
||||||
new TranslatableText("category.rei.damage.amount&dmg", display.getDamage())).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
new TranslatableText("category.rei.damage.amount&dmg", display.getDamage())).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||||
widgets.add(Widgets.createSlot(new Point(x - 20, y + 3)).entries(inputEntries.get(0)).markInput());
|
widgets.add(Widgets.createSlot(new Point(x - 20, y + 3)).entries(inputEntries.get(1)).markInput());
|
||||||
widgets.add(Widgets.createSlot(new Point(x + 1, y + 3)).entries(inputEntries.get(1)).markInput());
|
widgets.add(Widgets.createSlot(new Point(x + 1, y + 3)).entries(inputEntries.get(0)).markInput());
|
||||||
widgets.add(Widgets.createSlot(new Point(x + 61, y + 4)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
|
widgets.add(Widgets.createSlot(new Point(x + 61, y + 4)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
|
||||||
return widgets;
|
return widgets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,15 @@ import me.shedaniel.rei.server.ContainerInfo;
|
||||||
import net.minecraft.recipe.Recipe;
|
import net.minecraft.recipe.Recipe;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||||
|
|
||||||
public class REIAnvilDisplay implements TransferRecipeDisplay {
|
public class REIAnvilDisplay implements TransferRecipeDisplay {
|
||||||
|
|
||||||
private AnvilSmithingRecipe recipe;
|
private AnvilRecipe recipe;
|
||||||
private List<List<EntryStack>> input;
|
private List<List<EntryStack>> input;
|
||||||
private List<EntryStack> output;
|
private List<EntryStack> output;
|
||||||
|
|
||||||
public REIAnvilDisplay(AnvilSmithingRecipe recipe) {
|
public REIAnvilDisplay(AnvilRecipe recipe) {
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
||||||
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.recipe.BlastingRecipe;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class REIPlugin implements REIPluginV0 {
|
||||||
|
|
||||||
public final static Identifier PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
public final static Identifier PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
||||||
public final static Identifier ALLOYING = AlloyingRecipe.ID;
|
public final static Identifier ALLOYING = AlloyingRecipe.ID;
|
||||||
public final static Identifier SMITHING = AnvilSmithingRecipe.ID;
|
public final static Identifier SMITHING = AnvilRecipe.ID;
|
||||||
public final static Identifier INFUSION = InfusionRecipe.ID;
|
public final static Identifier INFUSION = InfusionRecipe.ID;
|
||||||
|
|
||||||
public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER);
|
public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER);
|
||||||
|
@ -35,7 +35,7 @@ public class REIPlugin implements REIPluginV0 {
|
||||||
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
|
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
|
||||||
recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new);
|
recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new);
|
||||||
recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new);
|
recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new);
|
||||||
recipeHelper.registerRecipes(SMITHING, AnvilSmithingRecipe.class, REIAnvilDisplay::new);
|
recipeHelper.registerRecipes(SMITHING, AnvilRecipe.class, REIAnvilDisplay::new);
|
||||||
recipeHelper.registerRecipes(INFUSION, InfusionRecipe.class, REIInfusionDisplay::new);
|
recipeHelper.registerRecipes(INFUSION, InfusionRecipe.class, REIInfusionDisplay::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,30 @@ package ru.betterend.interfaces;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||||
|
|
||||||
public interface AnvilScreenHandlerExtended {
|
public interface AnvilScreenHandlerExtended {
|
||||||
public void be_updateCurrentRecipe(AnvilSmithingRecipe recipe);
|
public void be_updateCurrentRecipe(AnvilRecipe recipe);
|
||||||
public AnvilSmithingRecipe be_getCurrentRecipe();
|
public AnvilRecipe be_getCurrentRecipe();
|
||||||
public List<AnvilSmithingRecipe> be_getRecipes();
|
public List<AnvilRecipe> be_getRecipes();
|
||||||
|
|
||||||
|
default void be_nextRecipe() {
|
||||||
|
List<AnvilRecipe> recipes = this.be_getRecipes();
|
||||||
|
AnvilRecipe current = this.be_getCurrentRecipe();
|
||||||
|
int i = recipes.indexOf(current) + 1;
|
||||||
|
if (i >= recipes.size()) {
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
this.be_updateCurrentRecipe(recipes.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
default void be_previousRecipe() {
|
||||||
|
List<AnvilRecipe> recipes = this.be_getRecipes();
|
||||||
|
AnvilRecipe current = this.be_getCurrentRecipe();
|
||||||
|
int i = recipes.indexOf(current) - 1;
|
||||||
|
if (i <= 0) {
|
||||||
|
i = recipes.size() - 1;
|
||||||
|
}
|
||||||
|
this.be_updateCurrentRecipe(recipes.get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import ru.betterend.interfaces.AnvilScreenHandlerExtended;
|
import ru.betterend.interfaces.AnvilScreenHandlerExtended;
|
||||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
|
||||||
|
|
||||||
@Mixin(AnvilScreen.class)
|
@Mixin(AnvilScreen.class)
|
||||||
public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
||||||
|
@ -34,6 +33,7 @@ public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
||||||
private TextFieldWidget nameField;
|
private TextFieldWidget nameField;
|
||||||
|
|
||||||
private List<AbstractButtonWidget> be_buttons = Lists.newArrayList();
|
private List<AbstractButtonWidget> be_buttons = Lists.newArrayList();
|
||||||
|
private AnvilScreenHandlerExtended anvilHandler;
|
||||||
|
|
||||||
public AnvilScreenMixin(AnvilScreenHandler handler, PlayerInventory playerInventory, Text title,
|
public AnvilScreenMixin(AnvilScreenHandler handler, PlayerInventory playerInventory, Text title,
|
||||||
Identifier texture) {
|
Identifier texture) {
|
||||||
|
@ -43,23 +43,22 @@ public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
||||||
@Inject(method = "setup", at = @At("TAIL"))
|
@Inject(method = "setup", at = @At("TAIL"))
|
||||||
protected void setup(CallbackInfo info) {
|
protected void setup(CallbackInfo info) {
|
||||||
this.be_buttons.clear();
|
this.be_buttons.clear();
|
||||||
int x = (this.width - this.backgroundWidth) / 2;
|
int x = (width - backgroundWidth) / 2;
|
||||||
int y = (this.height - this.backgroundHeight) / 2;
|
int y = (height - backgroundHeight) / 2;
|
||||||
|
this.anvilHandler = AnvilScreenHandlerExtended.class.cast(this.handler);
|
||||||
this.be_buttons.add(new ButtonWidget(x + 8, y + 45, 15, 20, new LiteralText("<"), (b) -> be_previousRecipe()));
|
this.be_buttons.add(new ButtonWidget(x + 8, y + 45, 15, 20, new LiteralText("<"), (b) -> be_previousRecipe()));
|
||||||
this.be_buttons.add(new ButtonWidget(x + 154, y + 45, 15, 20, new LiteralText(">"), (b) -> be_nextRecipe()));
|
this.be_buttons.add(new ButtonWidget(x + 154, y + 45, 15, 20, new LiteralText(">"), (b) -> be_nextRecipe()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderForeground", at = @At("TAIL"))
|
@Inject(method = "renderForeground", at = @At("TAIL"))
|
||||||
protected void renderForeground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
|
protected void renderForeground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
|
||||||
AnvilScreenHandlerExtended handler = AnvilScreenHandlerExtended.class.cast(this.handler);
|
if (anvilHandler.be_getRecipes().size() > 1) {
|
||||||
if (handler.be_getRecipes().size() > 1) {
|
|
||||||
this.be_buttons.forEach(button -> button.render(matrices, mouseX, mouseY, delta));
|
this.be_buttons.forEach(button -> button.render(matrices, mouseX, mouseY, delta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onSlotUpdate", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onSlotUpdate", at = @At("HEAD"), cancellable = true)
|
||||||
public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack, CallbackInfo info) {
|
public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack, CallbackInfo info) {
|
||||||
AnvilScreenHandlerExtended anvilHandler = AnvilScreenHandlerExtended.class.cast(this.handler);
|
|
||||||
if (anvilHandler.be_getCurrentRecipe() != null) {
|
if (anvilHandler.be_getCurrentRecipe() != null) {
|
||||||
this.nameField.setText("");
|
this.nameField.setText("");
|
||||||
this.nameField.setEditable(false);
|
this.nameField.setEditable(false);
|
||||||
|
@ -69,31 +68,19 @@ public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_nextRecipe() {
|
private void be_nextRecipe() {
|
||||||
AnvilScreenHandlerExtended handler = AnvilScreenHandlerExtended.class.cast(this.handler);
|
this.anvilHandler.be_nextRecipe();
|
||||||
List<AnvilSmithingRecipe> recipes = handler.be_getRecipes();
|
|
||||||
AnvilSmithingRecipe current = handler.be_getCurrentRecipe();
|
|
||||||
int i = recipes.indexOf(current) + 1;
|
|
||||||
if (i == recipes.size()) {
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
handler.be_updateCurrentRecipe(recipes.get(i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_previousRecipe() {
|
private void be_previousRecipe() {
|
||||||
AnvilScreenHandlerExtended handler = AnvilScreenHandlerExtended.class.cast(this.handler);
|
this.anvilHandler.be_previousRecipe();
|
||||||
List<AnvilSmithingRecipe> recipes = handler.be_getRecipes();
|
|
||||||
AnvilSmithingRecipe current = handler.be_getCurrentRecipe();
|
|
||||||
int i = recipes.indexOf(current) - 1;
|
|
||||||
if (i == 0) {
|
|
||||||
i = recipes.size() - 1;
|
|
||||||
}
|
|
||||||
handler.be_updateCurrentRecipe(recipes.get(i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
for (AbstractButtonWidget elem : be_buttons) {
|
for (AbstractButtonWidget elem : be_buttons) {
|
||||||
if (elem.mouseClicked(mouseX, mouseY, button)) {
|
if (elem.mouseClicked(mouseX, mouseY, button)) {
|
||||||
|
int i = be_buttons.indexOf(elem);
|
||||||
|
this.client.interactionManager.clickButton(handler.syncId, i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,13 @@ import net.minecraft.screen.ScreenHandlerContext;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
import ru.betterend.interfaces.AnvilScreenHandlerExtended;
|
import ru.betterend.interfaces.AnvilScreenHandlerExtended;
|
||||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||||
|
|
||||||
@Mixin(AnvilScreenHandler.class)
|
@Mixin(AnvilScreenHandler.class)
|
||||||
public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler implements AnvilScreenHandlerExtended {
|
public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler implements AnvilScreenHandlerExtended {
|
||||||
|
|
||||||
private List<AnvilSmithingRecipe> be_recipes = Collections.emptyList();
|
private List<AnvilRecipe> be_recipes = Collections.emptyList();
|
||||||
private AnvilSmithingRecipe be_currentRecipe;
|
private AnvilRecipe be_currentRecipe;
|
||||||
|
|
||||||
public AnvilScreenHandlerMixin(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory,
|
public AnvilScreenHandlerMixin(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory,
|
||||||
ScreenHandlerContext context) {
|
ScreenHandlerContext context) {
|
||||||
|
@ -44,7 +44,6 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple
|
||||||
ItemStack output = this.be_currentRecipe.craft(input, player);
|
ItemStack output = this.be_currentRecipe.craft(input, player);
|
||||||
if (!output.isEmpty()) {
|
if (!output.isEmpty()) {
|
||||||
info.setReturnValue(true);
|
info.setReturnValue(true);
|
||||||
info.cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,8 +51,8 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple
|
||||||
@Inject(method = "onTakeOutput", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onTakeOutput", at = @At("HEAD"), cancellable = true)
|
||||||
protected void onTakeOutput(PlayerEntity player, ItemStack stack, CallbackInfoReturnable<ItemStack> info) {
|
protected void onTakeOutput(PlayerEntity player, ItemStack stack, CallbackInfoReturnable<ItemStack> info) {
|
||||||
if (be_currentRecipe != null) {
|
if (be_currentRecipe != null) {
|
||||||
this.input.getStack(1).decrement(1);
|
this.input.getStack(0).decrement(1);
|
||||||
this.updateResult();
|
this.onContentChanged(input);
|
||||||
this.context.run((world, blockPos) -> {
|
this.context.run((world, blockPos) -> {
|
||||||
BlockState anvilState = world.getBlockState(blockPos);
|
BlockState anvilState = world.getBlockState(blockPos);
|
||||||
if (!player.abilities.creativeMode && anvilState.isIn(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) {
|
if (!player.abilities.creativeMode && anvilState.isIn(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) {
|
||||||
|
@ -70,16 +69,15 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
info.setReturnValue(stack);
|
info.setReturnValue(stack);
|
||||||
info.cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "updateResult", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "updateResult", at = @At("HEAD"), cancellable = true)
|
||||||
public void updateOutput(CallbackInfo info) {
|
public void updateOutput(CallbackInfo info) {
|
||||||
RecipeManager recipeManager = this.player.world.getRecipeManager();
|
RecipeManager recipeManager = this.player.world.getRecipeManager();
|
||||||
this.be_recipes = recipeManager.getAllMatches(AnvilSmithingRecipe.TYPE, input, player.world);
|
this.be_recipes = recipeManager.getAllMatches(AnvilRecipe.TYPE, input, player.world);
|
||||||
if (be_recipes.size() > 0) {
|
if (be_recipes.size() > 0) {
|
||||||
this.be_currentRecipe = recipeManager.getFirstMatch(AnvilSmithingRecipe.TYPE, input, player.world).get();
|
this.be_currentRecipe = recipeManager.getFirstMatch(AnvilRecipe.TYPE, input, player.world).get();
|
||||||
this.be_updateResult();
|
this.be_updateResult();
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
|
@ -92,6 +90,18 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onButtonClick(PlayerEntity player, int id) {
|
||||||
|
if (id == 0) {
|
||||||
|
this.be_previousRecipe();
|
||||||
|
return true;
|
||||||
|
} else if (id == 1) {
|
||||||
|
this.be_nextRecipe();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onButtonClick(player, id);
|
||||||
|
}
|
||||||
|
|
||||||
private void be_updateResult() {
|
private void be_updateResult() {
|
||||||
if (be_currentRecipe == null) return;
|
if (be_currentRecipe == null) return;
|
||||||
this.output.setStack(0, be_currentRecipe.craft(input));
|
this.output.setStack(0, be_currentRecipe.craft(input));
|
||||||
|
@ -99,18 +109,18 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void be_updateCurrentRecipe(AnvilSmithingRecipe recipe) {
|
public void be_updateCurrentRecipe(AnvilRecipe recipe) {
|
||||||
this.be_currentRecipe = recipe;
|
this.be_currentRecipe = recipe;
|
||||||
this.be_updateResult();
|
this.be_updateResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnvilSmithingRecipe be_getCurrentRecipe() {
|
public AnvilRecipe be_getCurrentRecipe() {
|
||||||
return this.be_currentRecipe;
|
return this.be_currentRecipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AnvilSmithingRecipe> be_getRecipes() {
|
public List<AnvilRecipe> be_getRecipes() {
|
||||||
return this.be_recipes;
|
return this.be_recipes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
59
src/main/java/ru/betterend/recipe/AnvilRecipes.java
Normal file
59
src/main/java/ru/betterend/recipe/AnvilRecipes.java
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
package ru.betterend.recipe;
|
||||||
|
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||||
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
|
public class AnvilRecipes {
|
||||||
|
public static void register() {
|
||||||
|
AnvilRecipe.Builder.create("ender_pearl_to_dust")
|
||||||
|
.setInput(Items.ENDER_PEARL)
|
||||||
|
.setOutput(EndItems.ENDER_DUST)
|
||||||
|
.setLevel(4)
|
||||||
|
.setDamage(5)
|
||||||
|
.build();
|
||||||
|
AnvilRecipe.Builder.create("ender_shard_to_dust")
|
||||||
|
.setInput(EndItems.ENDER_SHARD)
|
||||||
|
.setOutput(EndItems.ENDER_DUST)
|
||||||
|
.setLevel(2)
|
||||||
|
.setDamage(3)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
AnvilRecipe.Builder.create("aeternium_axe_head")
|
||||||
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
|
.setOutput(EndItems.AETERNIUM_AXE_HEAD)
|
||||||
|
.setLevel(4)
|
||||||
|
.setDamage(6)
|
||||||
|
.build();
|
||||||
|
AnvilRecipe.Builder.create("aeternium_pickaxe_head")
|
||||||
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
|
.setOutput(EndItems.AETERNIUM_PICKAXE_HEAD)
|
||||||
|
.setLevel(4)
|
||||||
|
.setDamage(6)
|
||||||
|
.build();
|
||||||
|
AnvilRecipe.Builder.create("aeternium_shovel_head")
|
||||||
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
|
.setOutput(EndItems.AETERNIUM_SHOVEL_HEAD)
|
||||||
|
.setLevel(4)
|
||||||
|
.setDamage(6)
|
||||||
|
.build();
|
||||||
|
AnvilRecipe.Builder.create("aeternium_hoe_head")
|
||||||
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
|
.setOutput(EndItems.AETERNIUM_HOE_HEAD)
|
||||||
|
.setLevel(4)
|
||||||
|
.setDamage(6)
|
||||||
|
.build();
|
||||||
|
AnvilRecipe.Builder.create("aeternium_hammer_head")
|
||||||
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
|
.setOutput(EndItems.AETERNIUM_HAMMER_HEAD)
|
||||||
|
.setLevel(4)
|
||||||
|
.setDamage(6)
|
||||||
|
.build();
|
||||||
|
AnvilRecipe.Builder.create("aeternium_sword_blade")
|
||||||
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
|
.setOutput(EndItems.AETERNIUM_SWORD_BLADE)
|
||||||
|
.setLevel(4)
|
||||||
|
.setDamage(6)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,15 @@ import ru.betterend.registry.EndTags;
|
||||||
public class CraftingRecipes {
|
public class CraftingRecipes {
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
|
if (BetterEnd.hasGuideBook()) {
|
||||||
|
GridRecipe.make("guide_book", GuideBookItem.GUIDE_BOOK)
|
||||||
|
.setShape("D", "B", "C")
|
||||||
|
.addMaterial('D', EndItems.ENDER_DUST)
|
||||||
|
.addMaterial('B', Items.BOOK)
|
||||||
|
.addMaterial('C', EndItems.CRYSTAL_SHARDS)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
GridRecipe.make("ender_pearl_to_block", EndBlocks.ENDER_BLOCK)
|
GridRecipe.make("ender_pearl_to_block", EndBlocks.ENDER_BLOCK)
|
||||||
.setShape("OO", "OO")
|
.setShape("OO", "OO")
|
||||||
.addMaterial('O', Items.ENDER_PEARL)
|
.addMaterial('O', Items.ENDER_PEARL)
|
||||||
|
@ -79,17 +88,6 @@ public class CraftingRecipes {
|
||||||
.setList("#")
|
.setList("#")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
registerHelmet(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_HELMET);
|
|
||||||
registerChestplate(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_CHESTPLATE);
|
|
||||||
registerLeggings(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_LEGGINGS);
|
|
||||||
registerBoots(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_BOOTS);
|
|
||||||
registerShovel(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_SHOVEL);
|
|
||||||
registerSword(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_SWORD);
|
|
||||||
registerPickaxe(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_PICKAXE);
|
|
||||||
registerAxe(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_AXE);
|
|
||||||
registerHoe(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_HOE);
|
|
||||||
registerHammer(material, EndItems.AETERNIUM_INGOT, EndItems.AETERNIUM_HAMMER);
|
|
||||||
|
|
||||||
registerHammer("iron", Items.IRON_INGOT, EndItems.IRON_HAMMER);
|
registerHammer("iron", Items.IRON_INGOT, EndItems.IRON_HAMMER);
|
||||||
registerHammer("golden", Items.GOLD_INGOT, EndItems.GOLDEN_HAMMER);
|
registerHammer("golden", Items.GOLD_INGOT, EndItems.GOLDEN_HAMMER);
|
||||||
registerHammer("diamond", Items.DIAMOND, EndItems.DIAMOND_HAMMER);
|
registerHammer("diamond", Items.DIAMOND, EndItems.DIAMOND_HAMMER);
|
||||||
|
@ -141,15 +139,6 @@ public class CraftingRecipes {
|
||||||
.addMaterial('B', EndItems.SHADOW_BERRY_COOKED)
|
.addMaterial('B', EndItems.SHADOW_BERRY_COOKED)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (BetterEnd.hasGuideBook()) {
|
|
||||||
GridRecipe.make("guide_book", GuideBookItem.GUIDE_BOOK)
|
|
||||||
.setShape("D", "B", "C")
|
|
||||||
.addMaterial('D', EndItems.ENDER_DUST)
|
|
||||||
.addMaterial('B', Items.BOOK)
|
|
||||||
.addMaterial('C', EndItems.CRYSTAL_SHARDS)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
GridRecipe.make("sulphur_gunpowder", Items.GUNPOWDER).setList("SCB").addMaterial('S', EndItems.CRYSTALLINE_SULPHUR).addMaterial('C', Items.COAL, Items.CHARCOAL).addMaterial('B', Items.BONE_MEAL).build();
|
GridRecipe.make("sulphur_gunpowder", Items.GUNPOWDER).setList("SCB").addMaterial('S', EndItems.CRYSTALLINE_SULPHUR).addMaterial('C', Items.COAL, Items.CHARCOAL).addMaterial('B', Items.BONE_MEAL).build();
|
||||||
|
|
||||||
GridRecipe.make("dense_emerald_ice", EndBlocks.DENSE_EMERALD_ICE).setShape("##", "##").addMaterial('#', EndBlocks.EMERALD_ICE).build();
|
GridRecipe.make("dense_emerald_ice", EndBlocks.DENSE_EMERALD_ICE).setShape("##", "##").addMaterial('#', EndBlocks.EMERALD_ICE).build();
|
||||||
|
|
|
@ -1,47 +1,67 @@
|
||||||
package ru.betterend.recipe;
|
package ru.betterend.recipe;
|
||||||
|
|
||||||
import net.minecraft.item.Items;
|
import ru.betterend.recipe.builders.SmithingTableRecipe;
|
||||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
public class SmithingRecipes {
|
public class SmithingRecipes {
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
AnvilSmithingRecipe.Builder.create("ender_pearl_to_dust")
|
SmithingTableRecipe.create("aeternium_sword_handle")
|
||||||
.setInput(Items.ENDER_PEARL)
|
.setResult(EndItems.AETERNIUM_SWORD_HANDLE)
|
||||||
.setOutput(EndItems.ENDER_DUST, 1)
|
.setBase(EndItems.TERMINITE_INGOT)
|
||||||
.setLevel(4)
|
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
|
||||||
.setDamage(5)
|
|
||||||
.build();
|
|
||||||
AnvilSmithingRecipe.Builder.create("ender_shard_to_dust")
|
|
||||||
.setInput(EndItems.ENDER_SHARD)
|
|
||||||
.setOutput(EndItems.ENDER_DUST, 1)
|
|
||||||
.setLevel(2)
|
|
||||||
.setDamage(3)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
AnvilSmithingRecipe.Builder.create("aeternium_axe_head")
|
SmithingTableRecipe.create("aeternium_sword")
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setResult(EndItems.AETERNIUM_SWORD)
|
||||||
.setOutput(EndItems.AETERNIUM_AXE_HEAD, 1)
|
.setBase(EndItems.AETERNIUM_SWORD_BLADE)
|
||||||
.setLevel(4)
|
.setAddition(EndItems.AETERNIUM_SWORD_HANDLE)
|
||||||
.setDamage(6)
|
|
||||||
.build();
|
.build();
|
||||||
AnvilSmithingRecipe.Builder.create("aeternium_pickaxe_head")
|
SmithingTableRecipe.create("aeternium_pickaxe")
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setResult(EndItems.AETERNIUM_PICKAXE)
|
||||||
.setOutput(EndItems.AETERNIUM_PICKAXE_HEAD, 1)
|
.setBase(EndItems.AETERNIUM_PICKAXE_HEAD)
|
||||||
.setLevel(4)
|
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
|
||||||
.setDamage(6)
|
|
||||||
.build();
|
.build();
|
||||||
AnvilSmithingRecipe.Builder.create("aeternium_shovel_head")
|
SmithingTableRecipe.create("aeternium_axe")
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setResult(EndItems.AETERNIUM_AXE)
|
||||||
.setOutput(EndItems.AETERNIUM_SHOVEL_HEAD, 1)
|
.setBase(EndItems.AETERNIUM_AXE_HEAD)
|
||||||
.setLevel(4)
|
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
|
||||||
.setDamage(6)
|
|
||||||
.build();
|
.build();
|
||||||
AnvilSmithingRecipe.Builder.create("aeternium_hoe_head")
|
SmithingTableRecipe.create("aeternium_shovel")
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setResult(EndItems.AETERNIUM_SHOVEL)
|
||||||
.setOutput(EndItems.AETERNIUM_HOE_HEAD, 1)
|
.setBase(EndItems.AETERNIUM_SHOVEL_HEAD)
|
||||||
.setLevel(4)
|
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
|
||||||
.setDamage(6)
|
.build();
|
||||||
|
SmithingTableRecipe.create("aeternium_hoe")
|
||||||
|
.setResult(EndItems.AETERNIUM_HOE)
|
||||||
|
.setBase(EndItems.AETERNIUM_HOE_HEAD)
|
||||||
|
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
|
||||||
|
.build();
|
||||||
|
SmithingTableRecipe.create("aeternium_hammer")
|
||||||
|
.setResult(EndItems.AETERNIUM_HAMMER)
|
||||||
|
.setBase(EndItems.AETERNIUM_HAMMER_HEAD)
|
||||||
|
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SmithingTableRecipe.create("aeternium_helmet")
|
||||||
|
.setResult(EndItems.AETERNIUM_HELMET)
|
||||||
|
.setBase(EndItems.TERMINITE_HELMET)
|
||||||
|
.setAddition(EndItems.AETERNIUM_INGOT)
|
||||||
|
.build();
|
||||||
|
SmithingTableRecipe.create("aeternium_chestplate")
|
||||||
|
.setResult(EndItems.AETERNIUM_CHESTPLATE)
|
||||||
|
.setBase(EndItems.TERMINITE_CHESTPLATE)
|
||||||
|
.setAddition(EndItems.AETERNIUM_INGOT)
|
||||||
|
.build();
|
||||||
|
SmithingTableRecipe.create("aeternium_leggings")
|
||||||
|
.setResult(EndItems.AETERNIUM_LEGGINGS)
|
||||||
|
.setBase(EndItems.TERMINITE_LEGGINGS)
|
||||||
|
.setAddition(EndItems.AETERNIUM_INGOT)
|
||||||
|
.build();
|
||||||
|
SmithingTableRecipe.create("aeternium_boots")
|
||||||
|
.setResult(EndItems.AETERNIUM_BOOTS)
|
||||||
|
.setBase(EndItems.TERMINITE_BOOTS)
|
||||||
|
.setAddition(EndItems.AETERNIUM_INGOT)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@ import ru.betterend.registry.EndTags;
|
||||||
import ru.betterend.util.ItemUtil;
|
import ru.betterend.util.ItemUtil;
|
||||||
import ru.betterend.util.RecipeHelper;
|
import ru.betterend.util.RecipeHelper;
|
||||||
|
|
||||||
public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
public class AnvilRecipe implements Recipe<Inventory> {
|
||||||
|
|
||||||
public final static String GROUP = "smithing";
|
public final static String GROUP = "smithing";
|
||||||
public final static RecipeType<AnvilSmithingRecipe> TYPE = EndRecipeManager.registerType(GROUP);
|
public final static RecipeType<AnvilRecipe> TYPE = EndRecipeManager.registerType(GROUP);
|
||||||
public final static Serializer SERIALIZER = EndRecipeManager.registerSerializer(GROUP, new Serializer());
|
public final static Serializer SERIALIZER = EndRecipeManager.registerSerializer(GROUP, new Serializer());
|
||||||
public final static Identifier ID = BetterEnd.makeID(GROUP);
|
public final static Identifier ID = BetterEnd.makeID(GROUP);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
private final int damage;
|
private final int damage;
|
||||||
private final int level;
|
private final int level;
|
||||||
|
|
||||||
public AnvilSmithingRecipe(Identifier identifier, Ingredient input, ItemStack output, int level, int damage) {
|
public AnvilRecipe(Identifier identifier, Ingredient input, ItemStack output, int level, int damage) {
|
||||||
this.id = identifier;
|
this.id = identifier;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
@ -70,7 +70,7 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
|
|
||||||
public ItemStack craft(Inventory craftingInventory, PlayerEntity player) {
|
public ItemStack craft(Inventory craftingInventory, PlayerEntity player) {
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative()) {
|
||||||
ItemStack hammer = craftingInventory.getStack(0);
|
ItemStack hammer = craftingInventory.getStack(1);
|
||||||
int damage = hammer.getDamage() + this.damage;
|
int damage = hammer.getDamage() + this.damage;
|
||||||
if (damage >= hammer.getMaxDamage()) return ItemStack.EMPTY;
|
if (damage >= hammer.getMaxDamage()) return ItemStack.EMPTY;
|
||||||
hammer.damage(this.damage, player, entity -> {
|
hammer.damage(this.damage, player, entity -> {
|
||||||
|
@ -81,12 +81,12 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(Inventory craftingInventory) {
|
public boolean matches(Inventory craftingInventory) {
|
||||||
ItemStack hammer = craftingInventory.getStack(0);
|
ItemStack hammer = craftingInventory.getStack(1);
|
||||||
if (hammer.isEmpty() || !EndTags.HAMMERS.contains(hammer.getItem())) {
|
if (hammer.isEmpty() || !EndTags.HAMMERS.contains(hammer.getItem())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int level = ((ToolItem) hammer.getItem()).getMaterial().getMiningLevel();
|
int level = ((ToolItem) hammer.getItem()).getMaterial().getMiningLevel();
|
||||||
return level >= this.level && this.input.test(craftingInventory.getStack(1));
|
return level >= this.level && this.input.test(craftingInventory.getStack(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDamage() {
|
public int getDamage() {
|
||||||
|
@ -127,7 +127,6 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private final static Builder INSTANCE = new Builder();
|
private final static Builder INSTANCE = new Builder();
|
||||||
private static boolean exist;
|
|
||||||
|
|
||||||
public static Builder create(String id) {
|
public static Builder create(String id) {
|
||||||
return create(BetterEnd.makeID(id));
|
return create(BetterEnd.makeID(id));
|
||||||
|
@ -139,7 +138,7 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
INSTANCE.output = null;
|
INSTANCE.output = null;
|
||||||
INSTANCE.level = 1;
|
INSTANCE.level = 1;
|
||||||
INSTANCE.damage = 1;
|
INSTANCE.damage = 1;
|
||||||
exist = Configs.RECIPE_CONFIG.getBoolean("anvil", id.getPath(), true);
|
INSTANCE.alright = true;
|
||||||
|
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
@ -149,14 +148,12 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
private ItemStack output;
|
private ItemStack output;
|
||||||
private int level = 1;
|
private int level = 1;
|
||||||
private int damage = 1;
|
private int damage = 1;
|
||||||
private boolean alright = true;
|
private boolean alright;
|
||||||
|
|
||||||
private Builder() {}
|
private Builder() {}
|
||||||
|
|
||||||
public Builder setInput(ItemConvertible... inputItems) {
|
public Builder setInput(ItemConvertible... inputItems) {
|
||||||
for (ItemConvertible item : inputItems) {
|
this.alright &= RecipeHelper.exists(inputItems);
|
||||||
this.alright &= RecipeHelper.exists(item);
|
|
||||||
}
|
|
||||||
this.setInput(Ingredient.ofItems(inputItems));
|
this.setInput(Ingredient.ofItems(inputItems));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +168,10 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setOutput(ItemConvertible output) {
|
||||||
|
return this.setOutput(output, 1);
|
||||||
|
}
|
||||||
|
|
||||||
public Builder setOutput(ItemConvertible output, int amount) {
|
public Builder setOutput(ItemConvertible output, int amount) {
|
||||||
this.alright &= RecipeHelper.exists(output);
|
this.alright &= RecipeHelper.exists(output);
|
||||||
this.output = new ItemStack(output, amount);
|
this.output = new ItemStack(output, amount);
|
||||||
|
@ -188,31 +189,31 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build() {
|
public void build() {
|
||||||
if (exist) {
|
if (Configs.RECIPE_CONFIG.getBoolean("anvil", id.getPath(), true)) {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
BetterEnd.LOGGER.warning("Input for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
|
BetterEnd.LOGGER.warning("Input for Anvil recipe can't be 'null', recipe {} will be ignored!", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(output == null) {
|
if(output == null) {
|
||||||
BetterEnd.LOGGER.warning("Output for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
|
BetterEnd.LOGGER.warning("Output for Anvil recipe can't be 'null', recipe {} will be ignored!", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (EndRecipeManager.getRecipe(TYPE, id) != null) {
|
if (EndRecipeManager.getRecipe(TYPE, id) != null) {
|
||||||
BetterEnd.LOGGER.warning("Can't add Smithing recipe! Id {} already exists!", id);
|
BetterEnd.LOGGER.warning("Can't add Anvil recipe! Id {} already exists!", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!alright) {
|
if (!alright) {
|
||||||
BetterEnd.LOGGER.debug("Can't add Smithing recipe {}! Ingeredient or output not exists.", id);
|
BetterEnd.LOGGER.debug("Can't add Anvil recipe {}! Ingeredient or output not exists.", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EndRecipeManager.addRecipe(TYPE, new AnvilSmithingRecipe(id, input, output, level, damage));
|
EndRecipeManager.addRecipe(TYPE, new AnvilRecipe(id, input, output, level, damage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Serializer implements RecipeSerializer<AnvilSmithingRecipe> {
|
public static class Serializer implements RecipeSerializer<AnvilRecipe> {
|
||||||
@Override
|
@Override
|
||||||
public AnvilSmithingRecipe read(Identifier id, JsonObject json) {
|
public AnvilRecipe read(Identifier id, JsonObject json) {
|
||||||
Ingredient input = Ingredient.fromJson(json.get("input"));
|
Ingredient input = Ingredient.fromJson(json.get("input"));
|
||||||
JsonObject result = JsonHelper.getObject(json, "result");
|
JsonObject result = JsonHelper.getObject(json, "result");
|
||||||
ItemStack output = ItemUtil.fromJsonRecipe(result);
|
ItemStack output = ItemUtil.fromJsonRecipe(result);
|
||||||
|
@ -222,21 +223,21 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
||||||
int level = JsonHelper.getInt(json, "level", 1);
|
int level = JsonHelper.getInt(json, "level", 1);
|
||||||
int damage = JsonHelper.getInt(json, "damage", 1);
|
int damage = JsonHelper.getInt(json, "damage", 1);
|
||||||
|
|
||||||
return new AnvilSmithingRecipe(id, input, output, level, damage);
|
return new AnvilRecipe(id, input, output, level, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnvilSmithingRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
public AnvilRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
||||||
Ingredient input = Ingredient.fromPacket(packetBuffer);
|
Ingredient input = Ingredient.fromPacket(packetBuffer);
|
||||||
ItemStack output = packetBuffer.readItemStack();
|
ItemStack output = packetBuffer.readItemStack();
|
||||||
int level = packetBuffer.readVarInt();
|
int level = packetBuffer.readVarInt();
|
||||||
int damage = packetBuffer.readVarInt();
|
int damage = packetBuffer.readVarInt();
|
||||||
|
|
||||||
return new AnvilSmithingRecipe(id, input, output, level, damage);
|
return new AnvilRecipe(id, input, output, level, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(PacketByteBuf packetBuffer, AnvilSmithingRecipe recipe) {
|
public void write(PacketByteBuf packetBuffer, AnvilRecipe recipe) {
|
||||||
recipe.input.write(packetBuffer);
|
recipe.input.write(packetBuffer);
|
||||||
packetBuffer.writeItemStack(recipe.output);
|
packetBuffer.writeItemStack(recipe.output);
|
||||||
packetBuffer.writeVarInt(recipe.level);
|
packetBuffer.writeVarInt(recipe.level);
|
|
@ -0,0 +1,101 @@
|
||||||
|
package ru.betterend.recipe.builders;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemConvertible;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.recipe.Ingredient;
|
||||||
|
import net.minecraft.recipe.RecipeType;
|
||||||
|
import net.minecraft.recipe.SmithingRecipe;
|
||||||
|
import net.minecraft.tag.Tag;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import ru.betterend.BetterEnd;
|
||||||
|
import ru.betterend.config.Configs;
|
||||||
|
import ru.betterend.recipe.EndRecipeManager;
|
||||||
|
import ru.betterend.util.RecipeHelper;
|
||||||
|
|
||||||
|
public class SmithingTableRecipe {
|
||||||
|
|
||||||
|
private final static SmithingTableRecipe BUILDER = new SmithingTableRecipe();
|
||||||
|
private final static RecipeType<SmithingRecipe> TYPE = RecipeType.SMITHING;
|
||||||
|
|
||||||
|
public static SmithingTableRecipe create(String name) {
|
||||||
|
return create(BetterEnd.makeID(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SmithingTableRecipe create(Identifier id) {
|
||||||
|
BUILDER.id = id;
|
||||||
|
BUILDER.base = null;
|
||||||
|
BUILDER.addition = null;
|
||||||
|
BUILDER.result = null;
|
||||||
|
BUILDER.alright = true;
|
||||||
|
|
||||||
|
return BUILDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Identifier id;
|
||||||
|
private Ingredient base;
|
||||||
|
private Ingredient addition;
|
||||||
|
private ItemStack result;
|
||||||
|
private boolean alright;
|
||||||
|
|
||||||
|
private SmithingTableRecipe() {}
|
||||||
|
|
||||||
|
public SmithingTableRecipe setResult(ItemConvertible item) {
|
||||||
|
return this.setResult(item, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmithingTableRecipe setResult(ItemConvertible item, int count) {
|
||||||
|
this.alright &= RecipeHelper.exists(item);
|
||||||
|
this.result = new ItemStack(item, count);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmithingTableRecipe setBase(ItemConvertible... items) {
|
||||||
|
this.alright &= RecipeHelper.exists(items);
|
||||||
|
this.base = Ingredient.ofItems(items);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmithingTableRecipe setBase(Tag<Item> tag) {
|
||||||
|
this.base = (Ingredient.fromTag(tag));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmithingTableRecipe setAddition(ItemConvertible... items) {
|
||||||
|
this.alright &= RecipeHelper.exists(items);
|
||||||
|
this.addition = Ingredient.ofItems(items);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmithingTableRecipe setAddition(Tag<Item> tag) {
|
||||||
|
this.addition = (Ingredient.fromTag(tag));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void build() {
|
||||||
|
if (Configs.RECIPE_CONFIG.getBoolean("smithing", id.getPath(), true)) {
|
||||||
|
if (base == null) {
|
||||||
|
BetterEnd.LOGGER.warning("Base input for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (addition == null) {
|
||||||
|
BetterEnd.LOGGER.warning("Addition input for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(result == null) {
|
||||||
|
BetterEnd.LOGGER.warning("Result for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (EndRecipeManager.getRecipe(TYPE, id) != null) {
|
||||||
|
BetterEnd.LOGGER.warning("Can't add Smithing recipe! Id {} already exists!", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!alright) {
|
||||||
|
BetterEnd.LOGGER.debug("Can't add Smithing recipe {}! Ingeredients or output not exists.", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EndRecipeManager.addRecipe(TYPE, new SmithingRecipe(id, base, addition, result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,4 +12,13 @@ public class RecipeHelper {
|
||||||
return Registry.ITEM.getId(item.asItem()) != Registry.ITEM.getDefaultId();
|
return Registry.ITEM.getId(item.asItem()) != Registry.ITEM.getDefaultId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean exists(ItemConvertible... items) {
|
||||||
|
for (ItemConvertible item : items) {
|
||||||
|
if (!exists(item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,15 @@
|
||||||
"item.betterend.crystalite_chestplate": "Crystalite Chestplate",
|
"item.betterend.crystalite_chestplate": "Crystalite Chestplate",
|
||||||
"item.betterend.crystalite_helmet": "Crystalite Helmet",
|
"item.betterend.crystalite_helmet": "Crystalite Helmet",
|
||||||
"item.betterend.crystalite_leggings": "Crystalite Leggings",
|
"item.betterend.crystalite_leggings": "Crystalite Leggings",
|
||||||
|
"item.betterend.aeternium_axe_head": "Aeternium Axe Head",
|
||||||
|
"item.betterend.aeternium_hammer_head": "Aeternium Hammer Head",
|
||||||
|
"item.betterend.aeternium_hoe_head": "Aeternium Hoe Head",
|
||||||
|
"item.betterend.aeternium_pickaxe_head": "Aeternium Pickaxe Head",
|
||||||
|
"item.betterend.aeternium_shovel_head": "Aeternium Shovel Head",
|
||||||
|
"item.betterend.aeternium_sword_blade": "Aeternium Sword Blade",
|
||||||
|
"item.betterend.aeternium_sword_handle": "Aeternium Sword Handle",
|
||||||
|
"item.betterend.leather_stripe": "Leather Stripe",
|
||||||
|
"item.betterend.leather_wrapped_stick": "Leather Wrapped Stick",
|
||||||
|
|
||||||
"effect.betterend.end_veil": "End Veil",
|
"effect.betterend.end_veil": "End Veil",
|
||||||
"enchantment.betterend.end_veil": "End Veil",
|
"enchantment.betterend.end_veil": "End Veil",
|
||||||
|
|
|
@ -66,6 +66,15 @@
|
||||||
"item.betterend.crystalite_chestplate": "Кристалитовая кираса",
|
"item.betterend.crystalite_chestplate": "Кристалитовая кираса",
|
||||||
"item.betterend.crystalite_helmet": "Кристалитовый шлем",
|
"item.betterend.crystalite_helmet": "Кристалитовый шлем",
|
||||||
"item.betterend.crystalite_leggings": "Кристалитовые поножи",
|
"item.betterend.crystalite_leggings": "Кристалитовые поножи",
|
||||||
|
"item.betterend.aeternium_axe_head": "Навершие Этериевого топора",
|
||||||
|
"item.betterend.aeternium_hammer_head": "Навершие Этериевого молота",
|
||||||
|
"item.betterend.aeternium_hoe_head": "Навершие Этериевой мотыги",
|
||||||
|
"item.betterend.aeternium_pickaxe_head": "Навершие Этериевой кирки",
|
||||||
|
"item.betterend.aeternium_shovel_head": "Навершие Этериевой лопаты",
|
||||||
|
"item.betterend.aeternium_sword_blade": "Лезвие Этериевого меча",
|
||||||
|
"item.betterend.aeternium_sword_handle": "Рукоятка Этериевого меча",
|
||||||
|
"item.betterend.leather_stripe": "Полоска кожи",
|
||||||
|
"item.betterend.leather_wrapped_stick": "Обернутая кожей палка",
|
||||||
|
|
||||||
"effect.betterend.end_veil": "Вуаль Края",
|
"effect.betterend.end_veil": "Вуаль Края",
|
||||||
"enchantment.betterend.end_veil": "Вуаль Края",
|
"enchantment.betterend.end_veil": "Вуаль Края",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue