-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...n/java/io/github/rektroth/whiteout/mixin/entity/boss/dragon/EnderDragonFightAccessor.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,22 @@ | ||
/* | ||
* Patch for MC-257487 | ||
* | ||
* Authored for CraftBukkit/Spigot by Jake Potrebic <[email protected]> on November 12, 2022. | ||
* Ported to Fabric by Rektroth <[email protected]> on October 12, 2023. | ||
*/ | ||
|
||
package io.github.rektroth.whiteout.mixin.entity.boss.dragon; | ||
|
||
import net.minecraft.entity.boss.ServerBossBar; | ||
import net.minecraft.entity.boss.dragon.EnderDragonFight; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(EnderDragonFight.class) | ||
public interface EnderDragonFightAccessor { | ||
@Accessor("bossBar") | ||
public ServerBossBar getBossBar(); | ||
|
||
@Accessor("bossBar") | ||
public void setBossBar(ServerBossBar bossBar); | ||
} |
47 changes: 47 additions & 0 deletions
47
...main/java/io/github/rektroth/whiteout/mixin/entity/boss/dragon/EnderDragonFightMixin.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,47 @@ | ||
/* | ||
* Patch for MC-257487 | ||
* | ||
* Authored for CraftBukkit/Spigot by Jake Potrebic <[email protected]> on November 12, 2022. | ||
* Ported to Fabric by Rektroth <[email protected]> on October 12, 2023. | ||
*/ | ||
|
||
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.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(EnderDragonFight.class) | ||
public class EnderDragonFightMixin { | ||
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) { | ||
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() { | ||
return false; | ||
} | ||
} |