diff --git a/common/src/main/java/gripe/_90/megacells/MEGACells.java b/common/src/main/java/gripe/_90/megacells/MEGACells.java index d03cc77c..6559f8ba 100644 --- a/common/src/main/java/gripe/_90/megacells/MEGACells.java +++ b/common/src/main/java/gripe/_90/megacells/MEGACells.java @@ -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; diff --git a/common/src/main/java/gripe/_90/megacells/util/CompressionChain.java b/common/src/main/java/gripe/_90/megacells/compression/CompressionChain.java similarity index 98% rename from common/src/main/java/gripe/_90/megacells/util/CompressionChain.java rename to common/src/main/java/gripe/_90/megacells/compression/CompressionChain.java index 8e006c3d..4de6c4d2 100644 --- a/common/src/main/java/gripe/_90/megacells/util/CompressionChain.java +++ b/common/src/main/java/gripe/_90/megacells/compression/CompressionChain.java @@ -1,4 +1,4 @@ -package gripe._90.megacells.util; +package gripe._90.megacells.compression; import java.math.BigInteger; import java.util.Collections; diff --git a/common/src/main/java/gripe/_90/megacells/util/CompressionService.java b/common/src/main/java/gripe/_90/megacells/compression/CompressionService.java similarity index 99% rename from common/src/main/java/gripe/_90/megacells/util/CompressionService.java rename to common/src/main/java/gripe/_90/megacells/compression/CompressionService.java index 933ef585..f527ca13 100644 --- a/common/src/main/java/gripe/_90/megacells/util/CompressionService.java +++ b/common/src/main/java/gripe/_90/megacells/compression/CompressionService.java @@ -1,4 +1,4 @@ -package gripe._90.megacells.util; +package gripe._90.megacells.compression; import java.util.Arrays; import java.util.Collection; diff --git a/common/src/main/java/gripe/_90/megacells/util/CompressionVariant.java b/common/src/main/java/gripe/_90/megacells/compression/CompressionVariant.java similarity index 85% rename from common/src/main/java/gripe/_90/megacells/util/CompressionVariant.java rename to common/src/main/java/gripe/_90/megacells/compression/CompressionVariant.java index 40eb1662..88dc27cf 100644 --- a/common/src/main/java/gripe/_90/megacells/util/CompressionVariant.java +++ b/common/src/main/java/gripe/_90/megacells/compression/CompressionVariant.java @@ -1,4 +1,4 @@ -package gripe._90.megacells.util; +package gripe._90.megacells.compression; import net.minecraft.world.item.Item; diff --git a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPattern.java b/common/src/main/java/gripe/_90/megacells/compression/DecompressionPattern.java similarity index 81% rename from common/src/main/java/gripe/_90/megacells/crafting/DecompressionPattern.java rename to common/src/main/java/gripe/_90/megacells/compression/DecompressionPattern.java index ae88cec1..c00216f8 100644 --- a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPattern.java +++ b/common/src/main/java/gripe/_90/megacells/compression/DecompressionPattern.java @@ -1,4 +1,4 @@ -package gripe._90.megacells.crafting; +package gripe._90.megacells.compression; import java.util.Objects; @@ -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; @@ -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 diff --git a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternItem.java b/common/src/main/java/gripe/_90/megacells/compression/DecompressionPatternItem.java similarity index 96% rename from common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternItem.java rename to common/src/main/java/gripe/_90/megacells/compression/DecompressionPatternItem.java index f147c8c9..41c9ddee 100644 --- a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternItem.java +++ b/common/src/main/java/gripe/_90/megacells/compression/DecompressionPatternItem.java @@ -1,4 +1,4 @@ -package gripe._90.megacells.crafting; +package gripe._90.megacells.compression; import org.jetbrains.annotations.Nullable; diff --git a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionService.java b/common/src/main/java/gripe/_90/megacells/compression/DecompressionService.java similarity index 84% rename from common/src/main/java/gripe/_90/megacells/crafting/DecompressionService.java rename to common/src/main/java/gripe/_90/megacells/compression/DecompressionService.java index 61e205e3..d9998daa 100644 --- a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionService.java +++ b/common/src/main/java/gripe/_90/megacells/compression/DecompressionService.java @@ -1,4 +1,4 @@ -package gripe._90.megacells.crafting; +package gripe._90.megacells.compression; import java.util.Collections; import java.util.List; @@ -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; @@ -89,7 +90,7 @@ private Set 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)); } @@ -103,10 +104,17 @@ private Set 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); + } } diff --git a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternEncoding.java b/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternEncoding.java deleted file mode 100644 index b7719923..00000000 --- a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternEncoding.java +++ /dev/null @@ -1,43 +0,0 @@ -package gripe._90.megacells.crafting; - -import java.util.Objects; - -import net.minecraft.nbt.CompoundTag; - -import appeng.api.stacks.AEItemKey; - -import gripe._90.megacells.util.CompressionVariant; - -public class DecompressionPatternEncoding { - private static final String NBT_BASE = "base"; - private static final String NBT_VARIANT = "variant"; - private static final String NBT_FACTOR = "factor"; - private static final String NBT_TO_COMPRESS = "toCompress"; - - public static AEItemKey getBase(CompoundTag nbt) { - Objects.requireNonNull(nbt, "Pattern must have a base tag."); - return AEItemKey.fromTag(nbt.getCompound(NBT_BASE)); - } - - public static AEItemKey getVariant(CompoundTag nbt) { - Objects.requireNonNull(nbt, "Pattern must have a variant tag."); - return AEItemKey.fromTag(nbt.getCompound(NBT_VARIANT)); - } - - public static int getFactor(CompoundTag nbt) { - Objects.requireNonNull(nbt, "Pattern must have a factor tag."); - return nbt.getInt(NBT_FACTOR); - } - - public static boolean getToCompress(CompoundTag nbt) { - Objects.requireNonNull(nbt, "Pattern must have a toCompress tag."); - return nbt.getBoolean(NBT_TO_COMPRESS); - } - - public static void encode(CompoundTag tag, AEItemKey base, CompressionVariant variant, boolean toCompress) { - tag.put(NBT_VARIANT, variant.item().toTag()); - tag.put(NBT_BASE, base.toTag()); - tag.putInt(NBT_FACTOR, variant.factor()); - tag.putBoolean(NBT_TO_COMPRESS, toCompress); - } -} diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java b/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java index e77a5ae0..1528f5f2 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java @@ -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; diff --git a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java index c9c6f2c2..2e9b2b9f 100644 --- a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java +++ b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java @@ -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"; diff --git a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellItem.java b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellItem.java index 6a33f0cd..8da49165 100644 --- a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellItem.java +++ b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellItem.java @@ -77,11 +77,10 @@ public void appendHoverText(ItemStack is, Level level, @NotNull List } } } 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( diff --git a/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java b/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java index d4dcc4b5..a3b4e1e5 100644 --- a/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java +++ b/common/src/main/java/gripe/_90/megacells/item/part/DecompressionModulePart.java @@ -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 diff --git a/fabric/src/main/java/gripe/_90/megacells/fabric/FabricPlatform.java b/fabric/src/main/java/gripe/_90/megacells/fabric/FabricPlatform.java index c8a9cf14..ba54f858 100644 --- a/fabric/src/main/java/gripe/_90/megacells/fabric/FabricPlatform.java +++ b/fabric/src/main/java/gripe/_90/megacells/fabric/FabricPlatform.java @@ -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 diff --git a/forge/src/main/java/gripe/_90/megacells/forge/ForgePlatform.java b/forge/src/main/java/gripe/_90/megacells/forge/ForgePlatform.java index 88b6640d..74f1fbe2 100644 --- a/forge/src/main/java/gripe/_90/megacells/forge/ForgePlatform.java +++ b/forge/src/main/java/gripe/_90/megacells/forge/ForgePlatform.java @@ -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 diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java index d0f1c4b6..f63aa917 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java @@ -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 diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellItem.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellItem.java index 75f9f42b..a84d6aea 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellItem.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellItem.java @@ -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); }