mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-30 07:57:59 +01:00
Split the elytra button into its own toggle
This commit is contained in:
parent
24934638fd
commit
29c72f654c
4 changed files with 53 additions and 30 deletions
|
@ -1,5 +1,7 @@
|
||||||
package com.minelittlepony.gui;
|
package com.minelittlepony.gui;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
@ -13,8 +15,12 @@ public abstract class GameGui extends GuiScreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String format(String string) {
|
protected static String format(String string, Object... pars) {
|
||||||
return I18n.format(string);
|
return I18n.format(string, pars);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String toTitleCase(String string) {
|
||||||
|
return WordUtils.capitalize(string.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiMainMenu;
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.init.SoundEvents;
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
@ -57,8 +58,10 @@ public class GuiSkins extends GameGui {
|
||||||
private Button btnUpload;
|
private Button btnUpload;
|
||||||
private Button btnClear;
|
private Button btnClear;
|
||||||
|
|
||||||
|
private Button btnModeSteve;
|
||||||
|
private Button btnModeAlex;
|
||||||
|
|
||||||
private Button btnModeSkin;
|
private Button btnModeSkin;
|
||||||
private Button btnModeSkinnySkin;
|
|
||||||
private Button btnModeElytra;
|
private Button btnModeElytra;
|
||||||
|
|
||||||
protected EntityPlayerModel localPlayer;
|
protected EntityPlayerModel localPlayer;
|
||||||
|
@ -231,17 +234,23 @@ public class GuiSkins extends GameGui {
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
mc.displayGuiScreen(new GuiMainMenu());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
addButton(btnModeSkin = new GuiItemStackButton(width - 25, 32, new ItemStack(Items.LEATHER_LEGGINGS), 0x3c5dcb, sender -> {
|
addButton(btnModeSteve = new GuiItemStackButton(width - 25, 32, new ItemStack(Items.LEATHER_LEGGINGS), 0x3c5dcb, sender -> {
|
||||||
switchSkinMode(sender, false, SKIN, ItemStack.EMPTY);
|
switchSkinMode(sender, false);
|
||||||
})).setEnabled(thinArmType).setTooltip("hdskins.mode.skin");
|
})).setEnabled(thinArmType).setTooltip("hdskins.mode.steve");
|
||||||
|
|
||||||
addButton(btnModeElytra = new GuiItemStackButton(width - 25, 82, new ItemStack(Items.ELYTRA), sender -> {
|
addButton(btnModeAlex = new GuiItemStackButton(width - 25, 51, new ItemStack(Items.LEATHER_LEGGINGS), 0xfff500, sender -> {
|
||||||
switchSkinMode(sender, thinArmType, ELYTRA, new ItemStack(Items.ELYTRA));
|
switchSkinMode(sender, true);
|
||||||
})).setEnabled(textureType == SKIN).setTooltip("hdskins.mode.elytra");
|
})).setEnabled(!thinArmType).setTooltip("hdskins.mode.alex");
|
||||||
|
|
||||||
|
|
||||||
|
addButton(btnModeSkin = new GuiItemStackButton(width - 25, 75, new ItemStack(Items.LEATHER_CHESTPLATE), sender -> {
|
||||||
|
switchSkinType(sender, SKIN);
|
||||||
|
})).setEnabled(textureType == ELYTRA).setTooltip(format("hdskins.mode.skin", toTitleCase(SKIN.name())));
|
||||||
|
|
||||||
|
addButton(btnModeElytra = new GuiItemStackButton(width - 25, 94, new ItemStack(Items.ELYTRA), sender -> {
|
||||||
|
switchSkinType(sender, ELYTRA);
|
||||||
|
})).setEnabled(textureType == SKIN).setTooltip(format("hdskins.mode.skin", toTitleCase(ELYTRA.name())));
|
||||||
|
|
||||||
addButton(btnModeSkinnySkin = new GuiItemStackButton(width - 25, 51, new ItemStack(Items.LEATHER_LEGGINGS), 0xfff500, sender -> {
|
|
||||||
switchSkinMode(sender, true, SKIN, ItemStack.EMPTY);
|
|
||||||
})).setEnabled(!thinArmType).setTooltip("hdskins.mode.skinny");
|
|
||||||
|
|
||||||
addButton(new Button(width - 25, height - 65, 20, 20, "?", sender -> {
|
addButton(new Button(width - 25, height - 65, 20, 20, "?", sender -> {
|
||||||
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ENTITY_VILLAGER_YES, 1));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ENTITY_VILLAGER_YES, 1));
|
||||||
|
@ -289,26 +298,32 @@ public class GuiSkins extends GameGui {
|
||||||
return isPowerOfTwo(w) && w == h * 2 || w == h && w <= MAX_SKIN_DIMENSION && h <= MAX_SKIN_DIMENSION;
|
return isPowerOfTwo(w) && w == h * 2 || w == h && w <= MAX_SKIN_DIMENSION && h <= MAX_SKIN_DIMENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void switchSkinMode(Button sender, boolean thin, Type newType, ItemStack stack) {
|
protected void switchSkinType(Button sender, Type newType) {
|
||||||
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_BREWING_STAND_BREW, 1));
|
||||||
|
|
||||||
|
textureType = newType;
|
||||||
|
|
||||||
|
btnModeSkin.enabled = textureType == ELYTRA;
|
||||||
|
btnModeElytra.enabled = textureType == SKIN;
|
||||||
|
|
||||||
|
ItemStack stack = newType == ELYTRA ? new ItemStack(Items.ELYTRA) : ItemStack.EMPTY;
|
||||||
|
// put on or take off the elytra
|
||||||
|
localPlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
||||||
|
remotePlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void switchSkinMode(Button sender, boolean thin) {
|
||||||
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_BREWING_STAND_BREW, 1));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_BREWING_STAND_BREW, 1));
|
||||||
|
|
||||||
thinArmType = thin;
|
thinArmType = thin;
|
||||||
textureType = newType;
|
|
||||||
|
|
||||||
btnModeSkin.enabled = thinArmType;
|
btnModeSteve.enabled = thinArmType;
|
||||||
btnModeSkinnySkin.enabled = !thinArmType;
|
btnModeAlex.enabled = !thinArmType;
|
||||||
btnModeElytra.enabled = textureType == SKIN;
|
|
||||||
|
|
||||||
sender.enabled = false;
|
|
||||||
|
|
||||||
// clear currently selected skin
|
// clear currently selected skin
|
||||||
selectedSkin = null;
|
selectedSkin = null;
|
||||||
localPlayer.releaseTextures();
|
localPlayer.releaseTextures();
|
||||||
|
|
||||||
// put on or take off the elytra
|
|
||||||
localPlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
|
||||||
remotePlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
|
||||||
|
|
||||||
localPlayer.setPreviewThinArms(thinArmType);
|
localPlayer.setPreviewThinArms(thinArmType);
|
||||||
remotePlayer.setPreviewThinArms(thinArmType);
|
remotePlayer.setPreviewThinArms(thinArmType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,10 @@ hdskins.upload=Uploading skin please wait...
|
||||||
hdskins.local=Local Skin
|
hdskins.local=Local Skin
|
||||||
hdskins.server=Server Skin
|
hdskins.server=Server Skin
|
||||||
|
|
||||||
hdskins.mode.skin=Skin (Steve)
|
hdskins.mode.steve=Steve Model
|
||||||
hdskins.mode.skinny=Skin (Alex)
|
hdskins.mode.alex=Alex Model
|
||||||
hdskins.mode.elytra=Elytra
|
|
||||||
|
hdskins.mode.skin=%s
|
||||||
|
|
||||||
hdskins.options.chevy=>>
|
hdskins.options.chevy=>>
|
||||||
hdskins.options.chevy.title=Upload Skin
|
hdskins.options.chevy.title=Upload Skin
|
||||||
|
|
|
@ -43,12 +43,13 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
|
||||||
addButton(btnModeWet = new GuiItemStackButton(width - 25, 139, new ItemStack(Items.WATER_BUCKET), sender -> {
|
addButton(btnModeWet = new GuiItemStackButton(width - 25, 137, new ItemStack(Items.WATER_BUCKET), sender -> {
|
||||||
setWet(true);
|
setWet(true);
|
||||||
})).setTooltip("minelp.mode.wet");
|
})).setEnabled(!isWet).setTooltip("minelp.mode.wet");
|
||||||
addButton(btnModeDry = new GuiItemStackButton(width - 25, 120, new ItemStack(Items.BUCKET), sender -> {
|
|
||||||
|
addButton(btnModeDry = new GuiItemStackButton(width - 25, 118, new ItemStack(Items.BUCKET), sender -> {
|
||||||
setWet(false);
|
setWet(false);
|
||||||
})).setEnabled(false).setTooltip("minelp.mode.dry");
|
})).setEnabled(isWet).setTooltip("minelp.mode.dry");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue