Skip to content

Commit

Permalink
Make various more improvements to bulk compression
Browse files Browse the repository at this point in the history
- Allow for compression/decompression recipes with amounts other than 4 and 9 (e.g. certain mods' "Tiny Coal/Charcoal")
- Add a new "compression blacklist" tag with which to prevent certain items from ever appearing in a compression chain, override or not
- Refine compression recipe logic in order to better catch other odd cases such as mods with atypical ingot/block recipes for their own metals (Closes #154, but does assume the presence of some unification mod such as AlmostUnified)
- Add better, more detailed logging for compression including debug logs for every individually generated chain and override
- Add some more default overrides such as string, snow and honeycomb
  • Loading branch information
62832 committed Dec 28, 2024
1 parent 1753704 commit 1e3ae7c
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 60 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ neoForge {

runs {
configureEach {
logLevel = org.slf4j.event.Level.DEBUG
gameDirectory = file("run")
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ run {
version("minecraft", mc)

val nf = mc.substringAfter('.')
version("neoforge", "${nf + (if (!nf.contains('.')) ".0" else "")}.66")
version("neoforge", "${nf + (if (!nf.contains('.')) ".0" else "")}.91")
version("parchment", "2024.07.28")

version("ae2", "19.1.1-beta")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import gripe._90.megacells.MEGACells;

@SuppressWarnings("unused")
@EventBusSubscriber(modid = MEGACells.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class MEGADataGenerators {
@SubscribeEvent
Expand All @@ -24,11 +23,11 @@ public static void onGatherData(GatherDataEvent event) {
generator.addProvider(event.includeServer(), new MEGARecipeProvider(output, registries));
generator.addProvider(event.includeServer(), new MEGALootProvider(output, registries));

var blockTags = new MEGATagProvider.BlockTags(output, registries, existing);
var blockTags = new MEGATagProvider.Block(output, registries, existing);
generator.addProvider(event.includeServer(), blockTags);
generator.addProvider(
event.includeServer(),
new MEGATagProvider.ItemTags(output, registries, blockTags.contentsGetter(), existing));
new MEGATagProvider.Item(output, registries, blockTags.contentsGetter(), existing));

generator.addProvider(
event.includeClient(),
Expand Down
35 changes: 25 additions & 10 deletions src/data/java/gripe/_90/megacells/datagen/MEGATagProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@
import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.data.tags.TagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.data.ExistingFileHelper;

import appeng.api.features.P2PTunnelAttunement;
import appeng.datagen.providers.tags.ConventionTags;

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.definition.MEGABlocks;
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.definition.MEGATags;

public class MEGATagProvider {
public static class BlockTags extends IntrinsicHolderTagsProvider<Block> {
public BlockTags(
public static class Block extends IntrinsicHolderTagsProvider<net.minecraft.world.level.block.Block> {
public Block(
PackOutput output, CompletableFuture<HolderLookup.Provider> registries, ExistingFileHelper existing) {
super(
output,
Expand All @@ -41,7 +42,7 @@ public BlockTags(
@Override
protected void addTags(@NotNull HolderLookup.Provider provider) {
for (var block : MEGABlocks.getBlocks()) {
tag(net.minecraft.tags.BlockTags.MINEABLE_WITH_PICKAXE).add(block.block());
tag(BlockTags.MINEABLE_WITH_PICKAXE).add(block.block());
}

tag(MEGATags.SKY_STEEL_BLOCK).add(MEGABlocks.SKY_STEEL_BLOCK.block());
Expand All @@ -61,20 +62,20 @@ public String getName() {
}
}

public static class ItemTags extends ItemTagsProvider {
public ItemTags(
public static class Item extends ItemTagsProvider {
public Item(
PackOutput output,
CompletableFuture<HolderLookup.Provider> registries,
CompletableFuture<TagsProvider.TagLookup<Block>> blockTags,
CompletableFuture<TagsProvider.TagLookup<net.minecraft.world.level.block.Block>> blockTags,
ExistingFileHelper existing) {
super(output, registries, blockTags, MEGACells.MODID, existing);
}

@Override
protected void addTags(@NotNull HolderLookup.Provider provider) {
copy(MEGATags.SKY_STEEL_BLOCK, TagKey.create(Registries.ITEM, MEGATags.SKY_STEEL_BLOCK.location()));
copy(MEGATags.SKY_BRONZE_BLOCK, TagKey.create(Registries.ITEM, MEGATags.SKY_BRONZE_BLOCK.location()));
copy(MEGATags.SKY_OSMIUM_BLOCK, TagKey.create(Registries.ITEM, MEGATags.SKY_OSMIUM_BLOCK.location()));
copy(MEGATags.SKY_STEEL_BLOCK);
copy(MEGATags.SKY_BRONZE_BLOCK);
copy(MEGATags.SKY_OSMIUM_BLOCK);

tag(MEGATags.SKY_STEEL_INGOT).add(MEGAItems.SKY_STEEL_INGOT.asItem());
tag(MEGATags.SKY_BRONZE_INGOT).add(MEGAItems.SKY_BRONZE_INGOT.asItem());
Expand All @@ -95,16 +96,30 @@ protected void addTags(@NotNull HolderLookup.Provider provider) {
.add(Items.CLAY_BALL)
.add(Items.MELON_SLICE)
.add(Items.ICE, Items.PACKED_ICE)
.add(Items.STRING)
.add(Items.SNOWBALL)
.add(Items.HONEYCOMB)
.add(Items.POINTED_DRIPSTONE)
.addOptionalTag(
ResourceLocation.fromNamespaceAndPath("functionalstorage", "ignore_crafting_check"));

tag(MEGATags.COMPRESSION_BLACKLIST)
.addTag(Tags.Items.SEEDS)
.addTag(ConventionTags.WRENCH)
.addOptionalTag(ResourceLocation.fromNamespaceAndPath("mysticalagriculture", "essences"))
.remove(ResourceLocation.fromNamespaceAndPath("mysticalagriculture", "inferium_essence"));

tag(Tags.Items.INGOTS)
.addTag(MEGATags.SKY_STEEL_INGOT)
.addTag(MEGATags.SKY_BRONZE_INGOT)
.addTag(MEGATags.SKY_OSMIUM_INGOT);
copy(Tags.Blocks.STORAGE_BLOCKS, Tags.Items.STORAGE_BLOCKS);
}

private void copy(TagKey<net.minecraft.world.level.block.Block> blockTag) {
copy(blockTag, TagKey.create(Registries.ITEM, blockTag.location()));
}

@NotNull
@Override
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21.1 2024-08-25T13:50:12.498501175 Tags (Item)
// 1.21.1 2024-12-27T14:46:27.46760465 Tags (Item)
e42fb28c86b642b8733975efead834402f7fe45b data/ae2/tags/item/p2p_attunements/fe_p2p_tunnel.json
bf572a87643cf277b91bffb416e388a94cd36747 data/c/tags/item/ingots.json
61e4876c9c48d312a89177d6a5c81319297777ac data/c/tags/item/ingots/sky_bronze.json
Expand All @@ -8,6 +8,7 @@ bf572a87643cf277b91bffb416e388a94cd36747 data/c/tags/item/ingots.json
d16fe455331319a8d365af59139ac5d88a119144 data/c/tags/item/storage_blocks/sky_bronze.json
7a65c757f9501fd29bc86bebcbae0d91f197ff43 data/c/tags/item/storage_blocks/sky_osmium.json
1bfe8421078982de39dc3cb1d5917d6385175b44 data/c/tags/item/storage_blocks/sky_steel.json
99c21c9a0d2d3ed906e8580c0e1752315f114ba6 data/megacells/tags/item/compression_overrides.json
2cb7c155468ad5c415e6b2722c64f359b70b1a98 data/megacells/tags/item/compression_blacklist.json
685f7cac39a1df27bd3a919f3a2ef841b85a4c87 data/megacells/tags/item/compression_overrides.json
6945345eddaa46dddeb49da1543ec0850f03278a data/megacells/tags/item/mega_interface.json
75a9b0d69567961cd99e9e16fc2f9d57a8101f82 data/megacells/tags/item/mega_pattern_provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"remove": [
"mysticalagriculture:inferium_essence"
],
"values": [
"#c:seeds",
"#c:tools/wrench",
{
"id": "#mysticalagriculture:essences",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"minecraft:melon_slice",
"minecraft:ice",
"minecraft:packed_ice",
"minecraft:string",
"minecraft:snowball",
"minecraft:honeycomb",
"minecraft:pointed_dripstone",
{
"id": "#functionalstorage:ignore_crafting_check",
"required": false
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/gripe/_90/megacells/MEGACells.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -42,7 +39,6 @@
import gripe._90.megacells.definition.MEGACreativeTab;
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.definition.MEGAMenus;
import gripe._90.megacells.definition.MEGATranslations;
import gripe._90.megacells.integration.Addons;
import gripe._90.megacells.integration.appmek.RadioactiveCellItem;
import gripe._90.megacells.item.cell.BulkCellItem;
Expand All @@ -51,7 +47,6 @@
@Mod(MEGACells.MODID)
public class MEGACells {
public static final String MODID = "megacells";
public static final Logger LOGGER = LoggerFactory.getLogger(MEGATranslations.ModName.getEnglishText());

public MEGACells(ModContainer container, IEventBus eventBus) {
MEGABlocks.DR.register(eventBus);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/gripe/_90/megacells/definition/MEGATags.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public final class MEGATags {
public static final TagKey<Item> MEGA_PATTERN_PROVIDER = ItemTags.create(MEGABlocks.MEGA_PATTERN_PROVIDER.id());

public static final TagKey<Item> COMPRESSION_OVERRIDES = ItemTags.create(MEGACells.makeId("compression_overrides"));
public static final TagKey<Item> COMPRESSION_BLACKLIST = ItemTags.create(MEGACells.makeId("compression_blacklist"));
}
8 changes: 6 additions & 2 deletions src/main/java/gripe/_90/megacells/item/part/CellDockPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.mojang.blaze3d.vertex.PoseStack;

import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
Expand Down Expand Up @@ -63,6 +65,8 @@

public class CellDockPart extends AEBasePart
implements InternalInventoryHost, IChestOrDrive, IStorageProvider, IPriorityHost {
private static final Logger LOGGER = LoggerFactory.getLogger(CellDockPart.class);

@PartModels
private static final IPartModel MODEL = new PartModel(MEGACells.makeId("part/cell_dock"));

Expand Down Expand Up @@ -127,14 +131,14 @@ public void readVisualStateFromNBT(CompoundTag data) {
try {
clientCell = BuiltInRegistries.ITEM.get(ResourceLocation.parse(data.getString("cellId")));
} catch (Exception e) {
MEGACells.LOGGER.warn("Couldn't read cell item for {} from {}", this, data);
LOGGER.warn("Couldn't read cell item for {} from {}", this, data);
clientCell = Items.AIR;
}

try {
clientCellState = CellState.valueOf(data.getString("cellStatus"));
} catch (Exception e) {
MEGACells.LOGGER.warn("Couldn't read cell status for {} from {}", this, data);
LOGGER.warn("Couldn't read cell status for {} from {}", this, data);
clientCellState = CellState.ABSENT;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/gripe/_90/megacells/misc/CompressionChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,10 @@ public record Variant(AEItemKey item, int factor) {
Variant(Item item, int factor) {
this(AEItemKey.of(item), factor);
}

@Override
public String toString() {
return factor + "x → " + item;
}
}
}
Loading

0 comments on commit 1e3ae7c

Please sign in to comment.