Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
- Fluid & checmical filter can use `amount` instead of `count`. `count` field will be removed in 0.8.
- When filter is invalid, an error will be thrown instead of return a silent ignorable string.

### Fixed
- Fixed support for Refined Storage version 2.0.0
- [#786] Minor performance improvements to the RS Bridges resources iteration - improves the performance with any get*Resource* function - Thanks to @SirYwell!
- [#784] Fixed that the energy detector transfer rate limit is not enforced
- Fixed an issue where the ME Bridge could void chemicals during exporting/importing
- Fixed an issue where export/import fluids and chemicals in the ME Bridge would not detect any remote target peripherals
- Fixed an issue when export/import with slots out of the range will cause error
- Fixed bridges will only export the first item that matches the filter
- [#794] Fixed bridges will only import fluids from the first tank.

## [1.21.1-0.7.55b] - 2025-07-14

Expand Down
19 changes: 15 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,17 @@ repositories {
}
maven {
name = "Create maven"
url = "https://maven.tterrag.com/"
url = "https://maven.createmod.net"
content {
includeGroup("com.simibubi.create")
includeGroup("dev.engine-room.flywheel")
includeGroup("net.createmod.ponder")
}
}
maven {
name = "Create Registrate maven"
url = "https://maven.ithundxr.dev/snapshots"
content {
includeGroup("com.tterrag.registrate")
}
}
Expand Down Expand Up @@ -234,9 +242,6 @@ dependencies {
transitive = false
}

// Needed for the refined storage mek integration
//compileOnlyApi("dev.emi:emi-neoforge:${emiVersion}")

// Extended requirements
// We don't use the api since we need a specific class from mekanism
compileOnly "mekanism:Mekanism:${mekanism_version}"
Expand All @@ -254,6 +259,12 @@ dependencies {
compileOnly "curse.maven:ae2things-609977:${ae2things_version}-sources"
runtimeOnly "curse.maven:ae2things-609977:${ae2things_version}-sources"

implementation ("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false }
implementation "net.createmod.ponder:Ponder-NeoForge-${minecraft_version}:${ponder_version}"
compileOnly "dev.engine-room.flywheel:flywheel-neoforge-api-${minecraft_version}:${flywheel_version}"
runtimeOnly "dev.engine-room.flywheel:flywheel-neoforge-${minecraft_version}:${flywheel_version}"
implementation "com.tterrag.registrate:Registrate:${registrate_version}"

// Minecolonies
compileOnly "com.ldtteam:blockui:${blockui_version}"
compileOnly "com.ldtteam:domum-ornamentum:${domumornamentum_version}"
Expand Down
20 changes: 11 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod_id=advancedperipherals
mod_version=0.7.55b
minecraft_version=1.21.1
mod_artifact_suffix=
neo_version=21.1.194
neo_version=21.1.200
parchment_minecraft_version=1.21.1
parchment_mappings_version=2024.11.17
loader_version=4
Expand All @@ -30,24 +30,26 @@ cc_version=1.116.0
ae2things_version=5637783
appliedenergistics_version=19.2.13
appliedmekanistics_version=5978711
refinedstorage_version=2.0.0
refinedstorage_mekanism_version=1.1.0
mekanism_version=1.21.1-10.7.15.81
minecolonies_version=1.1.1020-1.21.1-snapshot
patchouli_version=1.21-88
mekanism_version=1.21.1-10.7.15.81
powah_version=6143661
refinedstorage_mekanism_version=1.1.0
refinedstorage_version=2.0.0

# Mod dependencies which are needed for other mods
# minecolonies
structurize_version=1.0.775-1.21.1-snapshot
multipiston_version=1.2.51-1.21.1-snapshot
blockui_version=1.0.199-1.21.1-snapshot
domumornamentum_version=1.0.216-snapshot
# refined storage mek integration
emiVersion=1.1.11+1.21
multipiston_version=1.2.51-1.21.1-snapshot
structurize_version=1.0.775-1.21.1-snapshot
# powah
cloth_config_version=15.0.127

# Mod dependencies for testing stuff(Only used in the dev environment)
create_version=6.0.8-168
createadditions_version=5099752minecraft_version = 1.21.1
emi_version=1.1.22+1.21.1
createadditions_version=5099752
flywheel_version=1.0.5
ponder_version=1.0.64
registrate_version=MC1.21-1.3.0+62
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ public static Pair<Long, AEItemKey> findAEStackFromFilter(MEStorage monitor, @Nu
return Pair.of(0L, null);
}

@NotNull
public static List<Pair<Long, AEItemKey>> findAEStacksFromFilter(MEStorage monitor, ItemFilter filter) {
List<Pair<Long, AEItemKey>> items = new ArrayList<>();
for (Object2LongMap.Entry<AEKey> temp : monitor.getAvailableStacks()) {
if (temp.getKey() instanceof AEItemKey key && filter.test(key.toStack())) {
items.add(Pair.of(temp.getLongValue(), key));
}
}
return items;
}

@NotNull
public static Pair<Long, AEFluidKey> findAEFluidFromStack(MEStorage monitor, @Nullable ICraftingService crafting, FluidStack item) {
return findAEFluidFromFilter(monitor, crafting, FluidFilter.fromStack(item));
Expand All @@ -122,6 +133,17 @@ public static Pair<Long, AEFluidKey> findAEFluidFromFilter(MEStorage monitor, @N
return Pair.of(0L, null);
}

@NotNull
public static List<Pair<Long, AEFluidKey>> findAEFluidsFromFilter(MEStorage monitor, FluidFilter filter) {
List<Pair<Long, AEFluidKey>> fluids = new ArrayList<>();
for (Object2LongMap.Entry<AEKey> temp : monitor.getAvailableStacks()) {
if (temp.getKey() instanceof AEFluidKey key && filter.test(key.toStack(1))) {
fluids.add(Pair.of(temp.getLongValue(), key));
}
}
return fluids;
}

@NotNull
public static Pair<Long, MekanismKey> findAEChemicalFromStack(MEStorage monitor, @Nullable ICraftingService crafting, ChemicalStack stack) {
return findAEChemicalFromFilter(monitor, crafting, ChemicalFilter.fromStack(stack));
Expand All @@ -145,6 +167,17 @@ public static Pair<Long, MekanismKey> findAEChemicalFromFilter(MEStorage monitor
return Pair.of(0L, null);
}

@NotNull
public static List<Pair<Long, MekanismKey>> findAEChemicalsFromFilter(MEStorage monitor, ChemicalFilter filter) {
List<Pair<Long, MekanismKey>> chemicals = new ArrayList<>();
for (Object2LongMap.Entry<AEKey> temp : monitor.getAvailableStacks()) {
if (temp.getKey() instanceof MekanismKey key && filter.test(key.getStack())) {
chemicals.add(Pair.of(temp.getLongValue(), key));
}
}
return chemicals;
}

/**
* Finds a pattern from filters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.MEStorage;
import de.srendi.advancedperipherals.AdvancedPeripherals;
import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MEBridgePeripheral;
import de.srendi.advancedperipherals.common.util.Pair;
import de.srendi.advancedperipherals.common.util.inventory.ChemicalFilter;
import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemChemicalHandler;
import de.srendi.advancedperipherals.common.util.inventory.StorageProcessor;
import me.ramidzkh.mekae2.ae2.MekanismKey;
import mekanism.api.Action;
import mekanism.api.chemical.ChemicalStack;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
* Used to transfer a chemical between a tank and the ME system.
*
Expand All @@ -32,28 +34,43 @@ public MEChemicalHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSour

@NotNull
@Override
public ChemicalStack insertChemical(int tank, ChemicalStack resource, @NotNull Action action) {
if (resource.isEmpty())
public ChemicalStack insertChemical(ChemicalStack resource, @NotNull Action action) {
if (resource.isEmpty()) {
return resource;
}

ChemicalStack remain = resource.copy();
long amountInserted = storageMonitor.insert(MekanismKey.of(resource), resource.getAmount(), action == Action.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);
long amountInserted = storageMonitor.insert(MekanismKey.of(resource), resource.getAmount(), action.simulate() ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);
remain.setAmount(resource.getAmount() - amountInserted);
return remain;
}

@NotNull
@Override
public ChemicalStack extractChemical(ChemicalFilter filter, long count, Action simulate) {
Pair<Long, MekanismKey> chemicalKey = AEApi.findAEChemicalFromFilter(storageMonitor, null, filter);
if (chemicalKey.getRight() == null)
return ChemicalStack.EMPTY;

ChemicalStack extracted = chemicalKey.getRight().getStack();
public long extractChemicals(ChemicalFilter filter, StorageProcessor.Large<ChemicalStack> processor, Action action) {
List<Pair<Long, MekanismKey>> chemicalKeys = AEApi.findAEChemicalsFromFilter(storageMonitor, filter);
if (chemicalKeys.isEmpty()) {
return 0;
}

long amountExtracted = storageMonitor.extract(chemicalKey.getRight(), count, simulate == Action.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);
extracted.setAmount(amountExtracted);
AdvancedPeripherals.debug("Extracted chemical: " + extracted + " from filter: " + filter);
return extracted;
long needs = filter.getAmount();
for (Pair<Long, MekanismKey> pair : chemicalKeys) {
MekanismKey chemicalKey = pair.right();
long amount = storageMonitor.extract(chemicalKey, needs, Actionable.SIMULATE, actionSource);
if (amount == 0) {
continue;
}
long extracted = processor.process(chemicalKey.getStack().copyWithAmount(amount));
if (extracted == 0) {
continue;
}
needs -= extracted;
if (action.execute()) {
storageMonitor.extract(chemicalKey, extracted, Actionable.MODULATE, actionSource);
}
if (needs <= 0) {
break;
}
}
return filter.getAmount() - needs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
import de.srendi.advancedperipherals.common.util.Pair;
import de.srendi.advancedperipherals.common.util.inventory.FluidFilter;
import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemFluidHandler;
import de.srendi.advancedperipherals.common.util.inventory.StorageProcessor;
import net.neoforged.neoforge.fluids.FluidStack;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
* Used to transfer item between an inventory and the ME system.
*
Expand All @@ -30,21 +33,39 @@ public MEFluidHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource

@Override
public int fill(FluidStack resource, FluidAction action) {
if (resource.isEmpty())
if (resource.isEmpty()) {
return 0;
}
AEFluidKey itemKey = AEFluidKey.of(resource.getFluid());
long inserted = storageMonitor.insert(itemKey, resource.getAmount(), action == FluidAction.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);

return (int) Math.min(inserted, Integer.MAX_VALUE);
// should never overflow
return (int) (storageMonitor.insert(itemKey, resource.getAmount(), action.simulate() ? Actionable.SIMULATE : Actionable.MODULATE, actionSource));
}

@NotNull
@Override
public FluidStack drain(FluidFilter filter, FluidAction simulate) {
Pair<Long, AEFluidKey> fluidKey = AEApi.findAEFluidFromFilter(storageMonitor, null, filter);
if (fluidKey.getRight() == null)
return FluidStack.EMPTY;
long extracted = storageMonitor.extract(fluidKey.getRight(), filter.getCount(), simulate == FluidAction.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);
return new FluidStack(fluidKey.getRight().getFluid(), (int) Math.min(extracted, Integer.MAX_VALUE));
public int extractFluids(FluidFilter filter, StorageProcessor<FluidStack> processor, FluidAction action) {
List<Pair<Long, AEFluidKey>> fluidKeys = AEApi.findAEFluidsFromFilter(storageMonitor, filter);
if (fluidKeys.isEmpty()) {
return 0;
}
int needs = filter.getAmount();
for (Pair<Long, AEFluidKey> pair : fluidKeys) {
AEFluidKey fluidKey = pair.right();
int amount = (int) storageMonitor.extract(fluidKey, needs, Actionable.SIMULATE, actionSource);
if (amount == 0) {
continue;
}
int extracted = processor.process(new FluidStack(fluidKey.getFluid(), amount));
if (extracted == 0) {
continue;
}
needs -= extracted;
if (action.execute()) {
storageMonitor.extract(fluidKey, extracted, Actionable.MODULATE, actionSource);
}
if (needs <= 0) {
break;
}
}
return filter.getAmount() - needs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
import de.srendi.advancedperipherals.common.util.Pair;
import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemItemHandler;
import de.srendi.advancedperipherals.common.util.inventory.ItemFilter;
import de.srendi.advancedperipherals.common.util.inventory.StorageProcessor;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
* Used to transfer item between an inventory and the ME system.
*
Expand All @@ -30,25 +33,38 @@ public MEItemHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource a

@NotNull
@Override
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
public ItemStack insertItem(@NotNull ItemStack stack, boolean simulate) {
AEItemKey itemKey = AEItemKey.of(stack);
long inserted = storageMonitor.insert(itemKey, stack.getCount(), simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);
ItemStack insertedStack = stack.copy();
// Safe to cast here, the amount will never be higher than 64
insertedStack.setCount(insertedStack.getCount() - (int) inserted);
return insertedStack;
return stack.copyWithCount(stack.getCount() - (int) inserted);
}

@Override
public ItemStack extractItem(ItemFilter filter, int count, boolean simulate) {
Pair<Long, AEItemKey> itemKey = AEApi.findAEStackFromFilter(storageMonitor, null, filter);
if (itemKey.getRight() == null)
return ItemStack.EMPTY;
long extracted = storageMonitor.extract(itemKey.getRight(), count, simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);
// Safe to cast here, the amount will never be higher than 64
ItemStack stack = itemKey.getRight().toStack();
stack.setCount((int) extracted);
return stack;
public int extractItems(ItemFilter filter, StorageProcessor<ItemStack> processor, boolean simulate) {
List<Pair<Long, AEItemKey>> itemKeys = AEApi.findAEStacksFromFilter(storageMonitor, filter);
if (itemKeys.isEmpty()) {
return 0;
}
int needs = filter.getCount();
for (Pair<Long, AEItemKey> pair : itemKeys) {
AEItemKey itemKey = pair.right();
int count = (int) storageMonitor.extract(itemKey, needs, Actionable.SIMULATE, actionSource);
if (count == 0) {
continue;
}
int extracted = processor.process(itemKey.toStack().copyWithCount(count));
if (extracted == 0) {
continue;
}
needs -= extracted;
if (!simulate) {
storageMonitor.extract(itemKey, extracted, Actionable.MODULATE, actionSource);
}
if (needs <= 0) {
break;
}
}
return filter.getCount() - needs;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public final MethodResult craftFluid(IComputerAccess computer, IArguments argume
if (stack.getRight() == null && stack.getLeft() == 0)
return MethodResult.of(false, StatusConstants.NOT_CRAFTABLE.toString());

AECraftJob job = new AECraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getCount(), bridge, target);
AECraftJob job = new AECraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getAmount(), bridge, target);
bridge.addJob(job);
return MethodResult.of(job.withCPU(target));
}
Expand Down Expand Up @@ -763,7 +763,7 @@ public MethodResult craftChemical(IComputerAccess computer, IArguments arguments
if (stack.getRight() == null && stack.getLeft() == 0)
return MethodResult.of(false, StatusConstants.NOT_CRAFTABLE.toString());

AECraftJob job = new AECraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getCount(), bridge, target);
AECraftJob job = new AECraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getAmount(), bridge, target);
bridge.addJob(job);
return MethodResult.of(job.withCPU(target));
}
Expand Down
Loading