From 7f286f8d8801cb005e436f967e56ffef5e2683ae Mon Sep 17 00:00:00 2001 From: Merrg1n <22628584+Merrg1n@users.noreply.github.com> Date: Sun, 14 Aug 2022 15:32:05 +0800 Subject: rewrite force ripening mixins, may fix #1 --- .../PlayerManagerMixin.java | 106 +++------------------ 1 file changed, 15 insertions(+), 91 deletions(-) (limited to 'src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping') diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java index f4f8bec..d3c87d8 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java @@ -1,105 +1,29 @@ package com.keuin.ohmyvanillamc.mixins.rule.reintroduceLlamaItemDuping; import com.keuin.ohmyvanillamc.OmvmSettings; -import net.minecraft.advancement.PlayerAdvancementTracker; import net.minecraft.entity.Entity; -import net.minecraft.network.Packet; -import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.PlayerManager; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.stat.ServerStatHandler; -import net.minecraft.stat.Stats; -import org.apache.logging.log4j.Logger; -import org.spongepowered.asm.mixin.Final; +import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; /** * Reintroduce MC-161754 glitch */ @Mixin(PlayerManager.class) public abstract class PlayerManagerMixin { - - @Shadow - protected abstract void savePlayerData(ServerPlayerEntity player); - - @Shadow - @Final - private static Logger LOGGER; - - @Shadow - @Final - private List players; - - @Shadow - @Final - private MinecraftServer server; - - @Shadow - @Final - private Map playerMap; - - @Shadow - @Final - private Map statisticsMap; - - @Shadow - @Final - private Map advancementTrackers; - - @Shadow - public abstract void sendToAll(Packet packet); - - /** - * @reason re-introduce llama item duplicating glitch. - * @author trueKeuin - */ - @Overwrite - public void remove(ServerPlayerEntity player) { - ServerWorld serverWorld = player.getServerWorld(); - player.incrementStat(Stats.LEAVE_GAME); - this.savePlayerData(player); - if (player.hasVehicle()) { - Entity entity = player.getRootVehicle(); - if (entity.hasPlayerRider()) { - LOGGER.debug("Removing player mount"); - player.stopRiding(); - serverWorld.removeEntity(entity); - // entity.removed = true - entity.removed = !OmvmSettings.reintroduceLlamaItemDuplicating || entity.removed; - - Entity entity2; - for (Iterator var4 = entity.getPassengersDeep().iterator(); var4.hasNext(); // entity2.removed = true - entity2.removed = !OmvmSettings.reintroduceLlamaItemDuplicating || entity2.removed) { - entity2 = (Entity) var4.next(); - serverWorld.removeEntity(entity2); - } - - serverWorld.getChunk(player.chunkX, player.chunkZ).markDirty(); - } - } - - player.detach(); - serverWorld.removePlayer(player); - player.getAdvancementTracker().clearCriteria(); - this.players.remove(player); - this.server.getBossBarManager().onPlayerDisconnect(player); - UUID uUID = player.getUuid(); - ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) this.playerMap.get(uUID); - if (serverPlayerEntity == player) { - this.playerMap.remove(uUID); - this.statisticsMap.remove(uUID); - this.advancementTrackers.remove(uUID); - } - - this.sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.REMOVE_PLAYER, player)); + @Redirect( + method = "remove", + at = @At( + value = "FIELD", + opcode = Opcodes.PUTFIELD, + target = "Lnet/minecraft/entity/Entity;removed:Z" + ), + require = 2 + ) + private void Entity_setRemoved(Entity entity, boolean value) { +// OmvmExtension.LOGGER.info("set entity remove!"); + entity.removed = !OmvmSettings.reintroduceLlamaItemDuplicating || entity.removed; } } -- cgit v1.2.3