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

93 lines
2.9 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;
import com.minelittlepony.avatar.texture.TextureData;
import com.minelittlepony.avatar.texture.TextureType;
import com.minelittlepony.gui.Button;
import com.minelittlepony.gui.IconicButton;
2015-08-01 18:36:33 -04:00
import com.mojang.authlib.GameProfile;
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import com.voxelmodpack.hdskins.gui.GuiSkins;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
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 Button btnModeWet;
private Button btnModeDry;
private boolean isWet = false;
private static final String[] panoramas = new String[] {
"minelp:textures/cubemap/sugarcubecorner_%d.png",
"minelp:textures/cubemap/quillsandsofas_%d.png"
};
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(btnModeWet = new IconicButton(width - 25, 137, sender -> {
setWet(true);
}).setIcon(new ItemStack(Items.WATER_BUCKET))).setEnabled(!isWet).setTooltip("minelp.mode.wet");
addButton(btnModeDry = new IconicButton(width - 25, 118, sender -> {
setWet(false);
}).setIcon(new ItemStack(Items.BUCKET))).setEnabled(isWet).setTooltip("minelp.mode.dry");
}
@Override
protected void initPanorama() {
int i = (int)Math.floor(Math.random() * panoramas.length);
panorama.setSource(panoramas[i]);
}
protected void setWet(boolean wet) {
if (wet == isWet) {
return;
}
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_BREWING_STAND_BREW, 1));
isWet = wet;
localPlayer.releaseTextures();
btnModeDry.enabled = isWet;
btnModeWet.enabled = !isWet;
((EntityPonyModel)localPlayer).setWet(isWet);
((EntityPonyModel)remotePlayer).setWet(isWet);
}
2015-08-01 18:36:33 -04:00
@Override
protected void onSetLocalSkin(TextureType type) {
2016-11-24 23:40:19 -05:00
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
if (type == TextureType.SKIN) {
ponyManager.removePony(localPlayer.getLocal(TextureType.SKIN).getTexture());
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
@Override
protected void onSetRemoteSkin(TextureType type, TextureData texture) {
2016-12-21 01:20:02 -05:00
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");
if (type == TextureType.SKIN) {
ponyManager.removePony(texture.getLocation());
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
}