Skip to content

Commit

Permalink
Fix Accessor Mixin causing NPE with /test runclosest
Browse files Browse the repository at this point in the history
  • Loading branch information
2No2Name committed Apr 13, 2024
1 parent 9792b43 commit 40c681c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 42 deletions.
10 changes: 10 additions & 0 deletions src/main/java/mctester/common/test/creation/TestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,14 @@ public TestConfig variant(int variant) {
this.variant = variant;
return this;
}

public TestConfig manualOnly(boolean manualOnly) {
this.manualOnly = manualOnly;
return this;
}

public TestConfig skyAccess(boolean skyAccess) {
this.skyAccess = skyAccess;
return this;
}
}
6 changes: 3 additions & 3 deletions src/main/java/mctester/common/util/GameTestUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mctester.common.util;

import mctester.mixin.accessor.GameTestAccessor;
import mctester.mixin.accessor.GameTestStateAccessor;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.StructureBlockBlockEntity;
import net.minecraft.entity.Entity;
Expand All @@ -22,11 +22,11 @@

public class GameTestUtil {
public static BlockBox getTestBlockBox(GameTestState gameTest) {
return getTestBlockBox(((GameTestAccessor) gameTest).getStructureBlockBlockEntity());
return getTestBlockBox(gameTest.getStructureBlockBlockEntity());
}

public static Box getTestBox(GameTestState gameTest) {
return getTestBox(((GameTestAccessor) gameTest).getStructureBlockBlockEntity());
return getTestBox(gameTest.getStructureBlockBlockEntity());
}

private static BlockBox getTestBlockBox(StructureBlockBlockEntity structureBlockEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.function.LongConsumer;

@Mixin(GameTestState.class)
public class GameTestMixin implements GameTestHelper.GameTestAccess {
public class GameTestStateMixin implements GameTestHelper.GameTestAccess {
@Unique
private final GameTestHelper gameTestHelper = new GameTestHelper((GameTestState) (Object) this);
@Shadow
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/mctester/mixin/accessor/GameTestAccessor.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package mctester.mixin.accessor;

import net.minecraft.test.GameTestState;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(GameTestState.class)
public interface GameTestStateAccessor {

}
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
package mctester.mixin.fixes.function_lookup;

import net.minecraft.block.entity.StructureBlockBlockEntity;
import net.minecraft.server.command.TestCommand;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(TestCommand.class)
public class TestCommandMixin {

// @Redirect(
// method = "run(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/test/TestSet;Z)V",
// at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/block/entity/StructureBlockBlockEntity;getMetadata()Ljava/lang/String;"
// )
// )
// private static String getTestFunctionIdentifier(StructureBlockBlockEntity structureBlockBlockEntity) {
// String retval = structureBlockBlockEntity.getMetadata();
// if (retval.isEmpty()) {
// retval = structureBlockBlockEntity.getTemplateName();
// if (retval.startsWith("minecraft:")) {
// retval = retval.substring("minecraft:".length());
// }
// }
// return retval;
// } //TODO check if this is still needed
}
4 changes: 2 additions & 2 deletions src/main/resources/mctester.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"package": "mctester.mixin",
"compatibilityLevel": "JAVA_16",
"mixins": [
"GameTestMixin",
"GameTestStateMixin",
"accessor.BrainAccessor",
"accessor.GameTestAccessor",
"accessor.GameTestStateAccessor",
"accessor.GoalSelectorAccessor",
"accessor.MobEntityAccessor",
"accessor.TestContextAccessor",
Expand Down

0 comments on commit 40c681c

Please sign in to comment.