Added ingredient to make an oak drawer with non minecraft wood closes #23
This commit is contained in:
parent
ed17939eba
commit
9e16817e47
|
@ -60,7 +60,7 @@ minecraft {
|
|||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
|
||||
args '--mod', 'functionalstorage', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
args '--mod', 'functionalstorage,titanium', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
|
||||
mods {
|
||||
functionalstorage {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"type": "forge:conditional",
|
||||
"recipes": [
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"item": "functionalstorage:oak_1",
|
||||
"type": "forge:item_exists"
|
||||
}
|
||||
],
|
||||
"type": "forge:and"
|
||||
}
|
||||
],
|
||||
"recipe": {
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"PPP",
|
||||
"PCP",
|
||||
"PPP"
|
||||
],
|
||||
"key": {
|
||||
"P": {
|
||||
"type": "functionalstorage:woodless"
|
||||
},
|
||||
"C": {
|
||||
"tag": "forge:chests/wooden"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "functionalstorage:oak_1"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"type": "forge:conditional",
|
||||
"recipes": [
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"item": "functionalstorage:oak_2",
|
||||
"type": "forge:item_exists"
|
||||
}
|
||||
],
|
||||
"type": "forge:and"
|
||||
}
|
||||
],
|
||||
"recipe": {
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"PCP",
|
||||
"PPP",
|
||||
"PCP"
|
||||
],
|
||||
"key": {
|
||||
"P": {
|
||||
"type": "functionalstorage:woodless"
|
||||
},
|
||||
"C": {
|
||||
"tag": "forge:chests/wooden"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "functionalstorage:oak_2"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"type": "forge:conditional",
|
||||
"recipes": [
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"item": "functionalstorage:oak_4",
|
||||
"type": "forge:item_exists"
|
||||
}
|
||||
],
|
||||
"type": "forge:and"
|
||||
}
|
||||
],
|
||||
"recipe": {
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"CPC",
|
||||
"PPP",
|
||||
"CPC"
|
||||
],
|
||||
"key": {
|
||||
"P": {
|
||||
"type": "functionalstorage:woodless"
|
||||
},
|
||||
"C": {
|
||||
"tag": "forge:chests/wooden"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "functionalstorage:oak_4"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -20,6 +20,7 @@ import com.buuz135.functionalstorage.item.LinkingToolItem;
|
|||
import com.buuz135.functionalstorage.item.StorageUpgradeItem;
|
||||
import com.buuz135.functionalstorage.item.UpgradeItem;
|
||||
import com.buuz135.functionalstorage.network.EnderDrawerSyncMessage;
|
||||
import com.buuz135.functionalstorage.recipe.DrawerlessWoodIngredient;
|
||||
import com.buuz135.functionalstorage.util.*;
|
||||
import com.hrznstudio.titanium.block.BasicBlock;
|
||||
import com.hrznstudio.titanium.block.BasicTileBlock;
|
||||
|
@ -43,6 +44,7 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -53,7 +55,9 @@ import net.minecraftforge.client.event.RenderTooltipEvent;
|
|||
import net.minecraftforge.client.model.generators.BlockModelProvider;
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.util.NonNullLazy;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
@ -131,6 +135,9 @@ public class FunctionalStorage extends ModuleController {
|
|||
}
|
||||
}
|
||||
}).subscribe();
|
||||
EventManager.modGeneric(RegistryEvent.Register.class, RecipeSerializer.class).process(register -> {
|
||||
CraftingHelper.register(DrawerlessWoodIngredient.NAME, DrawerlessWoodIngredient.SERIALIZER);
|
||||
}).subscribe();
|
||||
}
|
||||
|
||||
|
||||
|
@ -265,9 +272,46 @@ public class FunctionalStorage extends ModuleController {
|
|||
.isPresent())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
if (false){
|
||||
event.getGenerator().addProvider(new BlockItemModelGeneratorProvider(event.getGenerator(), MOD_ID, blocksToProcess));
|
||||
event.getGenerator().addProvider(new FunctionalStorageBlockstateProvider(event.getGenerator(), event.getExistingFileHelper(), blocksToProcess));
|
||||
event.getGenerator().addProvider(new TitaniumLootTableProvider(event.getGenerator(), blocksToProcess));
|
||||
|
||||
event.getGenerator().addProvider(new FunctionalStorageItemTagsProvider(event.getGenerator(), new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper()));
|
||||
event.getGenerator().addProvider(new FunctionalStorageLangProvider(event.getGenerator(), MOD_ID, "en_us"));
|
||||
event.getGenerator().addProvider(new FunctionalStorageBlockTagsProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()));
|
||||
event.getGenerator().addProvider(new ItemModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
for (StorageUpgradeItem.StorageTier storageTier : STORAGE_UPGRADES.keySet()) {
|
||||
item(STORAGE_UPGRADES.get(storageTier).get());
|
||||
}
|
||||
item(COLLECTOR_UPGRADE.get());
|
||||
item(PULLING_UPGRADE.get());
|
||||
item(PUSHING_UPGRADE.get());
|
||||
item(VOID_UPGRADE.get());
|
||||
}
|
||||
|
||||
private void item(Item item) {
|
||||
singleTexture(item.getRegistryName().getPath(), new ResourceLocation("minecraft:item/generated"), "layer0", new ResourceLocation(MOD_ID, "items/" + item.getRegistryName().getPath()));
|
||||
}
|
||||
});
|
||||
event.getGenerator().addProvider(new BlockModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
for (DrawerType value : DrawerType.values()) {
|
||||
for (RegistryObject<Block> blockRegistryObject : DRAWER_TYPES.get(value).stream().map(Pair::getLeft).collect(Collectors.toList())) {
|
||||
withExistingParent(blockRegistryObject.get().getRegistryName().getPath() + "_locked", modLoc(blockRegistryObject.get().getRegistryName().getPath()))
|
||||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
}
|
||||
}
|
||||
withExistingParent(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath()))
|
||||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
withExistingParent(ENDER_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(ENDER_DRAWER.getLeft().get().getRegistryName().getPath()))
|
||||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
}
|
||||
});
|
||||
}
|
||||
event.getGenerator().addProvider(new TitaniumRecipeProvider(event.getGenerator()) {
|
||||
@Override
|
||||
public void register(Consumer<FinishedRecipe> consumer) {
|
||||
|
@ -363,39 +407,5 @@ public class FunctionalStorage extends ModuleController {
|
|||
.save(consumer);
|
||||
}
|
||||
});
|
||||
event.getGenerator().addProvider(new FunctionalStorageItemTagsProvider(event.getGenerator(), new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper()));
|
||||
event.getGenerator().addProvider(new FunctionalStorageLangProvider(event.getGenerator(), MOD_ID, "en_us"));
|
||||
event.getGenerator().addProvider(new FunctionalStorageBlockTagsProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()));
|
||||
event.getGenerator().addProvider(new ItemModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
for (StorageUpgradeItem.StorageTier storageTier : STORAGE_UPGRADES.keySet()) {
|
||||
item(STORAGE_UPGRADES.get(storageTier).get());
|
||||
}
|
||||
item(COLLECTOR_UPGRADE.get());
|
||||
item(PULLING_UPGRADE.get());
|
||||
item(PUSHING_UPGRADE.get());
|
||||
item(VOID_UPGRADE.get());
|
||||
}
|
||||
|
||||
private void item(Item item) {
|
||||
singleTexture(item.getRegistryName().getPath(), new ResourceLocation("minecraft:item/generated"), "layer0", new ResourceLocation(MOD_ID, "items/" + item.getRegistryName().getPath()));
|
||||
}
|
||||
});
|
||||
event.getGenerator().addProvider(new BlockModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
for (DrawerType value : DrawerType.values()) {
|
||||
for (RegistryObject<Block> blockRegistryObject : DRAWER_TYPES.get(value).stream().map(Pair::getLeft).collect(Collectors.toList())) {
|
||||
withExistingParent(blockRegistryObject.get().getRegistryName().getPath() + "_locked", modLoc(blockRegistryObject.get().getRegistryName().getPath()))
|
||||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
}
|
||||
}
|
||||
withExistingParent(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath()))
|
||||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
withExistingParent(ENDER_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(ENDER_DRAWER.getLeft().get().getRegistryName().getPath()))
|
||||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.buuz135.functionalstorage.block.tile.DrawerControllerTile;
|
|||
import com.buuz135.functionalstorage.block.tile.DrawerTile;
|
||||
import com.buuz135.functionalstorage.inventory.item.DrawerCapabilityProvider;
|
||||
import com.buuz135.functionalstorage.item.LinkingToolItem;
|
||||
import com.buuz135.functionalstorage.recipe.DrawerlessWoodIngredient;
|
||||
import com.buuz135.functionalstorage.util.IWoodType;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
|
@ -22,6 +23,7 @@ import net.minecraft.data.recipes.FinishedRecipe;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
@ -260,6 +262,14 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
|
|||
.define('P', woodType.getPlanks())
|
||||
.define('C', Tags.Items.CHESTS_WOODEN)
|
||||
.save(consumer);
|
||||
if (woodType.getName().equals("oak")){
|
||||
TitaniumShapedRecipeBuilder.shapedRecipe(this)
|
||||
.setName(new ResourceLocation(FunctionalStorage.MOD_ID, "oak_drawer_alternate_x1"))
|
||||
.pattern("PPP").pattern("PCP").pattern("PPP")
|
||||
.define('P', new DrawerlessWoodIngredient())
|
||||
.define('C', Tags.Items.CHESTS_WOODEN)
|
||||
.save(consumer);
|
||||
}
|
||||
}
|
||||
if (type == FunctionalStorage.DrawerType.X_2){
|
||||
TitaniumShapedRecipeBuilder.shapedRecipe(this)
|
||||
|
@ -267,6 +277,14 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
|
|||
.define('P', woodType.getPlanks())
|
||||
.define('C', Tags.Items.CHESTS_WOODEN)
|
||||
.save(consumer);
|
||||
if (woodType.getName().equals("oak")){
|
||||
TitaniumShapedRecipeBuilder.shapedRecipe(this)
|
||||
.setName(new ResourceLocation(FunctionalStorage.MOD_ID, "oak_drawer_alternate_x2"))
|
||||
.pattern("PCP").pattern("PPP").pattern("PCP")
|
||||
.define('P', new DrawerlessWoodIngredient())
|
||||
.define('C', Tags.Items.CHESTS_WOODEN)
|
||||
.save(consumer);
|
||||
}
|
||||
}
|
||||
if (type == FunctionalStorage.DrawerType.X_4){
|
||||
TitaniumShapedRecipeBuilder.shapedRecipe(this)
|
||||
|
@ -274,6 +292,14 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
|
|||
.define('P', woodType.getPlanks())
|
||||
.define('C', Tags.Items.CHESTS_WOODEN)
|
||||
.save(consumer);
|
||||
if (woodType.getName().equals("oak")){
|
||||
TitaniumShapedRecipeBuilder.shapedRecipe(this)
|
||||
.setName(new ResourceLocation(FunctionalStorage.MOD_ID, "oak_drawer_alternate_x4"))
|
||||
.pattern("CPC").pattern("PPP").pattern("CPC")
|
||||
.define('P', new DrawerlessWoodIngredient())
|
||||
.define('C', Tags.Items.CHESTS_WOODEN)
|
||||
.save(consumer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package com.buuz135.functionalstorage.recipe;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.hrznstudio.titanium.util.TagUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraftforge.common.crafting.IIngredientSerializer;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.buuz135.functionalstorage.FunctionalStorage.MOD_ID;
|
||||
|
||||
public class DrawerlessWoodIngredient extends Ingredient {
|
||||
|
||||
public static WoodlessIngredientSerializer SERIALIZER = new WoodlessIngredientSerializer();
|
||||
public static ResourceLocation NAME = new ResourceLocation(MOD_ID, "woodless");
|
||||
|
||||
private List<Item> woodless;
|
||||
|
||||
public DrawerlessWoodIngredient() {
|
||||
super(Stream.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItems() {
|
||||
return getWoods().stream().map(ItemStack::new).toArray(ItemStack[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable ItemStack stack) {
|
||||
return getWoods().contains(stack.getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredientSerializer<? extends Ingredient> getSerializer() {
|
||||
return SERIALIZER;
|
||||
}
|
||||
|
||||
private List<Item> getWoods(){
|
||||
if (woodless == null){
|
||||
woodless = TagUtil.getAllEntries(ForgeRegistries.ITEMS, ItemTags.PLANKS).stream().filter(item -> !item.getRegistryName().getNamespace().equalsIgnoreCase("minecraft")).collect(Collectors.toList());
|
||||
if (woodless.isEmpty()){
|
||||
woodless.add(Items.OAK_PLANKS);
|
||||
}
|
||||
}
|
||||
return woodless;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
JsonObject element = new JsonObject();
|
||||
element.addProperty("type", NAME.toString());
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidate() {
|
||||
super.invalidate();
|
||||
this.woodless = null;
|
||||
}
|
||||
|
||||
public static class WoodlessIngredientSerializer implements IIngredientSerializer<Ingredient>{
|
||||
|
||||
@Override
|
||||
public Ingredient parse(FriendlyByteBuf buffer) {
|
||||
return new DrawerlessWoodIngredient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient parse(JsonObject json) {
|
||||
return new DrawerlessWoodIngredient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buffer, Ingredient ingredient) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user