-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Rule:
lavaDamageDesyncFix
,clientSideDamageDesyncFix
,`chatLa…
…gFix`
- Loading branch information
Showing
8 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...n/java/carpetfixes/mixins/coreSystemFixes/YggdrasilUserApiService_syncBlockListMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package carpetfixes.mixins.coreSystemFixes; | ||
|
||
import carpetfixes.CarpetFixesSettings; | ||
import com.mojang.authlib.yggdrasil.YggdrasilUserApiService; | ||
import com.mojang.authlib.yggdrasil.response.BlockListResponse; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
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.Redirect; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(YggdrasilUserApiService.class) | ||
public abstract class YggdrasilUserApiService_syncBlockListMixin { | ||
|
||
@Shadow protected abstract Set<UUID> fetchBlockList(); | ||
|
||
@Shadow private Set<UUID> blockList; | ||
|
||
|
||
@Redirect( | ||
method = "isBlockedPlayer(Ljava/util/UUID;)Z", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lcom/mojang/authlib/yggdrasil/YggdrasilUserApiService;fetchBlockList()Ljava/util/Set;" | ||
) | ||
) | ||
public Set<UUID> isBlockedPlayerFetchAsync(YggdrasilUserApiService instance) { | ||
if (CarpetFixesSettings.chatLagFix) { | ||
CompletableFuture.runAsync(() -> this.blockList = this.fetchBlockList()); | ||
return null; //Skip first laggy check. Although load the blocklist async for the next messages | ||
} | ||
return this.fetchBlockList(); | ||
} | ||
|
||
|
||
@Redirect( | ||
method = "forceFetchBlockList()Ljava/util/Set;", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lcom/mojang/authlib/yggdrasil/response/BlockListResponse;getBlockedProfiles()Ljava/util/Set;" | ||
) | ||
) | ||
private Set<UUID> forceFetchBlockListDontReturnNull(BlockListResponse instance) { | ||
if (CarpetFixesSettings.chatLagFix) { //Do not return null or else the system will think the blockList is not loaded | ||
Set<UUID> uuids = instance.getBlockedProfiles(); | ||
return uuids == null ? new HashSet<UUID>() : uuids; | ||
} | ||
return instance.getBlockedProfiles(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/carpetfixes/mixins/entityFixes/Entity_clientDamageMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package carpetfixes.mixins.entityFixes; | ||
|
||
import carpetfixes.CarpetFixesSettings; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.ExperienceOrbEntity; | ||
import net.minecraft.entity.ItemEntity; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.world.World; | ||
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.CallbackInfoReturnable; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(Entity.class) | ||
public class Entity_clientDamageMixin { | ||
|
||
@Shadow public World world; | ||
|
||
private final Entity self = (Entity) (Object) this; | ||
|
||
|
||
@Inject( | ||
method = "isInvulnerableTo(Lnet/minecraft/entity/damage/DamageSource;)Z", | ||
at = @At("HEAD"), | ||
cancellable = true | ||
) | ||
public void isInvulnerableToAndClient(DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) { | ||
if (CarpetFixesSettings.clientSideDamageDesyncFix && (self instanceof ItemEntity || self instanceof ExperienceOrbEntity)) { | ||
cir.setReturnValue(true); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/carpetfixes/mixins/entityFixes/Entity_lavaDamageMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package carpetfixes.mixins.entityFixes; | ||
|
||
import carpetfixes.CarpetFixesSettings; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.world.World; | ||
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.CallbackInfoReturnable; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(Entity.class) | ||
public class Entity_lavaDamageMixin { | ||
|
||
@Shadow public World world; | ||
|
||
|
||
@Inject( | ||
method = "isFireImmune()Z", | ||
at = @At("HEAD"), | ||
cancellable = true | ||
) | ||
public void isFireImmuneAndServerSide(CallbackInfoReturnable<Boolean> cir) { | ||
if (CarpetFixesSettings.lavaDamageDesyncFix && this.world.isClient()) cir.setReturnValue(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters