test again
This commit is contained in:
@@ -1,69 +0,0 @@
|
|||||||
package io.akarin.server.mixin.nsc;
|
|
||||||
|
|
||||||
import java.util.Queue;
|
|
||||||
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 com.googlecode.concurentlocks.ReentrantReadWriteUpdateLock;
|
|
||||||
|
|
||||||
import io.akarin.api.internal.utils.CheckedConcurrentLinkedQueue;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.util.concurrent.Future;
|
|
||||||
import io.netty.util.concurrent.GenericFutureListener;
|
|
||||||
import net.minecraft.server.NetworkManager;
|
|
||||||
import net.minecraft.server.NetworkManager.QueuedPacket;
|
|
||||||
import net.minecraft.server.Packet;
|
|
||||||
import net.minecraft.server.PacketPlayOutMapChunk;
|
|
||||||
|
|
||||||
@Mixin(value = NetworkManager.class, remap = false)
|
|
||||||
public abstract class OptimisticNetworkManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* todo need to be fixed in near future
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
@Shadow public Channel channel;
|
|
||||||
@Shadow(aliases = "i") @Final private Queue<NetworkManager.QueuedPacket> packets;
|
|
||||||
@Shadow(aliases = "j") @Final private ReentrantReadWriteUpdateLock queueLock;
|
|
||||||
|
|
||||||
@Shadow public abstract Queue<NetworkManager.QueuedPacket> getPacketQueue();
|
|
||||||
@Shadow public abstract void dispatchPacket(Packet<?> packet, GenericFutureListener<? extends Future<? super Void>>[] genericFutureListeners);
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static final QueuedPacket SIGNAL_PACKET = new QueuedPacket(null);
|
|
||||||
|
|
||||||
@Overwrite // OBFHELPER: trySendQueue
|
|
||||||
private boolean m() {
|
|
||||||
if (this.channel != null && this.channel.isOpen()) {
|
|
||||||
if (this.packets.isEmpty()) { // return if the packet queue is empty so that the write lock by Anti-Xray doesn't affect the vanilla performance at all
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.queueLock.updateLock().lock();
|
|
||||||
try {
|
|
||||||
while (!this.packets.isEmpty()) {
|
|
||||||
NetworkManager.QueuedPacket packet = ((CheckedConcurrentLinkedQueue<QueuedPacket>) getPacketQueue()).poll(item -> {
|
|
||||||
return item.getPacket() instanceof PacketPlayOutMapChunk && !((PacketPlayOutMapChunk) item.getPacket()).isReady();
|
|
||||||
}, SIGNAL_PACKET);
|
|
||||||
|
|
||||||
if (packet != null) { // Fix NPE (Spigot bug caused by handleDisconnection())
|
|
||||||
if (packet == SIGNAL_PACKET) {
|
|
||||||
return false; // Return false if the peeked packet is a chunk packet which is not ready
|
|
||||||
} else {
|
|
||||||
dispatchPacket(packet.getPacket(), packet.getGenericFutureListeners()); // dispatch the packet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
this.queueLock.updateLock().unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return true; // Return true if all packets were dispatched
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Sponge, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.akarin.server.mixin.optimization;
|
|
||||||
|
|
||||||
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 net.minecraft.server.DamageSource;
|
|
||||||
import net.minecraft.server.EnchantmentManager;
|
|
||||||
import net.minecraft.server.Entity;
|
|
||||||
import net.minecraft.server.EntityHuman;
|
|
||||||
import net.minecraft.server.EntityLiving;
|
|
||||||
import net.minecraft.server.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fixes MC-128547(https://bugs.mojang.com/browse/MC-128547)
|
|
||||||
*/
|
|
||||||
@Mixin(value = EnchantmentManager.class, remap = false)
|
|
||||||
public abstract class WeakEnchantmentManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* todo need to be fixed in near future
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
@Shadow(aliases = "a") @Final private static EnchantmentManager.EnchantmentModifierProtection protection;
|
|
||||||
@Shadow(aliases = "c") @Final private static EnchantmentManager.EnchantmentModifierThorns thorns;
|
|
||||||
@Shadow(aliases = "d") @Final private static EnchantmentManager.EnchantmentModifierArthropods arthropods;
|
|
||||||
|
|
||||||
@Shadow private static void a(EnchantmentManager.EnchantmentModifier modifier, Iterable<ItemStack> iterable) {}
|
|
||||||
@Shadow private static void a(EnchantmentManager.EnchantmentModifier modifier, ItemStack itemstack) {}
|
|
||||||
|
|
||||||
@Overwrite
|
|
||||||
public static int a(Iterable<ItemStack> iterable, DamageSource damageSource) {
|
|
||||||
protection.a = 0; // OBFHELPER: damageModifier
|
|
||||||
protection.b = damageSource;
|
|
||||||
a(protection, iterable); // OBFHELPER: applyEnchantmentModifierArray
|
|
||||||
protection.b = null; // Akarin - Remove reference to Damagesource
|
|
||||||
return protection.a;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Overwrite
|
|
||||||
public static void a(EntityLiving user, Entity attacker) { // OBFHELPER: applyThornEnchantments
|
|
||||||
thorns.b = attacker;
|
|
||||||
thorns.a = user;
|
|
||||||
if (user != null) {
|
|
||||||
a(thorns, user.aQ()); // OBFHELPER: applyEnchantmentModifierArray - getEquipmentAndArmor
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attacker instanceof EntityHuman) {
|
|
||||||
a(thorns, user.getItemInMainHand()); // OBFHELPER: applyEnchantmentModifier
|
|
||||||
}
|
|
||||||
|
|
||||||
// Akarin Start - remove references to entity objects to avoid memory leaks
|
|
||||||
thorns.b = null;
|
|
||||||
thorns.a = null;
|
|
||||||
// Akarin end
|
|
||||||
}
|
|
||||||
|
|
||||||
@Overwrite
|
|
||||||
public static void b(EntityLiving user, Entity target) { // OBFHELPER: applyArthropodEnchantments
|
|
||||||
arthropods.a = user;
|
|
||||||
arthropods.b = target;
|
|
||||||
if (user != null) {
|
|
||||||
a(arthropods, user.aQ()); // OBFHELPER: applyEnchantmentModifierArray - getEquipmentAndArmor
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user instanceof EntityHuman) {
|
|
||||||
a(arthropods, user.getItemInMainHand()); // OBFHELPER: applyEnchantmentModifier
|
|
||||||
}
|
|
||||||
|
|
||||||
Akarin Start - remove references to entity objects to avoid memory leaks
|
|
||||||
arthropods.a = null;
|
|
||||||
arthropods.b = null;
|
|
||||||
// Akarin end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user