1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package me.km.networking;
- import java.util.TreeMap;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.Gui;
- import net.minecraft.client.network.NetworkPlayerInfo;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- @SideOnly(Side.CLIENT)
- public class PlayerHeadGui extends Gui
- {
- public final static PlayerHeadGui INSTANCE = new PlayerHeadGui(Minecraft.getMinecraft());
- private class HeadData
- {
- private final int x;
- private final int y;
- private final int scale;
- private final ResourceLocation rl;
-
- public HeadData(int x, int y, int scale, ResourceLocation rl)
- {
- this.x = x;
- this.y = y;
- this.scale = scale;
- this.rl = rl;
- }
-
- public void paint(Minecraft mc)
- {
- mc.getTextureManager().bindTexture(rl);
- Gui.drawScaledCustomSizeModalRect(x, y, 8, 8, 8, 8, 8 * scale, 8 * scale, 64.0F, 64.0F);
- Gui.drawScaledCustomSizeModalRect(x, y, 40, 8, 8, 8, 8 * scale, 8 * scale, 64.0F, 64.0F);
- }
- }
-
- private final TreeMap<Integer, HeadData> data;
- private final Minecraft mc;
-
- public PlayerHeadGui(Minecraft mc)
- {
- this.mc = mc;
- this.data = new TreeMap<>();
- }
-
- public void add(int i, int x, int y, int scale, String name)
- {
- NetworkPlayerInfo info = this.mc.player.connection.getPlayerInfo(name);
- if(info != null)
- {
- data.put(i, new HeadData(x, y, scale, info.getLocationSkin()));
- }
- }
-
- public void remove(int i)
- {
- data.remove(i);
- }
-
- public void clear()
- {
- data.clear();
- }
-
- public void paint()
- {
- data.values().forEach(head -> head.paint(mc));
- }
- }
|