5
5
import net .fabricmc .loader .api .FabricLoader ;
6
6
import net .minecraft .client .MinecraftClient ;
7
7
import net .minecraft .client .gui .DrawableHelper ;
8
+ import net .minecraft .client .network .ClientPlayerEntity ;
8
9
import net .minecraft .client .render .*;
9
10
import net .minecraft .client .util .math .MatrixStack ;
10
11
import net .minecraft .item .ItemStack ;
11
12
import net .minecraft .util .Identifier ;
12
13
13
14
public abstract class RendererBase extends DrawableHelper implements HudRenderCallback {
14
- private static final Identifier TEX = new Identifier ("microdurability" , "textures/gui/icons.png" );
15
+ protected static final Identifier TEX = new Identifier ("microdurability" , "textures/gui/icons.png" );
15
16
private final MinecraftClient mc ;
16
17
17
18
private float time = 0 ;
@@ -28,7 +29,7 @@ public void onHudRender(MatrixStack matrixStack, float delta) {
28
29
29
30
// Render held item low durability warning
30
31
if (MicroDurability .config .lowDurabilityWarning .displayWarningForTools ) {
31
- for (ItemStack item : mc .player . getItemsHand ( )) {
32
+ for (ItemStack item : getHandItems ( mc .player )) {
32
33
if (MicroDurability .shouldWarn (item )) {
33
34
if (MicroDurability .config .lowDurabilityWarning .blinkTime > 0
34
35
&& time < MicroDurability .config .lowDurabilityWarning .blinkTime * 20f ) {
@@ -84,9 +85,7 @@ public void renderBar(ItemStack stack, int x, int y) {
84
85
if (!MicroDurability .config .armorBars .displayBarsForUndamagedArmor && !stack .isItemBarVisible ()) return ;
85
86
if (!stack .isDamageable ()) return ;
86
87
87
- RenderSystem .disableDepthTest ();
88
- RenderSystem .disableTexture ();
89
- RenderSystem .disableBlend ();
88
+ disableRenderSystems ();
90
89
Tessellator tessellator = Tessellator .getInstance ();
91
90
BufferBuilder bufferBuilder = tessellator .getBuffer ();
92
91
int width = stack .getItemBarStep ();
@@ -109,10 +108,13 @@ public void renderBar(ItemStack stack, int x, int y) {
109
108
alpha = 255 ;
110
109
}
111
110
this .renderGuiQuad (bufferBuilder , x , y , width , 1 , red , green , blue , alpha );
112
- RenderSystem .enableBlend ();
113
- RenderSystem .enableTexture ();
114
- RenderSystem .enableDepthTest ();
111
+ enableRenderSystems ();
115
112
}
116
113
114
+ protected abstract void enableRenderSystems ();
115
+ protected abstract void disableRenderSystems ();
116
+
117
+ protected abstract Iterable <ItemStack > getHandItems (ClientPlayerEntity e );
118
+
117
119
protected abstract void renderGuiQuad (BufferBuilder buffer , int x , int y , int width , int height , int red , int green , int blue , int alpha );
118
120
}
0 commit comments