Improved handling of Slot-Based ComplexMaterials

This commit is contained in:
Frank 2023-05-20 18:26:27 +02:00
parent f9870d388e
commit 490ad640cd
29 changed files with 356 additions and 167 deletions

View file

@ -1,20 +1,19 @@
package org.betterx.bclib.complexmaterials;
import org.betterx.bclib.complexmaterials.entry.MaterialSlot;
import org.betterx.bclib.complexmaterials.entry.SlotMap;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.List;
public abstract class ComplexMaterialSet<M extends ComplexMaterialSet<?>> extends ComplexMaterial {
List<MaterialSlot<M>> slots;
SlotMap<M> slots;
protected ComplexMaterialSet(String modID, String baseName, String receipGroupPrefix) {
super(modID, baseName, receipGroupPrefix);
}
protected abstract List<MaterialSlot<M>> createMaterialSlots();
protected abstract SlotMap<M> createMaterialSlots();
@Override
@ -22,6 +21,7 @@ public abstract class ComplexMaterialSet<M extends ComplexMaterialSet<?>> extend
this.slots = createMaterialSlots();
for (MaterialSlot<M> slot : slots) {
slot.onInit((M) this);
slot.addBlockEntry((M) this, this::addBlockEntry);
}
for (MaterialSlot<M> slot : slots) {

View file

@ -1,7 +1,7 @@
package org.betterx.bclib.complexmaterials;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.complexmaterials.entry.MaterialSlot;
import org.betterx.bclib.complexmaterials.entry.SlotMap;
import org.betterx.bclib.complexmaterials.set.wood.WoodSlots;
import org.betterx.bclib.items.boat.BoatTypeOverride;
import org.betterx.worlds.together.tag.v3.TagManager;
@ -14,7 +14,6 @@ import net.minecraft.world.level.material.MapColor;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import java.util.List;
import java.util.function.Consumer;
import org.jetbrains.annotations.Nullable;
@ -97,9 +96,8 @@ public class WoodenComplexMaterial extends ComplexMaterialSet<WoodenComplexMater
}
@Override
protected List<MaterialSlot<WoodenComplexMaterial>> createMaterialSlots() {
var list = List.of(
protected SlotMap<WoodenComplexMaterial> createMaterialSlots() {
return SlotMap.of(
WoodSlots.STRIPPED_LOG,
WoodSlots.STRIPPED_BARK,
WoodSlots.LOG,
@ -119,12 +117,8 @@ public class WoodenComplexMaterial extends ComplexMaterialSet<WoodenComplexMater
WoodSlots.BARREL,
WoodSlots.CRAFTING_TABLE,
WoodSlots.BOOKSHELF,
WoodSlots.COMPOSTER,
WoodSlots.BOAT,
WoodSlots.CHEST_BOAT
WoodSlots.COMPOSTER
);
return list;
}
@Override

View file

@ -4,7 +4,6 @@ import org.betterx.bclib.complexmaterials.ComplexMaterial;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class MaterialSlot<M extends ComplexMaterial> {
@NotNull
@ -18,16 +17,8 @@ public abstract class MaterialSlot<M extends ComplexMaterial> {
public abstract void addRecipeEntry(M parentMaterial, Consumer<RecipeEntry> adder);
public void addItemEntry(M parentMaterial, Consumer<ItemEntry> adder) {
ItemEntry item = getItemEntry(parentMaterial);
if (item != null) {
adder.accept(item);
}
}
@Nullable
protected ItemEntry getItemEntry(M parentMaterial) {
return null;
}
public void onInit(M parentMaterial) {
}

View file

@ -0,0 +1,60 @@
package org.betterx.bclib.complexmaterials.entry;
import org.betterx.bclib.complexmaterials.ComplexMaterial;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class SimpleBlockOnlyMaterialSlot<M extends ComplexMaterial> extends SimpleMaterialSlot<M> {
public SimpleBlockOnlyMaterialSlot(@NotNull String suffix) {
super(suffix);
}
@Override
@Nullable
protected BlockEntry getBlockEntry(M parentMaterial) {
final BlockEntry entry = new BlockEntry(suffix, false, (c, p) -> this.createBlock(parentMaterial, p));
modifyBlockEntry(parentMaterial, entry);
return entry;
}
public static <M extends ComplexMaterial> SimpleBlockOnlyMaterialSlot<M> createBlockOnly(
@NotNull String suffix,
BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> maker
) {
return new SimpleBlockOnlyMaterialSlot(suffix) {
@Override
protected @NotNull Block createBlock(ComplexMaterial parentMaterial, BlockBehaviour.Properties settings) {
return maker.apply(parentMaterial, settings);
}
@Override
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
}
};
}
public static <M extends ComplexMaterial> SimpleBlockOnlyMaterialSlot<M> createBlockOnly(
@NotNull String suffix,
Supplier<Block> maker
) {
return new SimpleBlockOnlyMaterialSlot(suffix) {
@Override
protected @NotNull Block createBlock(ComplexMaterial parentMaterial, BlockBehaviour.Properties settings) {
return maker.get();
}
@Override
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
}
};
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,15 +25,14 @@ public abstract class SimpleMaterialSlot<M extends ComplexMaterial> extends Mate
@Nullable
protected BlockEntry getBlockEntry(M parentMaterial) {
var supplier = getBlockSupplier(parentMaterial);
if (supplier != null) {
final BlockEntry entry = new BlockEntry(suffix, supplier);
modifyBlockEntry(parentMaterial, entry);
return entry;
}
return null;
final BlockEntry entry = new BlockEntry(suffix, (c, p) -> this.createBlock(parentMaterial, p));
modifyBlockEntry(parentMaterial, entry);
return entry;
}
@NotNull
protected abstract Block createBlock(M parentMaterial, BlockBehaviour.Properties settings);
protected void modifyBlockEntry(M parentMaterial, @NotNull BlockEntry entry) {
}
@ -41,18 +41,28 @@ public abstract class SimpleMaterialSlot<M extends ComplexMaterial> extends Mate
adder.accept(getRecipeEntry(parentMaterial));
}
@NotNull
protected abstract BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(M parentMaterial);
protected @Nullable RecipeEntry getRecipeEntry(M parentMaterial) {
return new RecipeEntry(suffix, this::getRecipeSupplier);
return new RecipeEntry(suffix, this::makeRecipe);
}
protected abstract @Nullable void getRecipeSupplier(
protected abstract @Nullable void makeRecipe(
ComplexMaterial parentMaterial,
ResourceLocation id
);
@Override
public void addItemEntry(M parentMaterial, Consumer<ItemEntry> adder) {
ItemEntry item = getItemEntry(parentMaterial);
if (item != null) {
adder.accept(item);
}
}
@Nullable
protected ItemEntry getItemEntry(M parentMaterial) {
return null;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -65,4 +75,38 @@ public abstract class SimpleMaterialSlot<M extends ComplexMaterial> extends Mate
public int hashCode() {
return Objects.hash(suffix);
}
public static <M extends ComplexMaterial> SimpleMaterialSlot<M> createBlockItem(
@NotNull String suffix,
BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> maker
) {
return new SimpleMaterialSlot(suffix) {
@Override
protected @NotNull Block createBlock(ComplexMaterial parentMaterial, BlockBehaviour.Properties settings) {
return maker.apply(parentMaterial, settings);
}
@Override
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
}
};
}
public static <M extends ComplexMaterial> SimpleMaterialSlot<M> createBlockItem(
@NotNull String suffix,
Supplier<Block> maker
) {
return new SimpleMaterialSlot(suffix) {
@Override
protected @NotNull Block createBlock(ComplexMaterial parentMaterial, BlockBehaviour.Properties settings) {
return maker.get();
}
@Override
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
}
};
}
}

View file

@ -0,0 +1,49 @@
package org.betterx.bclib.complexmaterials.entry;
import org.betterx.bclib.complexmaterials.ComplexMaterialSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
public class SlotMap<M extends ComplexMaterialSet<? extends ComplexMaterialSet<?>>> implements Iterable<MaterialSlot<M>> {
private final Map<String, MaterialSlot<M>> map;
public SlotMap() {
this.map = new LinkedHashMap<>();
}
public static <M extends ComplexMaterialSet<? extends ComplexMaterialSet<?>>> SlotMap<M> of(MaterialSlot<M>... slots) {
final SlotMap<M> map = new SlotMap<>();
for (MaterialSlot<M> slot : slots) {
map.add(slot);
}
return map;
}
public SlotMap<M> replace(MaterialSlot<M> slot) {
return add(slot);
}
public SlotMap<M> add(MaterialSlot<M> slot) {
map.put(slot.suffix, slot);
return this;
}
public SlotMap<M> remove(MaterialSlot<M> slot) {
map.remove(slot.suffix);
return this;
}
public SlotMap<M> remove(String slot) {
map.remove(slot);
return this;
}
@NotNull
@Override
public Iterator<MaterialSlot<M>> iterator() {
return map.values().iterator();
}
}

View file

@ -0,0 +1,61 @@
package org.betterx.bclib.complexmaterials.set.wood;
import org.betterx.bclib.complexmaterials.ComplexMaterial;
import org.betterx.bclib.complexmaterials.WoodenComplexMaterial;
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class AbstractSaplingSlot extends SimpleMaterialSlot<WoodenComplexMaterial> {
protected static final String SAPLING_SUFFIX = "sapling";
protected AbstractSaplingSlot() {
super(SAPLING_SUFFIX);
}
@Override
protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) {
entry
.setBlockTags(BlockTags.SAPLINGS)
.setItemTags(ItemTags.SAPLINGS);
}
@Override
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
}
public static AbstractSaplingSlot create(BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> maker) {
return new AbstractSaplingSlot() {
@Override
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial,
BlockBehaviour.Properties settings
) {
return maker.apply(parentMaterial, settings);
}
};
}
public static AbstractSaplingSlot create(Supplier<Block> maker) {
return new AbstractSaplingSlot() {
@Override
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial,
BlockBehaviour.Properties settings
) {
return maker.get();
}
};
}
}

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,12 +23,12 @@ public class Bark extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new StripableBarkBlock(
return new StripableBarkBlock(
parentMaterial.woodColor,
complexMaterial.getBlock(WoodSlots.STRIPPED_BARK)
parentMaterial.getBlock(WoodSlots.STRIPPED_BARK)
);
}
@ -50,7 +49,7 @@ public class Bark extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial material, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, material.getBlock(suffix))
.setShape("##", "##")

View file

@ -14,7 +14,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class Barrel extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseBarrelBlock(complexMaterial.getBlock(WoodSlots.PLANKS));
return new BaseBarrelBlock(parentMaterial.getBlock(WoodSlots.PLANKS));
}
@Override
@ -37,7 +36,7 @@ public class Barrel extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setShape("#S#", "# #", "#S#")

View file

@ -9,10 +9,10 @@ import org.betterx.bclib.recipes.BCLRecipeBuilder;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -27,12 +27,11 @@ public class Boat extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (a, b) -> {
return null;
};
//this should never get called
return null;
}
@Override
@ -41,18 +40,22 @@ public class Boat extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setShape("# #", "###")
.addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS))
.setGroup("boat")
.setCategory(RecipeCategory.TRANSPORTATION)
.build();
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
makeBoatRecipe(id, parentMaterial.getBlock(WoodSlots.PLANKS), parentMaterial.getItem(suffix));
}
@Override
public void onInit(WoodenComplexMaterial parentMaterial) {
parentMaterial.initBoatType();
}
public static void makeBoatRecipe(ResourceLocation id, Block planks, Item boat) {
BCLRecipeBuilder
.crafting(id, boat)
.setShape("# #", "###")
.addMaterial('#', planks)
.setGroup("boat")
.setCategory(RecipeCategory.TRANSPORTATION)
.build();
}
}

View file

@ -14,7 +14,6 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class Bookshelf extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (cmx, settings) -> new BaseBookshelfBlock(cmx.getBlock(WoodSlots.PLANKS));
return new BaseBookshelfBlock(parentMaterial.getBlock(WoodSlots.PLANKS));
}
@Override
@ -36,7 +35,7 @@ public class Bookshelf extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setShape("###", "PPP", "###")

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,11 +23,11 @@ public class Button extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseWoodenButtonBlock(
complexMaterial.getBlock(WoodSlots.PLANKS),
return new BaseWoodenButtonBlock(
parentMaterial.getBlock(WoodSlots.PLANKS),
parentMaterial.woodType.setType()
);
}
@ -40,7 +39,7 @@ public class Button extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.shapeless()

View file

@ -14,7 +14,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class Chest extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseChestBlock(complexMaterial.getBlock(WoodSlots.PLANKS));
return new BaseChestBlock(parentMaterial.getBlock(WoodSlots.PLANKS));
}
@Override
@ -37,7 +36,7 @@ public class Chest extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setShape("###", "# #", "###")

View file

@ -12,10 +12,10 @@ import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -30,12 +30,11 @@ public class ChestBoat extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (a, b) -> {
return null;
};
//this should never get called
return null;
}
@Override
@ -47,18 +46,23 @@ public class ChestBoat extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix))
.shapeless()
.addMaterial('C', CommonItemTags.CHEST)
.addMaterial('#', parentMaterial.getBlock(WoodSlots.BOAT))
.setGroup("chest_boat")
.setCategory(RecipeCategory.TRANSPORTATION)
.build();
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
makeChestBoatRecipe(id, parentMaterial.getItem(WoodSlots.BOAT), parentMaterial.getItem(WoodSlots.CHEST_BOAT));
}
@Override
public void onInit(WoodenComplexMaterial parentMaterial) {
parentMaterial.initBoatType();
}
public static void makeChestBoatRecipe(ResourceLocation id, Item boat, Item chestBoat) {
BCLRecipeBuilder
.crafting(id, chestBoat)
.shapeless()
.addMaterial('C', CommonItemTags.CHEST)
.addMaterial('#', boat)
.setGroup("chest_boat")
.setCategory(RecipeCategory.TRANSPORTATION)
.build();
}
}

View file

@ -13,7 +13,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -23,10 +22,10 @@ public class Composter extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseComposterBlock(complexMaterial.getBlock(WoodSlots.PLANKS));
return new BaseComposterBlock(parentMaterial.getBlock(WoodSlots.PLANKS));
}
@Override
@ -35,7 +34,7 @@ public class Composter extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix))
.setShape("# #", "# #", "###")
.addMaterial('#', parentMaterial.getBlock(WoodSlots.SLAB))

View file

@ -14,7 +14,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class CraftingTable extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (cmx, settings) -> new BaseCraftingTableBlock(cmx.getBlock(WoodSlots.PLANKS));
return new BaseCraftingTableBlock(parentMaterial.getBlock(WoodSlots.PLANKS));
}
@Override
@ -37,7 +36,7 @@ public class CraftingTable extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setShape("##", "##")

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,11 +23,11 @@ public class Door extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseDoorBlock(
complexMaterial.getBlock(WoodSlots.PLANKS),
return new BaseDoorBlock(
parentMaterial.getBlock(WoodSlots.PLANKS),
parentMaterial.woodType.setType()
);
}
@ -40,7 +39,7 @@ public class Door extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setOutputCount(3)

View file

@ -15,7 +15,6 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -25,10 +24,10 @@ public class Fence extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseFenceBlock(complexMaterial.getBlock(WoodSlots.PLANKS));
return new BaseFenceBlock(parentMaterial.getBlock(WoodSlots.PLANKS));
}
@Override
@ -38,7 +37,7 @@ public class Fence extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setOutputCount(3)

View file

@ -14,7 +14,6 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,11 +23,11 @@ public class Gate extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseGateBlock(
complexMaterial.getBlock(WoodSlots.PLANKS),
return new BaseGateBlock(
parentMaterial.getBlock(WoodSlots.PLANKS),
parentMaterial.woodType.type()
);
}
@ -39,7 +38,7 @@ public class Gate extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix))
.setShape("I#I", "I#I")
.addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS))

View file

@ -14,7 +14,6 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class Ladder extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseLadderBlock(complexMaterial.getBlock(WoodSlots.PLANKS));
return new BaseLadderBlock(parentMaterial.getBlock(WoodSlots.PLANKS));
}
@Override
@ -36,7 +35,7 @@ public class Ladder extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setOutputCount(3)

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,12 +23,12 @@ public class Log extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseStripableLogBlock(
return new BaseStripableLogBlock(
parentMaterial.woodColor,
complexMaterial.getBlock(WoodSlots.STRIPPED_LOG)
parentMaterial.getBlock(WoodSlots.STRIPPED_LOG)
);
}
@ -49,7 +48,7 @@ public class Log extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial material, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, material.getBlock(suffix))
.setShape("##", "##")

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class Planks extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseBlock(settings);
return new BaseBlock(settings);
}
@Override
@ -38,7 +37,7 @@ public class Planks extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix))
.setOutputCount(4)
.shapeless()

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,11 +23,11 @@ public class PressurePlate extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new WoodenPressurePlateBlock(
complexMaterial.getBlock(WoodSlots.PLANKS),
return new WoodenPressurePlateBlock(
parentMaterial.getBlock(WoodSlots.PLANKS),
parentMaterial.woodType.setType()
);
}
@ -40,7 +39,7 @@ public class PressurePlate extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setShape("##")

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class Slab extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseSlabBlock(complexMaterial.getBlock(WoodSlots.PLANKS), false);
return new BaseSlabBlock(parentMaterial.getBlock(WoodSlots.PLANKS), false);
}
@Override
@ -37,7 +36,7 @@ public class Slab extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setOutputCount(6)

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class Stairs extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseStairsBlock(complexMaterial.getBlock(WoodSlots.PLANKS), false);
return new BaseStairsBlock(parentMaterial.getBlock(WoodSlots.PLANKS), false);
}
@Override
@ -37,7 +36,7 @@ public class Stairs extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, parentMaterial.getBlock(suffix))
.setOutputCount(4)

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,10 +23,10 @@ public class StrippedBark extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseBarkBlock(settings);
return new BaseBarkBlock(settings);
}
@Override
@ -46,7 +45,7 @@ public class StrippedBark extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial material, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, material.getBlock(suffix))
.setShape("##", "##")

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,9 +23,10 @@ public class StrippedLog extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
@NotNull
protected BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(WoodenComplexMaterial parentMaterial) {
return (complexMaterial, settings) -> new BaseRotatedPillarBlock(settings);
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return new BaseRotatedPillarBlock(settings);
}
@Override
@ -45,7 +45,7 @@ public class StrippedLog extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial material, ResourceLocation id) {
BCLRecipeBuilder
.crafting(id, material.getBlock(suffix))
.setShape("##", "##")

View file

@ -14,7 +14,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import java.util.function.BiFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -23,12 +22,11 @@ public class Trapdoor extends SimpleMaterialSlot<WoodenComplexMaterial> {
super("trapdoor");
}
@Override
protected @NotNull BiFunction<ComplexMaterial, BlockBehaviour.Properties, Block> getBlockSupplier(
WoodenComplexMaterial parentMaterial
protected @NotNull Block createBlock(
WoodenComplexMaterial parentMaterial, BlockBehaviour.Properties settings
) {
return (complexMaterial, settings) -> new BaseTrapdoorBlock(
complexMaterial.getBlock(WoodSlots.PLANKS),
return new BaseTrapdoorBlock(
parentMaterial.getBlock(WoodSlots.PLANKS),
parentMaterial.woodType.setType()
);
}
@ -40,7 +38,7 @@ public class Trapdoor extends SimpleMaterialSlot<WoodenComplexMaterial> {
}
@Override
protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) {
protected @Nullable void makeRecipe(ComplexMaterial parentMaterial, ResourceLocation id) {
BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix))
.setOutputCount(2)
.setShape("###", "###")

View file

@ -19,7 +19,6 @@ public class WoodSlots {
public static final MaterialSlot<WoodenComplexMaterial> DOOR = new Door();
public static final MaterialSlot<WoodenComplexMaterial> LADDER = new Ladder();
public static final Sign SIGN = new Sign();
public static final String WALL_SIGN = Sign.WALL_SUFFFIX;
public static final MaterialSlot<WoodenComplexMaterial> CHEST = new Chest();
public static final MaterialSlot<WoodenComplexMaterial> BARREL = new Barrel();
public static final MaterialSlot<WoodenComplexMaterial> CRAFTING_TABLE = new CraftingTable();
@ -27,6 +26,9 @@ public class WoodSlots {
public static final MaterialSlot<WoodenComplexMaterial> COMPOSTER = new Composter();
public static final MaterialSlot<WoodenComplexMaterial> BOAT = new Boat();
public static final MaterialSlot<WoodenComplexMaterial> CHEST_BOAT = new ChestBoat();
public static final String WALL_SIGN = Sign.WALL_SUFFFIX;
public static final String SAPLING = AbstractSaplingSlot.SAPLING_SUFFIX;
}