| 1 |  |  | package de.pewpewproject.lasertag.client.screen.widget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | import net.minecraft.client.font.TextRenderer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | import net.minecraft.client.gui.Drawable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | import net.minecraft.client.gui.DrawableHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | import net.minecraft.client.gui.Element; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | import net.minecraft.client.gui.Selectable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | import net.minecraft.client.util.math.MatrixStack; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | import net.minecraft.text.Text; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * Widget for a simple label | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @author Étienne Muser | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | public class LabelWidget extends DrawableHelper implements Drawable, Element, Selectable { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     private final int x; | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     private final int y; | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |     private final TextRenderer textRenderer; | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     private final Text text; | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     private final int color; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |      * Create a white label | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |      * @param x The x-position of the label (reference is left) | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      * @param y The y-position of the label (reference is top) | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |      * @param textRenderer The text renderer to use to render the label | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |      * @param text The text of the widget | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     public LabelWidget(int x, int y, TextRenderer textRenderer, Text text) { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         this(x, y, textRenderer, text, 0xFFFFFFFF); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |      * Create a label | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * @param x The x-position of the label (reference is left) | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      * @param y The y-position of the label (reference is top) | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |      * @param textRenderer The text renderer to use to render the label | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |      * @param text The text of the widget | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |      * @param color The color of the widget as 0xAARRGGBB | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     public LabelWidget(int x, int y, TextRenderer textRenderer, Text text, int color) { | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |         this.x = x; | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         this.y = y; | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         this.textRenderer = textRenderer; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         this.text = text; | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         this.color = color; | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |     @Override | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |     public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         this.textRenderer.drawWithShadow(matrices, text, x, y, color); | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     @Override | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     public SelectionType getType() { | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         return SelectionType.NONE; | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     @Override | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |     public void appendNarrations(NarrationMessageBuilder builder) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 68 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |  |