Merge pull request #23 from quiqueck/feature/ComplexMatStages

ComplexMaterial
This commit is contained in:
paulevsGitch 2021-07-30 19:11:51 +03:00 committed by GitHub
commit 694b5c54c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 156 additions and 53 deletions

View file

@ -8,6 +8,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.api.dataexchange.DataExchangeAPI;
import ru.bclib.api.datafixer.DataFixerAPI; import ru.bclib.api.datafixer.DataFixerAPI;
import java.io.File; import java.io.File;
@ -62,11 +63,14 @@ public class WorldDataAPI {
/** /**
* Register mod cache, world cache is located in world data folder. * Register mod cache, world cache is located in world data folder.
* <p>
* Will also register the Mod for the {@link DataExchangeAPI} using {@link DataExchangeAPI#registerMod(String)}
* *
* @param modID - {@link String} modID. * @param modID - {@link String} modID.
*/ */
public static void registerModCache(String modID) { public static void registerModCache(String modID) {
MODS.add(modID); MODS.add(modID);
DataExchangeAPI.registerMod(modID);
} }
/** /**

View file

@ -1,5 +1,6 @@
package ru.bclib.api.dataexchange; package ru.bclib.api.dataexchange;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
@ -7,9 +8,11 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
public class DataExchangeAPI { public class DataExchangeAPI {
private final static List<String> MODS = Lists.newArrayList();
private static DataExchangeAPI instance; private static DataExchangeAPI instance;
private ConnectorServerside server; private ConnectorServerside server;
private ConnectorClientside client; private ConnectorClientside client;
@ -46,6 +49,23 @@ public class DataExchangeAPI {
ServerPlayConnectionEvents.DISCONNECT.register(server::onPlayDisconnect); ServerPlayConnectionEvents.DISCONNECT.register(server::onPlayDisconnect);
} }
/**
* Register a mod to participate in the DataExchange.
*
* @param modID - {@link String} modID.
*/
public static void registerMod(String modID) {
MODS.add(modID);
}
/**
* Returns the IDs of all registered Mods.
* @return List of modIDs
*/
public static List<String> registeredMods(){
return MODS;
}
/** /**
* Add a new Descriptor for a DataHandler. * Add a new Descriptor for a DataHandler.
* @param desc The Descriptor you want to add. * @param desc The Descriptor you want to add.

View file

@ -1,5 +1,7 @@
package ru.bclib.api.dataexchange; package ru.bclib.api.dataexchange;
import io.netty.buffer.ByteBufUtil;
import io.netty.util.CharsetUtil;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
@ -16,6 +18,8 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.server.network.ServerGamePacketListenerImpl;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
public abstract class DataHandler { public abstract class DataHandler {
private final boolean originatesOnServer; private final boolean originatesOnServer;
@NotNull @NotNull
@ -104,4 +108,23 @@ public abstract class DataHandler {
public String toString() { public String toString() {
return "DataHandler{" + "originatesOnServer=" + originatesOnServer + ", identifier=" + identifier + '}'; return "DataHandler{" + "originatesOnServer=" + originatesOnServer + ", identifier=" + identifier + '}';
} }
/**
* Write a String to a buffer (Convenience Method)
* @param buf The buffer to write to
* @param s The String you want to write
*/
public static void writeString(FriendlyByteBuf buf, String s){
buf.writeByteArray(s.getBytes(StandardCharsets.UTF_8));
}
/**
* Read a string from a buffer (Convenience Method)
* @param buf Thea buffer to read from
* @return The received String
*/
public static String readString(FriendlyByteBuf buf){
byte[] data = buf.readByteArray();
return new String(data, StandardCharsets.UTF_8);
}
} }

View file

@ -1,5 +1,7 @@
package ru.bclib.api.dataexchange.handler; package ru.bclib.api.dataexchange.handler;
import io.netty.buffer.ByteBufUtil;
import io.netty.util.CharsetUtil;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.networking.v1.PacketSender; import net.fabricmc.fabric.api.networking.v1.PacketSender;
@ -8,11 +10,18 @@ import net.fabricmc.loader.api.ModContainer;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.api.WorldDataAPI;
import ru.bclib.api.dataexchange.DataExchangeAPI;
import ru.bclib.api.dataexchange.DataHandler; import ru.bclib.api.dataexchange.DataHandler;
import ru.bclib.api.dataexchange.DataHandlerDescriptor; import ru.bclib.api.dataexchange.DataHandlerDescriptor;
import ru.bclib.api.datafixer.DataFixerAPI; import ru.bclib.api.datafixer.DataFixerAPI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional; import java.util.Optional;
public class HelloServer extends DataHandler { public class HelloServer extends DataHandler {
@ -35,22 +44,41 @@ public class HelloServer extends DataHandler {
return getModVersion(BCLib.MOD_ID); return getModVersion(BCLib.MOD_ID);
} }
String bclibVersion ="0.0.0";
Map<String, String> modVersion = new HashMap<>();
@Override @Override
protected void deserializeFromIncomingData(FriendlyByteBuf buf, PacketSender responseSender, boolean fromClient) { protected void deserializeFromIncomingData(FriendlyByteBuf buf, PacketSender responseSender, boolean fromClient) {
String bclibVersion = DataFixerAPI.getModVersion(buf.readInt()); bclibVersion = DataFixerAPI.getModVersion(buf.readInt());
String localBclibVersion = getBCLibVersion(); modVersion = new HashMap<>();
BCLib.LOGGER.info("Hello Server received from BCLib. (server="+localBclibVersion+", client="+bclibVersion+")"); int count = buf.readInt();
for (int i=0; i< count; i++){
String id = readString(buf);
String version = DataFixerAPI.getModVersion(buf.readInt());
modVersion.put(id, version);
}
} }
@Override @Override
@Environment(EnvType.CLIENT) protected void runOnServer(MinecraftServer server) {
protected void runOnClient(Minecraft client) { String localBclibVersion = getBCLibVersion();
BCLib.LOGGER.info("Hello Server received from BCLib. (server="+localBclibVersion+", client="+bclibVersion+")");
for (Entry<String, String> e : modVersion.entrySet()){
String ver = getModVersion(e.getKey());
BCLib.LOGGER.info(" - " + e.getKey() + " (server="+ver+", client="+ver+")");
}
} }
@Override @Override
protected void serializeData(FriendlyByteBuf buf) { protected void serializeData(FriendlyByteBuf buf) {
final List<String> mods = DataExchangeAPI.registeredMods();
buf.writeInt(DataFixerAPI.getModVersion(getBCLibVersion())); buf.writeInt(DataFixerAPI.getModVersion(getBCLibVersion()));
buf.writeInt(mods.size());
for (String modID : mods) {
writeString(buf, modID);
buf.writeInt(DataFixerAPI.getModVersion(getModVersion(modID)));
}
} }
} }

View file

@ -242,9 +242,6 @@ public class DataFixerAPI {
} }
private static void runDataFixes(File dir, MigrationProfile profile, ProgressListener progress) { private static void runDataFixes(File dir, MigrationProfile profile, ProgressListener progress) {
System.out.println("RUNNING fixes");
if (dir!= null) return;
State state = new State(); State state = new State();
List<File> regions = getAllRegions(dir, null); List<File> regions = getAllRegions(dir, null);

View file

@ -38,10 +38,12 @@ public abstract class ComplexMaterial {
protected final String baseName; protected final String baseName;
protected final String modID; protected final String modID;
protected final String receipGroupPrefix;
public ComplexMaterial(String modID, String baseName) { public ComplexMaterial(String modID, String baseName, String receipGroupPrefix) {
this.baseName = baseName; this.baseName = baseName;
this.modID = modID; this.modID = modID;
this.receipGroupPrefix = receipGroupPrefix;
MATERIALS.add(this); MATERIALS.add(this);
} }
@ -248,6 +250,20 @@ public abstract class ComplexMaterial {
defaultBlockEntries.add(entry); defaultBlockEntries.add(entry);
} }
/**
* Replaces or Adds a default {@link BlockEntry} to this {@link ComplexMaterial}. Used to initiate blocks later.
* <p>
* If this {@link ComplexMaterial} does already contain an entry for the {@link ResourceLocation}, the entry will
* be removed first.
* @param entry {@link BlockEntry}
*/
protected void replaceOrAddBlockEntry(BlockEntry entry) {
int pos = defaultBlockEntries.indexOf(entry);
if (pos>=0) defaultBlockEntries.remove(entry);
addBlockEntry(entry);
}
/** /**
* Adds a default {@link ItemEntry} to this {@link ComplexMaterial}. Used to initiate items later. * Adds a default {@link ItemEntry} to this {@link ComplexMaterial}. Used to initiate items later.
* @param entry {@link ItemEntry} * @param entry {@link ItemEntry}

View file

@ -1,6 +1,5 @@
package ru.bclib.complexmaterials; package ru.bclib.complexmaterials;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
@ -36,14 +35,9 @@ import ru.bclib.blocks.BaseWoodenButtonBlock;
import ru.bclib.blocks.StripableBarkBlock; import ru.bclib.blocks.StripableBarkBlock;
import ru.bclib.blocks.WoodenPressurePlateBlock; import ru.bclib.blocks.WoodenPressurePlateBlock;
import ru.bclib.complexmaterials.entry.BlockEntry; import ru.bclib.complexmaterials.entry.BlockEntry;
import ru.bclib.complexmaterials.entry.ItemEntry;
import ru.bclib.complexmaterials.entry.RecipeEntry; import ru.bclib.complexmaterials.entry.RecipeEntry;
import ru.bclib.config.PathConfig;
import ru.bclib.recipes.GridRecipe; import ru.bclib.recipes.GridRecipe;
import java.util.Arrays;
import java.util.List;
public class WoodenComplexMaterial extends ComplexMaterial { public class WoodenComplexMaterial extends ComplexMaterial {
public static final ResourceLocation MATERIAL_ID = BCLib.makeID("wooden_material"); public static final ResourceLocation MATERIAL_ID = BCLib.makeID("wooden_material");
@ -73,8 +67,8 @@ public class WoodenComplexMaterial extends ComplexMaterial {
public final MaterialColor planksColor; public final MaterialColor planksColor;
public final MaterialColor woodColor; public final MaterialColor woodColor;
public WoodenComplexMaterial(String modID, String baseName, MaterialColor woodColor, MaterialColor planksColor) { public WoodenComplexMaterial(String modID, String baseName, String receipGroupPrefix, MaterialColor woodColor, MaterialColor planksColor) {
super(modID, baseName); super(modID, baseName, receipGroupPrefix);
this.planksColor = planksColor; this.planksColor = planksColor;
this.woodColor = woodColor; this.woodColor = woodColor;
} }
@ -97,14 +91,14 @@ public class WoodenComplexMaterial extends ComplexMaterial {
@Override @Override
protected void initDefault(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) { protected void initDefault(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
initDefault(blockSettings, itemSettings, new String[0]); initBase(blockSettings, itemSettings);
initStorage(blockSettings, itemSettings);
initDecorations(blockSettings, itemSettings);
} }
final protected void initDefault(FabricBlockSettings blockSettings, FabricItemSettings itemSettings, String[] excludedSuffixes) { final protected void initBase(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
Tag.Named<Block> tagBlockLog = getBlockTag(TAG_LOGS); Tag.Named<Block> tagBlockLog = getBlockTag(TAG_LOGS);
Tag.Named<Item> tagItemLog = getItemTag(TAG_LOGS); Tag.Named<Item> tagItemLog = getItemTag(TAG_LOGS);
List<String> excl = Arrays.asList(excludedSuffixes);
addBlockEntry( addBlockEntry(
new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> { new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> {
@ -123,14 +117,14 @@ public class WoodenComplexMaterial extends ComplexMaterial {
addBlockEntry( addBlockEntry(
new BlockEntry(BLOCK_LOG, (complexMaterial, settings) -> { new BlockEntry(BLOCK_LOG, (complexMaterial, settings) -> {
return new BaseStripableLogBlock(woodColor, getBlock("stripped_log")); return new BaseStripableLogBlock(woodColor, getBlock(BLOCK_STRIPPED_LOG));
}) })
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
); );
addBlockEntry( addBlockEntry(
new BlockEntry(BLOCK_BARK, (complexMaterial, settings) -> { new BlockEntry(BLOCK_BARK, (complexMaterial, settings) -> {
return new StripableBarkBlock(woodColor, getBlock("stripped_bark")); return new StripableBarkBlock(woodColor, getBlock(BLOCK_STRIPPED_BARK));
}) })
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
@ -164,9 +158,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
return new BaseDoorBlock(getBlock(BLOCK_PLANKS)); return new BaseDoorBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS).setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS)); }).setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS).setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS));
addBlockEntry(new BlockEntry(BLOCK_CRAFTING_TABLE, (complexMaterial, settings) -> {
return new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_WORKBENCHES).setItemTags(TagAPI.ITEM_WORKBENCHES));
addBlockEntry(new BlockEntry(BLOCK_LADDER, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_LADDER, (complexMaterial, settings) -> {
return new BaseLadderBlock(getBlock(BLOCK_PLANKS)); return new BaseLadderBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.CLIMBABLE)); }).setBlockTags(BlockTags.CLIMBABLE));
@ -174,24 +166,30 @@ public class WoodenComplexMaterial extends ComplexMaterial {
return new BaseSignBlock(getBlock(BLOCK_PLANKS)); return new BaseSignBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.SIGNS).setItemTags(ItemTags.SIGNS)); }).setBlockTags(BlockTags.SIGNS).setItemTags(ItemTags.SIGNS));
}
final protected void initStorage(FabricBlockSettings blockSettings, FabricItemSettings itemSettings){
addBlockEntry(new BlockEntry(BLOCK_CHEST, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_CHEST, (complexMaterial, settings) -> {
return new BaseChestBlock(getBlock(BLOCK_PLANKS)); return new BaseChestBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_CHEST).setItemTags(TagAPI.ITEM_CHEST)); }).setBlockTags(TagAPI.BLOCK_CHEST).setItemTags(TagAPI.ITEM_CHEST));
addBlockEntry(new BlockEntry(BLOCK_BARREL, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_BARREL, (complexMaterial, settings) -> {
return new BaseBarrelBlock(getBlock(BLOCK_PLANKS)); return new BaseBarrelBlock(getBlock(BLOCK_PLANKS));
})); }));
}
final protected void initDecorations(FabricBlockSettings blockSettings, FabricItemSettings itemSettings){
addBlockEntry(new BlockEntry(BLOCK_CRAFTING_TABLE, (complexMaterial, settings) -> {
return new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_WORKBENCHES).setItemTags(TagAPI.ITEM_WORKBENCHES));
if (!excl.contains(BLOCK_BOOKSHELF)) { addBlockEntry(new BlockEntry(BLOCK_BOOKSHELF, (complexMaterial, settings) -> {
addBlockEntry(new BlockEntry(BLOCK_BOOKSHELF, (complexMaterial, settings) -> { return new BaseBookshelfBlock(getBlock(BLOCK_PLANKS));
return new BaseBookshelfBlock(getBlock(BLOCK_PLANKS)); }).setBlockTags(TagAPI.BLOCK_BOOKSHELVES));
}).setBlockTags(TagAPI.BLOCK_BOOKSHELVES));
}
if (!excl.contains(BLOCK_COMPOSTER)) { addBlockEntry(new BlockEntry(BLOCK_COMPOSTER, (complexMaterial, settings) -> {
addBlockEntry(new BlockEntry(BLOCK_COMPOSTER, (complexMaterial, settings) -> { return new BaseComposterBlock(getBlock(BLOCK_PLANKS));
return new BaseComposterBlock(getBlock(BLOCK_PLANKS)); }));
}));
}
} }
@Override @Override
@ -219,7 +217,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(4) .setOutputCount(4)
.setList("#") .setList("#")
.addMaterial('#', log, bark, log_stripped, bark_stripped) .addMaterial('#', log, bark, log_stripped, bark_stripped)
.setGroup("end_planks") .setGroup(receipGroupPrefix +"_planks")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> { addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> {
@ -228,7 +226,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(4) .setOutputCount(4)
.setShape("# ", "## ", "###") .setShape("# ", "## ", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_planks_stairs") .setGroup(receipGroupPrefix +"_planks_stairs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> { addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> {
@ -237,7 +235,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(6) .setOutputCount(6)
.setShape("###") .setShape("###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_planks_slabs") .setGroup(receipGroupPrefix +"_planks_slabs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> { addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> {
@ -247,7 +245,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("#I#", "#I#") .setShape("#I#", "#I#")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup("end_planks_fences") .setGroup(receipGroupPrefix +"_planks_fences")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> { addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> {
@ -256,7 +254,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("I#I", "I#I") .setShape("I#I", "I#I")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup("end_planks_gates") .setGroup(receipGroupPrefix +"_planks_gates")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("button", (material, config, id) -> { addRecipeEntry(new RecipeEntry("button", (material, config, id) -> {
@ -264,7 +262,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setList("#") .setList("#")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_planks_buttons") .setGroup(receipGroupPrefix +"_planks_buttons")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> { addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> {
@ -272,7 +270,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setShape("##") .setShape("##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_planks_plates") .setGroup(receipGroupPrefix +"_planks_plates")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> { addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> {
@ -281,7 +279,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(2) .setOutputCount(2)
.setShape("###", "###") .setShape("###", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_trapdoors") .setGroup(receipGroupPrefix +"_trapdoors")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("door", (material, config, id) -> { addRecipeEntry(new RecipeEntry("door", (material, config, id) -> {
@ -290,7 +288,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(3) .setOutputCount(3)
.setShape("##", "##", "##") .setShape("##", "##", "##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_doors") .setGroup(receipGroupPrefix +"_doors")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> { addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> {
@ -298,7 +296,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setShape("##", "##") .setShape("##", "##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_tables") .setGroup(receipGroupPrefix +"_tables")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> { addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> {
@ -308,7 +306,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("I I", "I#I", "I I") .setShape("I I", "I#I", "I I")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup("end_ladders") .setGroup(receipGroupPrefix +"_ladders")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> { addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> {
@ -318,7 +316,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("###", "###", " I ") .setShape("###", "###", " I ")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup("end_signs") .setGroup(receipGroupPrefix +"_signs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> { addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> {
@ -326,7 +324,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setShape("###", "# #", "###") .setShape("###", "# #", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup("end_chests") .setGroup(receipGroupPrefix +"_chests")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> { addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> {
@ -335,7 +333,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("#S#", "# #", "#S#") .setShape("#S#", "# #", "#S#")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('S', getBlock(BLOCK_SLAB)) .addMaterial('S', getBlock(BLOCK_SLAB))
.setGroup("end_barrels") .setGroup(receipGroupPrefix +"_barrels")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> { addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> {
@ -344,7 +342,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("###", "PPP", "###") .setShape("###", "PPP", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('P', Items.BOOK) .addMaterial('P', Items.BOOK)
.setGroup("end_bookshelves") .setGroup(receipGroupPrefix +"_bookshelves")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> { addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> {
@ -387,7 +385,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("shulker", (material, config, id) -> { addRecipeEntry(new RecipeEntry("shulker", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_COMPOSTER)) GridRecipe.make(id, Blocks.SHULKER_BOX)
.checkConfig(config) .checkConfig(config)
.setShape("S", "#", "S") .setShape("S", "#", "S")
.addMaterial('S', Items.SHULKER_SHELL) .addMaterial('S', Items.SHULKER_SHELL)

View file

@ -1,8 +1,12 @@
package ru.bclib.complexmaterials.entry; package ru.bclib.complexmaterials.entry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public abstract class ComplexMaterialEntry { public abstract class ComplexMaterialEntry {
@NotNull
private final String suffix; private final String suffix;
protected ComplexMaterialEntry(String suffix) { protected ComplexMaterialEntry(String suffix) {
@ -20,4 +24,17 @@ public abstract class ComplexMaterialEntry {
public String getSuffix() { public String getSuffix() {
return suffix; return suffix;
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ComplexMaterialEntry that = (ComplexMaterialEntry) o;
return suffix.equals(that.suffix);
}
@Override
public int hashCode() {
return Objects.hash(suffix);
}
} }