Skip to content

Commit

Permalink
Merge pull request #459 from jchung01/vanilla-tweaks
Browse files Browse the repository at this point in the history
Change disconnect dupe fix event
  • Loading branch information
ACGaming authored May 9, 2024
2 parents 23c9373 + b79670d commit f7c1b1d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
package mod.acgaming.universaltweaks.bugfixes.entities.disconnectdupe;

import java.util.concurrent.FutureTask;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.fml.relauncher.Side;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.bugfixes.entities.disconnectdupe.mixin.PlayerListInvoker;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;

// Courtesy of Meldexun
@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID, value = Side.CLIENT)
// Courtesy of jchung01
@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID, value = Side.SERVER)
public class UTDisconnectDupe
{
@SubscribeEvent
public static void utDisconnectDupe(PlayerEvent.PlayerLoggedOutEvent event)
public static void utDisconnectDupe(ItemTossEvent event)
{
if (!UTConfigBugfixes.ENTITIES.utDisconnectDupeToggle || event.player.world.isRemote) return;
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTDisconnectDupe ::: Player logged out event");
MinecraftServer server = event.player.getServer();
if (server != null)
if (!UTConfigBugfixes.ENTITIES.utDisconnectDupeToggle || event.getPlayer().world.isRemote) return;
EntityPlayerMP player = (EntityPlayerMP) event.getPlayer();
if (!player.connection.getNetworkManager().channel().isOpen())
{
server.futureTaskQueue.add(new FutureTask<>(() -> {
((PlayerListInvoker) server.getPlayerList()).invokeWritePlayerData((EntityPlayerMP) event.player);
return null;
}));
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTDisconnectDupe ::: Player dropped item but is disconnected! Ignoring drop.");
event.setCanceled(true);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static class EntitiesCategory
public boolean utDestroyPacketToggle = true;

@Config.Name("Disconnect Dupe")
@Config.Comment("Fixes item duplications when players are dropping items and disconnecting (singleplayer only)")
@Config.Comment("Fixes item duplications when players are dropping items and disconnecting")
public boolean utDisconnectDupeToggle = true;

@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.bugfixes.entities.destroypacket.json", () -> UTConfigBugfixes.ENTITIES.utDestroyPacketToggle);
put("mixins.bugfixes.entities.desync.json", () -> UTConfigBugfixes.ENTITIES.ENTITY_DESYNC.utEntityDesyncToggle);
put("mixins.bugfixes.entities.dimensionchange.json", () -> UTConfigBugfixes.ENTITIES.utDimensionChangeToggle);
put("mixins.bugfixes.entities.disconnectdupe.json", () -> UTConfigBugfixes.ENTITIES.utDisconnectDupeToggle);
put("mixins.bugfixes.entities.entityid.json", () -> UTConfigBugfixes.ENTITIES.utEntityIDToggle);
put("mixins.bugfixes.entities.entitylists.json", () -> UTConfigBugfixes.ENTITIES.utEntityListsToggle);
put("mixins.bugfixes.entities.horsefalling.json", () -> UTConfigBugfixes.ENTITIES.utHorseFallingToggle);
Expand Down

This file was deleted.

0 comments on commit f7c1b1d

Please sign in to comment.