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

96 lines
3.1 KiB
Java
Raw Normal View History

2019-11-23 23:19:13 +02:00
package com.minelittlepony.client.hdskins;
2015-08-01 18:36:33 -04:00
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.common.client.gui.element.Cycler;
2019-04-14 13:32:01 +02:00
import com.minelittlepony.common.client.gui.style.Style;
2020-01-28 12:40:44 +02:00
import com.minelittlepony.hdskins.client.dummy.PlayerPreview;
import com.minelittlepony.hdskins.client.gui.GuiSkins;
2020-03-27 20:14:50 +02:00
import com.minelittlepony.hdskins.server.SkinServerList;
import com.minelittlepony.hdskins.profile.SkinType;
import com.minelittlepony.pony.IPonyManager;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
2018-09-06 13:44:41 +02:00
2019-05-27 17:59:15 +02:00
import net.minecraft.item.Items;
import net.minecraft.sound.SoundEvents;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.item.ItemStack;
2019-05-27 17:59:15 +02:00
import net.minecraft.util.Identifier;
2015-08-01 18:36:33 -04:00
/**
* Skin uploading GUI. Usually displayed over the main menu.
*/
2019-12-09 17:44:47 +02:00
class GuiSkinsMineLP extends GuiSkins {
2015-08-01 18:36:33 -04:00
2019-03-23 20:17:46 +02:00
private IPonyManager ponyManager = MineLittlePony.getInstance().getManager();
private boolean isWet = false;
private static final String[] panoramas = new String[] {
2019-04-14 13:32:01 +02:00
"minelittlepony:textures/cubemap/sugarcubecorner",
"minelittlepony:textures/cubemap/quillsandsofas",
"minelittlepony:textures/cubemap/sweetappleacres"
};
public GuiSkinsMineLP(Screen parent, SkinServerList servers) {
super(parent, servers);
}
2015-08-01 18:36:33 -04:00
@Override
public PlayerPreview createPreviewer() {
return new PonyPreview();
2015-08-01 18:36:33 -04:00
}
@Override
2019-05-27 17:59:15 +02:00
public void init() {
super.init();
addButton(new Cycler(width - 25, 142, 20, 20))
2019-04-14 13:32:01 +02:00
.setStyles(
new Style().setIcon(new ItemStack(Items.BUCKET)).setTooltip("minelp.mode.dry", 0, 10),
new Style().setIcon(new ItemStack(Items.WATER_BUCKET)).setTooltip("minelp.mode.wet", 0, 10)
2019-04-14 13:32:01 +02:00
)
.onChange(this::setWet)
.setValue(isWet ? 1 : 0);
}
@Override
2019-05-27 17:59:15 +02:00
protected Identifier getBackground() {
int i = (int)Math.floor(Math.random() * panoramas.length);
2019-05-27 17:59:15 +02:00
return new Identifier(panoramas[i]);
}
2019-04-14 13:32:01 +02:00
protected int setWet(int wet) {
2018-08-22 21:55:30 +02:00
playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);
2019-04-14 13:32:01 +02:00
isWet = wet == 1;
previewer.getLocal().getTextures().release();;
2019-04-14 13:32:01 +02:00
if (previewer instanceof PonyPreview) {
((PonyPreview)previewer).setWet(isWet);
}
2019-04-14 13:32:01 +02:00
return wet;
}
2015-08-01 18:36:33 -04:00
@Override
2019-08-23 11:12:20 +02:00
public void onSetLocalSkin(SkinType 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");
2019-08-23 11:12:20 +02:00
if (type == SkinType.SKIN) {
ponyManager.removePony(previewer.getLocal().getTextures().get(SkinType.SKIN).getId());
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
@Override
2019-08-23 11:12:20 +02:00
public void onSetRemoteSkin(SkinType type, Identifier 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");
2019-08-23 11:12:20 +02:00
if (type == SkinType.SKIN) {
ponyManager.removePony(location);
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
}