Skip to content

Commit

Permalink
Merge branch '62832:1.20' into 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Ftrless authored Nov 2, 2023
2 parents cf3607e + 1491b9d commit b613537
Show file tree
Hide file tree
Showing 43 changed files with 1,181 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ public void buildRecipes(Consumer<FinishedRecipe> consumer) {
MEGACells.makeId("transform/sky_steel_ingot"),
MEGAItems.SKY_STEEL_INGOT,
2,
TransformCircumstance.fluid(FluidTags.WATER),
Ingredient.of(ConventionTags.IRON_INGOT),
TransformCircumstance.fluid(FluidTags.LAVA),
Ingredient.of(AEItems.CERTUS_QUARTZ_CRYSTAL_CHARGED),
Ingredient.of(ConventionTags.IRON_INGOT),
Ingredient.of(AEBlocks.SKY_STONE_BLOCK));

InscriberRecipeBuilder.inscribe(AEItems.SINGULARITY, MEGAItems.ACCUMULATION_PROCESSOR_PRESS, 1)
Expand Down
8 changes: 2 additions & 6 deletions common/src/data/resources/megacells.data.mixins.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"required": true,
"minVersion": "0.8",
"minVersion": "0.8.5",
"package": "gripe._90.megacells.mixin.data",
"compatibilityLevel": "JAVA_17",
"mixins": ["TextureSlotAccessor"],
"injectors": {
"defaultRequire": 1
}
"mixins": ["TextureSlotAccessor"]
}
32 changes: 16 additions & 16 deletions common/src/main/java/gripe/_90/megacells/MEGACells.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

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;
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.integration.ae2wt.AE2WTIntegration;
import gripe._90.megacells.integration.appbot.AppBotIntegration;
import gripe._90.megacells.integration.appbot.AppBotItems;
import gripe._90.megacells.item.cell.MEGABulkCell;
import gripe._90.megacells.item.cell.BulkCellItem;
import gripe._90.megacells.misc.DecompressionService;

public final class MEGACells {
private MEGACells() {}
Expand All @@ -52,41 +52,41 @@ public static void initCommon() {
MEGABlocks.init();
MEGABlockEntities.init();

if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPBOT)) {
if (PLATFORM.isAddonLoaded(Addons.APPBOT)) {
AppBotItems.init();
}

initStorageCells();

MEGACells.PLATFORM.initCompression();
PLATFORM.initCompression();
GridServices.register(DecompressionService.class, DecompressionService.class);

MEGACells.PLATFORM.addVillagerTrade(MEGAItems.SKY_STEEL_INGOT, 8, 3, 20);
MEGACells.PLATFORM.addVillagerTrade(MEGAItems.ACCUMULATION_PROCESSOR_PRESS, 40, 1, 50);
PLATFORM.initLavaTransform();

PLATFORM.addVillagerTrade(MEGAItems.SKY_STEEL_INGOT, 8, 3, 20);
PLATFORM.addVillagerTrade(MEGAItems.ACCUMULATION_PROCESSOR_PRESS, 40, 1, 50);
}

private static void initStorageCells() {
Stream.of(MEGAItems.getItemCells(), MEGAItems.getItemPortables())
.flatMap(Collection::stream)
.forEach(c -> StorageCellModels.registerModel(c, MEGACells.makeId("block/drive/cells/mega_item_cell")));
.forEach(c -> StorageCellModels.registerModel(c, makeId("block/drive/cells/mega_item_cell")));
Stream.of(MEGAItems.getFluidCells(), MEGAItems.getFluidPortables())
.flatMap(Collection::stream)
.forEach(
c -> StorageCellModels.registerModel(c, MEGACells.makeId("block/drive/cells/mega_fluid_cell")));
.forEach(c -> StorageCellModels.registerModel(c, makeId("block/drive/cells/mega_fluid_cell")));

StorageCells.addCellHandler(MEGABulkCell.HANDLER);
StorageCellModels.registerModel(MEGAItems.BULK_ITEM_CELL, MEGACells.makeId("block/drive/cells/bulk_item_cell"));
StorageCells.addCellHandler(BulkCellItem.HANDLER);
StorageCellModels.registerModel(MEGAItems.BULK_ITEM_CELL, makeId("block/drive/cells/bulk_item_cell"));

MEGAItems.getItemPortables()
.forEach(cell -> HotkeyActions.registerPortableCell(cell, HotkeyAction.PORTABLE_ITEM_CELL));
MEGAItems.getFluidPortables()
.forEach(cell -> HotkeyActions.registerPortableCell(cell, HotkeyAction.PORTABLE_FLUID_CELL));

if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPBOT)) {
if (PLATFORM.isAddonLoaded(Addons.APPBOT)) {
Stream.of(AppBotItems.getCells(), AppBotItems.getPortables())
.flatMap(Collection::stream)
.forEach(c ->
StorageCellModels.registerModel(c, MEGACells.makeId("block/drive/cells/mega_mana_cell")));
.forEach(c -> StorageCellModels.registerModel(c, makeId("block/drive/cells/mega_mana_cell")));
}
}

Expand Down Expand Up @@ -152,11 +152,11 @@ public static void initUpgrades() {
Upgrades.add(MEGAItems.GREATER_ENERGY_CARD, portableCell, 2, portableCellGroup);
}

if (MEGACells.PLATFORM.isAddonLoaded(Addons.AE2WTLIB)) {
if (PLATFORM.isAddonLoaded(Addons.AE2WTLIB)) {
AE2WTIntegration.initUpgrades();
}

if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPBOT)) {
if (PLATFORM.isAddonLoaded(Addons.APPBOT)) {
AppBotIntegration.initUpgrades();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gripe._90.megacells.client.gui;

import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;

import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.style.ScreenStyle;

import gripe._90.megacells.menu.CellDockMenu;

public class CellDockScreen extends AEBaseScreen<CellDockMenu> {
public CellDockScreen(CellDockMenu menu, Inventory playerInventory, Component title, ScreenStyle style) {
super(menu, playerInventory, title, style);
widgets.addOpenPriorityButton();
}
}
8 changes: 8 additions & 0 deletions common/src/main/java/gripe/_90/megacells/core/Platform.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package gripe._90.megacells.core;

import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;

import appeng.api.orientation.BlockOrientation;

public interface Platform {
Loaders getLoader();

Expand All @@ -12,5 +16,9 @@ public interface Platform {

void initCompression();

void initLavaTransform();

void addVillagerTrade(ItemLike item, int cost, int quantity, int xp);

BakedModel createWrappedCellModel(Item cell, BlockOrientation orientation);
}

This file was deleted.

17 changes: 11 additions & 6 deletions common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import appeng.menu.me.common.MEStorageMenu;

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.crafting.DecompressionPatternItem;
import gripe._90.megacells.item.cell.MEGABulkCell;
import gripe._90.megacells.item.DecompressionPatternItem;
import gripe._90.megacells.item.cell.BulkCellItem;
import gripe._90.megacells.item.cell.MEGAPortableCell;
import gripe._90.megacells.item.part.CellDockPart;
import gripe._90.megacells.item.part.DecompressionModulePart;
import gripe._90.megacells.item.part.MEGAInterfacePart;
import gripe._90.megacells.item.part.MEGAPatternProviderPart;
Expand Down Expand Up @@ -84,8 +85,8 @@ public static List<ItemDefinition<?>> getItems() {

public static final ItemDefinition<MaterialItem> BULK_CELL_COMPONENT =
item("MEGA Bulk Storage Component", "bulk_cell_component", MaterialItem::new);
public static final ItemDefinition<MEGABulkCell> BULK_ITEM_CELL =
item("MEGA Bulk Item Storage Cell", "bulk_item_cell", MEGABulkCell::new);
public static final ItemDefinition<BulkCellItem> BULK_ITEM_CELL =
item("MEGA Bulk Item Storage Cell", "bulk_item_cell", BulkCellItem::new);

public static final ItemDefinition<MEGAPortableCell> PORTABLE_ITEM_CELL_1M = itemPortable(TIER_1M);
public static final ItemDefinition<MEGAPortableCell> PORTABLE_ITEM_CELL_4M = itemPortable(TIER_4M);
Expand Down Expand Up @@ -127,6 +128,11 @@ public static List<ItemDefinition<?>> getItems() {
p -> new PartItem<>(p, DecompressionModulePart.class, DecompressionModulePart::new));
});

public static final ItemDefinition<PartItem<CellDockPart>> CELL_DOCK = Util.make(() -> {
PartModels.registerModels(PartModelsHelper.createModels(CellDockPart.class));
return item("ME Cell Dock", "cell_dock", p -> new PartItem<>(p, CellDockPart.class, CellDockPart::new));
});

public static List<ItemDefinition<?>> getItemCells() {
return List.of(ITEM_CELL_1M, ITEM_CELL_4M, ITEM_CELL_16M, ITEM_CELL_64M, ITEM_CELL_256M);
}
Expand Down Expand Up @@ -207,8 +213,7 @@ private static ItemDefinition<MEGAPortableCell> fluidPortable(StorageTier tier)
return item(
tier.namePrefix().toUpperCase() + " Portable Fluid Cell",
"portable_fluid_cell_" + tier.namePrefix(),
p -> new MEGAPortableCell(
p, tier, AEKeyType.fluids(), MEStorageMenu.PORTABLE_FLUID_CELL_TYPE, 0x00F1C5));
p -> new MEGAPortableCell(p, tier, AEKeyType.fluids(), MEStorageMenu.PORTABLE_FLUID_CELL_TYPE, 0xF1C5));
}

public static <T extends Item> ItemDefinition<T> 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.item;

import org.jetbrains.annotations.Nullable;

Expand All @@ -9,6 +9,7 @@
import appeng.crafting.pattern.EncodedPatternItem;

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.misc.DecompressionPattern;

public class DecompressionPatternItem extends EncodedPatternItem {
public DecompressionPatternItem(Properties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
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.misc.CompressionChain;
import gripe._90.megacells.misc.CompressionService;

public class BulkCellInventory implements StorageCell {
private static final String KEY = "key";
private static final String UNIT_COUNT = "smallestUnitCount";
private static final String UNIT_FACTOR = "unitFactor";

private static final long STACK_LIMIT = (long) Math.pow(2, 42);

private final ISaveProvider container;
Expand All @@ -38,10 +40,11 @@ public class BulkCellInventory implements StorageCell {

private boolean isPersisted = true;

public BulkCellInventory(MEGABulkCell cell, ItemStack stack, ISaveProvider container) {
BulkCellInventory(ItemStack stack, ISaveProvider container) {
this.stack = stack;
this.container = container;

var cell = (BulkCellItem) stack.getItem();
var filter = cell.getConfigInventory(this.stack).getKey(0);
filterItem = filter instanceof AEItemKey item ? item : null;

Expand All @@ -55,6 +58,17 @@ public BulkCellInventory(MEGABulkCell cell, ItemStack stack, ISaveProvider conta
.getChain(storedItem != null ? storedItem : filterItem)
.orElseGet(CompressionChain::new);
unitFactor = compressionChain.unitFactor(storedItem != null ? storedItem : filterItem);

// Check newly-calculated factor against what's already recorded in order to adjust for a compression chain that
// has changed from the left of the stored item
var recordedFactor = !getTag().getString(UNIT_FACTOR).isEmpty()
? new BigInteger(getTag().getString(UNIT_FACTOR))
: unitFactor;

if (!unitFactor.equals(recordedFactor)) {
unitCount = unitCount.multiply(unitFactor).divide(recordedFactor);
saveChanges();
}
}

private long clampedLong(BigInteger toClamp, long limit) {
Expand Down Expand Up @@ -117,7 +131,7 @@ public long insert(AEKey what, long amount, Actionable mode, IActionSource sourc
return 0;
}

if (compressionEnabled && !compressionChain.containsVariant(item)) {
if (compressionEnabled && !what.equals(filterItem) && !compressionChain.containsVariant(item)) {
return 0;
}

Expand Down Expand Up @@ -150,7 +164,7 @@ public long extract(AEKey what, long amount, Actionable mode, IActionSource sour
return 0;
}

if (compressionEnabled && !compressionChain.containsVariant(item)) {
if (compressionEnabled && !what.equals(filterItem) && !compressionChain.containsVariant(item)) {
return 0;
}

Expand Down Expand Up @@ -196,9 +210,11 @@ public void persist() {
if (storedItem == null || unitCount.signum() < 1) {
getTag().remove(KEY);
getTag().remove(UNIT_COUNT);
getTag().remove(UNIT_FACTOR);
} else {
getTag().put(KEY, storedItem.toTagGeneric());
getTag().putString(UNIT_COUNT, unitCount.toString());
getTag().putString(UNIT_FACTOR, unitFactor.toString());
}

isPersisted = true;
Expand All @@ -215,7 +231,7 @@ public void getAvailableStacks(KeyCounter out) {
var compressionFactor = BigInteger.valueOf(variant.factor());
var key = variant.item();

if (count.divide(compressionFactor).signum() == 1 && variant != chain.last()) {
if (count.divide(compressionFactor).signum() == 1 && variant != chain.get(chain.size() - 1)) {
out.add(key, count.remainder(compressionFactor).longValue());
count = count.divide(compressionFactor);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -33,10 +32,10 @@
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.definition.MEGATranslations;

public class MEGABulkCell extends AEBaseItem implements ICellWorkbenchItem {
public class BulkCellItem extends AEBaseItem implements ICellWorkbenchItem {
public static final Handler HANDLER = new Handler();

public MEGABulkCell(Properties properties) {
public BulkCellItem(Properties properties) {
super(properties.stacksTo(1));
}

Expand Down Expand Up @@ -78,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 Expand Up @@ -133,14 +131,13 @@ private Handler() {}

@Override
public boolean isCell(ItemStack is) {
return is != null && is.getItem() instanceof MEGABulkCell;
return is != null && is.getItem() instanceof BulkCellItem;
}

@Nullable
@Override
public BulkCellInventory getCellInventory(ItemStack is, @Nullable ISaveProvider container) {
Objects.requireNonNull(is, "Cannot create cell inventory for null itemstack");
return isCell(is) ? new BulkCellInventory((MEGABulkCell) is.getItem(), is, container) : null;
public BulkCellInventory getCellInventory(ItemStack is, @Nullable ISaveProvider host) {
return isCell(is) ? new BulkCellInventory(is, host) : null;
}
}
}
Loading

0 comments on commit b613537

Please sign in to comment.