From 22e38878267f054385df2aa1a9adcef541dcc1ad Mon Sep 17 00:00:00 2001 From: Ramid Khan Date: Sat, 8 Jul 2023 16:27:25 +1000 Subject: [PATCH] Update to 1.20.1 --- .gitignore | 1 + build.gradle | 4 +- gradle.properties | 12 ++--- src/main/java/me/ramidzkh/mekae2/AMItems.java | 45 +++++++++++-------- src/main/java/me/ramidzkh/mekae2/AMText.java | 2 + .../ramidzkh/mekae2/AppliedMekanistics.java | 5 +-- .../mekae2/ae2/AMChemicalStackRenderer.java | 16 ++++--- .../me/ramidzkh/mekae2/ae2/MekanismKey.java | 30 +++++++++---- .../ramidzkh/mekae2/ae2/MekanismKeyType.java | 20 +++++++-- .../mekae2/data/BlockModelProvider.java | 6 +-- .../mekae2/data/BlockTagsProvider.java | 14 +++--- .../mekae2/data/ItemModelProvider.java | 6 +-- .../mekae2/data/ItemTagsProvider.java | 14 +++--- .../mekae2/data/MekAE2DataGenerators.java | 13 +++--- .../ramidzkh/mekae2/data/RecipeProvider.java | 15 ++++--- .../mekae2/item/ChemicalPortableCellItem.java | 5 ++- .../mekae2/qio/QioStorageAdapter.java | 21 +++------ .../me/ramidzkh/mekae2/qio/QioSupport.java | 41 +++++++++++++---- src/main/resources/META-INF/mods.toml | 6 +-- .../resources/assets/appmek/lang/en_us.json | 10 ++--- .../resources/assets/appmek/lang/pt_br.json | 10 ++--- .../resources/assets/appmek/lang/ru_ru.json | 10 ++--- 22 files changed, 184 insertions(+), 122 deletions(-) diff --git a/.gitignore b/.gitignore index eb55e24..9f0ce6e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .idea/ .vscode/ build/ +libs/ run/ diff --git a/build.gradle b/build.gradle index 20aad05..eb53199 100644 --- a/build.gradle +++ b/build.gradle @@ -20,8 +20,8 @@ repositories { } maven { - name = "Progwml6 maven" - url = uri("https://dvs1.progwml6.com/files/maven/") + name = "Jared maven" + url = uri("https://maven.blamejared.com/") content { includeGroup("mezz.jei") diff --git a/gradle.properties b/gradle.properties index cf39b34..121cd63 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -minecraft_version=1.19.2 -forge_version=43.2.4 -ae2_version=12.9.2 -mekanism_version=10.3.7.476 -jei_version=11.4.0.287 -jade_id=4096513 +minecraft_version=1.20.1 +forge_version=47.1.0 +ae2_version=15.0.4-beta +mekanism_version=10.3.9.homebaked +jei_version=15.2.0.22 +jade_id=4614153 org.gradle.daemon=false diff --git a/src/main/java/me/ramidzkh/mekae2/AMItems.java b/src/main/java/me/ramidzkh/mekae2/AMItems.java index 5844db7..2d11fc6 100644 --- a/src/main/java/me/ramidzkh/mekae2/AMItems.java +++ b/src/main/java/me/ramidzkh/mekae2/AMItems.java @@ -1,6 +1,7 @@ package me.ramidzkh.mekae2; import net.minecraft.Util; +import net.minecraft.core.registries.Registries; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -23,10 +24,13 @@ public class AMItems { + private static final DeferredRegister TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, + AppliedMekanistics.ID); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AppliedMekanistics.ID); public static void initialize(IEventBus bus) { + TABS.register(bus); ITEMS.register(bus); } @@ -34,17 +38,21 @@ private static Item basic() { return new MaterialItem(properties()); } - public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(AppliedMekanistics.ID) { - @Override - public ItemStack makeIcon() { - return new ItemStack(AMItems.CHEMICAL_CELL_64K.get()); - } - }; - private static Item.Properties properties() { - return new Item.Properties().tab(CREATIVE_TAB); + return new Item.Properties(); } + public static final RegistryObject CREATIVE_TAB = TABS.register("main", + () -> CreativeModeTab.builder() + .title(AMText.CREATIVE_TAB.formatted()) + .icon(() -> new ItemStack(AMItems.CHEMICAL_CELL_64K.get())) + .displayItems((params, output) -> { + for (var entry : ITEMS.getEntries()) { + output.accept(entry.get()); + } + }) + .build()); + public static final RegistryObject CHEMICAL_CELL_HOUSING = ITEMS.register("chemical_cell_housing", AMItems::basic); @@ -64,23 +72,24 @@ private static Item.Properties properties() { CHEMICAL_CELL_HOUSING.get())); public static final RegistryObject PORTABLE_CHEMICAL_CELL_1K = ITEMS.register( - "portable_chemical_storage_cell_1k", () -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, - StorageTier.SIZE_1K, properties().stacksTo(1))); + "portable_chemical_storage_cell_1k", + () -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, + StorageTier.SIZE_1K, properties().stacksTo(1), 0)); public static final RegistryObject PORTABLE_CHEMICAL_CELL_4K = ITEMS.register( - "portable_chemical_storage_cell_4k", () -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, - StorageTier.SIZE_4K, properties().stacksTo(1))); + "portable_chemical_storage_cell_4k", () -> new ChemicalPortableCellItem(18, + AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_4K, properties().stacksTo(1), 0)); public static final RegistryObject PORTABLE_CHEMICAL_CELL_16K = ITEMS.register( "portable_chemical_storage_cell_16k", - () -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_16K, - properties().stacksTo(1))); + () -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_16K, + properties().stacksTo(1), 0)); public static final RegistryObject PORTABLE_CHEMICAL_CELL_64K = ITEMS.register( "portable_chemical_storage_cell_64k", - () -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_64K, - properties().stacksTo(1))); + () -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_64K, + properties().stacksTo(1), 0)); public static final RegistryObject PORTABLE_CHEMICAL_CELL_256K = ITEMS.register( "portable_chemical_storage_cell_256k", - () -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_256K, - properties().stacksTo(1))); + () -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_256K, + properties().stacksTo(1), 0)); public static final RegistryObject> CHEMICAL_P2P_TUNNEL = Util.make(() -> { PartModels.registerModels(PartModelsHelper.createModels(ChemicalP2PTunnelPart.class)); diff --git a/src/main/java/me/ramidzkh/mekae2/AMText.java b/src/main/java/me/ramidzkh/mekae2/AMText.java index d99bedf..e7131a8 100644 --- a/src/main/java/me/ramidzkh/mekae2/AMText.java +++ b/src/main/java/me/ramidzkh/mekae2/AMText.java @@ -3,6 +3,8 @@ import net.minecraft.network.chat.Component; public enum AMText { + CHEMICAL("chemical"), + CREATIVE_TAB("creative_tab"), QIO_FREQUENCY("qio_frequency"), ; diff --git a/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java b/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java index 3bbf934..d09c169 100644 --- a/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java +++ b/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java @@ -4,7 +4,7 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -67,7 +67,7 @@ public AppliedMekanistics() { bus.addListener(MekAE2DataGenerators::onGatherData); bus.addListener((RegisterEvent event) -> { - if (!event.getRegistryKey().equals(Registry.BLOCK_REGISTRY)) { + if (!event.getRegistryKey().equals(Registries.BLOCK)) { return; } @@ -134,7 +134,6 @@ public boolean isSpecializedFor(ItemStack cell) { @Override public void openChestGui(Player player, IChestOrDrive chest, ICellHandler cellHandler, ItemStack cell) { - chest.getUp(); MenuOpener.open(MEStorageMenu.TYPE, player, MenuLocators.forBlockEntity((BlockEntity) chest)); } diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java b/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java index 0268ed8..2c59804 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java @@ -6,29 +6,31 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import appeng.api.client.AEStackRendering; -import appeng.api.client.IAEStackRenderHandler; +import appeng.api.client.AEKeyRenderHandler; +import appeng.api.client.AEKeyRendering; import appeng.client.gui.style.Blitter; import appeng.util.Platform; -public class AMChemicalStackRenderer implements IAEStackRenderHandler { +public class AMChemicalStackRenderer implements AEKeyRenderHandler { public static void initialize(IEventBus bus) { bus.addListener((FMLClientSetupEvent event) -> event.enqueueWork(() -> { - AEStackRendering.register(MekanismKeyType.TYPE, MekanismKey.class, new AMChemicalStackRenderer()); + AEKeyRendering.register(MekanismKeyType.TYPE, MekanismKey.class, new AMChemicalStackRenderer()); })); } @Override - public void drawInGui(Minecraft minecraft, PoseStack poseStack, int x, int y, int zIndex, MekanismKey what) { + public void drawInGui(Minecraft minecraft, GuiGraphics guiGraphics, int x, int y, MekanismKey what) { var stack = what.getStack(); Blitter.sprite( @@ -37,12 +39,12 @@ public void drawInGui(Minecraft minecraft, PoseStack poseStack, int x, int y, in // Most fluid texture have transparency, but we want an opaque slot .blending(false) .dest(x, y, 16, 16) - .blit(poseStack, 100 + zIndex); + .blit(guiGraphics); } @Override public void drawOnBlockFace(PoseStack poseStack, MultiBufferSource buffers, MekanismKey what, float scale, - int combinedLight) { + int combinedLight, Level level) { var stack = what.getStack(); var sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS) .apply(stack.getType().getIcon()); diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java index a6e6bf2..0f61061 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java @@ -10,6 +10,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -17,9 +18,13 @@ import mekanism.api.Coord4D; import mekanism.api.MekanismAPI; import mekanism.api.chemical.ChemicalStack; +import mekanism.api.chemical.gas.Gas; import mekanism.api.chemical.gas.GasStack; +import mekanism.api.chemical.infuse.InfuseType; import mekanism.api.chemical.infuse.InfusionStack; +import mekanism.api.chemical.pigment.Pigment; import mekanism.api.chemical.pigment.PigmentStack; +import mekanism.api.chemical.slurry.Slurry; import mekanism.api.chemical.slurry.SlurryStack; import appeng.api.stacks.AEKey; @@ -35,7 +40,6 @@ public class MekanismKey extends AEKey { private final ChemicalStack stack; private MekanismKey(ChemicalStack stack) { - super(stack.getTextComponent()); this.stack = stack; } @@ -88,11 +92,6 @@ public Object getPrimaryKey() { return stack.getType(); } - @Override - public String getModId() { - return stack.getTypeRegistryName().getNamespace(); - } - @Override public ResourceLocation getId() { return stack.getTypeRegistryName(); @@ -105,18 +104,33 @@ public void writeToPacket(FriendlyByteBuf data) { } @Override - public Component getDisplayName() { + protected Component computeDisplayName() { return stack.getType().getTextComponent(); } @Override public void addDrops(long amount, List drops, Level level, BlockPos pos) { - if (getStack()instanceof GasStack gasStack) { + if (stack instanceof GasStack gasStack) { MekanismAPI.getRadiationManager().dumpRadiation(new Coord4D(pos, level), ChemicalBridge.withAmount(gasStack, amount)); } } + @Override + public boolean isTagged(TagKey tag) { + if (stack.getType()instanceof Gas gas) { + return tag.registry().equals(MekanismAPI.gasRegistryName()) && gas.is((TagKey) tag); + } else if (stack.getType()instanceof InfuseType infuse) { + return tag.registry().equals(MekanismAPI.infuseTypeRegistryName()) && infuse.is((TagKey) tag); + } else if (stack.getType()instanceof Pigment pigment) { + return tag.registry().equals(MekanismAPI.pigmentRegistryName()) && pigment.is((TagKey) tag); + } else if (stack.getType()instanceof Slurry slurry) { + return tag.registry().equals(MekanismAPI.slurryRegistryName()) && slurry.is((TagKey) tag); + } else { + throw new UnsupportedOperationException(); + } + } + @Override public boolean equals(Object o) { if (this == o) diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java index 2031798..73c854a 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java @@ -1,12 +1,18 @@ package me.ramidzkh.mekae2.ae2; +import java.util.stream.Stream; + import javax.annotation.Nullable; +import com.google.common.collect.Streams; + import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; +import net.minecraft.tags.TagKey; +import me.ramidzkh.mekae2.AMText; import me.ramidzkh.mekae2.AppliedMekanistics; +import mekanism.api.MekanismAPI; import mekanism.api.chemical.gas.GasStack; import mekanism.api.chemical.infuse.InfusionStack; import mekanism.api.chemical.pigment.PigmentStack; @@ -21,8 +27,7 @@ public class MekanismKeyType extends AEKeyType { public static final AEKeyType TYPE = new MekanismKeyType(); private MekanismKeyType() { - super(AppliedMekanistics.id("chemical"), MekanismKey.class, - Component.translatable("gui." + AppliedMekanistics.ID + ".chemical")); + super(AppliedMekanistics.id("chemical"), MekanismKey.class, AMText.CHEMICAL.formatted()); } @Nullable @@ -49,6 +54,15 @@ public AEKey loadKeyFromTag(CompoundTag tag) { }; } + @Override + public Stream> getTagNames() { + return Streams.concat( + MekanismAPI.gasRegistry().tags().getTagNames(), + MekanismAPI.infuseTypeRegistry().tags().getTagNames(), + MekanismAPI.pigmentRegistry().tags().getTagNames(), + MekanismAPI.slurryRegistry().tags().getTagNames()); + } + // Copied from AEFluidKeys @Override public int getAmountPerOperation() { diff --git a/src/main/java/me/ramidzkh/mekae2/data/BlockModelProvider.java b/src/main/java/me/ramidzkh/mekae2/data/BlockModelProvider.java index ab2ae0d..ad9c500 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/BlockModelProvider.java +++ b/src/main/java/me/ramidzkh/mekae2/data/BlockModelProvider.java @@ -2,7 +2,7 @@ import java.util.Locale; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.ExistingFileHelper; @@ -15,8 +15,8 @@ public class BlockModelProvider extends net.minecraftforge.client.model.generato private static final ResourceLocation DRIVE_CELL = AppEng.makeId("block/drive/drive_cell"); - public BlockModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { - super(generator, AppliedMekanistics.ID, existingFileHelper); + public BlockModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) { + super(output, AppliedMekanistics.ID, existingFileHelper); existingFileHelper.trackGenerated(DRIVE_CELL, MODEL); } diff --git a/src/main/java/me/ramidzkh/mekae2/data/BlockTagsProvider.java b/src/main/java/me/ramidzkh/mekae2/data/BlockTagsProvider.java index 48ef81e..b0bf6ab 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/BlockTagsProvider.java +++ b/src/main/java/me/ramidzkh/mekae2/data/BlockTagsProvider.java @@ -1,19 +1,23 @@ package me.ramidzkh.mekae2.data; +import java.util.concurrent.CompletableFuture; + import org.jetbrains.annotations.Nullable; -import net.minecraft.data.DataGenerator; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; import net.minecraftforge.common.data.ExistingFileHelper; import me.ramidzkh.mekae2.AppliedMekanistics; -public class BlockTagsProvider extends net.minecraft.data.tags.BlockTagsProvider { +public class BlockTagsProvider extends net.minecraftforge.common.data.BlockTagsProvider { - public BlockTagsProvider(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) { - super(generator, AppliedMekanistics.ID, existingFileHelper); + public BlockTagsProvider(PackOutput output, CompletableFuture lookupProvider, + @Nullable ExistingFileHelper existingFileHelper) { + super(output, lookupProvider, AppliedMekanistics.ID, existingFileHelper); } @Override - protected void addTags() { + protected void addTags(HolderLookup.Provider provider) { } } diff --git a/src/main/java/me/ramidzkh/mekae2/data/ItemModelProvider.java b/src/main/java/me/ramidzkh/mekae2/data/ItemModelProvider.java index 17c644b..7ce1542 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/ItemModelProvider.java +++ b/src/main/java/me/ramidzkh/mekae2/data/ItemModelProvider.java @@ -1,6 +1,6 @@ package me.ramidzkh.mekae2.data; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraftforge.common.data.ExistingFileHelper; @@ -19,8 +19,8 @@ public class ItemModelProvider extends net.minecraftforge.client.model.generator private static final ResourceLocation PORTABLE_CELL_LED = AppEng.makeId("item/portable_cell_led"); private static final ResourceLocation OSMIUM_BLOCK = new ResourceLocation("mekanism", "block/block_osmium"); - public ItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { - super(generator, AppliedMekanistics.ID, existingFileHelper); + public ItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) { + super(output, AppliedMekanistics.ID, existingFileHelper); existingFileHelper.trackGenerated(P2P_TUNNEL_BASE_ITEM, MODEL); existingFileHelper.trackGenerated(P2P_TUNNEL_BASE_PART, MODEL); diff --git a/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java b/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java index 4c884ce..8369bed 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java +++ b/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java @@ -1,10 +1,13 @@ package me.ramidzkh.mekae2.data; +import java.util.concurrent.CompletableFuture; + import org.jetbrains.annotations.Nullable; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.tags.BlockTagsProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; import net.minecraftforge.common.data.ExistingFileHelper; import me.ramidzkh.mekae2.AMItems; @@ -14,13 +17,14 @@ public class ItemTagsProvider extends net.minecraft.data.tags.ItemTagsProvider { - public ItemTagsProvider(DataGenerator generator, BlockTagsProvider blockTagsProvider, + public ItemTagsProvider(PackOutput output, CompletableFuture lookupProvider, + CompletableFuture> blockTagsProvider, @Nullable ExistingFileHelper existingFileHelper) { - super(generator, blockTagsProvider, AppliedMekanistics.ID, existingFileHelper); + super(output, lookupProvider, blockTagsProvider, AppliedMekanistics.ID, existingFileHelper); } @Override - protected void addTags() { + protected void addTags(HolderLookup.Provider provider) { var tanks = P2PTunnelAttunement.getAttunementTag(AMItems.CHEMICAL_P2P_TUNNEL::get); tag(tanks).addOptional(new ResourceLocation("mekanism", "basic_chemical_tank")); diff --git a/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java b/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java index e489ef6..1fc7d42 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java +++ b/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java @@ -6,14 +6,17 @@ public class MekAE2DataGenerators { public static void onGatherData(GatherDataEvent event) { var generator = event.getGenerator(); + var packOutput = generator.getPackOutput(); + var lookupProvider = event.getLookupProvider(); var existingFileHelper = event.getExistingFileHelper(); - var blockTagsProvider = new BlockTagsProvider(generator, existingFileHelper); + var blockTagsProvider = new BlockTagsProvider(packOutput, lookupProvider, existingFileHelper); generator.addProvider(true, blockTagsProvider); - generator.addProvider(true, new ItemTagsProvider(generator, blockTagsProvider, existingFileHelper)); + generator.addProvider(true, new ItemTagsProvider(packOutput, lookupProvider, + blockTagsProvider.contentsGetter(), existingFileHelper)); - generator.addProvider(true, new BlockModelProvider(generator, existingFileHelper)); - generator.addProvider(true, new ItemModelProvider(generator, existingFileHelper)); - generator.addProvider(true, new RecipeProvider(generator)); + generator.addProvider(true, new BlockModelProvider(packOutput, existingFileHelper)); + generator.addProvider(true, new ItemModelProvider(packOutput, existingFileHelper)); + generator.addProvider(true, new RecipeProvider(packOutput)); } } diff --git a/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java b/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java index 739be03..0d2ca07 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java +++ b/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java @@ -3,8 +3,9 @@ import java.util.Locale; import java.util.function.Consumer; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.ShapedRecipeBuilder; import net.minecraft.data.recipes.ShapelessRecipeBuilder; import net.minecraft.resources.ResourceLocation; @@ -19,13 +20,13 @@ public class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider { - public RecipeProvider(DataGenerator generator) { - super(generator); + public RecipeProvider(PackOutput output) { + super(output); } @Override - protected void buildCraftingRecipes(Consumer consumer) { - ShapedRecipeBuilder.shaped(AMItems.CHEMICAL_CELL_HOUSING::get) + protected void buildRecipes(Consumer consumer) { + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, AMItems.CHEMICAL_CELL_HOUSING::get) .pattern("QRQ") .pattern("R R") .pattern("OOO") @@ -48,12 +49,12 @@ protected void buildCraftingRecipes(Consumer consumer) { var tierName = tier.toString().toLowerCase(Locale.ROOT); - ShapelessRecipeBuilder.shapeless(AMItems.get(tier).get()) + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, AMItems.get(tier)::get) .requires(housing) .requires(cellComponent) .unlockedBy("has_cell_component" + tierName, has(cellComponent)) .save(consumer); - ShapelessRecipeBuilder.shapeless(AMItems.getPortableCell(tier)::get) + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, AMItems.getPortableCell(tier)::get) .requires(AEBlocks.CHEST) .requires(cellComponent) .requires(AEBlocks.ENERGY_CELL) diff --git a/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java b/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java index ebdc01e..503eb20 100644 --- a/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java +++ b/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java @@ -13,8 +13,9 @@ public class ChemicalPortableCellItem extends PortableCellItem { - public ChemicalPortableCellItem(MenuType menuType, StorageTier tier, Properties props) { - super(MekanismKeyType.TYPE, menuType, tier, props); + public ChemicalPortableCellItem(int totalTypes, MenuType menuType, StorageTier tier, Properties props, + int defaultColor) { + super(MekanismKeyType.TYPE, totalTypes, menuType, tier, props, defaultColor); } @Override diff --git a/src/main/java/me/ramidzkh/mekae2/qio/QioStorageAdapter.java b/src/main/java/me/ramidzkh/mekae2/qio/QioStorageAdapter.java index 4bd4933..2a360f2 100644 --- a/src/main/java/me/ramidzkh/mekae2/qio/QioStorageAdapter.java +++ b/src/main/java/me/ramidzkh/mekae2/qio/QioStorageAdapter.java @@ -1,6 +1,7 @@ package me.ramidzkh.mekae2.qio; import java.util.Map; +import java.util.UUID; import java.util.WeakHashMap; import org.jetbrains.annotations.Nullable; @@ -19,8 +20,6 @@ import mekanism.api.security.SecurityMode; import appeng.api.config.Actionable; -import appeng.api.features.IPlayerRegistry; -import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.IActionSource; import appeng.api.stacks.AEItemKey; import appeng.api.stacks.AEKey; @@ -34,15 +33,13 @@ public class QioStorageAdapter implements MEStorage { private static final Map CACHE = new WeakHashMap<>(); private final DASHBOARD dashboard; - @Nullable - private final Direction queriedSide; - private final IActionSource querySrc; + private final @Nullable Direction queriedSide; + private final @Nullable UUID owner; - public QioStorageAdapter(DASHBOARD dashboard, @Nullable Direction queriedSide, - IActionSource querySrc) { + public QioStorageAdapter(DASHBOARD dashboard, @Nullable Direction queriedSide, @Nullable UUID owner) { this.dashboard = dashboard; this.queriedSide = queriedSide; - this.querySrc = querySrc; + this.owner = owner; } @Nullable @@ -61,13 +58,7 @@ public IQIOFrequency getFrequency() { var securityMode = utils.getSecurityMode(dashboard, dashboard.getLevel().isClientSide()); if (securityMode != SecurityMode.PUBLIC) { // Private or trusted: the player who placed the storage bus must have dashboard access. - var host = querySrc.machine().map(IActionHost::getActionableNode).orElse(null); - if (host == null) { - return null; - } - var storageBusOwner = IPlayerRegistry.getMapping(dashboard.getLevel()) - .getProfileId(host.getOwningPlayerId()); - if (!utils.canAccess(storageBusOwner, dashboard, dashboard.getLevel().isClientSide())) { + if (!utils.canAccess(owner, dashboard, dashboard.getLevel().isClientSide())) { return null; } } diff --git a/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java b/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java index ee29d0b..31d76df 100644 --- a/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java +++ b/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java @@ -18,10 +18,12 @@ import me.ramidzkh.mekae2.AppliedMekanistics; import mekanism.api.inventory.qio.IQIOComponent; -import appeng.api.storage.IStorageMonitorableAccessor; +import appeng.api.features.IPlayerRegistry; +import appeng.api.networking.GridHelper; +import appeng.api.storage.MEStorage; public class QioSupport { - private static final Capability STORAGE_MONITORABLE = CapabilityManager + public static final Capability STORAGE = CapabilityManager .get(new CapabilityToken<>() { }); private static final ResourceLocation DASHBOARD = new ResourceLocation("mekanism", "qio_dashboard"); @@ -40,14 +42,35 @@ public static void onBlockEntityCapability(AttachCapabilitiesEvent @Override public LazyOptional getCapability(@NotNull Capability capability, @Nullable Direction arg) { - if (capability == STORAGE_MONITORABLE) { - return LazyOptional.of(() -> (IStorageMonitorableAccessor) querySrc -> { - var adapter = new QioStorageAdapter<>((BlockEntity & IQIOComponent) object, arg, - querySrc); - // Make sure that we only allow non-null frequencies. - return adapter.getFrequency() == null ? null : adapter; - }).cast(); + out: if (capability == STORAGE && arg != null) { + // guess the source... + // if you're trying to qio across a compact machine wall or something, sorry! + var host = GridHelper.getNodeHost(object.getLevel(), object.getBlockPos().relative(arg)); + + if (host == null) { + break out; + } + + var source = host.getGridNode(arg.getOpposite()); + + // I don't know of any full-block nodes which query inventories, but we'll see + if (source == null) { + source = host.getGridNode(null); + } + + if (source == null) { + break out; + } + + var owner = IPlayerRegistry.getMapping(object.getLevel()) + .getProfileId(source.getOwningPlayerId()); + var adapter = new QioStorageAdapter<>((BlockEntity & IQIOComponent) object, arg, owner); + + if (adapter.getFrequency() != null) { + return LazyOptional.of(() -> adapter).cast(); + } } + return LazyOptional.empty(); } }); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a544a79..cbca76b 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -18,20 +18,20 @@ updateJSONURL = "https://api.modrinth.com/updates/applied-mekanistics/forge_upda [[dependencies.appmek]] modId = "forge" mandatory = true -versionRange = "[43.0.0,44.0.0)" +versionRange = "[47.0.0,48.0.0)" ordering = "NONE" side = "BOTH" [[dependencies.appmek]] modId = "ae2" mandatory = false -versionRange = "[12.8.4,13.0.0)" +versionRange = "[15.0.0,16.0.0)" ordering = "AFTER" side = "BOTH" [[dependencies.appmek]] modId = "mekanism" mandatory = true -versionRange = "[10.3.7,11.0.0)" +versionRange = "[10.3.9,11.0.0)" ordering = "AFTER" side = "BOTH" diff --git a/src/main/resources/assets/appmek/lang/en_us.json b/src/main/resources/assets/appmek/lang/en_us.json index 389723e..90850b0 100644 --- a/src/main/resources/assets/appmek/lang/en_us.json +++ b/src/main/resources/assets/appmek/lang/en_us.json @@ -1,7 +1,7 @@ { - "itemGroup.appmek": "Applied Mekanistics", - - "gui.appmek.chemical": "Chemical", + "text.appmek.chemical": "Chemical", + "text.appmek.creative_tab": "Applied Mekanistics", + "text.appmek.qio_frequency": "QIO Frequency (%s)", "item.appmek.chemical_cell_housing": "ME Chemical Cell Housing", "item.appmek.creative_chemical_cell": "Creative ME Chemical Cell", @@ -18,7 +18,5 @@ "item.appmek.portable_chemical_storage_cell_64k": "64k Portable Chemical Cell", "item.appmek.portable_chemical_storage_cell_256k": "256k Portable Chemical Cell", - "item.appmek.chemical_p2p_tunnel": "Chemical P2P Tunnel", - - "text.appmek.qio_frequency": "QIO Frequency (%s)" + "item.appmek.chemical_p2p_tunnel": "Chemical P2P Tunnel" } diff --git a/src/main/resources/assets/appmek/lang/pt_br.json b/src/main/resources/assets/appmek/lang/pt_br.json index 61711c7..57ece99 100644 --- a/src/main/resources/assets/appmek/lang/pt_br.json +++ b/src/main/resources/assets/appmek/lang/pt_br.json @@ -1,7 +1,7 @@ { - "itemGroup.appmek": "Applied Mekanistics", - - "gui.appmek.chemical": "Químico", + "text.appmek.chemical": "Químico", + "text.appmek.creative_tab": "Applied Mekanistics", + "text.appmek.qio_frequency": "OIQ Frequência (%s)", "item.appmek.chemical_cell_housing": "Cápsula para Células de Armazenamento de Químicos", "item.appmek.creative_chemical_cell": "Célula Criativa de Armazenamento de Químicos", @@ -18,7 +18,5 @@ "item.appmek.portable_chemical_storage_cell_64k": "Célula de Armazenamento Portátil de 64k para Químicos", "item.appmek.portable_chemical_storage_cell_256k": "Célula de Armazenamento Portátil de 256k para Químicos", - "item.appmek.chemical_p2p_tunnel": "Túnel P2P para Químicos", - - "text.appmek.qio_frequency": "OIQ Frequência (%s)" + "item.appmek.chemical_p2p_tunnel": "Túnel P2P para Químicos" } diff --git a/src/main/resources/assets/appmek/lang/ru_ru.json b/src/main/resources/assets/appmek/lang/ru_ru.json index d546fd8..e21be7e 100644 --- a/src/main/resources/assets/appmek/lang/ru_ru.json +++ b/src/main/resources/assets/appmek/lang/ru_ru.json @@ -1,7 +1,7 @@ { - "itemGroup.appmek": "Applied Mekanistics", - - "gui.appmek.chemical": "Химикат", + "text.appmek.chemical": "Химикат", + "text.appmek.creative_tab": "Applied Mekanistics", + "text.appmek.qio_frequency": "Переодичность QIO (%s)", "item.appmek.chemical_cell_housing": "Корпус химической ячейки ME", "item.appmek.creative_chemical_cell": "Творческая химическая ячейка ME", @@ -18,7 +18,5 @@ "item.appmek.portable_chemical_storage_cell_64k": "Переносная химическая ячейка 64К", "item.appmek.portable_chemical_storage_cell_256k": "Переносная химическая ячейка 256К", - "item.appmek.chemical_p2p_tunnel": "Химический P2P тоннель", - - "text.appmek.qio_frequency": "Переодичность QIO (%s)" + "item.appmek.chemical_p2p_tunnel": "Химический P2P тоннель" }