This commit is contained in:
skippyall
2024-09-17 09:55:43 +02:00
parent c497884884
commit 1dd6914454
27 changed files with 307 additions and 382 deletions
@@ -1,24 +0,0 @@
package io.github.skippyall.minions.mixins;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.world.PlayerSaveHandler;
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;
import java.util.Optional;
@Mixin(PlayerSaveHandler.class)
public class Debug2Mixin {
@Inject(method = "method_55788", at = @At("HEAD"))
public void debug(PlayerEntity playerEntity, NbtCompound nbt, CallbackInfoReturnable<NbtCompound> cir) {
System.out.println("loadPlayerData " + playerEntity.getNameForScoreboard());
}
@Inject(method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;Ljava/lang/String;)Ljava/util/Optional;", at = @At("RETURN"))
public void debug(PlayerEntity player, String extension, CallbackInfoReturnable<Optional<NbtCompound>> cir) {
System.out.println(cir.getReturnValue().isEmpty() + player.getUuidAsString());
}
}
@@ -1,32 +0,0 @@
package io.github.skippyall.minions.mixins;
import com.llamalad7.mixinextras.sugar.Local;
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NbtCompound;
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.CallbackInfo;
//@Mixin(SectionedEntityCache.class)
@Mixin(Entity.class)
public class DebugMixin {
/*@Inject(method = "forEachInBox", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ChunkSectionPos;asLong(III)J", shift = At.Shift.BEFORE, ordinal = 0))
private void debug(Box box, LazyIterationConsumer<EntityTrackingSection<?>> consumer, CallbackInfo ci) {
System.out.println("call");
}*/
@Inject(method = "readNbt", at = @At("HEAD"))
public void debug(NbtCompound nbt, CallbackInfo ci) {
if ((Object) this instanceof MinionFakePlayer) {
System.out.println("readNBT");
}
}
@Inject(method = "setPos", at = @At("HEAD"))
public void debug(double x, double y, double z, CallbackInfo ci) {
if ((Object) this instanceof MinionFakePlayer) {
//System.out.println("Set Minion Pos to " + x + " " + y + " " + z);
}
}
}
@@ -1,15 +0,0 @@
package io.github.skippyall.minions.mixins;
import com.mojang.authlib.GameProfile;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.UUID;
@Mixin(value = GameProfile.class, remap = false)
public interface GameProfileMixin{
@Mutable
@Accessor("id")
void setId(UUID id);
}
@@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
public abstract class MobEntityMixin {
@Redirect(method = "checkDespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getClosestPlayer(Lnet/minecraft/entity/Entity;D)Lnet/minecraft/entity/player/PlayerEntity;"))
public PlayerEntity checkMobDespawningMinion(World instance, Entity entity, double maxDistance) {
return instance.getClosestPlayer(entity.getX(), entity.getY(), entity.getZ(), maxDistance, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(entity1 -> {
return instance.getClosestPlayer(entity.getX(), entity.getY(), entity.getZ(), maxDistance, EntityPredicates.EXCEPT_SPECTATOR.and(entity1 -> {
if(entity1 instanceof ServerPlayerEntity player) {
if(player instanceof MinionFakePlayer minion) {
return MobSpawningModule.canMinionDespawnMobs(minion);
@@ -0,0 +1,21 @@
package io.github.skippyall.minions.mixins;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.SleepManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(SleepManager.class)
public class SleepManagerMixin {
@WrapOperation(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;isSpectator()Z"))
public boolean excludeMinions(ServerPlayerEntity instance, Operation<Boolean> original) {
if (instance instanceof MinionFakePlayer) {
return true;
} else {
return original.call(instance);
}
}
}
@@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
public class SpawnHelperMixin {
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;getClosestPlayer(DDDDZ)Lnet/minecraft/entity/player/PlayerEntity;"))
private static PlayerEntity checkMobSpawningMinion(ServerWorld instance, double x, double y, double z, double maxDistance, boolean b) {
return instance.getClosestPlayer(x, y, z, maxDistance, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(entity -> {
return instance.getClosestPlayer(x, y, z, maxDistance, EntityPredicates.EXCEPT_SPECTATOR.and(entity -> {
if(entity instanceof ServerPlayerEntity player) {
if(player instanceof MinionFakePlayer minion) {
return MobSpawningModule.canMinionSpawnMobs(minion);