- Got all hammers back
- Added anvil level and recipe input count
This commit is contained in:
parent
7b40047213
commit
68636e2ecd
18 changed files with 176 additions and 85 deletions
|
@ -9,50 +9,50 @@ public class AnvilRecipes {
|
|||
AnvilRecipe.Builder.create("ender_pearl_to_dust")
|
||||
.setInput(Items.ENDER_PEARL)
|
||||
.setOutput(EndItems.ENDER_DUST)
|
||||
.setLevel(4)
|
||||
.setToolLevel(4)
|
||||
.setDamage(5)
|
||||
.build();
|
||||
AnvilRecipe.Builder.create("ender_shard_to_dust")
|
||||
.setInput(EndItems.ENDER_SHARD)
|
||||
.setOutput(EndItems.ENDER_DUST)
|
||||
.setLevel(0)
|
||||
.setToolLevel(0)
|
||||
.setDamage(3)
|
||||
.build();
|
||||
|
||||
AnvilRecipe.Builder.create("aeternium_axe_head")
|
||||
.setInput(EndItems.AETERNIUM_INGOT)
|
||||
.setOutput(EndItems.AETERNIUM_AXE_HEAD)
|
||||
.setLevel(4)
|
||||
.setToolLevel(4)
|
||||
.setDamage(6)
|
||||
.build();
|
||||
AnvilRecipe.Builder.create("aeternium_pickaxe_head")
|
||||
.setInput(EndItems.AETERNIUM_INGOT)
|
||||
.setOutput(EndItems.AETERNIUM_PICKAXE_HEAD)
|
||||
.setLevel(4)
|
||||
.setToolLevel(4)
|
||||
.setDamage(6)
|
||||
.build();
|
||||
AnvilRecipe.Builder.create("aeternium_shovel_head")
|
||||
.setInput(EndItems.AETERNIUM_INGOT)
|
||||
.setOutput(EndItems.AETERNIUM_SHOVEL_HEAD)
|
||||
.setLevel(4)
|
||||
.setToolLevel(4)
|
||||
.setDamage(6)
|
||||
.build();
|
||||
AnvilRecipe.Builder.create("aeternium_hoe_head")
|
||||
.setInput(EndItems.AETERNIUM_INGOT)
|
||||
.setOutput(EndItems.AETERNIUM_HOE_HEAD)
|
||||
.setLevel(4)
|
||||
.setToolLevel(4)
|
||||
.setDamage(6)
|
||||
.build();
|
||||
AnvilRecipe.Builder.create("aeternium_hammer_head")
|
||||
.setInput(EndItems.AETERNIUM_INGOT)
|
||||
.setOutput(EndItems.AETERNIUM_HAMMER_HEAD)
|
||||
.setLevel(4)
|
||||
.setToolLevel(4)
|
||||
.setDamage(6)
|
||||
.build();
|
||||
AnvilRecipe.Builder.create("aeternium_sword_blade")
|
||||
.setInput(EndItems.AETERNIUM_INGOT)
|
||||
.setOutput(EndItems.AETERNIUM_SWORD_BLADE)
|
||||
.setLevel(4)
|
||||
.setToolLevel(4)
|
||||
.setDamage(6)
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package ru.betterend.recipe;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.potion.PotionUtil;
|
||||
|
@ -163,21 +164,25 @@ public class CraftingRecipes {
|
|||
GridRecipe.make("fiber_string", Items.STRING).setOutputCount(6).setShape("#", "#", "#").addMaterial('#', EndItems.SILK_FIBER).build();
|
||||
|
||||
GridRecipe.make("ender_eye_amber", Items.ENDER_EYE)
|
||||
.setShape("SAS", "APA", "SAS")
|
||||
.addMaterial('S', EndItems.CRYSTAL_SHARDS)
|
||||
.addMaterial('A', EndItems.AMBER_GEM)
|
||||
.addMaterial('P', Items.ENDER_PEARL)
|
||||
.build();
|
||||
.setShape("SAS", "APA", "SAS")
|
||||
.addMaterial('S', EndItems.CRYSTAL_SHARDS)
|
||||
.addMaterial('A', EndItems.AMBER_GEM)
|
||||
.addMaterial('P', Items.ENDER_PEARL)
|
||||
.build();
|
||||
|
||||
GridRecipe.make("iron_chandelier", EndBlocks.IRON_CHANDELIER).setShape("I#I", " # ").addMaterial('#', Items.IRON_INGOT).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build();
|
||||
GridRecipe.make("gold_chandelier", EndBlocks.GOLD_CHANDELIER).setShape("I#I", " # ").addMaterial('#', Items.GOLD_INGOT).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build();
|
||||
|
||||
GridRecipe.make("missing_tile", EndBlocks.MISSING_TILE)
|
||||
.setOutputCount(4)
|
||||
.setShape("#P", "P#")
|
||||
.addMaterial('#', EndBlocks.VIOLECITE.stone, EndBlocks.VIOLECITE.bricks, EndBlocks.VIOLECITE.tiles)
|
||||
.addMaterial('P', Blocks.PURPUR_BLOCK)
|
||||
.build();
|
||||
.setOutputCount(4)
|
||||
.setShape("#P", "P#")
|
||||
.addMaterial('#', EndBlocks.VIOLECITE.stone, EndBlocks.VIOLECITE.bricks, EndBlocks.VIOLECITE.tiles)
|
||||
.addMaterial('P', Blocks.PURPUR_BLOCK)
|
||||
.build();
|
||||
|
||||
registerHammer("iron", Items.IRON_INGOT, EndItems.IRON_HAMMER);
|
||||
registerHammer("golden", Items.GOLD_INGOT, EndItems.GOLDEN_HAMMER);
|
||||
registerHammer("diamond", Items.DIAMOND, EndItems.DIAMOND_HAMMER);
|
||||
}
|
||||
|
||||
private static void registerLantern(String name, Block lantern, Block slab) {
|
||||
|
@ -197,4 +202,12 @@ public class CraftingRecipes {
|
|||
.setOutputCount(2)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static void registerHammer(String name, Item material, Item result) {
|
||||
GridRecipe.make(name + "_hammer", result)
|
||||
.setShape("I I", "I#I", " # ")
|
||||
.addMaterial('I', material)
|
||||
.addMaterial('#', Items.STICK)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.recipe;
|
||||
|
||||
import net.minecraft.item.Items;
|
||||
import ru.betterend.recipe.builders.SmithingTableRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
@ -43,6 +44,12 @@ public class SmithingRecipes {
|
|||
.setBase(EndItems.AETERNIUM_HAMMER_HEAD)
|
||||
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
|
||||
.build();
|
||||
|
||||
SmithingTableRecipe.create("netherite_hammer")
|
||||
.setResult(EndItems.NETHERITE_HAMMER)
|
||||
.setBase(EndItems.DIAMOND_HAMMER)
|
||||
.setAddition(Items.NETHERITE_INGOT)
|
||||
.build();
|
||||
|
||||
SmithingTableRecipe.create("aeternium_helmet")
|
||||
.setResult(EndItems.AETERNIUM_HELMET)
|
||||
|
|
|
@ -41,13 +41,17 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
private final Ingredient input;
|
||||
private final ItemStack output;
|
||||
private final int damage;
|
||||
private final int level;
|
||||
private final int toolLevel;
|
||||
private final int anvilLevel;
|
||||
private final int inputCount;
|
||||
|
||||
public AnvilRecipe(Identifier identifier, Ingredient input, ItemStack output, int level, int damage) {
|
||||
public AnvilRecipe(Identifier identifier, Ingredient input, ItemStack output, int inputCount, int toolLevel, int anvilLevel, int damage) {
|
||||
this.id = identifier;
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.level = level;
|
||||
this.toolLevel = toolLevel;
|
||||
this.anvilLevel = anvilLevel;
|
||||
this.inputCount = inputCount;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
|
@ -75,9 +79,8 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
if (!player.isCreative()) {
|
||||
if (!checkHammerDurability(craftingInventory, player)) return ItemStack.EMPTY;
|
||||
ItemStack hammer = craftingInventory.getStack(1);
|
||||
hammer.damage(this.damage, player, entity -> {
|
||||
entity.sendEquipmentBreakStatus(null);
|
||||
});
|
||||
hammer.damage(this.damage, player, entity ->
|
||||
entity.sendEquipmentBreakStatus(null));
|
||||
}
|
||||
return this.craft(craftingInventory);
|
||||
}
|
||||
|
@ -94,20 +97,31 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
if (hammer.isEmpty() || !EndTags.HAMMERS.contains(hammer.getItem())) {
|
||||
return false;
|
||||
}
|
||||
ItemStack material = craftingInventory.getStack(0);
|
||||
int materialCount = material.getCount();
|
||||
int level = ((ToolItem) hammer.getItem()).getMaterial().getMiningLevel();
|
||||
return level >= this.level && this.input.test(craftingInventory.getStack(0));
|
||||
return this.input.test(craftingInventory.getStack(0)) &&
|
||||
materialCount >= this.inputCount &&
|
||||
level >= this.toolLevel;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
public int getInputCount() {
|
||||
return this.inputCount;
|
||||
}
|
||||
|
||||
public int getAnvilLevel() {
|
||||
return this.anvilLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedList<Ingredient> getPreviewInputs() {
|
||||
DefaultedList<Ingredient> defaultedList = DefaultedList.of();
|
||||
defaultedList.add(Ingredient.ofStacks(EndTags.HAMMERS.values().stream().filter(hammer -> {
|
||||
return ((ToolItem) hammer).getMaterial().getMiningLevel() >= level;
|
||||
}).map(ItemStack::new)));
|
||||
defaultedList.add(Ingredient.ofStacks(EndTags.HAMMERS.values().stream().filter(hammer ->
|
||||
((ToolItem) hammer).getMaterial().getMiningLevel() >= toolLevel).map(ItemStack::new)));
|
||||
defaultedList.add(input);
|
||||
|
||||
return defaultedList;
|
||||
|
@ -139,12 +153,12 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AnvilRecipe that = (AnvilRecipe) o;
|
||||
return damage == that.damage && level == that.level && id.equals(that.id) && input.equals(that.input) && output.equals(that.output);
|
||||
return damage == that.damage && toolLevel == that.toolLevel && id.equals(that.id) && input.equals(that.input) && output.equals(that.output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, input, output, damage, level);
|
||||
return Objects.hash(id, input, output, damage, toolLevel);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
@ -158,7 +172,9 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
INSTANCE.id = id;
|
||||
INSTANCE.input = null;
|
||||
INSTANCE.output = null;
|
||||
INSTANCE.level = 1;
|
||||
INSTANCE.inputCount = 1;
|
||||
INSTANCE.toolLevel = 1;
|
||||
INSTANCE.anvilLevel = 1;
|
||||
INSTANCE.damage = 1;
|
||||
INSTANCE.alright = true;
|
||||
|
||||
|
@ -168,7 +184,9 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
private Identifier id;
|
||||
private Ingredient input;
|
||||
private ItemStack output;
|
||||
private int level = 1;
|
||||
private int inputCount = 1;
|
||||
private int toolLevel = 1;
|
||||
private int anvilLevel = 1;
|
||||
private int damage = 1;
|
||||
private boolean alright;
|
||||
|
||||
|
@ -189,6 +207,11 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
this.input = ingredient;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInputCount(int count) {
|
||||
this.inputCount = count;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setOutput(ItemConvertible output) {
|
||||
return this.setOutput(output, 1);
|
||||
|
@ -200,8 +223,13 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setLevel(int level) {
|
||||
this.level = level;
|
||||
public Builder setToolLevel(int level) {
|
||||
this.toolLevel = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAnvilLevel(int level) {
|
||||
this.anvilLevel = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -228,7 +256,7 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
BetterEnd.LOGGER.debug("Can't add Anvil recipe {}! Ingeredient or output not exists.", id);
|
||||
return;
|
||||
}
|
||||
EndRecipeManager.addRecipe(TYPE, new AnvilRecipe(id, input, output, level, damage));
|
||||
EndRecipeManager.addRecipe(TYPE, new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,27 +270,33 @@ public class AnvilRecipe implements Recipe<Inventory>, BetterEndRecipe {
|
|||
if (output == null) {
|
||||
throw new IllegalStateException("Output item does not exists!");
|
||||
}
|
||||
int level = JsonHelper.getInt(json, "level", 1);
|
||||
int inputCount = JsonHelper.getInt(json, "inputCount", 1);
|
||||
int toolLevel = JsonHelper.getInt(json, "toolLevel", 1);
|
||||
int anvilLevel = JsonHelper.getInt(json, "anvilLevel", 1);
|
||||
int damage = JsonHelper.getInt(json, "damage", 1);
|
||||
|
||||
return new AnvilRecipe(id, input, output, level, damage);
|
||||
return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnvilRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
||||
Ingredient input = Ingredient.fromPacket(packetBuffer);
|
||||
ItemStack output = packetBuffer.readItemStack();
|
||||
int level = packetBuffer.readVarInt();
|
||||
int inputCount = packetBuffer.readVarInt();
|
||||
int toolLevel = packetBuffer.readVarInt();
|
||||
int anvilLevel = packetBuffer.readVarInt();
|
||||
int damage = packetBuffer.readVarInt();
|
||||
|
||||
return new AnvilRecipe(id, input, output, level, damage);
|
||||
return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf packetBuffer, AnvilRecipe recipe) {
|
||||
recipe.input.write(packetBuffer);
|
||||
packetBuffer.writeItemStack(recipe.output);
|
||||
packetBuffer.writeVarInt(recipe.level);
|
||||
packetBuffer.writeVarInt(recipe.inputCount);
|
||||
packetBuffer.writeVarInt(recipe.toolLevel);
|
||||
packetBuffer.writeVarInt(recipe.anvilLevel);
|
||||
packetBuffer.writeVarInt(recipe.damage);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue