Skip to content

Commit

Permalink
Improve dimension change tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jun 3, 2024
1 parent 77d1825 commit 6d987f6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import mod.acgaming.universaltweaks.bugfixes.blocks.blockoverlay.UTBlockOverlayLists;
import mod.acgaming.universaltweaks.bugfixes.entities.desync.UTEntityDesync;
import mod.acgaming.universaltweaks.bugfixes.entities.dimensionchange.UTDimensionChangeEvents;
import mod.acgaming.universaltweaks.bugfixes.misc.help.UTHelp;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
Expand Down Expand Up @@ -46,7 +45,6 @@
import mod.acgaming.universaltweaks.tweaks.performance.autosave.UTAutoSaveOFCompat;
import mod.acgaming.universaltweaks.tweaks.performance.craftingcache.UTCraftingCache;
import mod.acgaming.universaltweaks.tweaks.performance.entityradiuscheck.UTEntityRadiusCheck;
import mod.acgaming.universaltweaks.tweaks.world.voidfog.UTVoidFog;
import mod.acgaming.universaltweaks.util.UTKeybindings;
import mod.acgaming.universaltweaks.util.UTPacketHandler;
import mod.acgaming.universaltweaks.util.UTReflectionUtil;
Expand Down Expand Up @@ -152,7 +150,6 @@ public void preInit(FMLPreInitializationEvent event)
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
if (UTConfigBugfixes.ENTITIES.utDimensionChangeToggle) MinecraftForge.EVENT_BUS.register(new UTDimensionChangeEvents());
if (UTConfigTweaks.MISC.ARMOR_CURVE.utArmorCurveToggle) UTArmorCurve.initExpressions();
if (Loader.isModLoaded("abyssalcraft") && UTConfigMods.ABYSSALCRAFT.utOptimizedItemTransferToggle) MinecraftForge.EVENT_BUS.register(new UTAbyssalCraftEvents());
if (Loader.isModLoaded("arcanearchives") && UTConfigMods.ARCANE_ARCHIVES.utDuplicationFixesToggle) MinecraftForge.EVENT_BUS.register(new UTArcaneArchivesEvents());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package mod.acgaming.universaltweaks.bugfixes.entities.dimensionchange.mixin;

import com.mojang.authlib.GameProfile;
import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.play.server.SPacketEntityEffect;
import net.minecraft.network.play.server.SPacketPlayerAbilities;
import net.minecraft.network.play.server.SPacketSetExperience;
import net.minecraft.network.play.server.SPacketUpdateHealth;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ITeleporter;

import com.mojang.authlib.GameProfile;
import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -24,28 +21,32 @@

// MC-124177
// https://bugs.mojang.com/browse/MC-124177
// Courtesy of FxMorin
@Mixin(EntityPlayerMP.class)
public abstract class UTDimensionChangeMixin extends EntityPlayer
{
@Shadow
public NetHandlerPlayServer connection;
@Shadow public NetHandlerPlayServer connection;

@Shadow private int lastExperience;

@Shadow private float lastHealth;

@Shadow private int lastFoodLevel;

protected UTDimensionChangeMixin(World worldIn, GameProfile gameProfileIn)
{
super(worldIn, gameProfileIn);
}

@Inject(method = "changeDimension", at = @At(value = "HEAD"), remap = false)
@Inject(method = "changeDimension", at = @At(value = "TAIL"), remap = false)
public void utChangeDimension(int dimensionIn, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir)
{
if (!UTConfigBugfixes.ENTITIES.utDimensionChangeToggle) return;
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTDimensionChange ::: Change dimension");
this.connection.sendPacket(new SPacketUpdateHealth(this.getHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel()));
this.connection.sendPacket(new SPacketSetExperience(this.experience, this.experienceTotal, this.experienceLevel));
this.connection.sendPacket(new SPacketPlayerAbilities(this.capabilities));
for (PotionEffect effect : getActivePotionEffects())
{
this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), effect));
}
for (PotionEffect effect : this.getActivePotionEffects()) this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), effect));
this.lastExperience = -1;
this.lastHealth = -1.0F;
this.lastFoodLevel = -1;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package mod.acgaming.universaltweaks.bugfixes.entities.dimensionchange.mixin;

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.network.play.server.SPacketServerDifficulty;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.PlayerList;
import net.minecraftforge.common.util.ITeleporter;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down

0 comments on commit 6d987f6

Please sign in to comment.