Skip to content

Commit

Permalink
Updated to Latest AE
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexeption committed Aug 8, 2023
1 parent 83cdc79 commit 5a32933
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ repositories {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.20.1-47.0.3'
minecraft 'net.minecraftforge:forge:1.20.1-47.1.43'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
runtimeOnly fg.deobf("mezz.jei:jei-1.20.1-forge:15.0.0.12")
compileOnly fg.deobf("appeng:appliedenergistics2-forge:15.0.2-alpha")
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:15.0.2-alpha")
compileOnly fg.deobf("appeng:appliedenergistics2-forge:15.0.9-beta")
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:15.0.9-beta")
}

jar {
Expand Down Expand Up @@ -208,7 +208,7 @@ modrinth {
gameVersions = ["1.20.1"]
loaders = ["forge"]
dependencies {
required.version "ae2", "forge-15.0.2-alpha"
required.version "ae2", "forge-15.0.9-beta"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import appeng.api.implementations.blockentities.IWirelessAccessPoint;
import appeng.api.implementations.menuobjects.ItemMenuHost;
import appeng.api.networking.IGrid;
import appeng.blockentity.networking.WirelessAccessPointBlockEntity;
import appeng.helpers.WirelessTerminalMenuHost;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import uk.co.hexeption.aeinfinitybooster.setup.ModItems;

Expand All @@ -25,18 +28,20 @@ public class MixinWirelessTerminalMenuHost extends ItemMenuHost {
@Shadow
private double currentDistanceFromGrid;

@Shadow @Final private IGrid targetGrid;

public MixinWirelessTerminalMenuHost(Player player, int slot, ItemStack itemStack) {
super(player, slot, itemStack);
}

@Inject(method = "testWap", at = @At("HEAD"), cancellable = true)
private void testWap(IWirelessAccessPoint wirelessAccessPoint, CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "getWapSqDistance", at = @At("HEAD"), cancellable = true)
private void testWap(IWirelessAccessPoint wirelessAccessPoint, CallbackInfoReturnable<Double> cir) {

wirelessAccessPoint.getGrid().getMachines(WirelessAccessPointBlockEntity.class).forEach(wirelessBlockEntity -> {

if (wirelessBlockEntity.getInternalInventory().getStackInSlot(0).is(ModItems.DIMENSION_CARD.get())) {
currentDistanceFromGrid = 32;
cir.setReturnValue(true);
cir.setReturnValue(Double.MAX_VALUE / 2);
}

if (!this.getPlayer().level().dimension().location().toString().equals(wirelessAccessPoint.getLocation().getLevel().dimension().location().toString())) {
Expand All @@ -45,9 +50,23 @@ private void testWap(IWirelessAccessPoint wirelessAccessPoint, CallbackInfoRetur

if (wirelessBlockEntity.getInternalInventory().getStackInSlot(0).is(ModItems.INFINITY_CARD.get())) {
currentDistanceFromGrid = 16;
cir.setReturnValue(true);
cir.setReturnValue(Double.MAX_VALUE / 2);
}
});
}

// Make sure we don't use more power than we should
@Redirect(method = "extractAEPower", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(DD)D"))
private double testPowerMultiplier(double a, double b) {
for (var wap : this.targetGrid.getMachines(WirelessAccessPointBlockEntity.class)) {
if (wap.getInternalInventory().getStackInSlot(0).is(ModItems.INFINITY_CARD.get())) {
return 16;
}
if (wap.getInternalInventory().getStackInSlot(0).is(ModItems.DIMENSION_CARD.get())) {
return 32;
}
}
return Math.min(a, b);
}

}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ordering = "NONE"
side = "BOTH"
[[dependencies.aeinfinitybooster]]
modId = "ae2"
versionRange = "[15.0.2-alpha,)"
versionRange = "[15.0.9-beta,)"
mandatory = true
ordering = "AFTER"
side = "BOTH"

0 comments on commit 5a32933

Please sign in to comment.