MineLittlePony/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java

104 lines
3.3 KiB
Java
Raw Normal View History

2016-11-16 23:45:04 -05:00
package com.minelittlepony.hdskins.gui;
2015-08-01 18:36:33 -04:00
2016-11-24 23:40:19 -05:00
import com.minelittlepony.MineLittlePony;
2016-11-16 23:45:04 -05:00
import com.minelittlepony.PonyManager;
2015-08-01 18:36:33 -04:00
import com.mojang.authlib.GameProfile;
2016-12-21 01:20:02 -05:00
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.voxelmodpack.hdskins.gui.CubeMapRegistry;
2015-08-01 18:36:33 -04:00
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import com.voxelmodpack.hdskins.gui.GuiItemStackButton;
import com.voxelmodpack.hdskins.gui.GuiSkins;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
2017-06-16 01:41:36 -04:00
import net.minecraft.util.ResourceLocation;
2015-08-01 18:36:33 -04:00
/**
* Skin uploading GUI. Usually displayed over the main menu.
*/
public class GuiSkinsMineLP extends GuiSkins {
2015-08-01 18:36:33 -04:00
2018-06-10 18:54:50 +02:00
private PonyManager ponyManager = MineLittlePony.getInstance().getManager();
private GuiButton btnModeWet;
private GuiButton btnModeDry;
private boolean isWet = false;
2015-08-01 18:36:33 -04:00
@Override
protected EntityPlayerModel getModel(GameProfile profile) {
return new EntityPonyModel(profile);
2015-08-01 18:36:33 -04:00
}
@Override
public void initGui() {
super.initGui();
buttonList.add(btnModeWet = new GuiItemStackButton(7, 2, 99, new ItemStack(Items.WATER_BUCKET)));
buttonList.add(btnModeDry = new GuiItemStackButton(8, 2, 80, new ItemStack(Items.BUCKET)));
btnModeDry.enabled = isWet;
btnModeWet.enabled = !isWet;
}
@Override
protected void initPanorama() {
panorama.setSource(CubeMapRegistry.pickResource());
}
@Override
protected void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == this.btnModeDry.id) {
this.isWet = false;
this.localPlayer.releaseTextures();
} else if (guiButton.id == this.btnModeWet.id) {
this.isWet = true;
this.localPlayer.releaseTextures();
}
btnModeDry.enabled = isWet;
btnModeWet.enabled = !isWet;
((EntityPonyModel)this.localPlayer).setWet(isWet);
((EntityPonyModel)this.remotePlayer).setWet(isWet);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTick) {
super.drawScreen(mouseX, mouseY, partialTick);
if (btnModeDry.isMouseOver() || btnModeWet.isMouseOver()) {
int y = Math.max(mouseY, 16);
String text;
if (btnModeDry.isMouseOver()) {
text = "minelp.mode.dry";
} else {
text = "minelp.mode.wet";
}
this.drawHoveringText(I18n.format(text), mouseX, y);
};
}
2015-08-01 18:36:33 -04:00
@Override
protected void onSetLocalSkin(Type type) {
2016-11-24 23:40:19 -05:00
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
if (type == Type.SKIN) {
ponyManager.removePony(localPlayer.getSkinTexture());
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
@Override
protected void onSetRemoteSkin(Type type, ResourceLocation resource, MinecraftProfileTexture profileTexture) {
2016-12-21 01:20:02 -05:00
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");
if (ponyManager != null && resource != null && type == Type.SKIN) {
ponyManager.removePony(resource);
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
}