-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix registry and attribute errors in tests mocking the server pl…
…ayer
- Loading branch information
1 parent
d990c78
commit d480bfc
Showing
8 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...a/io/github/opencubicchunks/cubicchunks/mixin/test/common/MixinDefaultAttributesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.opencubicchunks.cubicchunks.mixin.test.common; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; | ||
import net.minecraft.world.entity.ai.attributes.DefaultAttributes; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(DefaultAttributes.class) | ||
public class MixinDefaultAttributesTest { | ||
@Redirect(method = "<clinit>", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/ai/attributes/DefaultAttributes;SUPPLIERS:Ljava/util/Map;", shift = At.Shift.BY, by = -1)) | ||
private static ImmutableMap<?, ?> cubic_chunks_3$fixNeoForgeRegistryError(ImmutableMap.Builder<?, ?> instance) { | ||
return ImmutableMap.builder().build(); | ||
} | ||
|
||
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;createLivingAttributes()Lnet/minecraft/world/entity/ai/attributes/AttributeSupplier$Builder;")) | ||
private static AttributeSupplier.Builder cubic_chunks_3$fixNeoForgeRegistryError() { | ||
return AttributeSupplier.builder(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/MixinEntityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.opencubicchunks.cubicchunks.mixin.test.common; | ||
|
||
import net.minecraft.core.Holder; | ||
import net.minecraft.world.entity.Entity; | ||
import net.neoforged.neoforge.fluids.FluidType; | ||
import org.mockito.Mockito; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(Entity.class) | ||
public abstract class MixinEntityTest { | ||
@Redirect(method = "<init>", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;forgeFluidTypeOnEyes:Lnet/neoforged/neoforge/fluids/FluidType;", shift = At.Shift.BY, by = -3)) | ||
private Holder<FluidType> cubic_chunks_3$fixNeoForgeRegistryError() { | ||
return Mockito.mock(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...t/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/MixinLivingEntityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.github.opencubicchunks.cubicchunks.mixin.test.common; | ||
|
||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.attributes.Attribute; | ||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; | ||
import org.mockito.Mockito; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class MixinLivingEntityTest { | ||
@Inject(method = "createLivingAttributes", at = @At(value = "HEAD"), cancellable = true) | ||
private static void cubic_chunks_3$mockLivingAttributesInitialization(CallbackInfoReturnable<AttributeSupplier.Builder> cir) { | ||
cir.setReturnValue(Mockito.mock()); | ||
} | ||
|
||
@Inject(method = "getAttributeValue(Lnet/minecraft/world/entity/ai/attributes/Attribute;)D", at = @At(value = "HEAD"), cancellable = true) | ||
private void cubic_chunks_3$fixNeoForgeErrors(Attribute pAttribute, CallbackInfoReturnable<Double> cir) { | ||
cir.setReturnValue(1d); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/MixinMobTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.github.opencubicchunks.cubicchunks.mixin.test.common; | ||
|
||
import net.minecraft.world.entity.Mob; | ||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(Mob.class) | ||
public abstract class MixinMobTest { | ||
@Inject(method = "createMobAttributes", at = @At(value = "HEAD"), cancellable = true) | ||
private static void cubic_chunks_3$fixNeoForgeErrors(CallbackInfoReturnable<AttributeSupplier.Builder> cir) { | ||
cir.setReturnValue(AttributeSupplier.builder()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/MixinPlayerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.github.opencubicchunks.cubicchunks.mixin.test.common; | ||
|
||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(Player.class) | ||
public class MixinPlayerTest { | ||
@Inject(method = "createAttributes", at = @At(value = "HEAD"), cancellable = true) | ||
private static void cubic_chunks_3$fixNeoForgeErrors(CallbackInfoReturnable<AttributeSupplier.Builder> cir) { | ||
cir.setReturnValue(AttributeSupplier.builder()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package io.github.opencubicchunks.cubicchunks.mixin.test.common; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import io.github.opencubicchunks.cc_core.annotation.MethodsReturnNonnullByDefault; |
7 changes: 7 additions & 0 deletions
7
...va/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/level/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package io.github.opencubicchunks.cubicchunks.mixin.test.common.server.level; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import io.github.opencubicchunks.cc_core.annotation.MethodsReturnNonnullByDefault; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters