1
0
Fork 0
mirror of https://github.com/haselkern/Minecraft-ArmorStand.git synced 2025-05-17 15:05:33 +00:00

Support for 1.9 dual wielding

Hooray! 🎉
This commit is contained in:
Lars Martens 2015-09-10 17:29:54 +02:00
parent 50861b90fd
commit ae9858d6ae
2 changed files with 105 additions and 63 deletions

View file

@ -93,12 +93,17 @@
</table> </table>
</div> </div>
<label><input type="checkbox" name="usecustomequipment">Use Custom Equipment</label> <select id="equipmode">
<option value="none">No Equipment</option>
<option value="1.8">Minecraft 1.8- Equipment</option>
<option value="1.9">Minecraft 1.9+ Equipment</option>
</select>
<div id="customequipment"> <div id="customequipment">
<div class="padding"> <div class="padding">
Enter the text id of an item (for example <i>stone</i> or <i>iron_sword</i>) into the appropriate slots. You can enter an arbitrary item for the head or hand, but the other slots must contain an appropriate item. Enter the text id of an item (for example <i>stone</i> or <i>iron_sword</i>) into the appropriate slots. You can enter an arbitrary item for the head or hand, but the other slots must contain an appropriate item.
<input type="text" class="equipment" name="equipSword" placeholder="Item in hand"> <input type="text" class="equipment" name="equipHandRight" placeholder="Item in right hand">
<input type="text" class="equipment" id="equipHandLeft" name="equipHandLeft" placeholder="Item in left hand">
<input type="text" class="equipment" name="equipShoes" placeholder="Shoes"> <input type="text" class="equipment" name="equipShoes" placeholder="Shoes">
<div class="colorfield" id="shoecolor"></div> <div class="colorfield" id="shoecolor"></div>

View file

@ -37,8 +37,9 @@ var noGravity = false;
var showArms = false; var showArms = false;
var small = false; var small = false;
var useCustomEquipment; var equipmentMode;
var equipSword; var equipHandRight;
var equipHandLeft;
var equipShoes; var equipShoes;
var equipLeggings; var equipLeggings;
var equipChestplate; var equipChestplate;
@ -82,7 +83,7 @@ $(document).ready(function(){
$("input").on("input", function(){ $("input").on("input", function(){
handleInput(); handleInput();
}); });
$(':checkbox, #equipCustomHeadMode').change(function() { $(':checkbox, #equipCustomHeadMode, #equipmode').change(function() {
handleInput(); handleInput();
}); });
@ -264,8 +265,9 @@ function handleInput(){
showArms = getCheckBoxInput("showarms"); showArms = getCheckBoxInput("showarms");
small = getCheckBoxInput("small"); small = getCheckBoxInput("small");
useCustomEquipment = getCheckBoxInput("usecustomequipment"); equipmentMode = $("#equipmode").val(); // use direct jQuery for dropdowns
equipSword = getInput("equipSword"); equipHandRight = getInput("equipHandRight");
equipHandLeft = getInput("equipHandLeft");
equipShoes = getInput("equipShoes"); equipShoes = getInput("equipShoes");
equipLeggings = getInput("equipLeggings"); equipLeggings = getInput("equipLeggings");
equipChestplate = getInput("equipChestplate"); equipChestplate = getInput("equipChestplate");
@ -311,10 +313,18 @@ function updateUI(){
else else
$("#inputarms").slideUp(); $("#inputarms").slideUp();
if(useCustomEquipment) if(equipmentMode != "none"){
$("#customequipment").slideDown(); $("#customequipment").slideDown();
else if(equipmentMode == "1.9"){
$("#equipHandLeft").show();
}
else{
$("#equipHandLeft").hide();
}
}
else{
$("#customequipment").slideUp(); $("#customequipment").slideUp();
}
//Different colorinputs for armorparts //Different colorinputs for armorparts
if(isLeatherArmor(equipShoes)) if(isLeatherArmor(equipShoes))
@ -393,65 +403,36 @@ function generateCode(){
if(rotation != 0) if(rotation != 0)
tags.push("Rotation:["+rotation+"f]"); tags.push("Rotation:["+rotation+"f]");
//Equipment //1.8 Equipment
if(useCustomEquipment){ if(equipmentMode == "1.8"){
var equip = []; var equip = [];
if(equipSword != "") equip.push(getHandRightItem());
equip.push("{id:\""+equipSword+"\",Count:1b}"); equip.push(getShoesItem());
else equip.push(getLeggingsItem());
equip.push("{}"); equip.push(getChestplateItem());
equip.push(getHeadItem());
if(equipShoes != "")
equip.push("{id:\""+equipShoes+"\",Count:1b"
+getLeatherColorString($("#shoecolor"), isLeatherArmor(equipShoes))
+"}");
else
equip.push("{}");
if(equipLeggings != "")
equip.push("{id:\""+equipLeggings+"\",Count:1b"
+getLeatherColorString($("#leggingscolor"), isLeatherArmor(equipShoes))
+"}");
else
equip.push("{}");
if(equipChestplate != "")
equip.push("{id:\""+equipChestplate+"\",Count:1b"
+getLeatherColorString($("#chestplatecolor"), isLeatherArmor(equipShoes))
+"}");
else
equip.push("{}");
if(equipHelmet != ""){
// Use input as item
if(equipCustomHeadMode == "item"){
equip.push("{id:\""+equipHelmet+"\",Count:1b"
+getLeatherColorString($("#helmetcolor"), isLeatherArmor(equipShoes))
+"}");
}
// Use input as player name
else if(equipCustomHeadMode == "player"){
equip.push("{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+equipHelmet+"\"}}");
}
// Use input as url
// Best reference: http://redd.it/24quwx
else if(equipCustomHeadMode == "url"){
var uuid = generateUUID();
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
equip.push('{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}');
}
}
else
equip.push("{}");
tags.push("Equipment:["+equip.join(",")+"]"); tags.push("Equipment:["+equip.join(",")+"]");
} }
// 1.9 Equipment
else if(equipmentMode == "1.9"){
var armor = [];
armor.push(getShoesItem());
armor.push(getLeggingsItem());
armor.push(getChestplateItem());
armor.push(getHeadItem());
tags.push("ArmorItems:["+armor.join(",")+"]");
var hands = [];
hands.push(getHandRightItem());
hands.push(getHandLeftItem());
tags.push("HandItems:["+hands.join(",")+"]");
}
//DisabledSlots //DisabledSlots
if(useDisabledSlots){ if(useDisabledSlots){
@ -484,6 +465,62 @@ function generateCode(){
return code; return code;
} }
function getHandRightItem(){
if(equipHandRight == "") return "{}";
return "{id:\""+equipHandRight+"\",Count:1b}";
}
function getHandLeftItem(){
if(equipHandLeft == "") return "{}";
return "{id:\""+equipHandLeft+"\",Count:1b}";
}
function getShoesItem(){
if(equipShoes == "") return "{}";
return "{id:\""+equipShoes+"\",Count:1b"
+getLeatherColorString($("#shoecolor"), isLeatherArmor(equipShoes))
+"}";
}
function getLeggingsItem(){
if(equipLeggings == "") return "{}";
return "{id:\""+equipLeggings+"\",Count:1b"
+getLeatherColorString($("#leggingscolor"), isLeatherArmor(equipShoes))
+"}";
}
function getChestplateItem(){
if(equipChestplate == "") return "{}";
return "{id:\""+equipChestplate+"\",Count:1b"
+getLeatherColorString($("#chestplatecolor"), isLeatherArmor(equipShoes))
+"}";
}
function getHeadItem(){
if(equipHelmet == "") return "{}";
// Use input as item
if(equipCustomHeadMode == "item"){
return "{id:\""+equipHelmet+"\",Count:1b"
+getLeatherColorString($("#helmetcolor"), isLeatherArmor(equipShoes))
+"}";
}
// Use input as player name
else if(equipCustomHeadMode == "player"){
return "{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+equipHelmet+"\"}}";
}
// Use input as url
// Best reference: http://redd.it/24quwx
else if(equipCustomHeadMode == "url"){
var uuid = generateUUID();
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
return '{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}';
}
}
function calculateDisabledSlotsFlag() { function calculateDisabledSlotsFlag() {
var dH = $("#dH").is(":checked") ? 1 << (4) : 0; var dH = $("#dH").is(":checked") ? 1 << (4) : 0;
var dC = $("#dC").is(":checked") ? 1 << (3) : 0; var dC = $("#dC").is(":checked") ? 1 << (3) : 0;