Skip to content

Commit

Permalink
More refactoring and reorganisation
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Oct 30, 2023
1 parent f0b1da8 commit a757781
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 78 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/gripe/_90/megacells/MEGACells.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import appeng.core.localization.GuiText;
import appeng.hotkeys.HotkeyActions;

import gripe._90.megacells.compression.DecompressionService;
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.core.Platform;
import gripe._90.megacells.crafting.DecompressionService;
import gripe._90.megacells.definition.MEGABlockEntities;
import gripe._90.megacells.definition.MEGABlocks;
import gripe._90.megacells.definition.MEGAConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gripe._90.megacells.util;
package gripe._90.megacells.compression;

import java.math.BigInteger;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gripe._90.megacells.util;
package gripe._90.megacells.compression;

import java.util.Arrays;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gripe._90.megacells.util;
package gripe._90.megacells.compression;

import net.minecraft.world.item.Item;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gripe._90.megacells.crafting;
package gripe._90.megacells.compression;

import java.util.Objects;

Expand All @@ -11,6 +11,11 @@
import appeng.api.stacks.GenericStack;

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;
Expand All @@ -23,12 +28,12 @@ public DecompressionPattern(ItemStack stack) {

public DecompressionPattern(AEItemKey definition) {
this.definition = definition;
var tag = Objects.requireNonNull(definition.getTag());

base = DecompressionPatternEncoding.getBase(tag);
variant = DecompressionPatternEncoding.getVariant(tag);
factor = DecompressionPatternEncoding.getFactor(tag);
toCompress = DecompressionPatternEncoding.getToCompress(tag);
var tag = Objects.requireNonNull(definition.getTag());
base = AEItemKey.fromTag(tag.getCompound(NBT_BASE));
variant = AEItemKey.fromTag(tag.getCompound(NBT_VARIANT));
factor = tag.getInt(NBT_FACTOR);
toCompress = tag.getBoolean(NBT_TO_COMPRESS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gripe._90.megacells.crafting;
package gripe._90.megacells.compression;

import org.jetbrains.annotations.Nullable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gripe._90.megacells.crafting;
package gripe._90.megacells.compression;

import java.util.Collections;
import java.util.List;
Expand All @@ -16,6 +16,7 @@
import appeng.api.networking.IGridService;
import appeng.api.networking.IGridServiceProvider;
import appeng.api.networking.crafting.ICraftingProvider;
import appeng.api.stacks.AEItemKey;

import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.item.cell.BulkCellInventory;
Expand Down Expand Up @@ -89,7 +90,7 @@ private Set<IPatternDetails> generatePatterns(BulkCellInventory cell) {
var pattern = new ItemStack(MEGAItems.DECOMPRESSION_PATTERN);
var decompressed = decompressionChain.get(decompressionChain.indexOf(variant) + 1);

DecompressionPatternEncoding.encode(pattern.getOrCreateTag(), decompressed.item(), variant, false);
encodePattern(pattern.getOrCreateTag(), decompressed.item(), variant, false);
patterns.add(new DecompressionPattern(pattern));
}

Expand All @@ -103,10 +104,17 @@ private Set<IPatternDetails> generatePatterns(BulkCellInventory cell) {
var pattern = new ItemStack(MEGAItems.DECOMPRESSION_PATTERN);
var decompressed = compressionChain.get(compressionChain.indexOf(variant) - 1);

DecompressionPatternEncoding.encode(pattern.getOrCreateTag(), decompressed.item(), variant, true);
encodePattern(pattern.getOrCreateTag(), decompressed.item(), variant, true);
patterns.add(new DecompressionPattern(pattern));
}

return patterns;
}

private void encodePattern(CompoundTag tag, AEItemKey base, CompressionVariant variant, boolean toCompress) {
tag.put(DecompressionPattern.NBT_VARIANT, variant.item().toTag());
tag.put(DecompressionPattern.NBT_BASE, base.toTag());
tag.putInt(DecompressionPattern.NBT_FACTOR, variant.factor());
tag.putBoolean(DecompressionPattern.NBT_TO_COMPRESS, toCompress);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import appeng.menu.me.common.MEStorageMenu;

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.crafting.DecompressionPatternItem;
import gripe._90.megacells.compression.DecompressionPatternItem;
import gripe._90.megacells.item.cell.BulkCellItem;
import gripe._90.megacells.item.cell.MEGAPortableCell;
import gripe._90.megacells.item.part.CellDockPart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.cells.StorageCell;

import gripe._90.megacells.util.CompressionChain;
import gripe._90.megacells.util.CompressionService;
import gripe._90.megacells.compression.CompressionChain;
import gripe._90.megacells.compression.CompressionService;

public class BulkCellInventory implements StorageCell {
private static final String KEY = "key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ public void appendHoverText(ItemStack is, Level level, @NotNull List<Component>
}
}
} else {
if (storedItem != null) {
lines.add(MEGATranslations.MismatchedFilter.text().withStyle(ChatFormatting.DARK_RED));
} else {
lines.add(Tooltips.of(MEGATranslations.NotPartitioned.text()));
}
lines.add(
storedItem != null
? MEGATranslations.MismatchedFilter.text().withStyle(ChatFormatting.DARK_RED)
: Tooltips.of(MEGATranslations.NotPartitioned.text()));
}

lines.add(Tooltips.of(MEGATranslations.Compression.text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import appeng.parts.PartModel;

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.crafting.DecompressionPattern;
import gripe._90.megacells.crafting.DecompressionService;
import gripe._90.megacells.compression.DecompressionPattern;
import gripe._90.megacells.compression.DecompressionService;

public class DecompressionModulePart extends AEBasePart implements ICraftingProvider, IGridTickable {
@PartModels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import appeng.core.definitions.AEBlocks;
import appeng.init.InitVillager;

import gripe._90.megacells.compression.CompressionService;
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.core.Loaders;
import gripe._90.megacells.core.Platform;
import gripe._90.megacells.util.CompressionService;

public final class FabricPlatform implements Platform {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
import appeng.core.definitions.AEBlocks;
import appeng.init.InitVillager;

import gripe._90.megacells.compression.CompressionService;
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.core.Loaders;
import gripe._90.megacells.core.Platform;
import gripe._90.megacells.util.CompressionService;

public final class ForgePlatform implements Platform {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,10 @@ public double getIdleDrain() {
}

public boolean isBlackListed(AEKey what) {
if (what instanceof MekanismKey key) {
if (key.getStack().getRaw().getChemical() == MekanismGases.SPENT_NUCLEAR_WASTE.getChemical()) {
return !MEGAConfig.INSTANCE.isSpentWasteAllowed();
} else {
return ChemicalAttributeValidator.DEFAULT.process(key.getStack());
}
} else {
return true;
}
return !(what instanceof MekanismKey key)
|| (key.getStack().getRaw().getChemical() == MekanismGases.SPENT_NUCLEAR_WASTE.getChemical()
? !MEGAConfig.INSTANCE.isSpentWasteAllowed()
: ChemicalAttributeValidator.DEFAULT.process(key.getStack()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public RadioactiveCellItem(Properties properties) {
super(properties.stacksTo(1));
}

@Override
public ConfigInventory getConfigInventory(ItemStack is) {
return CellConfig.create(MekanismKeyType.TYPE.filter(), is, 1);
}
Expand Down

0 comments on commit a757781

Please sign in to comment.