Update upstream

This commit is contained in:
IzzelAliz 2022-05-04 10:06:32 +08:00
parent ee7fcdafc0
commit 9449d0bd9c
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
9 changed files with 1 additions and 101 deletions

View File

@ -241,7 +241,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
return;
}
s = event.getReason();
ArclightCaptures.captureQuitMessage(s);
ArclightCaptures.captureQuitMessage(event.getLeaveMessage());
Component textComponent = CraftChatMessage.fromString(s, true)[0];
this.connection.send(new ClientboundDisconnectPacket(textComponent), future -> this.connection.disconnect(textComponent));
this.onDisconnect(textComponent);

View File

@ -7,7 +7,6 @@ import io.izzel.arclight.common.bridge.core.command.ICommandSourceBridge;
import io.izzel.arclight.common.bridge.core.entity.EntityBridge;
import io.izzel.arclight.common.bridge.core.entity.InternalEntityBridge;
import io.izzel.arclight.common.bridge.core.entity.LivingEntityBridge;
import io.izzel.arclight.common.bridge.core.entity.MobEntityBridge;
import io.izzel.arclight.common.bridge.core.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.core.network.datasync.EntityDataManagerBridge;
import io.izzel.arclight.common.bridge.core.world.TeleporterBridge;
@ -36,7 +35,6 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
@ -554,20 +552,6 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
@Inject(method = "load", at = @At(value = "RETURN"))
public void arclight$read$ReadBukkitValues(CompoundTag compound, CallbackInfo ci) {
// CraftBukkit start
if ((Object) this instanceof LivingEntity entity) {
this.tickCount = compound.getInt("Spigot.ticksLived");
// Reset the persistence for tamed animals
if (entity instanceof TamableAnimal && !isLevelAtLeast(compound, 2) && !compound.getBoolean("PersistenceRequired")) {
Mob entityInsentient = (Mob) entity;
((MobEntityBridge) entityInsentient).bridge$setPersistenceRequired(!entityInsentient.removeWhenFarAway(0));
}
}
this.persist = !compound.contains("Bukkit.persist") || compound.getBoolean("Bukkit.persist");
// CraftBukkit end
// CraftBukkit start - Reset world
if ((Object) this instanceof ServerPlayer) {
Server server = Bukkit.getServer();

View File

@ -34,7 +34,6 @@ import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
@ -184,15 +183,6 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri
if (canPickup) mobEntity.setCanPickUpLoot(true);
}
@Redirect(method = "readAdditionalSaveData", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/nbt/CompoundTag;getBoolean(Ljava/lang/String;)Z"))
public boolean arclight$setIfTrue(CompoundTag nbt, String key) {
if (nbt.contains("PersistenceRequired")) {
return nbt.getBoolean(key);
} else {
return !this.removeWhenFarAway(0.0);
}
}
@Inject(method = "serverAiStep", cancellable = true, at = @At("HEAD"))
private void arclight$unaware(CallbackInfo ci) {
if (!this.aware) {
@ -244,11 +234,6 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri
}
}
@Redirect(method = "checkDespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;removeWhenFarAway(D)Z"))
public boolean arclight$checkDespawn(Mob mobEntity, double distanceToClosestPlayer) {
return this.overridePersistenceRequired || mobEntity.removeWhenFarAway(distanceToClosestPlayer);
}
@Inject(method = "interact", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;dropLeash(ZZ)V"))
private void arclight$unleash(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
if (CraftEventFactory.callPlayerUnleashEntityEvent((Mob) (Object) this, player).isCancelled()) {
@ -351,11 +336,8 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri
return this.persistenceRequired;
}
@Unique private boolean overridePersistenceRequired;
public void setPersistenceRequired(boolean value) {
this.persistenceRequired = value;
this.overridePersistenceRequired = true;
}
@Override

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.world.entity.animal;
import io.izzel.arclight.common.mixin.core.world.entity.PathfinderMobMixin;
import net.minecraft.world.entity.animal.AbstractFish;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(AbstractFish.class)
public abstract class AbstractFishMixin extends PathfinderMobMixin {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public boolean removeWhenFarAway(double distanceToClosestPlayer) {
return true;
}
@Inject(method = "setFromBucket", at = @At("RETURN"))
private void arclight$updatePersist(boolean p_203706_1_, CallbackInfo ci) {
this.persistenceRequired = this.isPersistenceRequired();
}
}

View File

@ -12,7 +12,6 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
@ -96,9 +95,6 @@ public abstract class AnimalMixin extends AgeableMobMixin implements AnimalEntit
return;
}
if (child != null) {
if (child instanceof TamableAnimal && ((TamableAnimal) child).isTame()) {
child.persistenceRequired = true;
}
ServerPlayer serverplayerentity = this.getLoveCause();
if (serverplayerentity == null && animalEntity.getLoveCause() != null) {
serverplayerentity = animalEntity.getLoveCause();

View File

@ -1,9 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.entity.animal;
import io.izzel.arclight.common.mixin.core.world.entity.animal.AnimalMixin;
import net.minecraft.world.entity.animal.Chicken;
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.callback.CallbackInfo;
@ -11,17 +9,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Chicken.class)
public abstract class ChickenMixin extends AnimalMixin {
// @formatter:off
@Shadow public abstract boolean isChickenJockey();
// @formatter:on
@Inject(method = "aiStep", at = @At("HEAD"))
private void arclight$persist(CallbackInfo ci) {
if (this.isChickenJockey()) {
this.persistenceRequired = !this.removeWhenFarAway(0.0);
}
}
@Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/Chicken;spawnAtLocation(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;"))
private void arclight$forceDropOn(CallbackInfo ci) {
this.forceDrops = true;

View File

@ -1,9 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.entity.animal;
import io.izzel.arclight.common.mixin.core.world.entity.animal.AnimalMixin;
import net.minecraft.world.entity.animal.Ocelot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(Ocelot.class)
@ -14,13 +12,4 @@ public abstract class OcelotMixin extends AnimalMixin {
// @formatter:on
public boolean spawnBonus = true;
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public boolean removeWhenFarAway(double distanceToClosestPlayer) {
return !this.isTrusting() /*&& this.ticksExisted > 2400*/;
}
}

View File

@ -37,16 +37,6 @@ public abstract class WorldEntitySpawnerMixin {
@Shadow public static void spawnCategoryForChunk(MobCategory p_234967_0_, ServerLevel p_234967_1_, LevelChunk p_234967_2_, NaturalSpawner.SpawnPredicate p_234967_3_, NaturalSpawner.AfterSpawnCallback p_234967_4_) { }
// @formatter:on
@Redirect(method = "createState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;requiresCustomPersistence()Z"))
private static boolean arclight$specialDespawn(Mob mobEntity) {
return false;
}
@Redirect(method = "createState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;isPersistenceRequired()Z"))
private static boolean arclight$specialDespawn2(Mob mobEntity) {
return mobEntity.removeWhenFarAway(0) && mobEntity.isPersistenceRequired();
}
/**
* @author IzzelAliz
* @reason

View File

@ -123,7 +123,6 @@
"world.entity.ai.goal.TemptGoalMixin",
"world.entity.ai.village.VillageSiegeMixin",
"world.entity.ambient.BatMixin",
"world.entity.animal.AbstractFishMixin",
"world.entity.animal.AnimalMixin",
"world.entity.animal.Bee_GrowCropGoalMixin",
"world.entity.animal.Bee_HurtByOtherGoalMixin",