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

93 lines
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;
import com.minelittlepony.gui.IconicToggle;
import com.minelittlepony.gui.Style;
import com.minelittlepony.pony.data.PonyManager;
2015-08-01 18:36:33 -04:00
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
2015-08-01 18:36:33 -04:00
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import com.voxelmodpack.hdskins.gui.GuiSkins;
2018-09-06 13:44:41 +02:00
import com.voxelmodpack.hdskins.server.SkinServer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
2015-08-01 18:36:33 -04:00
import java.util.List;
/**
* 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 boolean isWet = false;
private static final String[] panoramas = new String[] {
"minelittlepony:textures/cubemap/sugarcubecorner_%d.png",
2018-10-12 10:24:24 +02:00
"minelittlepony:textures/cubemap/quillsandsofas_%d.png",
"minelittlepony:textures/cubemap/sweetappleacres_%d.png"
};
public GuiSkinsMineLP(List<SkinServer> servers) {
super(servers);
}
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();
addButton(new IconicToggle(width - 25, 142, 2, sender -> setWet(sender.getValue() == 1))
.setStyle(new Style().setIcon(new ItemStack(Items.WATER_BUCKET)).setTooltip("minelp.mode.wet"), 1)
.setStyle(new Style().setIcon(new ItemStack(Items.BUCKET)).setTooltip("minelp.mode.dry"), 0)
.setValue(isWet ? 1 : 0)
.setTooltipOffset(0, 10));
}
@Override
protected void initPanorama() {
int i = (int)Math.floor(Math.random() * panoramas.length);
panorama.setSource(panoramas[i]);
}
protected void setWet(boolean wet) {
2018-08-22 21:55:30 +02:00
playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);
isWet = wet;
localPlayer.releaseTextures();
((EntityPonyModel)localPlayer).setWet(isWet);
((EntityPonyModel)remotePlayer).setWet(isWet);
}
2015-08-01 18:36:33 -04:00
@Override
public void onSetLocalSkin(Type type) {
super.onSetLocalSkin(type);
2018-08-22 21:55:30 +02:00
2016-11-24 23:40:19 -05:00
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
2018-08-22 21:55:30 +02:00
if (type == Type.SKIN) {
ponyManager.removePony(localPlayer.getLocal(Type.SKIN).getTexture());
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
@Override
public void onSetRemoteSkin(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) {
super.onSetRemoteSkin(type, location, profileTexture);
2016-12-21 01:20:02 -05:00
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");
2018-08-22 21:55:30 +02:00
if (type == Type.SKIN) {
ponyManager.removePony(location);
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
}