Moved AnvilReceipts to BCLib
This commit is contained in:
parent
83b6c84f7d
commit
2e61a58e26
17 changed files with 553 additions and 1277 deletions
|
@ -1,20 +1,18 @@
|
||||||
package ru.betterend.blocks.basis;
|
package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import ru.bclib.blocks.BaseAnvilBlock;
|
import ru.bclib.blocks.LeveledAnvilBlock;
|
||||||
import ru.betterend.complexmaterials.MetalMaterial;
|
import ru.betterend.complexmaterials.MetalMaterial;
|
||||||
|
|
||||||
public class EndAnvilBlock extends BaseAnvilBlock {
|
public class EndAnvilBlock extends LeveledAnvilBlock {
|
||||||
protected MetalMaterial metalMaterial;
|
protected MetalMaterial metalMaterial;
|
||||||
protected final int level;
|
|
||||||
|
|
||||||
public EndAnvilBlock(MaterialColor color, int level) {
|
public EndAnvilBlock(MaterialColor color, int level) {
|
||||||
super(color);
|
super(color, level);
|
||||||
this.level = level;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EndAnvilBlock(MetalMaterial metalMaterial, MaterialColor color, int level) {
|
public EndAnvilBlock(MetalMaterial metalMaterial, MaterialColor color, int level) {
|
||||||
this(color, level);
|
super(color, level);
|
||||||
this.metalMaterial = metalMaterial;
|
this.metalMaterial = metalMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import ru.bclib.items.tool.BaseAxeItem;
|
||||||
import ru.bclib.items.tool.BaseHoeItem;
|
import ru.bclib.items.tool.BaseHoeItem;
|
||||||
import ru.bclib.items.tool.BaseShovelItem;
|
import ru.bclib.items.tool.BaseShovelItem;
|
||||||
import ru.bclib.items.tool.BaseSwordItem;
|
import ru.bclib.items.tool.BaseSwordItem;
|
||||||
|
import ru.bclib.recipes.AnvilRecipe;
|
||||||
import ru.bclib.recipes.FurnaceRecipe;
|
import ru.bclib.recipes.FurnaceRecipe;
|
||||||
import ru.bclib.recipes.GridRecipe;
|
import ru.bclib.recipes.GridRecipe;
|
||||||
import ru.bclib.recipes.SmithingTableRecipe;
|
import ru.bclib.recipes.SmithingTableRecipe;
|
||||||
|
@ -43,451 +44,458 @@ import ru.betterend.item.EndArmorItem;
|
||||||
import ru.betterend.item.tool.EndHammerItem;
|
import ru.betterend.item.tool.EndHammerItem;
|
||||||
import ru.betterend.item.tool.EndPickaxe;
|
import ru.betterend.item.tool.EndPickaxe;
|
||||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
public class MetalMaterial {
|
public class MetalMaterial {
|
||||||
public final Block ore;
|
public final Block ore;
|
||||||
public final Block block;
|
public final Block block;
|
||||||
public final Block tile;
|
public final Block tile;
|
||||||
public final Block bars;
|
public final Block bars;
|
||||||
public final Block pressurePlate;
|
public final Block pressurePlate;
|
||||||
public final Block door;
|
public final Block door;
|
||||||
public final Block trapdoor;
|
public final Block trapdoor;
|
||||||
public final Block chain;
|
public final Block chain;
|
||||||
public final Block stairs;
|
public final Block stairs;
|
||||||
public final Block slab;
|
public final Block slab;
|
||||||
|
|
||||||
public final Block chandelier;
|
public final Block chandelier;
|
||||||
public final Block bulb_lantern;
|
public final Block bulb_lantern;
|
||||||
public final ColoredMaterial bulb_lantern_colored;
|
public final ColoredMaterial bulb_lantern_colored;
|
||||||
|
|
||||||
public final Block anvilBlock;
|
public final Block anvilBlock;
|
||||||
|
|
||||||
public final Item rawOre;
|
public final Item rawOre;
|
||||||
public final Item nugget;
|
public final Item nugget;
|
||||||
public final Item ingot;
|
public final Item ingot;
|
||||||
|
|
||||||
public final Item shovelHead;
|
public final Item shovelHead;
|
||||||
public final Item pickaxeHead;
|
public final Item pickaxeHead;
|
||||||
public final Item axeHead;
|
public final Item axeHead;
|
||||||
public final Item hoeHead;
|
public final Item hoeHead;
|
||||||
public final Item swordBlade;
|
public final Item swordBlade;
|
||||||
public final Item swordHandle;
|
public final Item swordHandle;
|
||||||
|
|
||||||
public final Item shovel;
|
public final Item shovel;
|
||||||
public final Item sword;
|
public final Item sword;
|
||||||
public final Item pickaxe;
|
public final Item pickaxe;
|
||||||
public final Item axe;
|
public final Item axe;
|
||||||
public final Item hoe;
|
public final Item hoe;
|
||||||
public final Item hammer;
|
public final Item hammer;
|
||||||
|
|
||||||
public final Item forgedPlate;
|
public final Item forgedPlate;
|
||||||
public final Item helmet;
|
public final Item helmet;
|
||||||
public final Item chestplate;
|
public final Item chestplate;
|
||||||
public final Item leggings;
|
public final Item leggings;
|
||||||
public final Item boots;
|
public final Item boots;
|
||||||
|
|
||||||
public final Tag.Named<Item> alloyingOre;
|
public final Tag.Named<Item> alloyingOre;
|
||||||
|
|
||||||
public static MetalMaterial makeNormal(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
|
public static MetalMaterial makeNormal(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
|
||||||
return new MetalMaterial(
|
return new MetalMaterial(
|
||||||
name,
|
name,
|
||||||
true,
|
true,
|
||||||
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color),
|
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)
|
||||||
EndItems.makeEndItemSettings(),
|
.materialColor(color),
|
||||||
material,
|
EndItems.makeEndItemSettings(),
|
||||||
armor
|
material,
|
||||||
);
|
armor
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static MetalMaterial makeNormal(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
|
public static MetalMaterial makeNormal(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
|
||||||
return new MetalMaterial(
|
return new MetalMaterial(
|
||||||
name,
|
name,
|
||||||
true,
|
true,
|
||||||
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)
|
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)
|
||||||
.materialColor(color)
|
.materialColor(color)
|
||||||
.hardness(hardness)
|
.hardness(hardness)
|
||||||
.resistance(resistance),
|
.resistance(resistance),
|
||||||
EndItems.makeEndItemSettings(),
|
EndItems.makeEndItemSettings(),
|
||||||
material,
|
material,
|
||||||
armor
|
armor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MetalMaterial makeOreless(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
|
public static MetalMaterial makeOreless(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
|
||||||
return new MetalMaterial(
|
return new MetalMaterial(
|
||||||
name,
|
name,
|
||||||
false,
|
false,
|
||||||
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color),
|
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)
|
||||||
EndItems.makeEndItemSettings(),
|
.materialColor(color),
|
||||||
material,
|
EndItems.makeEndItemSettings(),
|
||||||
armor
|
material,
|
||||||
);
|
armor
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static MetalMaterial makeOreless(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
|
public static MetalMaterial makeOreless(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
|
||||||
return new MetalMaterial(
|
return new MetalMaterial(
|
||||||
name,
|
name,
|
||||||
false,
|
false,
|
||||||
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)
|
FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)
|
||||||
.materialColor(color)
|
.materialColor(color)
|
||||||
.hardness(hardness)
|
.hardness(hardness)
|
||||||
.resistance(resistance),
|
.resistance(resistance),
|
||||||
EndItems.makeEndItemSettings(),
|
EndItems.makeEndItemSettings(),
|
||||||
material,
|
material,
|
||||||
armor
|
armor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MetalMaterial(String name, boolean hasOre, FabricBlockSettings settings, Properties itemSettings, Tier material, ArmorMaterial armor) {
|
private MetalMaterial(String name, boolean hasOre, FabricBlockSettings settings, Properties itemSettings, Tier material, ArmorMaterial armor) {
|
||||||
BlockBehaviour.Properties lanternProperties = FabricBlockSettings.copyOf(settings)
|
BlockBehaviour.Properties lanternProperties = FabricBlockSettings.copyOf(settings)
|
||||||
.hardness(1)
|
.hardness(1)
|
||||||
.resistance(1)
|
.resistance(1)
|
||||||
.luminance(15)
|
.luminance(15)
|
||||||
.sound(SoundType.LANTERN);
|
.sound(SoundType.LANTERN);
|
||||||
final int level = material.getLevel();
|
final int level = material.getLevel();
|
||||||
|
|
||||||
rawOre = hasOre ? EndItems.registerEndItem(name + "_raw", new ModelProviderItem(itemSettings)) : null;
|
rawOre = hasOre ? EndItems.registerEndItem(name + "_raw", new ModelProviderItem(itemSettings)) : null;
|
||||||
ore = hasOre ? EndBlocks.registerBlock(name + "_ore", new BaseOreBlock(rawOre, 1, 3, 1)) : null;
|
ore = hasOre ? EndBlocks.registerBlock(name + "_ore", new BaseOreBlock(rawOre, 1, 3, 1)) : null;
|
||||||
alloyingOre = hasOre ? TagAPI.makeItemTag(BetterEnd.MOD_ID, name + "_alloying") : null;
|
alloyingOre = hasOre ? TagAPI.makeItemTag(BetterEnd.MOD_ID, name + "_alloying") : null;
|
||||||
if (hasOre) {
|
if (hasOre) {
|
||||||
TagAPI.addTag(alloyingOre, ore, rawOre);
|
TagAPI.addTag(alloyingOre, ore, rawOre);
|
||||||
}
|
}
|
||||||
|
|
||||||
block = EndBlocks.registerBlock(name + "_block", new BaseBlock(settings));
|
block = EndBlocks.registerBlock(name + "_block", new BaseBlock(settings));
|
||||||
tile = EndBlocks.registerBlock(name + "_tile", new BaseBlock(settings));
|
tile = EndBlocks.registerBlock(name + "_tile", new BaseBlock(settings));
|
||||||
stairs = EndBlocks.registerBlock(name + "_stairs", new BaseStairsBlock(tile));
|
stairs = EndBlocks.registerBlock(name + "_stairs", new BaseStairsBlock(tile));
|
||||||
slab = EndBlocks.registerBlock(name + "_slab", new BaseSlabBlock(tile));
|
slab = EndBlocks.registerBlock(name + "_slab", new BaseSlabBlock(tile));
|
||||||
door = EndBlocks.registerBlock(name + "_door", new BaseDoorBlock(block));
|
door = EndBlocks.registerBlock(name + "_door", new BaseDoorBlock(block));
|
||||||
trapdoor = EndBlocks.registerBlock(name + "_trapdoor", new BaseTrapdoorBlock(block));
|
trapdoor = EndBlocks.registerBlock(name + "_trapdoor", new BaseTrapdoorBlock(block));
|
||||||
bars = EndBlocks.registerBlock(name + "_bars", new BaseMetalBarsBlock(block));
|
bars = EndBlocks.registerBlock(name + "_bars", new BaseMetalBarsBlock(block));
|
||||||
chain = EndBlocks.registerBlock(name + "_chain", new BaseChainBlock(block.defaultMaterialColor()));
|
chain = EndBlocks.registerBlock(name + "_chain", new BaseChainBlock(block.defaultMaterialColor()));
|
||||||
pressurePlate = EndBlocks.registerBlock(name + "_plate", new WoodenPressurePlateBlock(block));
|
pressurePlate = EndBlocks.registerBlock(name + "_plate", new WoodenPressurePlateBlock(block));
|
||||||
|
|
||||||
chandelier = EndBlocks.registerBlock(name + "_chandelier", new ChandelierBlock(block));
|
chandelier = EndBlocks.registerBlock(name + "_chandelier", new ChandelierBlock(block));
|
||||||
bulb_lantern = EndBlocks.registerBlock(name + "_bulb_lantern", new BulbVineLanternBlock(lanternProperties));
|
bulb_lantern = EndBlocks.registerBlock(name + "_bulb_lantern", new BulbVineLanternBlock(lanternProperties));
|
||||||
bulb_lantern_colored = new ColoredMaterial(BulbVineLanternColoredBlock::new, bulb_lantern, false);
|
bulb_lantern_colored = new ColoredMaterial(BulbVineLanternColoredBlock::new, bulb_lantern, false);
|
||||||
|
|
||||||
nugget = EndItems.registerEndItem(name + "_nugget", new ModelProviderItem(itemSettings));
|
nugget = EndItems.registerEndItem(name + "_nugget", new ModelProviderItem(itemSettings));
|
||||||
ingot = EndItems.registerEndItem(name + "_ingot", new ModelProviderItem(itemSettings));
|
ingot = EndItems.registerEndItem(name + "_ingot", new ModelProviderItem(itemSettings));
|
||||||
|
|
||||||
shovelHead = EndItems.registerEndItem(name + "_shovel_head");
|
shovelHead = EndItems.registerEndItem(name + "_shovel_head");
|
||||||
pickaxeHead = EndItems.registerEndItem(name + "_pickaxe_head");
|
pickaxeHead = EndItems.registerEndItem(name + "_pickaxe_head");
|
||||||
axeHead = EndItems.registerEndItem(name + "_axe_head");
|
axeHead = EndItems.registerEndItem(name + "_axe_head");
|
||||||
hoeHead = EndItems.registerEndItem(name + "_hoe_head");
|
hoeHead = EndItems.registerEndItem(name + "_hoe_head");
|
||||||
swordBlade = EndItems.registerEndItem(name + "_sword_blade");
|
swordBlade = EndItems.registerEndItem(name + "_sword_blade");
|
||||||
swordHandle = EndItems.registerEndItem(name + "_sword_handle");
|
swordHandle = EndItems.registerEndItem(name + "_sword_handle");
|
||||||
|
|
||||||
shovel = EndItems.registerEndTool(name + "_shovel", new BaseShovelItem(material, 1.5F, -3.0F, itemSettings));
|
shovel = EndItems.registerEndTool(name + "_shovel", new BaseShovelItem(material, 1.5F, -3.0F, itemSettings));
|
||||||
sword = EndItems.registerEndTool(name + "_sword", new BaseSwordItem(material, 3, -2.4F, itemSettings));
|
sword = EndItems.registerEndTool(name + "_sword", new BaseSwordItem(material, 3, -2.4F, itemSettings));
|
||||||
pickaxe = EndItems.registerEndTool(name + "_pickaxe", new EndPickaxe(material, 1, -2.8F, itemSettings));
|
pickaxe = EndItems.registerEndTool(name + "_pickaxe", new EndPickaxe(material, 1, -2.8F, itemSettings));
|
||||||
axe = EndItems.registerEndTool(name + "_axe", new BaseAxeItem(material, 6.0F, -3.0F, itemSettings));
|
axe = EndItems.registerEndTool(name + "_axe", new BaseAxeItem(material, 6.0F, -3.0F, itemSettings));
|
||||||
hoe = EndItems.registerEndTool(name + "_hoe", new BaseHoeItem(material, -3, 0.0F, itemSettings));
|
hoe = EndItems.registerEndTool(name + "_hoe", new BaseHoeItem(material, -3, 0.0F, itemSettings));
|
||||||
hammer = EndItems.registerEndTool(
|
hammer = EndItems.registerEndTool(
|
||||||
name + "_hammer",
|
name + "_hammer",
|
||||||
new EndHammerItem(material, 5.0F, -3.2F, 0.3D, itemSettings)
|
new EndHammerItem(material, 5.0F, -3.2F, 0.3D, itemSettings)
|
||||||
);
|
);
|
||||||
|
|
||||||
forgedPlate = EndItems.registerEndItem(name + "_forged_plate");
|
forgedPlate = EndItems.registerEndItem(name + "_forged_plate");
|
||||||
helmet = EndItems.registerEndItem(name + "_helmet", new EndArmorItem(armor, EquipmentSlot.HEAD, itemSettings));
|
helmet = EndItems.registerEndItem(name + "_helmet", new EndArmorItem(armor, EquipmentSlot.HEAD, itemSettings));
|
||||||
chestplate = EndItems.registerEndItem(
|
chestplate = EndItems.registerEndItem(
|
||||||
name + "_chestplate",
|
name + "_chestplate",
|
||||||
new EndArmorItem(armor, EquipmentSlot.CHEST, itemSettings)
|
new EndArmorItem(armor, EquipmentSlot.CHEST, itemSettings)
|
||||||
);
|
);
|
||||||
leggings = EndItems.registerEndItem(
|
leggings = EndItems.registerEndItem(
|
||||||
name + "_leggings",
|
name + "_leggings",
|
||||||
new EndArmorItem(armor, EquipmentSlot.LEGS, itemSettings)
|
new EndArmorItem(armor, EquipmentSlot.LEGS, itemSettings)
|
||||||
);
|
);
|
||||||
boots = EndItems.registerEndItem(name + "_boots", new EndArmorItem(armor, EquipmentSlot.FEET, itemSettings));
|
boots = EndItems.registerEndItem(name + "_boots", new EndArmorItem(armor, EquipmentSlot.FEET, itemSettings));
|
||||||
|
|
||||||
anvilBlock = EndBlocks.registerBlock(
|
anvilBlock = EndBlocks.registerBlock(
|
||||||
name + "_anvil",
|
name + "_anvil",
|
||||||
new EndAnvilBlock(this, block.defaultMaterialColor(), level)
|
new EndAnvilBlock(this, block.defaultMaterialColor(), level)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasOre) {
|
if (hasOre) {
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_ingot_furnace_ore", ore, ingot)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_ingot_furnace_ore", ore, ingot)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_ingot")
|
.setGroup("end_ingot")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_ingot_furnace_raw", rawOre, ingot)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_ingot_furnace_raw", rawOre, ingot)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_ingot")
|
.setGroup("end_ingot")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
AlloyingRecipe.Builder.create(name + "_ingot_alloy")
|
AlloyingRecipe.Builder.create(name + "_ingot_alloy")
|
||||||
.setInput(alloyingOre, alloyingOre)
|
.setInput(alloyingOre, alloyingOre)
|
||||||
.setOutput(ingot, 3)
|
.setOutput(ingot, 3)
|
||||||
.setExpiriense(2.1F)
|
.setExpiriense(2.1F)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic recipes
|
// Basic recipes
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_ingot_from_nuggets", ingot)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_ingot_from_nuggets", ingot)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("###", "###", "###")
|
.setShape("###", "###", "###")
|
||||||
.addMaterial('#', nugget)
|
.addMaterial('#', nugget)
|
||||||
.setGroup("end_metal_ingots_nug")
|
.setGroup("end_metal_ingots_nug")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_nuggets_from_ingot", nugget)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_nuggets_from_ingot", nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutputCount(9)
|
.setOutputCount(9)
|
||||||
.setList("#")
|
.setList("#")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.setGroup("end_metal_nuggets_ing")
|
.setGroup("end_metal_nuggets_ing")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_block", block)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_block", block)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("###", "###", "###")
|
.setShape("###", "###", "###")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.setGroup("end_metal_blocks")
|
.setGroup("end_metal_blocks")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_ingot_from_block", ingot)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_ingot_from_block", ingot)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutputCount(9)
|
.setOutputCount(9)
|
||||||
.setList("#")
|
.setList("#")
|
||||||
.addMaterial('#', block)
|
.addMaterial('#', block)
|
||||||
.setGroup("end_metal_ingots")
|
.setGroup("end_metal_ingots")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Block recipes
|
// Block recipes
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_tile", tile)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_tile", tile)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutputCount(4)
|
.setOutputCount(4)
|
||||||
.setShape("##", "##")
|
.setShape("##", "##")
|
||||||
.addMaterial('#', block)
|
.addMaterial('#', block)
|
||||||
.setGroup("end_metal_tiles")
|
.setGroup("end_metal_tiles")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_bars", bars)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_bars", bars)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutputCount(16)
|
.setOutputCount(16)
|
||||||
.setShape("###", "###")
|
.setShape("###", "###")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.setGroup("end_metal_bars")
|
.setGroup("end_metal_bars")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_pressure_plate", pressurePlate)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_pressure_plate", pressurePlate)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("##")
|
.setShape("##")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.setGroup("end_metal_plates")
|
.setGroup("end_metal_plates")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_door", door)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_door", door)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutputCount(3)
|
.setOutputCount(3)
|
||||||
.setShape("##", "##", "##")
|
.setShape("##", "##", "##")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.setGroup("end_metal_doors")
|
.setGroup("end_metal_doors")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_trapdoor", trapdoor)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_trapdoor", trapdoor)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("##", "##")
|
.setShape("##", "##")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.setGroup("end_metal_trapdoors")
|
.setGroup("end_metal_trapdoors")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_stairs", stairs)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_stairs", stairs)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutputCount(4)
|
.setOutputCount(4)
|
||||||
.setShape("# ", "## ", "###")
|
.setShape("# ", "## ", "###")
|
||||||
.addMaterial('#', block, tile)
|
.addMaterial('#', block, tile)
|
||||||
.setGroup("end_metal_stairs")
|
.setGroup("end_metal_stairs")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_slab", slab)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_slab", slab)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutputCount(6)
|
.setOutputCount(6)
|
||||||
.setShape("###")
|
.setShape("###")
|
||||||
.addMaterial('#', block, tile)
|
.addMaterial('#', block, tile)
|
||||||
.setGroup("end_metal_slabs")
|
.setGroup("end_metal_slabs")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_chain", chain)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_chain", chain)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("N", "#", "N")
|
.setShape("N", "#", "N")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.addMaterial('N', nugget)
|
.addMaterial('N', nugget)
|
||||||
.setGroup("end_metal_chain")
|
.setGroup("end_metal_chain")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_anvil", anvilBlock)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_anvil", anvilBlock)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("###", " I ", "III")
|
.setShape("###", " I ", "III")
|
||||||
.addMaterial('#', block, tile)
|
.addMaterial('#', block, tile)
|
||||||
.addMaterial('I', ingot)
|
.addMaterial('I', ingot)
|
||||||
.setGroup("end_metal_anvil")
|
.setGroup("end_metal_anvil")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_bulb_lantern", bulb_lantern)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_bulb_lantern", bulb_lantern)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("C", "I", "#")
|
.setShape("C", "I", "#")
|
||||||
.addMaterial('C', chain)
|
.addMaterial('C', chain)
|
||||||
.addMaterial('I', ingot)
|
.addMaterial('I', ingot)
|
||||||
.addMaterial('#', EndItems.GLOWING_BULB)
|
.addMaterial('#', EndItems.GLOWING_BULB)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_chandelier", chandelier)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_chandelier", chandelier)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("I#I", " # ")
|
.setShape("I#I", " # ")
|
||||||
.addMaterial('#', ingot)
|
.addMaterial('#', ingot)
|
||||||
.addMaterial('I', EndItems.LUMECORN_ROD)
|
.addMaterial('I', EndItems.LUMECORN_ROD)
|
||||||
.setGroup("end_metal_chandelier")
|
.setGroup("end_metal_chandelier")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Tools & armor into nuggets
|
// Tools & armor into nuggets
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_axe_nugget", axe, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_axe_nugget", axe, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_hoe_nugget", hoe, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_hoe_nugget", hoe, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_pickaxe_nugget", pickaxe, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_pickaxe_nugget", pickaxe, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_sword_nugget", sword, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_sword_nugget", sword, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_hammer_nugget", hammer, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_hammer_nugget", hammer, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_helmet_nugget", helmet, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_helmet_nugget", helmet, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_chestplate_nugget", chestplate, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_chestplate_nugget", chestplate, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_leggings_nugget", leggings, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_leggings_nugget", leggings, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_boots_nugget", boots, nugget)
|
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_boots_nugget", boots, nugget)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_nugget")
|
.setGroup("end_nugget")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
|
|
||||||
// Tool parts from ingots
|
// Tool parts from ingots
|
||||||
AnvilRecipe.Builder.create(name + "_shovel_head")
|
AnvilRecipe.create(name + "_shovel_head")
|
||||||
.setInput(ingot)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutput(shovelHead)
|
.setInput(ingot)
|
||||||
.setAnvilLevel(level)
|
.setOutput(shovelHead)
|
||||||
.setToolLevel(level)
|
.setAnvilLevel(level)
|
||||||
.setDamage(level)
|
.setToolLevel(level)
|
||||||
.build();
|
.setDamage(level)
|
||||||
AnvilRecipe.Builder.create(name + "_pickaxe_head")
|
.build();
|
||||||
.setInput(ingot)
|
AnvilRecipe.create(name + "_pickaxe_head")
|
||||||
.setInputCount(3)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutput(pickaxeHead)
|
.setInput(ingot)
|
||||||
.setAnvilLevel(level)
|
.setInputCount(3)
|
||||||
.setToolLevel(level)
|
.setOutput(pickaxeHead)
|
||||||
.setDamage(level)
|
.setAnvilLevel(level)
|
||||||
.build();
|
.setToolLevel(level)
|
||||||
AnvilRecipe.Builder.create(name + "_axe_head")
|
.setDamage(level)
|
||||||
.setInput(ingot)
|
.build();
|
||||||
.setInputCount(3)
|
AnvilRecipe.create(name + "_axe_head")
|
||||||
.setOutput(axeHead)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setAnvilLevel(level)
|
.setInput(ingot)
|
||||||
.setToolLevel(level)
|
.setInputCount(3)
|
||||||
.setDamage(level)
|
.setOutput(axeHead)
|
||||||
.build();
|
.setAnvilLevel(level)
|
||||||
AnvilRecipe.Builder.create(name + "_hoe_head")
|
.setToolLevel(level)
|
||||||
.setInput(ingot)
|
.setDamage(level)
|
||||||
.setInputCount(2)
|
.build();
|
||||||
.setOutput(hoeHead)
|
AnvilRecipe.create(name + "_hoe_head")
|
||||||
.setAnvilLevel(level)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setToolLevel(level)
|
.setInput(ingot)
|
||||||
.setDamage(level)
|
.setInputCount(2)
|
||||||
.build();
|
.setOutput(hoeHead)
|
||||||
AnvilRecipe.Builder.create(name + "_sword_blade")
|
.setAnvilLevel(level)
|
||||||
.setInput(ingot)
|
.setToolLevel(level)
|
||||||
.setOutput(swordBlade)
|
.setDamage(level)
|
||||||
.setAnvilLevel(level)
|
.build();
|
||||||
.setToolLevel(level)
|
AnvilRecipe.create(name + "_sword_blade")
|
||||||
.setDamage(level)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.build();
|
.setInput(ingot)
|
||||||
AnvilRecipe.Builder.create(name + "_forged_plate")
|
.setOutput(swordBlade)
|
||||||
.setInput(ingot)
|
.setAnvilLevel(level)
|
||||||
.setOutput(forgedPlate)
|
.setToolLevel(level)
|
||||||
.setAnvilLevel(level)
|
.setDamage(level)
|
||||||
.setToolLevel(level)
|
.build();
|
||||||
.setDamage(level)
|
AnvilRecipe.create(name + "_forged_plate")
|
||||||
.build();
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
|
.setInput(ingot)
|
||||||
|
.setOutput(forgedPlate)
|
||||||
|
.setAnvilLevel(level)
|
||||||
|
.setToolLevel(level)
|
||||||
|
.setDamage(level)
|
||||||
|
.build();
|
||||||
|
|
||||||
// Tools from parts
|
// Tools from parts
|
||||||
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_hammer")
|
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_hammer")
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setResult(hammer)
|
.setResult(hammer)
|
||||||
.setBase(block)
|
.setBase(block)
|
||||||
.setAddition(Items.STICK)
|
.setAddition(Items.STICK)
|
||||||
.build();
|
.build();
|
||||||
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_axe")
|
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_axe")
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setResult(axe)
|
.setResult(axe)
|
||||||
.setBase(axeHead)
|
.setBase(axeHead)
|
||||||
.setAddition(Items.STICK)
|
.setAddition(Items.STICK)
|
||||||
.build();
|
.build();
|
||||||
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_pickaxe")
|
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_pickaxe")
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setResult(pickaxe)
|
.setResult(pickaxe)
|
||||||
.setBase(pickaxeHead)
|
.setBase(pickaxeHead)
|
||||||
.setAddition(Items.STICK)
|
.setAddition(Items.STICK)
|
||||||
.build();
|
.build();
|
||||||
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_hoe")
|
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_hoe")
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setResult(hoe)
|
.setResult(hoe)
|
||||||
.setBase(hoeHead)
|
.setBase(hoeHead)
|
||||||
.setAddition(Items.STICK)
|
.setAddition(Items.STICK)
|
||||||
.build();
|
.build();
|
||||||
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword_handle")
|
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword_handle")
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setResult(swordHandle)
|
.setResult(swordHandle)
|
||||||
.setBase(ingot)
|
.setBase(ingot)
|
||||||
.setAddition(Items.STICK)
|
.setAddition(Items.STICK)
|
||||||
.build();
|
.build();
|
||||||
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword")
|
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword")
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setResult(sword)
|
.setResult(sword)
|
||||||
.setBase(swordBlade)
|
.setBase(swordBlade)
|
||||||
.setAddition(swordHandle)
|
.setAddition(swordHandle)
|
||||||
.build();
|
.build();
|
||||||
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_shovel")
|
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_shovel")
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setResult(shovel)
|
.setResult(shovel)
|
||||||
.setBase(shovelHead)
|
.setBase(shovelHead)
|
||||||
.setAddition(Items.STICK)
|
.setAddition(Items.STICK)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Armor crafting
|
// Armor crafting
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_helmet", helmet)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_helmet", helmet)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("###", "# #")
|
.setShape("###", "# #")
|
||||||
.addMaterial('#', forgedPlate)
|
.addMaterial('#', forgedPlate)
|
||||||
.setGroup("end_metal_helmets")
|
.setGroup("end_metal_helmets")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_chestplate", chestplate)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_chestplate", chestplate)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("# #", "###", "###")
|
.setShape("# #", "###", "###")
|
||||||
.addMaterial('#', forgedPlate)
|
.addMaterial('#', forgedPlate)
|
||||||
.setGroup("end_metal_chestplates")
|
.setGroup("end_metal_chestplates")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_leggings", leggings)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_leggings", leggings)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("###", "# #", "# #")
|
.setShape("###", "# #", "# #")
|
||||||
.addMaterial('#', forgedPlate)
|
.addMaterial('#', forgedPlate)
|
||||||
.setGroup("end_metal_leggings")
|
.setGroup("end_metal_leggings")
|
||||||
.build();
|
.build();
|
||||||
GridRecipe.make(BetterEnd.MOD_ID, name + "_boots", boots)
|
GridRecipe.make(BetterEnd.MOD_ID, name + "_boots", boots)
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setShape("# #", "# #")
|
.setShape("# #", "# #")
|
||||||
.addMaterial('#', forgedPlate)
|
.addMaterial('#', forgedPlate)
|
||||||
.setGroup("end_metal_boots")
|
.setGroup("end_metal_boots")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
TagAPI.addTag(BlockTags.ANVIL, anvilBlock);
|
TagAPI.addTag(BlockTags.ANVIL, anvilBlock);
|
||||||
TagAPI.addTag(BlockTags.BEACON_BASE_BLOCKS, block);
|
TagAPI.addTag(BlockTags.BEACON_BASE_BLOCKS, block);
|
||||||
TagAPI.addTag(ItemTags.BEACON_PAYMENT_ITEMS, ingot);
|
TagAPI.addTag(ItemTags.BEACON_PAYMENT_ITEMS, ingot);
|
||||||
TagAPI.addTag(TagAPI.BLOCK_DRAGON_IMMUNE, ore, bars);
|
TagAPI.addTag(TagAPI.BLOCK_DRAGON_IMMUNE, ore, bars);
|
||||||
TagAPI.addTag(TagAPI.ITEM_HAMMERS, hammer);
|
TagAPI.addTag(TagAPI.ITEM_HAMMERS, hammer);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,10 @@
|
||||||
package ru.betterend.integration.rei;
|
package ru.betterend.integration.rei;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||||
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
|
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
|
||||||
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
|
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
|
||||||
|
@ -7,11 +12,7 @@ import me.shedaniel.rei.api.common.util.EntryIngredients;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import ru.bclib.recipes.AnvilRecipe;
|
||||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class REIAnvilDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
|
public class REIAnvilDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package ru.betterend.integration.rei;
|
package ru.betterend.integration.rei;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
|
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
|
||||||
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
|
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
|
||||||
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
|
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
|
||||||
|
@ -17,17 +22,13 @@ import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import ru.bclib.blocks.BaseFurnaceBlock;
|
import ru.bclib.blocks.BaseFurnaceBlock;
|
||||||
|
import ru.bclib.recipes.AnvilRecipe;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||||
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;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
//https://github.com/shedaniel/RoughlyEnoughItems/blob/6.x-1.17/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
|
//https://github.com/shedaniel/RoughlyEnoughItems/blob/6.x-1.17/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
|
||||||
public class REIPlugin implements REIClientPlugin {
|
public class REIPlugin implements REIClientPlugin {
|
||||||
public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package ru.betterend.interfaces;
|
|
||||||
|
|
||||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface AnvilScreenHandlerExtended {
|
|
||||||
void be_updateCurrentRecipe(AnvilRecipe recipe);
|
|
||||||
|
|
||||||
AnvilRecipe be_getCurrentRecipe();
|
|
||||||
|
|
||||||
List<AnvilRecipe> be_getRecipes();
|
|
||||||
|
|
||||||
default void be_nextRecipe() {
|
|
||||||
List<AnvilRecipe> recipes = be_getRecipes();
|
|
||||||
if (recipes.size() < 2) return;
|
|
||||||
AnvilRecipe current = be_getCurrentRecipe();
|
|
||||||
int i = recipes.indexOf(current) + 1;
|
|
||||||
if (i >= recipes.size()) {
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
be_updateCurrentRecipe(recipes.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
default void be_previousRecipe() {
|
|
||||||
List<AnvilRecipe> recipes = be_getRecipes();
|
|
||||||
if (recipes.size() < 2) return;
|
|
||||||
AnvilRecipe current = be_getCurrentRecipe();
|
|
||||||
int i = recipes.indexOf(current) - 1;
|
|
||||||
if (i <= 0) {
|
|
||||||
i = recipes.size() - 1;
|
|
||||||
}
|
|
||||||
be_updateCurrentRecipe(recipes.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
package ru.betterend.interfaces;
|
|
||||||
|
|
||||||
public interface BetterEndRecipe {}
|
|
|
@ -1,95 +0,0 @@
|
||||||
package ru.betterend.mixin.client;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
|
||||||
import net.minecraft.client.gui.screens.inventory.AnvilScreen;
|
|
||||||
import net.minecraft.client.gui.screens.inventory.ItemCombinerScreen;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
||||||
import net.minecraft.world.inventory.AnvilMenu;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import ru.betterend.interfaces.AnvilScreenHandlerExtended;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mixin(AnvilScreen.class)
|
|
||||||
public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
private EditBox name;
|
|
||||||
|
|
||||||
private final List<AbstractWidget> be_buttons = Lists.newArrayList();
|
|
||||||
|
|
||||||
public AnvilScreenMixin(AnvilMenu handler, Inventory playerInventory, Component title, ResourceLocation texture) {
|
|
||||||
super(handler, playerInventory, title, texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "subInit", at = @At("TAIL"))
|
|
||||||
protected void be_subInit(CallbackInfo info) {
|
|
||||||
int x = (width - imageWidth) / 2;
|
|
||||||
int y = (height - imageHeight) / 2;
|
|
||||||
be_buttons.clear();
|
|
||||||
be_buttons.add(new Button(x + 8, y + 45, 15, 20, new TextComponent("<"), b -> be_previousRecipe()));
|
|
||||||
be_buttons.add(new Button(x + 154, y + 45, 15, 20, new TextComponent(">"), b -> be_nextRecipe()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "renderFg", at = @At("TAIL"))
|
|
||||||
protected void be_renderForeground(PoseStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
|
|
||||||
be_buttons.forEach(button -> {
|
|
||||||
button.render(matrices, mouseX, mouseY, delta);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "slotChanged", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void be_onSlotUpdate(AbstractContainerMenu handler, int slotId, ItemStack stack, CallbackInfo info) {
|
|
||||||
AnvilScreenHandlerExtended anvilHandler = (AnvilScreenHandlerExtended) handler;
|
|
||||||
if (anvilHandler.be_getCurrentRecipe() != null) {
|
|
||||||
if (anvilHandler.be_getRecipes().size() > 1) {
|
|
||||||
be_buttons.forEach(button -> button.visible = true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
be_buttons.forEach(button -> button.visible = false);
|
|
||||||
}
|
|
||||||
name.setValue("");
|
|
||||||
info.cancel();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
be_buttons.forEach(button -> button.visible = false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void be_nextRecipe() {
|
|
||||||
((AnvilScreenHandlerExtended) menu).be_nextRecipe();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void be_previousRecipe() {
|
|
||||||
((AnvilScreenHandlerExtended) menu).be_previousRecipe();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
|
||||||
if (minecraft != null) {
|
|
||||||
for (AbstractWidget elem : be_buttons) {
|
|
||||||
if (elem.visible && elem.mouseClicked(mouseX, mouseY, button)) {
|
|
||||||
if (minecraft.gameMode != null) {
|
|
||||||
int i = be_buttons.indexOf(elem);
|
|
||||||
minecraft.gameMode.handleInventoryButtonClick(menu.containerId, i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.mouseClicked(mouseX, mouseY, button);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package ru.betterend.mixin.client;
|
|
||||||
|
|
||||||
import net.minecraft.client.ClientRecipeBook;
|
|
||||||
import net.minecraft.client.RecipeBookCategories;
|
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
import ru.betterend.interfaces.BetterEndRecipe;
|
|
||||||
|
|
||||||
@Mixin(ClientRecipeBook.class)
|
|
||||||
public abstract class ClientRecipeBookMixin {
|
|
||||||
@Inject(method = "getCategory", at = @At("HEAD"), cancellable = true)
|
|
||||||
private static void be_getGroupForRecipe(Recipe<?> recipe, CallbackInfoReturnable<RecipeBookCategories> info) {
|
|
||||||
if (recipe instanceof BetterEndRecipe) {
|
|
||||||
info.setReturnValue(RecipeBookCategories.UNKNOWN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,159 +0,0 @@
|
||||||
package ru.betterend.mixin.common;
|
|
||||||
|
|
||||||
import net.minecraft.tags.BlockTags;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.inventory.AnvilMenu;
|
|
||||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
|
||||||
import net.minecraft.world.inventory.DataSlot;
|
|
||||||
import net.minecraft.world.inventory.ItemCombinerMenu;
|
|
||||||
import net.minecraft.world.inventory.MenuType;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeManager;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
import ru.bclib.blocks.BaseAnvilBlock;
|
|
||||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
|
||||||
import ru.betterend.interfaces.AnvilScreenHandlerExtended;
|
|
||||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Mixin(AnvilMenu.class)
|
|
||||||
public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilScreenHandlerExtended {
|
|
||||||
private List<AnvilRecipe> be_recipes = Collections.emptyList();
|
|
||||||
private AnvilRecipe be_currentRecipe;
|
|
||||||
private DataSlot anvilLevel;
|
|
||||||
|
|
||||||
public AnvilMenuMixin(int syncId, Inventory playerInventory) {
|
|
||||||
super(MenuType.ANVIL, syncId, playerInventory, ContainerLevelAccess.NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/inventory/ContainerLevelAccess;)V", at = @At("TAIL"))
|
|
||||||
public void be_initAnvilLevel(int syncId, Inventory inventory, ContainerLevelAccess context, CallbackInfo info) {
|
|
||||||
this.anvilLevel = addDataSlot(DataSlot.standalone());
|
|
||||||
if (context != ContainerLevelAccess.NULL) {
|
|
||||||
int level = context.evaluate((world, blockPos) -> {
|
|
||||||
Block anvilBlock = world.getBlockState(blockPos).getBlock();
|
|
||||||
if (anvilBlock instanceof EndAnvilBlock) {
|
|
||||||
return ((EndAnvilBlock) anvilBlock).getCraftingLevel();
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}, 1);
|
|
||||||
anvilLevel.set(level);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
anvilLevel.set(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract void createResult();
|
|
||||||
|
|
||||||
@Inject(method = "mayPickup", at = @At("HEAD"), cancellable = true)
|
|
||||||
protected void be_canTakeOutput(Player player, boolean present, CallbackInfoReturnable<Boolean> info) {
|
|
||||||
if (be_currentRecipe != null) {
|
|
||||||
info.setReturnValue(be_currentRecipe.checkHammerDurability(inputSlots, player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "onTake", at = @At("HEAD"), cancellable = true)
|
|
||||||
protected void be_onTakeOutput(Player player, ItemStack stack, CallbackInfo info) {
|
|
||||||
if (be_currentRecipe != null) {
|
|
||||||
inputSlots.getItem(0).shrink(be_currentRecipe.getInputCount());
|
|
||||||
stack = be_currentRecipe.craft(inputSlots, player);
|
|
||||||
slotsChanged(inputSlots);
|
|
||||||
access.execute((world, blockPos) -> {
|
|
||||||
BlockState anvilState = world.getBlockState(blockPos);
|
|
||||||
BaseAnvilBlock anvil = (BaseAnvilBlock) anvilState.getBlock();
|
|
||||||
if (!player.getAbilities().instabuild && anvilState.is(BlockTags.ANVIL) && player.getRandom().nextDouble() < 0.1) {
|
|
||||||
BlockState damagedState = anvil.damageAnvilUse(anvilState, player.getRandom());
|
|
||||||
if (damagedState == null) {
|
|
||||||
world.removeBlock(blockPos, false);
|
|
||||||
world.levelEvent(1029, blockPos, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
world.setBlock(blockPos, damagedState, 2);
|
|
||||||
world.levelEvent(1030, blockPos, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
world.levelEvent(1030, blockPos, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
info.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "createResult", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void be_updateOutput(CallbackInfo info) {
|
|
||||||
RecipeManager recipeManager = this.player.level.getRecipeManager();
|
|
||||||
be_recipes = recipeManager.getRecipesFor(AnvilRecipe.TYPE, inputSlots, player.level);
|
|
||||||
if (be_recipes.size() > 0) {
|
|
||||||
int anvilLevel = this.anvilLevel.get();
|
|
||||||
be_recipes = be_recipes.stream()
|
|
||||||
.filter(recipe -> anvilLevel >= recipe.getAnvilLevel())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (be_recipes.size() > 0) {
|
|
||||||
if (be_currentRecipe == null || !be_recipes.contains(be_currentRecipe)) {
|
|
||||||
be_currentRecipe = be_recipes.get(0);
|
|
||||||
}
|
|
||||||
be_updateResult();
|
|
||||||
info.cancel();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
be_currentRecipe = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "setItemName", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void be_setNewItemName(String string, CallbackInfo info) {
|
|
||||||
if (be_currentRecipe != null) {
|
|
||||||
info.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean clickMenuButton(Player player, int id) {
|
|
||||||
if (id == 0) {
|
|
||||||
be_previousRecipe();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == 1) {
|
|
||||||
be_nextRecipe();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.clickMenuButton(player, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void be_updateResult() {
|
|
||||||
if (be_currentRecipe == null) return;
|
|
||||||
resultSlots.setItem(0, be_currentRecipe.assemble(inputSlots));
|
|
||||||
broadcastChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void be_updateCurrentRecipe(AnvilRecipe recipe) {
|
|
||||||
this.be_currentRecipe = recipe;
|
|
||||||
be_updateResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AnvilRecipe be_getCurrentRecipe() {
|
|
||||||
return be_currentRecipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AnvilRecipe> be_getRecipes() {
|
|
||||||
return be_recipes;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +1,84 @@
|
||||||
package ru.betterend.recipe;
|
package ru.betterend.recipe;
|
||||||
|
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
import ru.bclib.recipes.AnvilRecipe;
|
||||||
|
import ru.betterend.config.Configs;
|
||||||
import ru.betterend.item.material.EndToolMaterial;
|
import ru.betterend.item.material.EndToolMaterial;
|
||||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
public class AnvilRecipes {
|
public class AnvilRecipes {
|
||||||
public static void register() {
|
public static void register() {
|
||||||
AnvilRecipe.Builder.create("ender_pearl_to_dust")
|
AnvilRecipe.create("ender_pearl_to_dust")
|
||||||
.setInput(Items.ENDER_PEARL)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutput(EndItems.ENDER_DUST)
|
.setInput(Items.ENDER_PEARL)
|
||||||
.setToolLevel(4)
|
.setOutput(EndItems.ENDER_DUST)
|
||||||
.setDamage(5)
|
.setToolLevel(4)
|
||||||
.build();
|
.setDamage(5)
|
||||||
AnvilRecipe.Builder.create("ender_shard_to_dust")
|
.build();
|
||||||
.setInput(EndItems.ENDER_SHARD)
|
AnvilRecipe.create("ender_shard_to_dust")
|
||||||
.setOutput(EndItems.ENDER_DUST)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setToolLevel(0)
|
.setInput(EndItems.ENDER_SHARD)
|
||||||
.setDamage(3)
|
.setOutput(EndItems.ENDER_DUST)
|
||||||
.build();
|
.setToolLevel(0)
|
||||||
|
.setDamage(3)
|
||||||
|
.build();
|
||||||
|
|
||||||
int anvilLevel = EndToolMaterial.AETERNIUM.getLevel();
|
int anvilLevel = EndToolMaterial.AETERNIUM.getLevel();
|
||||||
AnvilRecipe.Builder.create("aeternium_axe_head")
|
AnvilRecipe.create("aeternium_axe_head")
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setOutput(EndItems.AETERNIUM_AXE_HEAD)
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
.setAnvilLevel(anvilLevel)
|
.setOutput(EndItems.AETERNIUM_AXE_HEAD)
|
||||||
.setToolLevel(anvilLevel)
|
.setAnvilLevel(anvilLevel)
|
||||||
.setDamage(6)
|
.setToolLevel(anvilLevel)
|
||||||
.build();
|
.setDamage(6)
|
||||||
AnvilRecipe.Builder.create("aeternium_pickaxe_head")
|
.build();
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
AnvilRecipe.create("aeternium_pickaxe_head")
|
||||||
.setOutput(EndItems.AETERNIUM_PICKAXE_HEAD)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setAnvilLevel(anvilLevel)
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
.setToolLevel(anvilLevel)
|
.setOutput(EndItems.AETERNIUM_PICKAXE_HEAD)
|
||||||
.setDamage(6)
|
.setAnvilLevel(anvilLevel)
|
||||||
.build();
|
.setToolLevel(anvilLevel)
|
||||||
AnvilRecipe.Builder.create("aeternium_shovel_head")
|
.setDamage(6)
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.build();
|
||||||
.setOutput(EndItems.AETERNIUM_SHOVEL_HEAD)
|
AnvilRecipe.create("aeternium_shovel_head")
|
||||||
.setAnvilLevel(anvilLevel)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setToolLevel(anvilLevel)
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
.setDamage(6)
|
.setOutput(EndItems.AETERNIUM_SHOVEL_HEAD)
|
||||||
.build();
|
.setAnvilLevel(anvilLevel)
|
||||||
AnvilRecipe.Builder.create("aeternium_hoe_head")
|
.setToolLevel(anvilLevel)
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setDamage(6)
|
||||||
.setOutput(EndItems.AETERNIUM_HOE_HEAD)
|
.build();
|
||||||
.setAnvilLevel(anvilLevel)
|
AnvilRecipe.create("aeternium_hoe_head")
|
||||||
.setToolLevel(anvilLevel)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setDamage(6)
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
.build();
|
.setOutput(EndItems.AETERNIUM_HOE_HEAD)
|
||||||
AnvilRecipe.Builder.create("aeternium_hammer_head")
|
.setAnvilLevel(anvilLevel)
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setToolLevel(anvilLevel)
|
||||||
.setOutput(EndItems.AETERNIUM_HAMMER_HEAD)
|
.setDamage(6)
|
||||||
.setAnvilLevel(anvilLevel)
|
.build();
|
||||||
.setToolLevel(EndToolMaterial.THALLASIUM.getLevel())
|
AnvilRecipe.create("aeternium_hammer_head")
|
||||||
.setDamage(6)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.build();
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
AnvilRecipe.Builder.create("aeternium_sword_blade")
|
.setOutput(EndItems.AETERNIUM_HAMMER_HEAD)
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setAnvilLevel(anvilLevel)
|
||||||
.setOutput(EndItems.AETERNIUM_SWORD_BLADE)
|
.setToolLevel(EndToolMaterial.THALLASIUM.getLevel())
|
||||||
.setAnvilLevel(anvilLevel)
|
.setDamage(6)
|
||||||
.setToolLevel(anvilLevel)
|
.build();
|
||||||
.setDamage(6)
|
AnvilRecipe.create("aeternium_sword_blade")
|
||||||
.build();
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
AnvilRecipe.Builder.create("aeternium_forged_plate")
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
.setInput(EndItems.AETERNIUM_INGOT)
|
.setOutput(EndItems.AETERNIUM_SWORD_BLADE)
|
||||||
.setOutput(EndItems.AETERNIUM_FORGED_PLATE)
|
.setAnvilLevel(anvilLevel)
|
||||||
.setAnvilLevel(anvilLevel)
|
.setToolLevel(anvilLevel)
|
||||||
.setToolLevel(anvilLevel)
|
.setDamage(6)
|
||||||
.setDamage(6)
|
.build();
|
||||||
.build();
|
AnvilRecipe.create("aeternium_forged_plate")
|
||||||
}
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
|
.setInput(EndItems.AETERNIUM_INGOT)
|
||||||
|
.setOutput(EndItems.AETERNIUM_FORGED_PLATE)
|
||||||
|
.setAnvilLevel(anvilLevel)
|
||||||
|
.setToolLevel(anvilLevel)
|
||||||
|
.setDamage(6)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,15 @@ import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import ru.bclib.interfaces.UnknownReceipBookCategory;
|
||||||
import ru.bclib.recipes.BCLRecipeManager;
|
import ru.bclib.recipes.BCLRecipeManager;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.config.Configs;
|
import ru.betterend.config.Configs;
|
||||||
import ru.betterend.interfaces.BetterEndRecipe;
|
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.util.ItemUtil;
|
import ru.bclib.util.ItemUtil;
|
||||||
import ru.betterend.util.RecipeHelper;
|
import ru.bclib.util.RecipeHelper;
|
||||||
|
|
||||||
public class AlloyingRecipe implements Recipe<Container>, BetterEndRecipe {
|
public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCategory {
|
||||||
public final static String GROUP = "alloying";
|
public final static String GROUP = "alloying";
|
||||||
public final static RecipeType<AlloyingRecipe> TYPE = BCLRecipeManager.registerType(BetterEnd.MOD_ID, GROUP);
|
public final static RecipeType<AlloyingRecipe> TYPE = BCLRecipeManager.registerType(BetterEnd.MOD_ID, GROUP);
|
||||||
public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer(
|
public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer(
|
||||||
|
|
|
@ -1,329 +0,0 @@
|
||||||
package ru.betterend.recipe.builders;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.core.NonNullList;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.TagParser;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.Tag;
|
|
||||||
import net.minecraft.util.GsonHelper;
|
|
||||||
import net.minecraft.world.Container;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.TieredItem;
|
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import ru.bclib.api.TagAPI;
|
|
||||||
import ru.bclib.recipes.BCLRecipeManager;
|
|
||||||
import ru.betterend.BetterEnd;
|
|
||||||
import ru.betterend.config.Configs;
|
|
||||||
import ru.betterend.interfaces.BetterEndRecipe;
|
|
||||||
import ru.betterend.util.ItemUtil;
|
|
||||||
import ru.betterend.util.RecipeHelper;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class AnvilRecipe implements Recipe<Container>, BetterEndRecipe {
|
|
||||||
public final static String GROUP = "smithing";
|
|
||||||
public final static RecipeType<AnvilRecipe> TYPE = BCLRecipeManager.registerType(BetterEnd.MOD_ID, GROUP);
|
|
||||||
public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer(
|
|
||||||
BetterEnd.MOD_ID,
|
|
||||||
GROUP,
|
|
||||||
new Serializer()
|
|
||||||
);
|
|
||||||
public final static ResourceLocation ID = BetterEnd.makeID(GROUP);
|
|
||||||
|
|
||||||
private final ResourceLocation id;
|
|
||||||
private final Ingredient input;
|
|
||||||
private final ItemStack output;
|
|
||||||
private final int damage;
|
|
||||||
private final int toolLevel;
|
|
||||||
private final int anvilLevel;
|
|
||||||
private final int inputCount;
|
|
||||||
|
|
||||||
public AnvilRecipe(ResourceLocation identifier, Ingredient input, ItemStack output, int inputCount, int toolLevel, int anvilLevel, int damage) {
|
|
||||||
this.id = identifier;
|
|
||||||
this.input = input;
|
|
||||||
this.output = output;
|
|
||||||
this.toolLevel = toolLevel;
|
|
||||||
this.anvilLevel = anvilLevel;
|
|
||||||
this.inputCount = inputCount;
|
|
||||||
this.damage = damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeSerializer<?> getSerializer() {
|
|
||||||
return SERIALIZER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getResultItem() {
|
|
||||||
return this.output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(Container craftingInventory, Level world) {
|
|
||||||
return this.matches(craftingInventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack assemble(Container craftingInventory) {
|
|
||||||
return this.output.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack craft(Container craftingInventory, Player player) {
|
|
||||||
if (!player.isCreative()) {
|
|
||||||
if (!checkHammerDurability(craftingInventory, player)) return ItemStack.EMPTY;
|
|
||||||
ItemStack hammer = craftingInventory.getItem(1);
|
|
||||||
hammer.hurtAndBreak(this.damage, player, entity -> entity.broadcastBreakEvent((InteractionHand) null));
|
|
||||||
}
|
|
||||||
return this.assemble(craftingInventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkHammerDurability(Container craftingInventory, Player player) {
|
|
||||||
if (player.isCreative()) return true;
|
|
||||||
ItemStack hammer = craftingInventory.getItem(1);
|
|
||||||
int damage = hammer.getDamageValue() + this.damage;
|
|
||||||
return damage < hammer.getMaxDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean matches(Container craftingInventory) {
|
|
||||||
ItemStack hammer = craftingInventory.getItem(1);
|
|
||||||
if (hammer.isEmpty() || !TagAPI.ITEM_HAMMERS.contains(hammer.getItem())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ItemStack material = craftingInventory.getItem(0);
|
|
||||||
int materialCount = material.getCount();
|
|
||||||
int level = ((TieredItem) hammer.getItem()).getTier().getLevel();
|
|
||||||
return this.input.test(craftingInventory.getItem(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 NonNullList<Ingredient> getIngredients() {
|
|
||||||
NonNullList<Ingredient> defaultedList = NonNullList.create();
|
|
||||||
defaultedList.add(Ingredient.of(TagAPI.ITEM_HAMMERS.getValues()
|
|
||||||
.stream()
|
|
||||||
.filter(hammer -> ((TieredItem) hammer).getTier()
|
|
||||||
.getLevel() >= toolLevel)
|
|
||||||
.map(ItemStack::new)));
|
|
||||||
defaultedList.add(input);
|
|
||||||
|
|
||||||
return defaultedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public boolean canCraftInDimensions(int width, int height) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeType<?> getType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSpecial() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
AnvilRecipe that = (AnvilRecipe) o;
|
|
||||||
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, toolLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "AnvilRecipe [" + id + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
private final static Builder INSTANCE = new Builder();
|
|
||||||
|
|
||||||
public static Builder create(String id) {
|
|
||||||
return create(BetterEnd.makeID(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder create(ResourceLocation id) {
|
|
||||||
INSTANCE.id = id;
|
|
||||||
INSTANCE.input = null;
|
|
||||||
INSTANCE.output = null;
|
|
||||||
INSTANCE.inputCount = 1;
|
|
||||||
INSTANCE.toolLevel = 1;
|
|
||||||
INSTANCE.anvilLevel = 1;
|
|
||||||
INSTANCE.damage = 1;
|
|
||||||
INSTANCE.alright = true;
|
|
||||||
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResourceLocation id;
|
|
||||||
private Ingredient input;
|
|
||||||
private ItemStack output;
|
|
||||||
private int inputCount = 1;
|
|
||||||
private int toolLevel = 1;
|
|
||||||
private int anvilLevel = 1;
|
|
||||||
private int damage = 1;
|
|
||||||
private boolean alright;
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setInput(ItemLike... inputItems) {
|
|
||||||
this.alright &= RecipeHelper.exists(inputItems);
|
|
||||||
this.setInput(Ingredient.of(inputItems));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setInput(Tag<Item> inputTag) {
|
|
||||||
this.setInput(Ingredient.of(inputTag));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setInput(Ingredient ingredient) {
|
|
||||||
this.input = ingredient;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setInputCount(int count) {
|
|
||||||
this.inputCount = count;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setOutput(ItemLike output) {
|
|
||||||
return this.setOutput(output, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setOutput(ItemLike output, int amount) {
|
|
||||||
this.alright &= RecipeHelper.exists(output);
|
|
||||||
this.output = new ItemStack(output, amount);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setToolLevel(int level) {
|
|
||||||
this.toolLevel = level;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setAnvilLevel(int level) {
|
|
||||||
this.anvilLevel = level;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setDamage(int damage) {
|
|
||||||
this.damage = damage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void build() {
|
|
||||||
if (Configs.RECIPE_CONFIG.getBoolean("anvil", id.getPath(), true)) {
|
|
||||||
if (input == null) {
|
|
||||||
BetterEnd.LOGGER.warning("Input for Anvil recipe can't be 'null', recipe {} will be ignored!", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (output == null) {
|
|
||||||
BetterEnd.LOGGER.warning("Output for Anvil recipe can't be 'null', recipe {} will be ignored!", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BCLRecipeManager.getRecipe(TYPE, id) != null) {
|
|
||||||
BetterEnd.LOGGER.warning("Can't add Anvil recipe! Id {} already exists!", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!alright) {
|
|
||||||
BetterEnd.LOGGER.debug("Can't add Anvil recipe {}! Ingeredient or output not exists.", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BCLRecipeManager.addRecipe(
|
|
||||||
TYPE,
|
|
||||||
new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Serializer implements RecipeSerializer<AnvilRecipe> {
|
|
||||||
@Override
|
|
||||||
public AnvilRecipe fromJson(ResourceLocation id, JsonObject json) {
|
|
||||||
Ingredient input = Ingredient.fromJson(json.get("input"));
|
|
||||||
JsonObject result = GsonHelper.getAsJsonObject(json, "result");
|
|
||||||
ItemStack output = ItemUtil.fromJsonRecipe(result);
|
|
||||||
if (output == null) {
|
|
||||||
throw new IllegalStateException("Output item does not exists!");
|
|
||||||
}
|
|
||||||
if (result.has("nbt")) {
|
|
||||||
try {
|
|
||||||
String nbtData = GsonHelper.getAsString(result, "nbt");
|
|
||||||
CompoundTag nbt = TagParser.parseTag(nbtData);
|
|
||||||
output.setTag(nbt);
|
|
||||||
}
|
|
||||||
catch (CommandSyntaxException ex) {
|
|
||||||
BetterEnd.LOGGER.warning("Error parse nbt data for output.", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int inputCount = GsonHelper.getAsInt(json, "inputCount", 1);
|
|
||||||
int toolLevel = GsonHelper.getAsInt(json, "toolLevel", 1);
|
|
||||||
int anvilLevel = GsonHelper.getAsInt(json, "anvilLevel", 1);
|
|
||||||
int damage = GsonHelper.getAsInt(json, "damage", 1);
|
|
||||||
|
|
||||||
return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AnvilRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf packetBuffer) {
|
|
||||||
Ingredient input = Ingredient.fromNetwork(packetBuffer);
|
|
||||||
ItemStack output = packetBuffer.readItem();
|
|
||||||
int inputCount = packetBuffer.readVarInt();
|
|
||||||
int toolLevel = packetBuffer.readVarInt();
|
|
||||||
int anvilLevel = packetBuffer.readVarInt();
|
|
||||||
int damage = packetBuffer.readVarInt();
|
|
||||||
|
|
||||||
return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toNetwork(FriendlyByteBuf packetBuffer, AnvilRecipe recipe) {
|
|
||||||
recipe.input.toNetwork(packetBuffer);
|
|
||||||
packetBuffer.writeItem(recipe.output);
|
|
||||||
packetBuffer.writeVarInt(recipe.inputCount);
|
|
||||||
packetBuffer.writeVarInt(recipe.toolLevel);
|
|
||||||
packetBuffer.writeVarInt(recipe.anvilLevel);
|
|
||||||
packetBuffer.writeVarInt(recipe.damage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,9 @@
|
||||||
package ru.betterend.recipe.builders;
|
package ru.betterend.recipe.builders;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
@ -17,16 +20,14 @@ import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import ru.bclib.interfaces.UnknownReceipBookCategory;
|
||||||
import ru.bclib.recipes.BCLRecipeManager;
|
import ru.bclib.recipes.BCLRecipeManager;
|
||||||
|
import ru.bclib.util.ItemUtil;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.config.Configs;
|
import ru.betterend.config.Configs;
|
||||||
import ru.betterend.interfaces.BetterEndRecipe;
|
|
||||||
import ru.betterend.rituals.InfusionRitual;
|
import ru.betterend.rituals.InfusionRitual;
|
||||||
import ru.betterend.util.ItemUtil;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
public class InfusionRecipe implements Recipe<InfusionRitual>, UnknownReceipBookCategory {
|
||||||
|
|
||||||
public class InfusionRecipe implements Recipe<InfusionRitual>, BetterEndRecipe {
|
|
||||||
public final static String GROUP = "infusion";
|
public final static String GROUP = "infusion";
|
||||||
public final static RecipeType<InfusionRecipe> TYPE = BCLRecipeManager.registerType(BetterEnd.MOD_ID, GROUP);
|
public final static RecipeType<InfusionRecipe> TYPE = BCLRecipeManager.registerType(BetterEnd.MOD_ID, GROUP);
|
||||||
public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer(
|
public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer(
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
package ru.betterend.util;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.GsonHelper;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import ru.betterend.BetterEnd;
|
|
||||||
|
|
||||||
public class ItemUtil {
|
|
||||||
|
|
||||||
public static String toStackString(@NotNull ItemStack stack) {
|
|
||||||
try {
|
|
||||||
if (stack == null) {
|
|
||||||
throw new IllegalStateException("Stack can't be null!");
|
|
||||||
}
|
|
||||||
Item item = stack.getItem();
|
|
||||||
return Registry.ITEM.getKey(item) + ":" + stack.getCount();
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
BetterEnd.LOGGER.error("ItemStack serialization error!", ex);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static ItemStack fromStackString(String stackString) {
|
|
||||||
if (stackString == null || stackString.equals("")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
String[] parts = stackString.split(":");
|
|
||||||
if (parts.length < 2) return null;
|
|
||||||
if (parts.length == 2) {
|
|
||||||
ResourceLocation itemId = new ResourceLocation(stackString);
|
|
||||||
Item item = Registry.ITEM.getOptional(itemId).orElseThrow(() -> {
|
|
||||||
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
|
||||||
});
|
|
||||||
return new ItemStack(item);
|
|
||||||
}
|
|
||||||
ResourceLocation itemId = new ResourceLocation(parts[0], parts[1]);
|
|
||||||
Item item = Registry.ITEM.getOptional(itemId).orElseThrow(() -> {
|
|
||||||
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
|
||||||
});
|
|
||||||
return new ItemStack(item, Integer.valueOf(parts[2]));
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
BetterEnd.LOGGER.error("ItemStack deserialization error!", ex);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static ItemStack fromJsonRecipe(JsonObject recipe) {
|
|
||||||
try {
|
|
||||||
if (!recipe.has("item")) {
|
|
||||||
throw new IllegalStateException("Invalid JsonObject. Entry 'item' does not exists!");
|
|
||||||
}
|
|
||||||
ResourceLocation itemId = new ResourceLocation(GsonHelper.getAsString(recipe, "item"));
|
|
||||||
Item item = Registry.ITEM.getOptional(itemId).orElseThrow(() -> {
|
|
||||||
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
|
||||||
});
|
|
||||||
int count = GsonHelper.getAsInt(recipe, "count", 1);
|
|
||||||
return new ItemStack(item, count);
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
BetterEnd.LOGGER.error("ItemStack deserialization error!", ex);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package ru.betterend.util;
|
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
|
|
||||||
public class RecipeHelper {
|
|
||||||
public static boolean exists(ItemLike item) {
|
|
||||||
if (item instanceof Block) {
|
|
||||||
return Registry.BLOCK.getKey((Block) item) != Registry.BLOCK.getDefaultKey();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Registry.ITEM.getKey(item.asItem()) != Registry.ITEM.getDefaultKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean exists(ItemLike... items) {
|
|
||||||
for (ItemLike item : items) {
|
|
||||||
if (!exists(item)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,12 +8,10 @@
|
||||||
"ClientPlayNetworkHandlerMixin",
|
"ClientPlayNetworkHandlerMixin",
|
||||||
"HumanoidMobRendererMixin",
|
"HumanoidMobRendererMixin",
|
||||||
"ArmorStandRendererMixin",
|
"ArmorStandRendererMixin",
|
||||||
"ClientRecipeBookMixin",
|
|
||||||
"MinecraftClientMixin",
|
"MinecraftClientMixin",
|
||||||
"PlayerRendererMixin",
|
"PlayerRendererMixin",
|
||||||
"LevelRendererMixin",
|
"LevelRendererMixin",
|
||||||
"MusicTrackerMixin",
|
"MusicTrackerMixin",
|
||||||
"AnvilScreenMixin",
|
|
||||||
"BiomeColorsMixin",
|
"BiomeColorsMixin",
|
||||||
"ModelLoaderMixin",
|
"ModelLoaderMixin",
|
||||||
"LocalPlayerMixin",
|
"LocalPlayerMixin",
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
"ServerPlayerMixin",
|
"ServerPlayerMixin",
|
||||||
"SpikeFeatureMixin",
|
"SpikeFeatureMixin",
|
||||||
"ServerLevelMixin",
|
"ServerLevelMixin",
|
||||||
"AnvilMenuMixin",
|
|
||||||
"EnderManMixin",
|
"EnderManMixin",
|
||||||
"EndSpikeMixin",
|
"EndSpikeMixin",
|
||||||
"MonsterMixin",
|
"MonsterMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue