From 9205549aff545305b99c44518e9d07e9a5e9409d Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Mon, 21 Mar 2022 20:14:28 +0100 Subject: [PATCH] Port to 1.18.2 --- build.gradle | 14 ++-- .../functionalstorage/FunctionalStorage.java | 70 ++++++++++--------- .../block/ArmoryCabinetBlock.java | 2 +- .../block/CompactingDrawerBlock.java | 7 +- .../functionalstorage/block/DrawerBlock.java | 9 +-- .../block/DrawerControllerBlock.java | 2 +- .../block/EnderDrawerBlock.java | 7 +- .../block/tile/ArmoryCabinetTile.java | 5 +- .../block/tile/CompactingDrawerTile.java | 15 +--- .../block/tile/ControllableDrawerTile.java | 5 +- .../block/tile/DrawerControllerTile.java | 7 +- .../block/tile/DrawerTile.java | 5 +- .../block/tile/EnderDrawerTile.java | 5 +- .../FunctionalStorageBlockTagsProvider.java | 7 +- .../FunctionalStorageItemTagsProvider.java | 4 +- .../data/FunctionalStorageLangProvider.java | 13 ++-- .../functionalstorage/util/StorageTags.java | 5 +- 17 files changed, 90 insertions(+), 92 deletions(-) diff --git a/build.gradle b/build.gradle index 4793e27..2fed1fc 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ java { minecraft { - mappings channel: 'official', version: '1.18.1' + mappings channel: 'official', version: '1.18.2' accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') runs { @@ -91,14 +91,14 @@ repositories { dependencies { - minecraft 'net.minecraftforge:forge:1.18.1-39.0.5' + minecraft 'net.minecraftforge:forge:1.18.2-40.0.19' implementation fg.deobf (project.dependencies.create('com.hrznstudio:titanium:1.18-3.4.0-27')) - compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.46:api") - runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.46") - runtimeOnly fg.deobf("curse.maven:refined-storage-243076:3569563") + compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.3.143:api") + runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.3.143") + //runtimeOnly fg.deobf("curse.maven:refined-storage-243076:3569563") implementation fg.deobf("curse.maven:the-one-probe-245211:3586969") - runtimeOnly fg.deobf("curse.maven:create-328085:3600402") - runtimeOnly fg.deobf("curse.maven:flywheel-486392:3600401") + //runtimeOnly fg.deobf("curse.maven:create-328085:3600402") + //runtimeOnly fg.deobf("curse.maven:flywheel-486392:3600401") annotationProcessor "org.spongepowered:mixin:0.8.5:processor" } diff --git a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java index e20231f..0692bdf 100644 --- a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java +++ b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java @@ -1,6 +1,10 @@ package com.buuz135.functionalstorage; import com.buuz135.functionalstorage.block.*; +import com.buuz135.functionalstorage.block.tile.CompactingDrawerTile; +import com.buuz135.functionalstorage.block.tile.DrawerControllerTile; +import com.buuz135.functionalstorage.block.tile.DrawerTile; +import com.buuz135.functionalstorage.block.tile.EnderDrawerTile; import com.buuz135.functionalstorage.client.CompactingDrawerRenderer; import com.buuz135.functionalstorage.client.ControllerRenderer; import com.buuz135.functionalstorage.client.DrawerRenderer; @@ -40,6 +44,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.ColorHandlerEvent; @@ -57,6 +62,7 @@ import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -82,11 +88,11 @@ public class FunctionalStorage extends ModuleController { public static List WOOD_TYPES = new ArrayList<>(); - public static HashMap>> DRAWER_TYPES = new HashMap<>(); - public static RegistryObject COMPACTING_DRAWER; - public static RegistryObject DRAWER_CONTROLLER; - public static RegistryObject ARMORY_CABINET; - public static RegistryObject ENDER_DRAWER; + public static HashMap, RegistryObject>>>> DRAWER_TYPES = new HashMap<>(); + public static Pair, RegistryObject>> COMPACTING_DRAWER; + public static Pair, RegistryObject>> DRAWER_CONTROLLER; + public static Pair, RegistryObject>> ARMORY_CABINET; + public static Pair, RegistryObject>> ENDER_DRAWER; public static RegistryObject LINKING_TOOL; public static HashMap> STORAGE_UPGRADES = new HashMap<>(); @@ -134,23 +140,23 @@ public class FunctionalStorage extends ModuleController { for (DrawerType value : DrawerType.values()) { for (IWoodType woodType : WOOD_TYPES) { String name = woodType.getName() + "_" + value.getSlots(); - DRAWER_TYPES.computeIfAbsent(value, drawerType -> new ArrayList<>()).add(getRegistries().register(Block.class, name, () -> new DrawerBlock(woodType, value))); + DRAWER_TYPES.computeIfAbsent(value, drawerType -> new ArrayList<>()).add(getRegistries().registerBlockWithTile(name, () -> new DrawerBlock(woodType, value))); } - DRAWER_TYPES.get(value).forEach(blockRegistryObject -> TAB.addIconStacks(() -> new ItemStack(blockRegistryObject.get()))); + DRAWER_TYPES.get(value).forEach(blockRegistryObject -> TAB.addIconStacks(() -> new ItemStack(blockRegistryObject.getLeft().get()))); } - COMPACTING_DRAWER = getRegistries().register(Block.class, "compacting_drawer", () -> new CompactingDrawerBlock("compacting_drawer")); - DRAWER_CONTROLLER = getRegistries().register(Block.class, "storage_controller", DrawerControllerBlock::new); - LINKING_TOOL = getRegistries().register(Item.class, "linking_tool", LinkingToolItem::new); + COMPACTING_DRAWER = getRegistries().registerBlockWithTile("compacting_drawer", () -> new CompactingDrawerBlock("compacting_drawer")); + DRAWER_CONTROLLER = getRegistries().registerBlockWithTile("storage_controller", DrawerControllerBlock::new); + LINKING_TOOL = getRegistries().registerGeneric(Item.class, "linking_tool", LinkingToolItem::new); for (StorageUpgradeItem.StorageTier value : StorageUpgradeItem.StorageTier.values()) { - STORAGE_UPGRADES.put(value, getRegistries().register(Item.class, value.name().toLowerCase(Locale.ROOT) + (value == StorageUpgradeItem.StorageTier.IRON ? "_downgrade" : "_upgrade"), () -> new StorageUpgradeItem(value))); + STORAGE_UPGRADES.put(value, getRegistries().registerGeneric(Item.class, value.name().toLowerCase(Locale.ROOT) + (value == StorageUpgradeItem.StorageTier.IRON ? "_downgrade" : "_upgrade"), () -> new StorageUpgradeItem(value))); } - COLLECTOR_UPGRADE = getRegistries().register(Item.class, "collector_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); - PULLING_UPGRADE = getRegistries().register(Item.class, "puller_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); - PUSHING_UPGRADE = getRegistries().register(Item.class, "pusher_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); - VOID_UPGRADE = getRegistries().register(Item.class, "void_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); - ARMORY_CABINET = getRegistries().register(Block.class, "armory_cabinet", ArmoryCabinetBlock::new); - CONFIGURATION_TOOL = getRegistries().register(Item.class, "configuration_tool", ConfigurationToolItem::new); - ENDER_DRAWER = getRegistries().register(Block.class, "ender_drawer", EnderDrawerBlock::new); + COLLECTOR_UPGRADE = getRegistries().registerGeneric(Item.class, "collector_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); + PULLING_UPGRADE = getRegistries().registerGeneric(Item.class, "puller_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); + PUSHING_UPGRADE = getRegistries().registerGeneric(Item.class, "pusher_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); + VOID_UPGRADE = getRegistries().registerGeneric(Item.class, "void_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); + ARMORY_CABINET = getRegistries().registerBlockWithTile("armory_cabinet", ArmoryCabinetBlock::new); + CONFIGURATION_TOOL = getRegistries().registerGeneric(Item.class, "configuration_tool", ConfigurationToolItem::new); + ENDER_DRAWER = getRegistries().registerBlockWithTile("ender_drawer", EnderDrawerBlock::new); } public enum DrawerType { @@ -186,12 +192,12 @@ public class FunctionalStorage extends ModuleController { EventManager.mod(EntityRenderersEvent.RegisterRenderers.class).process(registerRenderers -> { for (DrawerType value : DrawerType.values()) { DRAWER_TYPES.get(value).forEach(blockRegistryObject -> { - registerRenderers.registerBlockEntityRenderer(((BasicTileBlock) blockRegistryObject.get()).getTileEntityType(), p_173571_ -> new DrawerRenderer()); + registerRenderers.registerBlockEntityRenderer((BlockEntityType) blockRegistryObject.getRight().get(), p_173571_ -> new DrawerRenderer()); }); } - registerRenderers.registerBlockEntityRenderer(((BasicTileBlock) COMPACTING_DRAWER.get()).getTileEntityType(), p_173571_ -> new CompactingDrawerRenderer()); - registerRenderers.registerBlockEntityRenderer(((BasicTileBlock) DRAWER_CONTROLLER.get()).getTileEntityType(), p -> new ControllerRenderer()); - registerRenderers.registerBlockEntityRenderer(((BasicTileBlock) ENDER_DRAWER.get()).getTileEntityType(), p_173571_ -> new EnderDrawerRenderer()); + registerRenderers.registerBlockEntityRenderer((BlockEntityType) COMPACTING_DRAWER.getRight().get(), p_173571_ -> new CompactingDrawerRenderer()); + registerRenderers.registerBlockEntityRenderer((BlockEntityType) DRAWER_CONTROLLER.getRight().get(), p -> new ControllerRenderer()); + registerRenderers.registerBlockEntityRenderer((BlockEntityType) ENDER_DRAWER.getRight().get(), p_173571_ -> new EnderDrawerRenderer()); }).subscribe(); EventManager.mod(ColorHandlerEvent.Item.class).process(item -> { item.getItemColors().register((stack, tint) -> { @@ -222,15 +228,15 @@ public class FunctionalStorage extends ModuleController { }).subscribe(); EventManager.mod(FMLClientSetupEvent.class).process(event -> { for (DrawerType value : DrawerType.values()) { - for (RegistryObject blockRegistryObject : DRAWER_TYPES.get(value)) { + for (RegistryObject blockRegistryObject : DRAWER_TYPES.get(value).stream().map(Pair::getLeft).collect(Collectors.toList())) { ItemBlockRenderTypes.setRenderLayer(blockRegistryObject.get(), RenderType.cutout()); } } - ItemBlockRenderTypes.setRenderLayer(COMPACTING_DRAWER.get(), RenderType.cutout()); - ItemBlockRenderTypes.setRenderLayer(ENDER_DRAWER.get(), RenderType.cutout()); + ItemBlockRenderTypes.setRenderLayer(COMPACTING_DRAWER.getLeft().get(), RenderType.cutout()); + ItemBlockRenderTypes.setRenderLayer(ENDER_DRAWER.getLeft().get(), RenderType.cutout()); }).subscribe(); EventManager.forge(RenderTooltipEvent.Pre.class).process(itemTooltipEvent -> { - if (itemTooltipEvent.getItemStack().getItem().equals(FunctionalStorage.ENDER_DRAWER.get().asItem()) && itemTooltipEvent.getItemStack().hasTag()) { + if (itemTooltipEvent.getItemStack().getItem().equals(FunctionalStorage.ENDER_DRAWER.getLeft().get().asItem()) && itemTooltipEvent.getItemStack().hasTag()) { TooltipUtil.renderItems(itemTooltipEvent.getPoseStack(), EnderDrawerBlock.getFrequencyDisplay(itemTooltipEvent.getItemStack().getTag().getCompound("BlockEntityTag").getString("frequency")), itemTooltipEvent.getX() + 14, itemTooltipEvent.getY() + 11); } if (itemTooltipEvent.getItemStack().is(FunctionalStorage.LINKING_TOOL.get()) && itemTooltipEvent.getItemStack().getOrCreateTag().contains(LinkingToolItem.NBT_ENDER)) { @@ -314,14 +320,14 @@ public class FunctionalStorage extends ModuleController { UpgradeRecipeBuilder.smithing(Ingredient.of(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()), Ingredient.of(Items.NETHERITE_INGOT), STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get()) .unlocks("has_netherite_ingot", has(Items.NETHERITE_INGOT)) .save(consumer, STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get().getRegistryName()); - TitaniumShapedRecipeBuilder.shapedRecipe(DRAWER_CONTROLLER.get()) + TitaniumShapedRecipeBuilder.shapedRecipe(DRAWER_CONTROLLER.getLeft().get()) .pattern("IBI").pattern("CDC").pattern("IBI") .define('I', Tags.Items.STONE) .define('B', Tags.Items.STORAGE_BLOCKS_QUARTZ) .define('C', StorageTags.DRAWER) .define('D', Items.COMPARATOR) .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(ARMORY_CABINET.get()) + TitaniumShapedRecipeBuilder.shapedRecipe(ARMORY_CABINET.getLeft().get()) .pattern("ICI").pattern("CDC").pattern("IBI") .define('I', Tags.Items.STONE) .define('B', Tags.Items.INGOTS_NETHERITE) @@ -349,7 +355,7 @@ public class FunctionalStorage extends ModuleController { .define('R', Tags.Items.DUSTS_REDSTONE) .define('D', StorageTags.DRAWER) .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(ENDER_DRAWER.get()) + TitaniumShapedRecipeBuilder.shapedRecipe(ENDER_DRAWER.getLeft().get()) .pattern("PPP").pattern("LCL").pattern("PPP") .define('P', ItemTags.PLANKS) .define('C', Tags.Items.CHESTS_ENDER) @@ -380,14 +386,14 @@ public class FunctionalStorage extends ModuleController { @Override protected void registerModels() { for (DrawerType value : DrawerType.values()) { - for (RegistryObject blockRegistryObject : DRAWER_TYPES.get(value)) { + for (RegistryObject 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.get().getRegistryName().getPath() + "_locked", modLoc(COMPACTING_DRAWER.get().getRegistryName().getPath())) + withExistingParent(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath())) .texture("lock_icon", modLoc("blocks/lock")); - withExistingParent(ENDER_DRAWER.get().getRegistryName().getPath() + "_locked", modLoc(ENDER_DRAWER.get().getRegistryName().getPath())) + withExistingParent(ENDER_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(ENDER_DRAWER.getLeft().get().getRegistryName().getPath())) .texture("lock_icon", modLoc("blocks/lock")); } }); diff --git a/src/main/java/com/buuz135/functionalstorage/block/ArmoryCabinetBlock.java b/src/main/java/com/buuz135/functionalstorage/block/ArmoryCabinetBlock.java index 4b75a02..b5aabf2 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/ArmoryCabinetBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/ArmoryCabinetBlock.java @@ -31,7 +31,7 @@ public class ArmoryCabinetBlock extends RotatableBlock { @Override public BlockEntityType.BlockEntitySupplier getTileEntityFactory() { - return (p_155268_, p_155269_) -> new ArmoryCabinetTile(this, p_155268_, p_155269_); + return (p_155268_, p_155269_) -> new ArmoryCabinetTile(this, FunctionalStorage.ARMORY_CABINET.getRight().get(), p_155268_, p_155269_); } @NotNull diff --git a/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java b/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java index 61687b2..18f7336 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java @@ -76,11 +76,6 @@ public class CompactingDrawerBlock extends RotatableBlock registerDefaultState(defaultBlockState().setValue(RotatableBlock.FACING_HORIZONTAL, Direction.NORTH).setValue(DrawerBlock.LOCKED, false)); } - @Override - public void addAlternatives(DeferredRegistryHelper registry) { - super.addAlternatives(registry); - } - @NotNull @Override public RotationType getRotationType() { @@ -89,7 +84,7 @@ public class CompactingDrawerBlock extends RotatableBlock @Override public BlockEntityType.BlockEntitySupplier getTileEntityFactory() { - return (blockPos, state) -> new CompactingDrawerTile(this, blockPos, state); + return (blockPos, state) -> new CompactingDrawerTile(this, (BlockEntityType) FunctionalStorage.COMPACTING_DRAWER.getRight().get(), blockPos, state); } @Override diff --git a/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java b/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java index 6144722..6648ff4 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java @@ -50,6 +50,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.common.Tags; import net.minecraftforge.common.capabilities.ICapabilityProvider; +import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,6 +60,7 @@ import java.util.HashMap; import java.util.List; import java.util.function.Consumer; import java.util.function.Supplier; +import java.util.stream.Collectors; public class DrawerBlock extends RotatableBlock { @@ -140,11 +142,6 @@ public class DrawerBlock extends RotatableBlock { p_206840_1_.add(LOCKED); } - @Override - public void addAlternatives(DeferredRegistryHelper registry) { - super.addAlternatives(registry); - } - @NotNull @Override public RotationType getRotationType() { @@ -153,7 +150,7 @@ public class DrawerBlock extends RotatableBlock { @Override public BlockEntityType.BlockEntitySupplier getTileEntityFactory() { - return (blockPos, state) -> new DrawerTile(this, blockPos, state, type); + return (blockPos, state) -> new DrawerTile(this, (BlockEntityType) FunctionalStorage.DRAWER_TYPES.get(type).stream().filter(registryObjectRegistryObjectPair -> registryObjectRegistryObjectPair.getLeft().get().equals(this)).map(Pair::getRight).findFirst().get().get(), blockPos, state, type); } @Override diff --git a/src/main/java/com/buuz135/functionalstorage/block/DrawerControllerBlock.java b/src/main/java/com/buuz135/functionalstorage/block/DrawerControllerBlock.java index aa3ea06..5422302 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/DrawerControllerBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/DrawerControllerBlock.java @@ -29,7 +29,7 @@ public class DrawerControllerBlock extends RotatableBlock @Override public BlockEntityType.BlockEntitySupplier getTileEntityFactory() { - return (p_155268_, p_155269_) -> new DrawerControllerTile(this, p_155268_, p_155269_); + return (p_155268_, p_155269_) -> new DrawerControllerTile(this, (BlockEntityType) FunctionalStorage.DRAWER_CONTROLLER.getRight().get(), p_155268_, p_155269_); } @NotNull diff --git a/src/main/java/com/buuz135/functionalstorage/block/EnderDrawerBlock.java b/src/main/java/com/buuz135/functionalstorage/block/EnderDrawerBlock.java index 3eba620..8e6eb8e 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/EnderDrawerBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/EnderDrawerBlock.java @@ -74,11 +74,6 @@ public class EnderDrawerBlock extends RotatableBlock { p_206840_1_.add(LOCKED); } - @Override - public void addAlternatives(DeferredRegistryHelper registry) { - super.addAlternatives(registry); - } - @NotNull @Override public RotationType getRotationType() { @@ -87,7 +82,7 @@ public class EnderDrawerBlock extends RotatableBlock { @Override public BlockEntityType.BlockEntitySupplier getTileEntityFactory() { - return (blockPos, state) -> new EnderDrawerTile(this, blockPos, state); + return (blockPos, state) -> new EnderDrawerTile(this, (BlockEntityType) FunctionalStorage.ENDER_DRAWER.getRight().get(),blockPos, state); } @Override diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/ArmoryCabinetTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/ArmoryCabinetTile.java index 11050e0..f6a8a5e 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/ArmoryCabinetTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/ArmoryCabinetTile.java @@ -9,6 +9,7 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; @@ -25,8 +26,8 @@ public class ArmoryCabinetTile extends ActiveTile { public ArmoryCabinetInventoryHandler handler; private final LazyOptional lazyStorage; - public ArmoryCabinetTile(BasicTileBlock base, BlockPos pos, BlockState state) { - super(base, pos, state); + public ArmoryCabinetTile(BasicTileBlock base, BlockEntityType entityType, BlockPos pos, BlockState state) { + super(base, entityType, pos, state); this.handler = new ArmoryCabinetInventoryHandler() { @Override public void onChange() { diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java index 29c5bba..d6a62e1 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java @@ -1,36 +1,27 @@ package com.buuz135.functionalstorage.block.tile; import com.buuz135.functionalstorage.FunctionalStorage; -import com.buuz135.functionalstorage.inventory.BigInventoryHandler; import com.buuz135.functionalstorage.inventory.CompactingInventoryHandler; import com.buuz135.functionalstorage.util.CompactingUtil; import com.hrznstudio.titanium.annotation.Save; import com.hrznstudio.titanium.block.BasicTileBlock; -import com.hrznstudio.titanium.block.tile.ActiveTile; -import com.hrznstudio.titanium.util.RayTraceUtils; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.util.datafix.fixes.ItemStackTheFlatteningFix; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.ItemHandlerHelper; -import net.minecraftforge.items.ItemStackHandler; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.HashMap; -import java.util.UUID; public class CompactingDrawerTile extends ControllableDrawerTile { @@ -39,8 +30,8 @@ public class CompactingDrawerTile extends ControllableDrawerTile lazyStorage; private boolean hasCheckedRecipes; - public CompactingDrawerTile(BasicTileBlock base, BlockPos pos, BlockState state) { - super(base, pos, state); + public CompactingDrawerTile(BasicTileBlock base, BlockEntityType blockEntityType, BlockPos pos, BlockState state) { + super(base, blockEntityType, pos, state); this.handler = new CompactingInventoryHandler() { @Override public void onChange() { diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/ControllableDrawerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/ControllableDrawerTile.java index ff98192..0ddf778 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/ControllableDrawerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/ControllableDrawerTile.java @@ -25,6 +25,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; @@ -54,8 +55,8 @@ public abstract class ControllableDrawerTile @Save private DrawerOptions drawerOptions; - public ControllableDrawerTile(BasicTileBlock base, BlockPos pos, BlockState state) { - super(base, pos, state); + public ControllableDrawerTile(BasicTileBlock base, BlockEntityType entityType, BlockPos pos, BlockState state) { + super(base, entityType, pos, state); this.drawerOptions = new DrawerOptions(); this.storageUpgrades = new InventoryComponent>("storage_upgrades", 10, 70, getStorageSlotAmount()) { @NotNull diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerControllerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerControllerTile.java index 5f8679c..c05eca7 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerControllerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerControllerTile.java @@ -16,6 +16,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.capabilities.Capability; @@ -41,8 +42,8 @@ public class DrawerControllerTile extends ControllableDrawerTile lazyStorage; - public DrawerControllerTile(BasicTileBlock base, BlockPos pos, BlockState state) { - super(base, pos, state); + public DrawerControllerTile(BasicTileBlock base, BlockEntityType blockEntityType, BlockPos pos, BlockState state) { + super(base, blockEntityType, pos, state); this.connectedDrawers = new ConnectedDrawers(null); this.handler = new ControllerInventoryHandler() { @Override @@ -147,7 +148,7 @@ public class DrawerControllerTile extends ControllableDrawerTile { private final LazyOptional lazyStorage; private FunctionalStorage.DrawerType type; - public DrawerTile(BasicTileBlock base, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type) { - super(base, pos, state); + public DrawerTile(BasicTileBlock base, BlockEntityType blockEntityType, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type) { + super(base, blockEntityType, pos, state); this.type = type; this.handler = new BigInventoryHandler(type) { @Override diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java index c163475..1a2bb04 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java @@ -18,6 +18,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; @@ -36,8 +37,8 @@ public class EnderDrawerTile extends ControllableDrawerTile { private String frequency; private LazyOptional lazyStorage; - public EnderDrawerTile(BasicTileBlock base, BlockPos pos, BlockState state) { - super(base, pos, state); + public EnderDrawerTile(BasicTileBlock base, BlockEntityType blockEntityType, BlockPos pos, BlockState state) { + super(base, blockEntityType, pos, state); this.frequency = UUID.randomUUID().toString(); this.lazyStorage = LazyOptional.empty(); } diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageBlockTagsProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageBlockTagsProvider.java index 4d7566b..4e60ee6 100644 --- a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageBlockTagsProvider.java +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageBlockTagsProvider.java @@ -11,8 +11,11 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.registries.RegistryObject; +import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; +import java.util.stream.Collectors; + public class FunctionalStorageBlockTagsProvider extends BlockTagsProvider { public FunctionalStorageBlockTagsProvider(DataGenerator p_126530_, String modId, @Nullable ExistingFileHelper existingFileHelper) { @@ -23,10 +26,10 @@ public class FunctionalStorageBlockTagsProvider extends BlockTagsProvider { protected void addTags() { TagAppender tTagAppender = this.tag(BlockTags.MINEABLE_WITH_AXE); for (FunctionalStorage.DrawerType drawerType : FunctionalStorage.DRAWER_TYPES.keySet()) { - for (RegistryObject blockRegistryObject : FunctionalStorage.DRAWER_TYPES.get(drawerType)) { + for (RegistryObject blockRegistryObject : FunctionalStorage.DRAWER_TYPES.get(drawerType).stream().map(Pair::getLeft).collect(Collectors.toList())) { tTagAppender.add(blockRegistryObject.get()); } } - this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(FunctionalStorage.COMPACTING_DRAWER.get()).add(FunctionalStorage.DRAWER_CONTROLLER.get()).add(FunctionalStorage.ARMORY_CABINET.get()).add(FunctionalStorage.ENDER_DRAWER.get()); + this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(FunctionalStorage.COMPACTING_DRAWER.getLeft().get()).add(FunctionalStorage.DRAWER_CONTROLLER.getLeft().get()).add(FunctionalStorage.ARMORY_CABINET.getLeft().get()).add(FunctionalStorage.ENDER_DRAWER.getLeft().get()); } } diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java index d259be4..258b252 100644 --- a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java @@ -15,9 +15,11 @@ import net.minecraftforge.common.ForgeTier; import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.registries.RegistryObject; +import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; import java.nio.file.Path; +import java.util.stream.Collectors; public class FunctionalStorageItemTagsProvider extends ItemTagsProvider { @@ -29,7 +31,7 @@ public class FunctionalStorageItemTagsProvider extends ItemTagsProvider { protected void addTags() { TagsProvider.TagAppender tTagAppender = this.tag(StorageTags.DRAWER); for (FunctionalStorage.DrawerType drawerType : FunctionalStorage.DRAWER_TYPES.keySet()) { - for (RegistryObject blockRegistryObject : FunctionalStorage.DRAWER_TYPES.get(drawerType)) { + for (RegistryObject blockRegistryObject : FunctionalStorage.DRAWER_TYPES.get(drawerType).stream().map(Pair::getLeft).collect(Collectors.toList())) { tTagAppender.add(blockRegistryObject.get().asItem()); } } diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java index 0d78bcc..7c59044 100644 --- a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java @@ -8,6 +8,9 @@ import net.minecraft.world.level.block.Block; import net.minecraftforge.common.data.LanguageProvider; import net.minecraftforge.registries.RegistryObject; import org.apache.commons.lang3.text.WordUtils; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.stream.Collectors; public class FunctionalStorageLangProvider extends LanguageProvider { @@ -19,13 +22,13 @@ public class FunctionalStorageLangProvider extends LanguageProvider { protected void addTranslations() { this.add("itemGroup.functionalstorage", "Functional Storage"); for (FunctionalStorage.DrawerType drawerType : FunctionalStorage.DRAWER_TYPES.keySet()) { - for (RegistryObject blockRegistryObject : FunctionalStorage.DRAWER_TYPES.get(drawerType)) { + for (RegistryObject blockRegistryObject : FunctionalStorage.DRAWER_TYPES.get(drawerType).stream().map(Pair::getLeft).collect(Collectors.toList())) { DrawerBlock drawerBlock = (DrawerBlock) blockRegistryObject.get(); this.add(drawerBlock, WordUtils.capitalize(drawerBlock.getWoodType().getName().replace('_', ' ').toLowerCase()) + " Drawer (" +drawerBlock.getType().getDisplayName() +")"); } } - this.add(FunctionalStorage.COMPACTING_DRAWER.get(), "Compacting Drawer"); - this.add(FunctionalStorage.ENDER_DRAWER.get(), "Ender Drawer" ); + this.add(FunctionalStorage.COMPACTING_DRAWER.getLeft().get(), "Compacting Drawer"); + this.add(FunctionalStorage.ENDER_DRAWER.getLeft().get(), "Ender Drawer" ); this.add("linkingtool.linkingmode", "Linking Mode: "); this.add("linkingtool.linkingmode.single", "Single"); this.add("linkingtool.linkingmode.single.desc", "Links a drawer to a controller"); @@ -39,7 +42,7 @@ public class FunctionalStorageLangProvider extends LanguageProvider { this.add("key.categories.utility", "Utility"); this.add("key.categories.storage", "Storage"); this.add(FunctionalStorage.LINKING_TOOL.get(), "Linking Tool"); - this.add(FunctionalStorage.DRAWER_CONTROLLER.get(), "Storage Controller"); + this.add(FunctionalStorage.DRAWER_CONTROLLER.getLeft().get(), "Storage Controller"); this.add("storageupgrade.desc", "Multiplies the block storage by "); for (StorageUpgradeItem.StorageTier storageTier : FunctionalStorage.STORAGE_UPGRADES.keySet()) { this.add(FunctionalStorage.STORAGE_UPGRADES.get(storageTier).get(), WordUtils.capitalize(storageTier.name().toLowerCase()) + (storageTier == StorageUpgradeItem.StorageTier.IRON ? " Downgrade" : " Upgrade")); @@ -48,7 +51,7 @@ public class FunctionalStorageLangProvider extends LanguageProvider { this.add(FunctionalStorage.PULLING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PULLING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); this.add(FunctionalStorage.PUSHING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PUSHING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); this.add(FunctionalStorage.VOID_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.VOID_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); - this.add(FunctionalStorage.ARMORY_CABINET.get(), "Armory Cabinet"); + this.add(FunctionalStorage.ARMORY_CABINET.getLeft().get(), "Armory Cabinet"); this.add(FunctionalStorage.CONFIGURATION_TOOL.get(), "Configuration Tool"); this.add("item.utility.downgrade", "Downgrades the slots to a max of 64 items"); this.add("item.utility.direction", "Direction: "); diff --git a/src/main/java/com/buuz135/functionalstorage/util/StorageTags.java b/src/main/java/com/buuz135/functionalstorage/util/StorageTags.java index 6ff4a6e..66ae3fa 100644 --- a/src/main/java/com/buuz135/functionalstorage/util/StorageTags.java +++ b/src/main/java/com/buuz135/functionalstorage/util/StorageTags.java @@ -3,12 +3,13 @@ package com.buuz135.functionalstorage.util; import com.buuz135.functionalstorage.FunctionalStorage; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraftforge.common.Tags; public class StorageTags { - public static Tags.IOptionalNamedTag DRAWER = ItemTags.createOptional(new ResourceLocation(FunctionalStorage.MOD_ID, "drawer")); - public static Tags.IOptionalNamedTag IGNORE_CRAFTING_CHECK = ItemTags.createOptional(new ResourceLocation(FunctionalStorage.MOD_ID, "ignore_crafting_check")); + public static TagKey DRAWER = ItemTags.create(new ResourceLocation(FunctionalStorage.MOD_ID, "drawer")); + public static TagKey IGNORE_CRAFTING_CHECK = ItemTags.create(new ResourceLocation(FunctionalStorage.MOD_ID, "ignore_crafting_check")); }