Skip to content

Commit

Permalink
Remove compression chain limiter (and Fabric config)
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Dec 3, 2023
1 parent 50c2207 commit d08a019
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 64 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
ae2(required){curseforge:223794}{modrinth:XxWD5pD3}
appbot(optional){curseforge:610632}{modrinth:545hUrw9}
ae2wtlib(optional){curseforge:459929}{modrinth:pNabrMMw}
cloth-config(required){curseforge:348521}{modrinth:9s6osm5g}
files: fabric/build/libs/*[0-9].jar
- name: Publish release files (Forge)
Expand Down
3 changes: 0 additions & 3 deletions common/src/main/java/gripe/_90/megacells/MEGACells.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.core.Platform;
import gripe._90.megacells.definition.MEGABlockEntities;
import gripe._90.megacells.definition.MEGAConfig;
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.integration.appbot.AppBotItems;
import gripe._90.megacells.item.cell.BulkCellItem;
Expand All @@ -43,8 +42,6 @@ public static ResourceLocation makeId(String path) {
}

public static void initCommon() {
MEGAConfig.load();

PLATFORM.initItems();
PLATFORM.register();
PLATFORM.initUpgrades();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@ public final class MEGAConfig implements ConfigData {

private MEGAConfig() {}

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 2, max = 12)
private int CompressionChainLimit = 3;

@ConfigEntry.Gui.Tooltip
private boolean AllowSpentWaste = false;

public int getCompressionChainLimit() {
return CompressionChainLimit;
}

public boolean isSpentWasteAllowed() {
return AllowSpentWaste;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,22 @@ private Set<IPatternDetails> generateDecompressionPatterns() {
return Set.of();
}

var patterns = new ObjectLinkedOpenHashSet<IPatternDetails>();
var decompressionChain = compressionChain.limited();
var decompressionChain = new CompressionChain();
decompressionChain.addAll(compressionChain);
Collections.reverse(decompressionChain);

var patterns = new ObjectLinkedOpenHashSet<IPatternDetails>();

for (var variant : decompressionChain) {
if (variant == decompressionChain.get(decompressionChain.size() - 1)) {
continue;
}

var decompressed = decompressionChain.get(decompressionChain.indexOf(variant) + 1);
patterns.add(new DecompressionPattern(decompressed.item(), variant, false));
}

var remainingChain = compressionChain.subList(decompressionChain.size() - 1, compressionChain.size());

for (var variant : remainingChain) {
if (variant == remainingChain.get(0)) {
continue;
}

var decompressed = remainingChain.get(remainingChain.indexOf(variant) - 1);
patterns.add(new DecompressionPattern(decompressed.item(), variant, true));
patterns.add(new DecompressionPattern(decompressed.item(), variant));
}

return patterns;
return Collections.unmodifiableSet(patterns);
}

@Override
Expand Down Expand Up @@ -264,7 +255,7 @@ public void getAvailableStacks(KeyCounter out) {
if (storedItem != null) {
if (compressionEnabled && storedItem.equals(filterItem) && !compressionChain.isEmpty()) {
var count = unitCount;
var chain = compressionChain.limited().lastMultiplierSwapped();
var chain = compressionChain.lastMultiplierSwapped();

for (var variant : chain) {
var compressionFactor = BigInteger.valueOf(variant.factor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

import appeng.api.stacks.AEItemKey;

import gripe._90.megacells.definition.MEGAConfig;

public class CompressionChain extends ObjectArrayList<CompressionService.Variant> {
public void add(AEItemKey item, byte factor) {
add(new CompressionService.Variant(item, factor));
Expand Down Expand Up @@ -44,11 +42,4 @@ public CompressionChain lastMultiplierSwapped() {

return chain;
}

public CompressionChain limited() {
var chainLength = MEGAConfig.INSTANCE.getCompressionChainLimit();
var chain = new CompressionChain();
chain.addAll(size <= chainLength ? this : subList(0, chainLength));
return chain;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ public class DecompressionPattern implements IPatternDetails {
static final String NBT_BASE = "base";
static final String NBT_VARIANT = "variant";
static final String NBT_FACTOR = "factor";
static final String NBT_TO_COMPRESS = "toCompress";

private final AEItemKey definition;
private final AEItemKey base;
private final AEItemKey variant;
private final byte factor;
private final boolean toCompress;

public DecompressionPattern(AEItemKey definition) {
this.definition = definition;
Expand All @@ -31,20 +29,17 @@ public DecompressionPattern(AEItemKey definition) {
base = AEItemKey.fromTag(tag.getCompound(NBT_BASE));
variant = AEItemKey.fromTag(tag.getCompound(NBT_VARIANT));
factor = tag.getByte(NBT_FACTOR);
toCompress = tag.getBoolean(NBT_TO_COMPRESS);
}

public DecompressionPattern(AEItemKey base, CompressionService.Variant variant, boolean toCompress) {
public DecompressionPattern(AEItemKey base, CompressionService.Variant variant) {
this.base = base;
this.variant = variant.item();
this.factor = variant.factor();
this.toCompress = toCompress;

var tag = new CompoundTag();
tag.put(NBT_BASE, this.base.toTag());
tag.put(NBT_VARIANT, this.variant.toTag());
tag.putByte(NBT_FACTOR, this.factor);
tag.putBoolean(NBT_TO_COMPRESS, this.toCompress);

definition = AEItemKey.of(MEGAItems.DECOMPRESSION_PATTERN, tag);
}
Expand All @@ -56,12 +51,12 @@ public AEItemKey getDefinition() {

@Override
public IInput[] getInputs() {
return new IInput[] {toCompress ? new Input(base, factor) : new Input(variant, 1)};
return new IInput[] {new Input(variant, 1)};
}

@Override
public GenericStack[] getOutputs() {
return new GenericStack[] {toCompress ? new GenericStack(variant, 1) : new GenericStack(base, factor)};
return new GenericStack[] {new GenericStack(base, factor)};
}

@Override
Expand Down

This file was deleted.

6 changes: 2 additions & 4 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
"environment": "*",
"entrypoints": {
"ae2": ["gripe._90.megacells.fabric.MEGACellsFabric"],
"ae2:client": ["gripe._90.megacells.fabric.MEGACellsClient"],
"modmenu": ["gripe._90.megacells.integration.modmenu.ModMenuIntegration"]
"ae2:client": ["gripe._90.megacells.fabric.MEGACellsClient"]
},
"mixins": ["megacells.mixins.json"],
"depends": {
"minecraft": "$minecraftVersion",
"ae2": ">=$ae2Version",
"cloth-config": "*"
"ae2": ">=$ae2Version"
},
"suggests": {
"ae2wtlib": ">=$ae2wtVersion",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.definition.MEGAConfig;
import gripe._90.megacells.integration.appmek.AppMekIntegration;

@Mod(MEGACells.MODID)
public class MEGACellsForge {
public MEGACellsForge() {
MEGAConfig.load();
MEGACells.initCommon();

if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPMEK)) {
Expand Down

0 comments on commit d08a019

Please sign in to comment.