Port to 26.1
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public interface EntityAccessor {
|
||||
@@ -12,5 +12,5 @@ public interface EntityAccessor {
|
||||
boolean minions$canAddPassenger(Entity other);
|
||||
|
||||
@Invoker("getIndirectPassengersStream")
|
||||
Stream<Entity> minions$streamIntoPassengers();
|
||||
Stream<Entity> minions$getIndirectPassengersStream();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import io.github.skippyall.minions.mixinhelper.EntityViewMixinHelper;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.EntityGetter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.EntityGetter;
|
||||
|
||||
@Mixin(EntityGetter.class)
|
||||
public interface EntityGetterMixin {
|
||||
|
||||
@@ -22,6 +22,6 @@ public abstract class EntityMixin {
|
||||
@Inject(method = "isLocalInstanceAuthoritative", at = @At("HEAD"), cancellable = true)
|
||||
private void isFakePlayer(CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (getControllingPassenger() instanceof MinionFakePlayer) cir.setReturnValue(!level.isClientSide);
|
||||
if (getControllingPassenger() instanceof MinionFakePlayer) cir.setReturnValue(!level.isClientSide());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.skin.Base64SkinProvider;
|
||||
import io.github.skippyall.minions.registration.MinionConfigOptions;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -29,7 +29,7 @@ public class MinecraftServerMixin {
|
||||
}
|
||||
|
||||
@Inject(method = "handleCustomClickAction", at = @At("HEAD"), cancellable = true)
|
||||
private void onCustomClickAction(ResourceLocation id, Optional<Tag> payload, CallbackInfo ci) {
|
||||
private void onCustomClickAction(Identifier id, Optional<Tag> payload, CallbackInfo ci) {
|
||||
if(id.equals(Base64SkinProvider.CUSTOM_DIALOG_ACTION)) {
|
||||
Base64SkinProvider.onCustomDialogAction(payload);
|
||||
ci.cancel();
|
||||
|
||||
@@ -18,23 +18,20 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mixin(PlayerList.class)
|
||||
public class PlayerListMixin {
|
||||
|
||||
@Inject(method = "load", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void fixStartingPos(ServerPlayer player, ProblemReporter errorReporter, CallbackInfoReturnable<Optional<ValueInput>> cir)
|
||||
@Inject(method = "placeNewPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;level()Lnet/minecraft/server/level/ServerLevel;"))
|
||||
private void fixStartingPos(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci)
|
||||
{
|
||||
if (player instanceof MinionFakePlayer)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ public abstract class PlayerMixin {
|
||||
* To make sure player attacks are able to knockback fake players
|
||||
*/
|
||||
@ModifyExpressionValue(
|
||||
method = "attack",
|
||||
method = "causeExtraKnockback",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "Lnet/minecraft/world/entity/Entity;hurtMarked:Z",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
@@ -22,7 +23,7 @@ public abstract class TickRateManagerMixin {
|
||||
|
||||
return !isActualPlayer(entity) && // not carrying players
|
||||
((EntityAccessor) entity)
|
||||
.minions$streamIntoPassengers()
|
||||
.minions$getIndirectPassengersStream()
|
||||
.noneMatch(TickRateManagerMixin::isActualPlayer);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -18,9 +18,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = DistanceManager.FixedPlayerDistanceChunkTracker.class)
|
||||
public abstract class DistanceManager$FixedPlayerDistanceChunkTrackerMixin extends ChunkTrackerMixin implements ChunkLevelManager$DistanceFromNearestPlayerTrackerAccessor {
|
||||
@Final
|
||||
@Shadow
|
||||
DistanceManager field_17462;
|
||||
@Final
|
||||
DistanceManager this$0;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@@ -40,7 +40,7 @@ public abstract class DistanceManager$FixedPlayerDistanceChunkTrackerMixin exten
|
||||
|
||||
@Override
|
||||
public boolean minions$isRealPlayerInChunk(long chunkPos) {
|
||||
ObjectSet<ServerPlayer> players = ((ChunkLevelManagerAccessor)field_17462).minions$getPlayers(chunkPos);
|
||||
ObjectSet<ServerPlayer> players = ((ChunkLevelManagerAccessor)this$0).minions$getPlayers(chunkPos);
|
||||
boolean contains = false;
|
||||
if(players != null) {
|
||||
contains = players.stream().anyMatch(player -> {
|
||||
@@ -56,14 +56,14 @@ public abstract class DistanceManager$FixedPlayerDistanceChunkTrackerMixin exten
|
||||
@Inject(method = "runAllUpdates", at = @At("HEAD"))
|
||||
public void minions$sync(CallbackInfo info) {
|
||||
if (minions$target) {
|
||||
((ChunkLevelManagerAccessor)field_17462).minions$getMinionless().runAllUpdates();
|
||||
((ChunkLevelManagerAccessor)this$0).minions$getMinionless().runAllUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void minions$updateLevel(long chunkPos, int distance, boolean decrease, CallbackInfo info) {
|
||||
if (minions$target && (distance == Integer.MAX_VALUE || minions$isRealPlayerInChunk(chunkPos))) {
|
||||
((ChunkLevelManagerAccessor)field_17462).minions$getMinionless().update(chunkPos, distance, decrease);
|
||||
((ChunkLevelManagerAccessor)this$0).minions$getMinionless().update(chunkPos, distance, decrease);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -5,6 +5,10 @@ import io.github.skippyall.minions.mixinhelper.antimobcap.ChunkLevelManager$Dist
|
||||
import io.github.skippyall.minions.mixinhelper.antimobcap.ChunkLevelManagerAccessor;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.TicketStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -14,10 +18,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.TicketStorage;
|
||||
|
||||
@Mixin(DistanceManager.class)
|
||||
public class DistanceManagerMixin implements ChunkLevelManagerAccessor {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(Grave.class)
|
||||
public class GraveMixin {
|
||||
@ModifyArg(method = "createBlock", at = @At(value = "INVOKE", target = "Leu/pb4/graves/grave/Grave;<init>(JLcom/mojang/authlib/GameProfile;BLnet/minecraft/world/entity/HumanoidArm;Lnet/minecraft/core/BlockPos;Lnet/minecraft/resources/ResourceLocation;Leu/pb4/graves/grave/GraveType;JJILnet/minecraft/network/chat/Component;Ljava/util/Collection;Ljava/util/Collection;ZI)V"))
|
||||
@ModifyArg(method = "createBlock", at = @At(value = "INVOKE", target = "Leu/pb4/graves/grave/Grave;<init>(JLcom/mojang/authlib/GameProfile;BLnet/minecraft/world/entity/HumanoidArm;Lnet/minecraft/core/BlockPos;Lnet/minecraft/resources/Identifier;Leu/pb4/graves/grave/GraveType;JJILnet/minecraft/network/chat/Component;Ljava/util/Collection;Ljava/util/Collection;ZI)V"))
|
||||
private static boolean createGrave(boolean profile, @Local(argsOnly = true) ServerPlayer player) {
|
||||
if(player instanceof MinionFakePlayer) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user