Skip to content

Commit

Permalink
Make it actually work :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rektroth committed Apr 24, 2024
1 parent 44a7104 commit 264ba39
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Whiteout is an attempt to implement the bug fixes offered by the [Paper](https:/
## Patches
### Present

| Bug | Lazy? | Name |
|-----------|-------|-----------------------------------------------------------------------------------------------------|
| [MC-4](https://bugs.mojang.com/browse/MC-4) | Yes | Item drops sometimes appear at the wrong location |
| [MC-158900](https://bugs.mojang.com/browse/MC-158900) | No | "bad packet id 26" upon connecting after tempban expire |
| Bug | Lazy? | Name |
|-------------------------------------------------------|-------|----------------------------------------------------------------------|
| [MC-4](https://bugs.mojang.com/browse/MC-4) | Yes | Item drops sometimes appear at the wrong location |
| [MC-158900](https://bugs.mojang.com/browse/MC-158900) | No | "bad packet id 26" upon connecting after tempban expire |
| [MC-257487](https://bugs.mojang.com/browse/MC-257487) | No | The ender dragon's name is not reset when it is respawned in the end |

Some of the patches are "lazy". This means that the Paper maintainers are not incredibly pleased with the manner in which the bug was patched, but the patch works nonetheless. These patches will be disabled by default when configurability is implemented.

Expand Down Expand Up @@ -40,7 +41,6 @@ Some of the patches are "lazy". This means that the Paper maintainers are not in
| [MC-252817](https://bugs.mojang.com/browse/MC-252817) | Placing a map into an item frame and removing it does not remove the green player marker |
| [MC-253884](https://bugs.mojang.com/browse/MC-253884) | Particles produced from the bad omen effect being consumed cannot be seen by other player |
| [MC-253721](https://bugs.mojang.com/browse/MC-253721) | Wrong logs when running /op @a |
| [MC-257487](https://bugs.mojang.com/browse/MC-257487) | The ender dragon's name is not reset when it is respawned in the end |

Although MC-27056 covers the most common permanent block breaking exploit, Paper's general patch for breaking permanent blocks is also planned, as well as the general patch for gravity block duplication.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@
public interface EnderDragonFightAccessor {
@Accessor("bossBar")
public ServerBossBar getBossBar();

@Accessor("bossBar")
public void setBossBar(ServerBossBar bossBar);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,35 @@
package io.github.rektroth.whiteout.mixin.entity.boss.dragon;

import io.github.rektroth.whiteout.mixin.entity.boss.dragon.EnderDragonFightAccessor;
import net.minecraft.entity.boss.BossBar;
import net.minecraft.entity.boss.ServerBossBar;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.boss.dragon.EnderDragonFight;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EnderDragonFight.class)
public class EnderDragonFightMixin {
@Unique
private static final Text DEFAULT_BOSS_EVENT_NAME = Text.translatable("entity.minecraft.ender_dragon");

@Inject(at = @At("HEAD"), method = "<init>")
private void fixBossBar() {
((EnderDragonFightAccessor)((EnderDragonFight)(Object)this)).setBossBar((ServerBossBar)(new ServerBossBar(DEFAULT_BOSS_EVENT_NAME, BossBar.Color.PINK, BossBar.Style.PROGRESS)).setDragonMusic(true).setThickenFog(true));
}

@Inject(at = @At("TAIL"), method = "updateFight(Lnet/minecraft/entity/boss/dragon/EnderDragonEntity;)V")
private void fixedCustomNameCheck(EnderDragonEntity dragon) {
private void fixedCustomNameCheck(EnderDragonEntity dragon, CallbackInfo ci) {
ServerBossBar bossBar = ((EnderDragonFightAccessor)((EnderDragonFight)(Object)this)).getBossBar();

if (dragon.hasCustomName()) {
bossBar.setName(dragon.getDisplayName());
} else {
bossBar.setName(DEFAULT_BOSS_EVENT_NAME);
}

((EnderDragonFightAccessor)((EnderDragonFight)(Object)this)).setBossBar(bossBar);
}

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/boss/dragon/EnderDragonEntity;hasCustomName()Z"), method = "updateFight(Lnet/minecraft/entity/boss/dragon/EnderDragonEntity;)V")
private boolean skipBadCustomNameCheck() {
private boolean skipBadCustomNameCheck(EnderDragonEntity instance) {
return false;
}
}
4 changes: 3 additions & 1 deletion src/main/resources/whiteout.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"mixins": [
"entity.EntityMixin",
"server.PlayerManagerAccessor",
"server.PlayerManagerMixin"
"server.PlayerManagerMixin",
"entity.boss.dragon.EnderDragonFightAccessor",
"entity.boss.dragon.EnderDragonFightMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 264ba39

Please sign in to comment.