From b8563e1ac1b6c0c283a9d2e0b8b5bf6c8ad4b947 Mon Sep 17 00:00:00 2001 From: 90 Date: Fri, 19 Jul 2024 22:52:40 +0100 Subject: [PATCH] Reorganise entry points, definitions, pretty much everything --- .../_90/fulleng/datagen/FullDropProvider.java | 4 +- .../fulleng/datagen/FullModelProvider.java | 23 +- .../fulleng/datagen/FullRecipeProvider.java | 26 +- .../_90/fulleng/datagen/FullTagProvider.java | 3 +- .../fulleng/FullBlockEnergisticsClient.java | 64 +++++ .../_90/fulleng/FullblockEnergistics.java | 223 +++++++++--------- .../gripe/_90/fulleng/block/FullBlock.java | 5 + .../_90/fulleng/block/TerminalBlock.java | 4 +- .../monitor/ConversionMonitorBlockEntity.java | 4 +- .../monitor/StorageMonitorBlockEntity.java | 4 +- .../terminal/CraftingTerminalBlockEntity.java | 4 +- .../PatternAccessTerminalBlockEntity.java | 4 +- .../PatternEncodingTerminalBlockEntity.java | 4 +- .../terminal/StorageTerminalBlockEntity.java | 4 +- ...tyRenderer.java => MonitorBERenderer.java} | 4 +- .../_90/fulleng/definition/FullEngBEs.java | 73 ------ .../_90/fulleng/definition/FullEngBlocks.java | 78 ------ .../requester/RequesterIntegration.java | 15 +- .../requester/RequesterTerminalBlock.java | 20 -- .../RequesterTerminalBlockEntity.java | 6 +- .../requester/RequesterTerminalMenu.java | 16 -- .../integration/tooltips/TooltipProvider.java | 4 +- .../java/gripe/_90/fulleng/mixin/Plugin.java | 45 ++++ src/main/resources/fulleng.mixins.json | 1 + 24 files changed, 290 insertions(+), 348 deletions(-) create mode 100644 src/main/java/gripe/_90/fulleng/FullBlockEnergisticsClient.java rename src/main/java/gripe/_90/fulleng/client/{MonitorBlockEntityRenderer.java => MonitorBERenderer.java} (87%) delete mode 100644 src/main/java/gripe/_90/fulleng/definition/FullEngBEs.java delete mode 100644 src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java delete mode 100644 src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java delete mode 100644 src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalMenu.java create mode 100644 src/main/java/gripe/_90/fulleng/mixin/Plugin.java diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java index 2d88f9f..dab0e2d 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java @@ -20,7 +20,7 @@ import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; -import gripe._90.fulleng.definition.FullEngBlocks; +import gripe._90.fulleng.FullblockEnergistics; public class FullDropProvider extends LootTableProvider { public FullDropProvider(PackOutput output, CompletableFuture registries) { @@ -40,7 +40,7 @@ public void generate(@NotNull BiConsumer, LootTable.Build @Override public void generate() { - for (var block : FullEngBlocks.BLOCKS.getEntries()) { + for (var block : FullblockEnergistics.BLOCKS.getEntries()) { add( block.get(), LootTable.lootTable() diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java index a02de45..c6e21c2 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java @@ -15,10 +15,10 @@ import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.FullBlock; import gripe._90.fulleng.block.MonitorBlock; -import gripe._90.fulleng.definition.FullEngBlocks; public class FullModelProvider extends AE2BlockStateProvider { - private static final ResourceLocation TERMINAL_OFF = FullblockEnergistics.makeId("block/terminal_off"); + private static final ResourceLocation TERMINAL_OFF = + ResourceLocation.fromNamespaceAndPath(FullblockEnergistics.MODID, "block/terminal_off"); public FullModelProvider(PackOutput output, ExistingFileHelper existing) { super(output, FullblockEnergistics.MODID, existing); @@ -26,15 +26,15 @@ public FullModelProvider(PackOutput output, ExistingFileHelper existing) { @Override protected void registerStatesAndModels() { - terminal(FullEngBlocks.TERMINAL, "ae2:part/terminal"); - terminal(FullEngBlocks.CRAFTING_TERMINAL, "ae2:part/crafting_terminal"); - terminal(FullEngBlocks.PATTERN_ENCODING_TERMINAL, "ae2:part/pattern_encoding_terminal"); - terminal(FullEngBlocks.PATTERN_ACCESS_TERMINAL, "ae2:part/pattern_access_terminal"); + terminal(FullblockEnergistics.TERMINAL, "ae2:part/terminal"); + terminal(FullblockEnergistics.CRAFTING_TERMINAL, "ae2:part/crafting_terminal"); + terminal(FullblockEnergistics.PATTERN_ENCODING_TERMINAL, "ae2:part/pattern_encoding_terminal"); + terminal(FullblockEnergistics.PATTERN_ACCESS_TERMINAL, "ae2:part/pattern_access_terminal"); - monitor(FullEngBlocks.STORAGE_MONITOR, "ae2:part/storage_monitor"); - monitor(FullEngBlocks.CONVERSION_MONITOR, "ae2:part/conversion_monitor"); + monitor(FullblockEnergistics.STORAGE_MONITOR, "ae2:part/storage_monitor"); + monitor(FullblockEnergistics.CONVERSION_MONITOR, "ae2:part/conversion_monitor"); - terminal(FullEngBlocks.REQUESTER_TERMINAL, "merequester:part/requester_terminal"); + terminal(FullblockEnergistics.REQUESTER_TERMINAL, "merequester:part/requester_terminal"); } private void terminal(DeferredBlock terminal, String texturePrefix) { @@ -43,14 +43,15 @@ private void terminal(DeferredBlock terminal, String texturePrefix) { existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_medium"), ModelProvider.TEXTURE); existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_dark"), ModelProvider.TEXTURE); - var onModel = terminal != FullEngBlocks.TERMINAL + var onModel = terminal != FullblockEnergistics.TERMINAL ? models().withExistingParent( "block/" + terminal.getId().getPath(), FullblockEnergistics.MODID + ":block/terminal") .texture("lightsBright", texturePrefix + "_bright") .texture("lightsMedium", texturePrefix + "_medium") .texture("lightsDark", texturePrefix + "_dark") .renderType("cutout") - : models().getExistingFile(FullblockEnergistics.makeId("block/terminal")); + : models().getExistingFile( + ResourceLocation.fromNamespaceAndPath(FullblockEnergistics.MODID, "block/terminal")); var builder = MultiVariantGenerator.multiVariant(terminal.get()) .with(createFacingSpinDispatch()) diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java index 72571fb..af6ef24 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java @@ -11,11 +11,11 @@ import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.ShapelessRecipeBuilder; +import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.registries.DeferredBlock; import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.FullBlock; -import gripe._90.fulleng.definition.FullEngBlocks; import gripe._90.fulleng.integration.Addons; public class FullRecipeProvider extends RecipeProvider { @@ -25,16 +25,16 @@ public FullRecipeProvider(PackOutput output, CompletableFuture> bl ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, block) .requires(part) .unlockedBy("has_" + partId, has(part)) - .save(output, FullblockEnergistics.makeId("terminals/block_" + partId + "_from_part")); + .save( + output, + ResourceLocation.fromNamespaceAndPath( + FullblockEnergistics.MODID, "terminals/block_" + partId + "_from_part")); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, part) .requires(block) .unlockedBy("has_" + partId, has(part)) - .save(output, FullblockEnergistics.makeId("terminals/part_" + partId + "_from_block")); + .save( + output, + ResourceLocation.fromNamespaceAndPath( + FullblockEnergistics.MODID, "terminals/part_" + partId + "_from_block")); } } diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java index 5dace23..1524c99 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java @@ -11,7 +11,6 @@ import net.neoforged.neoforge.common.data.BlockTagsProvider; import gripe._90.fulleng.FullblockEnergistics; -import gripe._90.fulleng.definition.FullEngBlocks; public class FullTagProvider extends BlockTagsProvider { public FullTagProvider(PackOutput output, CompletableFuture registries) { @@ -20,7 +19,7 @@ public FullTagProvider(PackOutput output, CompletableFuture tag(BlockTags.MINEABLE_WITH_PICKAXE) + FullblockEnergistics.BLOCKS.getEntries().forEach(b -> tag(BlockTags.MINEABLE_WITH_PICKAXE) .add(BuiltInRegistries.BLOCK.getResourceKey(b.get()).orElseThrow())); } diff --git a/src/main/java/gripe/_90/fulleng/FullBlockEnergisticsClient.java b/src/main/java/gripe/_90/fulleng/FullBlockEnergisticsClient.java new file mode 100644 index 0000000..413d145 --- /dev/null +++ b/src/main/java/gripe/_90/fulleng/FullBlockEnergisticsClient.java @@ -0,0 +1,64 @@ +package gripe._90.fulleng; + +import java.util.Objects; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; +import net.minecraft.world.phys.BlockHitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.event.ModelEvent; +import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.network.PacketDistributor; + +import appeng.api.util.AEColor; +import appeng.client.render.ColorableBlockEntityBlockColor; +import appeng.client.render.StaticItemColor; +import appeng.core.network.serverbound.PartLeftClickPacket; + +import gripe._90.fulleng.block.entity.monitor.ConversionMonitorBlockEntity; +import gripe._90.fulleng.client.MonitorBERenderer; + +@SuppressWarnings("unused") +@Mod(value = FullblockEnergistics.MODID, dist = Dist.CLIENT) +public class FullBlockEnergisticsClient { + public FullBlockEnergisticsClient(IEventBus eventBus) { + eventBus.addListener((ModelEvent.RegisterGeometryLoaders event) -> { + BlockEntityRenderers.register(FullblockEnergistics.STORAGE_MONITOR_BE.get(), MonitorBERenderer::new); + BlockEntityRenderers.register(FullblockEnergistics.CONVERSION_MONITOR_BE.get(), MonitorBERenderer::new); + }); + + eventBus.addListener((RegisterColorHandlersEvent.Block event) -> { + for (var block : FullblockEnergistics.BLOCKS.getEntries()) { + event.register(ColorableBlockEntityBlockColor.INSTANCE, block.get()); + } + }); + + eventBus.addListener((RegisterColorHandlersEvent.Item event) -> { + for (var block : FullblockEnergistics.BLOCKS.getEntries()) { + event.register(new StaticItemColor(AEColor.TRANSPARENT), block.get()); + } + }); + + NeoForge.EVENT_BUS.addListener((PlayerInteractEvent.LeftClickBlock event) -> { + var level = event.getLevel(); + + if (level.isClientSide()) { + if (!(Minecraft.getInstance().hitResult instanceof BlockHitResult hitResult)) { + return; + } + + if (level.getBlockEntity(hitResult.getBlockPos()) instanceof ConversionMonitorBlockEntity monitor + && hitResult.getDirection() == monitor.getFront()) { + PacketDistributor.sendToServer( + new PartLeftClickPacket(hitResult, event.getEntity().isShiftKeyDown())); + Objects.requireNonNull(Minecraft.getInstance().gameMode).destroyDelay = 5; + event.setCanceled(true); + } + } + }); + } +} diff --git a/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java b/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java index 15f8e31..677e1dd 100644 --- a/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java +++ b/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java @@ -1,140 +1,151 @@ package gripe._90.fulleng; -import java.util.Objects; +import java.util.function.Function; +import java.util.function.Supplier; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.core.Direction; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; -import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; -import net.neoforged.neoforge.client.event.ModelEvent; -import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; -import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; -import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; -import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; -import net.neoforged.neoforge.network.PacketDistributor; -import net.neoforged.neoforge.registries.RegisterEvent; +import net.neoforged.neoforge.registries.DeferredBlock; +import net.neoforged.neoforge.registries.DeferredRegister; import appeng.api.AECapabilities; import appeng.api.ids.AECreativeTabIds; import appeng.api.networking.IInWorldGridNodeHost; -import appeng.api.util.AEColor; -import appeng.client.render.ColorableBlockEntityBlockColor; -import appeng.client.render.StaticItemColor; -import appeng.core.AppEng; -import appeng.core.network.serverbound.PartLeftClickPacket; - +import appeng.block.AEBaseBlockItem; +import appeng.block.AEBaseEntityBlock; +import appeng.blockentity.AEBaseBlockEntity; +import appeng.core.definitions.AEItems; +import appeng.core.definitions.AEParts; +import appeng.core.definitions.ItemDefinition; +import appeng.items.parts.PartItem; +import appeng.parts.reporting.AbstractDisplayPart; +import appeng.parts.reporting.AbstractMonitorPart; + +import gripe._90.fulleng.block.FullBlock; +import gripe._90.fulleng.block.MonitorBlock; +import gripe._90.fulleng.block.TerminalBlock; import gripe._90.fulleng.block.entity.monitor.ConversionMonitorBlockEntity; -import gripe._90.fulleng.client.MonitorBlockEntityRenderer; -import gripe._90.fulleng.definition.FullEngBEs; -import gripe._90.fulleng.definition.FullEngBlocks; +import gripe._90.fulleng.block.entity.monitor.StorageMonitorBlockEntity; +import gripe._90.fulleng.block.entity.terminal.CraftingTerminalBlockEntity; +import gripe._90.fulleng.block.entity.terminal.PatternAccessTerminalBlockEntity; +import gripe._90.fulleng.block.entity.terminal.PatternEncodingTerminalBlockEntity; +import gripe._90.fulleng.block.entity.terminal.StorageTerminalBlockEntity; +import gripe._90.fulleng.block.entity.terminal.TerminalBlockEntity; import gripe._90.fulleng.integration.Addons; +import gripe._90.fulleng.integration.IntegrationBlockItem; import gripe._90.fulleng.integration.requester.RequesterIntegration; -import gripe._90.fulleng.integration.requester.RequesterTerminalMenu; +import gripe._90.fulleng.integration.requester.RequesterTerminalBlockEntity; @Mod(FullblockEnergistics.MODID) public class FullblockEnergistics { public static final String MODID = "fulleng"; - public static ResourceLocation makeId(String path) { - return ResourceLocation.fromNamespaceAndPath(MODID, path); - } - - public FullblockEnergistics(IEventBus modEventBus) { - FullEngBlocks.register(modEventBus); - FullEngBEs.DR.register(modEventBus); - - modEventBus.addListener(this::register); - modEventBus.addListener(this::registerCapabilities); - modEventBus.addListener(this::addToCreativeTab); + public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID); + private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID); + + // spotless:off + public static final DeferredBlock> TERMINAL = terminal(AEParts.TERMINAL); + public static final DeferredBlock> CRAFTING_TERMINAL = terminal(AEParts.CRAFTING_TERMINAL); + public static final DeferredBlock> PATTERN_ENCODING_TERMINAL = terminal(AEParts.PATTERN_ENCODING_TERMINAL); + public static final DeferredBlock> PATTERN_ACCESS_TERMINAL = terminal(AEParts.PATTERN_ACCESS_TERMINAL); + + public static final DeferredBlock> STORAGE_MONITOR = monitor(AEParts.STORAGE_MONITOR); + public static final DeferredBlock> CONVERSION_MONITOR = monitor(AEParts.CONVERSION_MONITOR); + // spotless:on + + public static final DeferredBlock> REQUESTER_TERMINAL = block( + "requester_terminal", + () -> new TerminalBlock<>( + Addons.MEREQUESTER.isLoaded() + ? RequesterIntegration.getRequesterTerminalPart() + : AEItems.MISSING_CONTENT), + block -> new IntegrationBlockItem(block, Addons.MEREQUESTER)); + + private static final DeferredRegister> BE_TYPES = + DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, MODID); + + // spotless:off + public static final Supplier> TERMINAL_BE = be("terminal", StorageTerminalBlockEntity.class, StorageTerminalBlockEntity::new, TERMINAL); + public static final Supplier> CRAFTING_TERMINAL_BE = be("crafting_terminal", CraftingTerminalBlockEntity.class, CraftingTerminalBlockEntity::new, CRAFTING_TERMINAL); + public static final Supplier> PATTERN_ENCODING_TERMINAL_BE = be("pattern_encoding_terminal", PatternEncodingTerminalBlockEntity.class, PatternEncodingTerminalBlockEntity::new, PATTERN_ENCODING_TERMINAL); + public static final Supplier> PATTERN_ACCESS_TERMINAL_BE = be("pattern_access_terminal", PatternAccessTerminalBlockEntity.class, PatternAccessTerminalBlockEntity::new, PATTERN_ACCESS_TERMINAL); + + public static final Supplier> STORAGE_MONITOR_BE = be("storage_monitor", StorageMonitorBlockEntity.class, StorageMonitorBlockEntity::new, STORAGE_MONITOR); + public static final Supplier> CONVERSION_MONITOR_BE = be("conversion_monitor", ConversionMonitorBlockEntity.class, ConversionMonitorBlockEntity::new, CONVERSION_MONITOR); + + public static final Supplier> REQUESTER_TERMINAL_BE = be("requester_terminal", RequesterTerminalBlockEntity.class, RequesterTerminalBlockEntity::new, REQUESTER_TERMINAL); + // spotless:on + + public FullblockEnergistics(IEventBus eventBus) { + BLOCKS.register(eventBus); + ITEMS.register(eventBus); + BE_TYPES.register(eventBus); + + eventBus.addListener((RegisterCapabilitiesEvent event) -> { + for (var type : BE_TYPES.getEntries()) { + event.registerBlockEntity( + AECapabilities.IN_WORLD_GRID_NODE_HOST, type.get(), (be, context) -> (IInWorldGridNodeHost) be); + } - if (FMLEnvironment.dist.isClient()) { - new Client(modEventBus); - } + event.registerBlockEntity( + Capabilities.ItemHandler.BLOCK, + PATTERN_ENCODING_TERMINAL_BE.get(), + (be, context) -> context != Direction.NORTH + ? be.getLogic().getBlankPatternInv().toItemHandler() + : null); + }); + + eventBus.addListener((BuildCreativeModeTabContentsEvent event) -> { + if (event.getTabKey().equals(AECreativeTabIds.MAIN)) { + for (var block : BLOCKS.getEntries()) { + if (block.get() instanceof FullBlock fullBlock && fullBlock.shouldShowInCreative()) { + event.accept(fullBlock); + } + } + } + }); } - private void register(RegisterEvent event) { - if (Addons.MEREQUESTER.isLoaded()) { - event.register( - Registries.MENU, AppEng.makeId("requester_terminal_f"), () -> RequesterTerminalMenu.TYPE_FULLBLOCK); - } + private static

+ DeferredBlock> terminal(ItemDefinition> equivalentPart) { + return block(equivalentPart.id().getPath(), () -> new TerminalBlock<>(equivalentPart)); } - private void registerCapabilities(RegisterCapabilitiesEvent event) { - for (var type : FullEngBEs.DR.getEntries()) { - event.registerBlockEntity( - AECapabilities.IN_WORLD_GRID_NODE_HOST, type.get(), (be, context) -> (IInWorldGridNodeHost) be); - } - - event.registerBlockEntity( - Capabilities.ItemHandler.BLOCK, - FullEngBEs.PATTERN_ENCODING_TERMINAL.get(), - (be, context) -> context != Direction.NORTH - ? be.getLogic().getBlankPatternInv().toItemHandler() - : null); + private static

+ DeferredBlock> monitor(ItemDefinition> equivalentPart) { + return block(equivalentPart.id().getPath(), () -> new MonitorBlock<>(equivalentPart)); } - private void addToCreativeTab(BuildCreativeModeTabContentsEvent event) { - if (event.getTabKey().equals(AECreativeTabIds.MAIN)) { - FullEngBlocks.BLOCKS.getEntries().forEach(b -> event.accept(b.get())); - } + private static DeferredBlock block(String id, Supplier supplier) { + return block(id, supplier, block -> new AEBaseBlockItem(block, new Item.Properties())); } - private static class Client { - private Client(IEventBus modEventBus) { - modEventBus.addListener(this::initScreens); - modEventBus.addListener(this::initBlockEntityRenders); - modEventBus.addListener(this::registerBlockColourProviders); - modEventBus.addListener(this::registerItemColourProviders); - NeoForge.EVENT_BUS.addListener(this::addConversionMonitorHook); - } - - private void initScreens(RegisterMenuScreensEvent event) { - if (Addons.MEREQUESTER.isLoaded()) { - RequesterIntegration.initScreen(event); - } - } - - private void initBlockEntityRenders(ModelEvent.RegisterGeometryLoaders ignoredEvent) { - BlockEntityRenderers.register(FullEngBEs.STORAGE_MONITOR.get(), MonitorBlockEntityRenderer::new); - BlockEntityRenderers.register(FullEngBEs.CONVERSION_MONITOR.get(), MonitorBlockEntityRenderer::new); - } - - private void registerBlockColourProviders(RegisterColorHandlersEvent.Block event) { - for (var block : FullEngBlocks.BLOCKS.getEntries()) { - event.register(new ColorableBlockEntityBlockColor(), block.get()); - } - } - - private void registerItemColourProviders(RegisterColorHandlersEvent.Item event) { - for (var block : FullEngBlocks.BLOCKS.getEntries()) { - event.register(new StaticItemColor(AEColor.TRANSPARENT), block.get()); - } - } - - private void addConversionMonitorHook(PlayerInteractEvent.LeftClickBlock event) { - var level = event.getLevel(); - - if (level.isClientSide()) { - if (!(Minecraft.getInstance().hitResult instanceof BlockHitResult hitResult)) { - return; - } + private static DeferredBlock block( + String id, Supplier blockSupplier, Function itemFunction) { + var block = BLOCKS.register(id, blockSupplier); + ITEMS.register(id, () -> itemFunction.apply(block.get())); + return block; + } - if (level.getBlockEntity(hitResult.getBlockPos()) instanceof ConversionMonitorBlockEntity monitor - && hitResult.getDirection() == monitor.getFront()) { - PacketDistributor.sendToServer( - new PartLeftClickPacket(hitResult, event.getEntity().isShiftKeyDown())); - Objects.requireNonNull(Minecraft.getInstance().gameMode).destroyDelay = 5; - event.setCanceled(true); - } - } - } + @SuppressWarnings("DataFlowIssue") + private static Supplier> be( + String id, + Class entityClass, + BlockEntityType.BlockEntitySupplier supplier, + Supplier> block) { + return BE_TYPES.register(id, () -> { + var type = BlockEntityType.Builder.of(supplier, block.get()).build(null); + AEBaseBlockEntity.registerBlockEntityItem(type, block.get().asItem()); + block.get().setBlockEntity(entityClass, type, null, null); + return type; + }); } } diff --git a/src/main/java/gripe/_90/fulleng/block/FullBlock.java b/src/main/java/gripe/_90/fulleng/block/FullBlock.java index 016dd3d..d3911f1 100644 --- a/src/main/java/gripe/_90/fulleng/block/FullBlock.java +++ b/src/main/java/gripe/_90/fulleng/block/FullBlock.java @@ -14,6 +14,7 @@ import appeng.api.orientation.IOrientationStrategy; import appeng.api.orientation.OrientationStrategies; import appeng.block.AEBaseEntityBlock; +import appeng.core.definitions.AEItems; import gripe._90.fulleng.block.entity.FullBlockEntity; @@ -52,6 +53,10 @@ public ItemLike getEquivalentPart() { return equivalentPart; } + public boolean shouldShowInCreative() { + return equivalentPart != AEItems.MISSING_CONTENT; + } + @NotNull @Override public String getDescriptionId() { diff --git a/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java b/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java index ca68bcf..ef8a794 100644 --- a/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java +++ b/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java @@ -11,9 +11,9 @@ import appeng.menu.MenuOpener; import appeng.menu.locator.MenuLocators; +import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.entity.terminal.PatternEncodingTerminalBlockEntity; import gripe._90.fulleng.block.entity.terminal.TerminalBlockEntity; -import gripe._90.fulleng.definition.FullEngBlocks; public class TerminalBlock extends FullBlock { public TerminalBlock(ItemDefinition equivalentPart) { @@ -44,7 +44,7 @@ public InteractionResult useWithoutItem( @Override public boolean hasAnalogOutputSignal(BlockState state) { - return state.is(FullEngBlocks.PATTERN_ENCODING_TERMINAL.get()); + return state.is(FullblockEnergistics.PATTERN_ENCODING_TERMINAL.get()); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java index df9225b..8655d69 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java @@ -18,11 +18,11 @@ import appeng.menu.me.crafting.CraftAmountMenu; import appeng.util.inv.PlayerInternalInventory; -import gripe._90.fulleng.definition.FullEngBEs; +import gripe._90.fulleng.FullblockEnergistics; public class ConversionMonitorBlockEntity extends StorageMonitorBlockEntity implements ISubMenuHost { public ConversionMonitorBlockEntity(BlockPos pos, BlockState state) { - super(FullEngBEs.CONVERSION_MONITOR.get(), pos, state); + super(FullblockEnergistics.CONVERSION_MONITOR_BE.get(), pos, state); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java index c9a483d..cfe9651 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java @@ -23,8 +23,8 @@ import appeng.api.util.INetworkToolAware; import appeng.core.localization.PlayerMessages; +import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.entity.FullBlockEntity; -import gripe._90.fulleng.definition.FullEngBEs; @SuppressWarnings("UnstableApiUsage") public class StorageMonitorBlockEntity extends FullBlockEntity implements INetworkToolAware { @@ -39,7 +39,7 @@ public class StorageMonitorBlockEntity extends FullBlockEntity implements INetwo private IStackWatcher craftingWatcher; public StorageMonitorBlockEntity(BlockPos pos, BlockState state) { - this(FullEngBEs.STORAGE_MONITOR.get(), pos, state); + this(FullblockEnergistics.STORAGE_MONITOR_BE.get(), pos, state); } public StorageMonitorBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java index f4a6baf..4f3fd98 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java @@ -16,13 +16,13 @@ import appeng.parts.reporting.CraftingTerminalPart; import appeng.util.inv.AppEngInternalInventory; -import gripe._90.fulleng.definition.FullEngBEs; +import gripe._90.fulleng.FullblockEnergistics; public class CraftingTerminalBlockEntity extends StorageTerminalBlockEntity { private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory(this, 9); public CraftingTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBEs.CRAFTING_TERMINAL.get(), pos, blockState); + super(FullblockEnergistics.CRAFTING_TERMINAL_BE.get(), pos, blockState); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java index 5b6c7b8..15800cc 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java @@ -14,11 +14,11 @@ import appeng.api.util.IConfigManagerBuilder; import appeng.menu.implementations.PatternAccessTermMenu; -import gripe._90.fulleng.definition.FullEngBEs; +import gripe._90.fulleng.FullblockEnergistics; public class PatternAccessTerminalBlockEntity extends TerminalBlockEntity implements IPatternAccessTermMenuHost { public PatternAccessTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBEs.PATTERN_ACCESS_TERMINAL.get(), pos, blockState); + super(FullblockEnergistics.PATTERN_ACCESS_TERMINAL_BE.get(), pos, blockState); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java index 495ef0a..60ae3d5 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java @@ -16,14 +16,14 @@ import appeng.parts.encoding.PatternEncodingLogic; import appeng.util.inv.AppEngInternalInventory; -import gripe._90.fulleng.definition.FullEngBEs; +import gripe._90.fulleng.FullblockEnergistics; public class PatternEncodingTerminalBlockEntity extends StorageTerminalBlockEntity implements IPatternTerminalLogicHost, IPatternTerminalMenuHost { private final PatternEncodingLogic logic = new PatternEncodingLogic(this); public PatternEncodingTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBEs.PATTERN_ENCODING_TERMINAL.get(), pos, blockState); + super(FullblockEnergistics.PATTERN_ENCODING_TERMINAL_BE.get(), pos, blockState); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java index 2c858bf..a93874b 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java @@ -29,14 +29,14 @@ import appeng.util.inv.AppEngInternalInventory; import appeng.util.inv.InternalInventoryHost; -import gripe._90.fulleng.definition.FullEngBEs; +import gripe._90.fulleng.FullblockEnergistics; public class StorageTerminalBlockEntity extends TerminalBlockEntity implements ITerminalHost, IViewCellStorage, InternalInventoryHost { private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5); public StorageTerminalBlockEntity(BlockPos pos, BlockState state) { - this(FullEngBEs.TERMINAL.get(), pos, state); + this(FullblockEnergistics.TERMINAL_BE.get(), pos, state); } public StorageTerminalBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { diff --git a/src/main/java/gripe/_90/fulleng/client/MonitorBlockEntityRenderer.java b/src/main/java/gripe/_90/fulleng/client/MonitorBERenderer.java similarity index 87% rename from src/main/java/gripe/_90/fulleng/client/MonitorBlockEntityRenderer.java rename to src/main/java/gripe/_90/fulleng/client/MonitorBERenderer.java index 5f9a483..8bf05dd 100644 --- a/src/main/java/gripe/_90/fulleng/client/MonitorBlockEntityRenderer.java +++ b/src/main/java/gripe/_90/fulleng/client/MonitorBERenderer.java @@ -12,8 +12,8 @@ import gripe._90.fulleng.block.entity.monitor.StorageMonitorBlockEntity; -public class MonitorBlockEntityRenderer implements BlockEntityRenderer { - public MonitorBlockEntityRenderer(BlockEntityRendererProvider.Context ignoredContext) {} +public class MonitorBERenderer implements BlockEntityRenderer { + public MonitorBERenderer(BlockEntityRendererProvider.Context ignoredContext) {} @Override public void render( diff --git a/src/main/java/gripe/_90/fulleng/definition/FullEngBEs.java b/src/main/java/gripe/_90/fulleng/definition/FullEngBEs.java deleted file mode 100644 index c92ed2f..0000000 --- a/src/main/java/gripe/_90/fulleng/definition/FullEngBEs.java +++ /dev/null @@ -1,73 +0,0 @@ -package gripe._90.fulleng.definition; - -import java.util.function.Supplier; - -import net.minecraft.core.registries.Registries; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.neoforged.neoforge.registries.DeferredRegister; - -import appeng.block.AEBaseEntityBlock; -import appeng.blockentity.AEBaseBlockEntity; - -import gripe._90.fulleng.FullblockEnergistics; -import gripe._90.fulleng.block.entity.monitor.ConversionMonitorBlockEntity; -import gripe._90.fulleng.block.entity.monitor.StorageMonitorBlockEntity; -import gripe._90.fulleng.block.entity.terminal.CraftingTerminalBlockEntity; -import gripe._90.fulleng.block.entity.terminal.PatternAccessTerminalBlockEntity; -import gripe._90.fulleng.block.entity.terminal.PatternEncodingTerminalBlockEntity; -import gripe._90.fulleng.block.entity.terminal.StorageTerminalBlockEntity; -import gripe._90.fulleng.integration.requester.RequesterTerminalBlockEntity; - -public class FullEngBEs { - public static final DeferredRegister> DR = - DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, FullblockEnergistics.MODID); - - public static final Supplier> TERMINAL = - be("terminal", StorageTerminalBlockEntity.class, StorageTerminalBlockEntity::new, FullEngBlocks.TERMINAL); - public static final Supplier> CRAFTING_TERMINAL = be( - "crafting_terminal", - CraftingTerminalBlockEntity.class, - CraftingTerminalBlockEntity::new, - FullEngBlocks.CRAFTING_TERMINAL); - public static final Supplier> PATTERN_ENCODING_TERMINAL = be( - "pattern_encoding_terminal", - PatternEncodingTerminalBlockEntity.class, - PatternEncodingTerminalBlockEntity::new, - FullEngBlocks.PATTERN_ENCODING_TERMINAL); - public static final Supplier> PATTERN_ACCESS_TERMINAL = be( - "pattern_access_terminal", - PatternAccessTerminalBlockEntity.class, - PatternAccessTerminalBlockEntity::new, - FullEngBlocks.PATTERN_ACCESS_TERMINAL); - - public static final Supplier> STORAGE_MONITOR = be( - "storage_monitor", - StorageMonitorBlockEntity.class, - StorageMonitorBlockEntity::new, - FullEngBlocks.STORAGE_MONITOR); - public static final Supplier> CONVERSION_MONITOR = be( - "conversion_monitor", - ConversionMonitorBlockEntity.class, - ConversionMonitorBlockEntity::new, - FullEngBlocks.CONVERSION_MONITOR); - - public static final Supplier> REQUESTER_TERMINAL = be( - "requester_terminal", - RequesterTerminalBlockEntity.class, - RequesterTerminalBlockEntity::new, - FullEngBlocks.REQUESTER_TERMINAL); - - @SuppressWarnings("DataFlowIssue") - static Supplier> be( - String id, - Class entityClass, - BlockEntityType.BlockEntitySupplier supplier, - Supplier> block) { - return DR.register(id, () -> { - var type = BlockEntityType.Builder.of(supplier, block.get()).build(null); - AEBaseBlockEntity.registerBlockEntityItem(type, block.get().asItem()); - block.get().setBlockEntity(entityClass, type, null, null); - return type; - }); - } -} diff --git a/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java b/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java deleted file mode 100644 index 4f016ec..0000000 --- a/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java +++ /dev/null @@ -1,78 +0,0 @@ -package gripe._90.fulleng.definition; - -import java.util.function.Function; -import java.util.function.Supplier; - -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.neoforge.registries.DeferredBlock; -import net.neoforged.neoforge.registries.DeferredRegister; - -import appeng.block.AEBaseBlockItem; -import appeng.core.definitions.AEParts; -import appeng.core.definitions.ItemDefinition; -import appeng.items.parts.PartItem; -import appeng.parts.reporting.AbstractDisplayPart; -import appeng.parts.reporting.AbstractMonitorPart; - -import gripe._90.fulleng.FullblockEnergistics; -import gripe._90.fulleng.block.MonitorBlock; -import gripe._90.fulleng.block.TerminalBlock; -import gripe._90.fulleng.block.entity.monitor.ConversionMonitorBlockEntity; -import gripe._90.fulleng.block.entity.monitor.StorageMonitorBlockEntity; -import gripe._90.fulleng.block.entity.terminal.CraftingTerminalBlockEntity; -import gripe._90.fulleng.block.entity.terminal.PatternAccessTerminalBlockEntity; -import gripe._90.fulleng.block.entity.terminal.PatternEncodingTerminalBlockEntity; -import gripe._90.fulleng.block.entity.terminal.StorageTerminalBlockEntity; -import gripe._90.fulleng.block.entity.terminal.TerminalBlockEntity; -import gripe._90.fulleng.integration.Addons; -import gripe._90.fulleng.integration.IntegrationBlockItem; -import gripe._90.fulleng.integration.requester.RequesterTerminalBlock; -import gripe._90.fulleng.integration.requester.RequesterTerminalBlockEntity; - -public class FullEngBlocks { - public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(FullblockEnergistics.MODID); - private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(FullblockEnergistics.MODID); - - public static void register(IEventBus bus) { - BLOCKS.register(bus); - ITEMS.register(bus); - } - - // spotless:off - public static final DeferredBlock> TERMINAL = terminal(AEParts.TERMINAL); - public static final DeferredBlock> CRAFTING_TERMINAL = terminal(AEParts.CRAFTING_TERMINAL); - public static final DeferredBlock> PATTERN_ENCODING_TERMINAL = terminal(AEParts.PATTERN_ENCODING_TERMINAL); - public static final DeferredBlock> PATTERN_ACCESS_TERMINAL = terminal(AEParts.PATTERN_ACCESS_TERMINAL); - - public static final DeferredBlock> STORAGE_MONITOR = monitor(AEParts.STORAGE_MONITOR); - public static final DeferredBlock> CONVERSION_MONITOR = monitor(AEParts.CONVERSION_MONITOR); - // spotless:on - - public static final DeferredBlock> REQUESTER_TERMINAL = block( - "requester_terminal", - RequesterTerminalBlock::new, - block -> new IntegrationBlockItem(block, Addons.MEREQUESTER)); - - static

DeferredBlock> terminal( - ItemDefinition> equivalentPart) { - return block(equivalentPart.id().getPath(), () -> new TerminalBlock<>(equivalentPart)); - } - - static

DeferredBlock> monitor( - ItemDefinition> equivalentPart) { - return block(equivalentPart.id().getPath(), () -> new MonitorBlock<>(equivalentPart)); - } - - static DeferredBlock block(String id, Supplier supplier) { - return block(id, supplier, block -> new AEBaseBlockItem(block, new Item.Properties())); - } - - static DeferredBlock block( - String id, Supplier blockSupplier, Function itemFunction) { - var block = BLOCKS.register(id, blockSupplier); - ITEMS.register(id, () -> itemFunction.apply(block.get())); - return block; - } -} diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java index 7136e19..a3dfb69 100644 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java +++ b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java @@ -1,23 +1,18 @@ package gripe._90.fulleng.integration.requester; import com.almostreliable.merequester.Registration; -import com.almostreliable.merequester.client.RequesterTerminalScreen; -import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; +import net.minecraft.world.inventory.MenuType; import appeng.core.definitions.ItemDefinition; -import appeng.init.client.InitScreens; public final class RequesterIntegration { - static ItemDefinition getRequesterTerminalPart() { + public static ItemDefinition getRequesterTerminalPart() { return Registration.REQUESTER_TERMINAL; } - public static void initScreen(RegisterMenuScreensEvent event) { - InitScreens.register( - event, - RequesterTerminalMenu.TYPE_FULLBLOCK, - RequesterTerminalScreen::new, - "/screens/requester_terminal.json"); + static MenuType getRequesterTerminalMenu() { + // TODO + return null; } } diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java deleted file mode 100644 index c06bbcb..0000000 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java +++ /dev/null @@ -1,20 +0,0 @@ -package gripe._90.fulleng.integration.requester; - -import org.jetbrains.annotations.NotNull; - -import appeng.core.definitions.AEParts; - -import gripe._90.fulleng.block.TerminalBlock; -import gripe._90.fulleng.integration.Addons; - -public class RequesterTerminalBlock extends TerminalBlock { - public RequesterTerminalBlock() { - super(Addons.MEREQUESTER.isLoaded() ? RequesterIntegration.getRequesterTerminalPart() : AEParts.TERMINAL); - } - - @NotNull - @Override - public String getDescriptionId() { - return "item." + Addons.MEREQUESTER.getModId() + ".requester_terminal"; - } -} diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java index 270732d..a0202c8 100644 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java @@ -4,17 +4,17 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.level.block.state.BlockState; +import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.entity.terminal.TerminalBlockEntity; -import gripe._90.fulleng.definition.FullEngBEs; import gripe._90.fulleng.integration.Addons; public class RequesterTerminalBlockEntity extends TerminalBlockEntity { public RequesterTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBEs.REQUESTER_TERMINAL.get(), pos, blockState); + super(FullblockEnergistics.REQUESTER_TERMINAL_BE.get(), pos, blockState); } @Override public MenuType getMenuType() { - return Addons.MEREQUESTER.isLoaded() ? RequesterTerminalMenu.TYPE_FULLBLOCK : null; + return Addons.MEREQUESTER.isLoaded() ? RequesterIntegration.getRequesterTerminalMenu() : null; } } diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalMenu.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalMenu.java deleted file mode 100644 index c4e6cd8..0000000 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalMenu.java +++ /dev/null @@ -1,16 +0,0 @@ -package gripe._90.fulleng.integration.requester; - -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.inventory.MenuType; - -import appeng.menu.implementations.MenuTypeBuilder; - -public class RequesterTerminalMenu extends com.almostreliable.merequester.terminal.RequesterTerminalMenu { - public static final MenuType TYPE_FULLBLOCK = MenuTypeBuilder.create( - RequesterTerminalMenu::new, RequesterTerminalBlockEntity.class) - .build("requester_terminal_f"); - - protected RequesterTerminalMenu(int id, Inventory playerInventory, RequesterTerminalBlockEntity host) { - super(TYPE_FULLBLOCK, id, playerInventory, host); - } -} diff --git a/src/main/java/gripe/_90/fulleng/integration/tooltips/TooltipProvider.java b/src/main/java/gripe/_90/fulleng/integration/tooltips/TooltipProvider.java index 0d49bf9..b1fc615 100644 --- a/src/main/java/gripe/_90/fulleng/integration/tooltips/TooltipProvider.java +++ b/src/main/java/gripe/_90/fulleng/integration/tooltips/TooltipProvider.java @@ -1,5 +1,7 @@ package gripe._90.fulleng.integration.tooltips; +import net.minecraft.resources.ResourceLocation; + import appeng.api.integrations.igtooltip.ClientRegistration; import gripe._90.fulleng.FullblockEnergistics; @@ -15,7 +17,7 @@ public void registerClient(ClientRegistration registration) { registration.addBlockEntityBody( StorageMonitorBlockEntity.class, MonitorBlock.class, - FullblockEnergistics.makeId(STORAGE_MONITOR), + ResourceLocation.fromNamespaceAndPath(FullblockEnergistics.MODID, STORAGE_MONITOR), new MonitorDataProvider()); } } diff --git a/src/main/java/gripe/_90/fulleng/mixin/Plugin.java b/src/main/java/gripe/_90/fulleng/mixin/Plugin.java new file mode 100644 index 0000000..e1067c8 --- /dev/null +++ b/src/main/java/gripe/_90/fulleng/mixin/Plugin.java @@ -0,0 +1,45 @@ +package gripe._90.fulleng.mixin; + +import java.util.List; +import java.util.Set; + +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import gripe._90.fulleng.integration.Addons; + +public class Plugin implements IMixinConfigPlugin { + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + for (var addon : Addons.values()) { + if (mixinClassName.contains(addon.getModId())) { + return addon.isLoaded(); + } + } + + return true; + } + + @Override + public void onLoad(String mixinPackage) {} + + @Override + public String getRefMapperConfig() { + return ""; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) {} + + @Override + public List getMixins() { + return List.of(); + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} +} diff --git a/src/main/resources/fulleng.mixins.json b/src/main/resources/fulleng.mixins.json index d7af384..bc65cee 100644 --- a/src/main/resources/fulleng.mixins.json +++ b/src/main/resources/fulleng.mixins.json @@ -2,6 +2,7 @@ "required": true, "minVersion": "0.8.5", "package": "gripe._90.fulleng.mixin", + "plugin": "gripe._90.fulleng.mixin.Plugin", "compatibilityLevel": "JAVA_21", "mixins": ["PartLeftClickPacketMixin"], "client": ["client.ModelManagerMixin", "client.UnlitQuadHooksAccessor"]