1
0
Fork 0
mirror of https://github.com/haselkern/Minecraft-ArmorStand.git synced 2025-05-17 15:05:33 +00:00
This commit is contained in:
BuildTools 2017-09-13 20:28:24 -04:00
commit ed22598853
6 changed files with 285 additions and 35932 deletions

View file

@ -1,8 +1,8 @@
Minecraft Armor Stand Minecraft Armor Stand
================= =================
###[Try it out](http://haselkern.github.io/Minecraft-ArmorStand) ### [Try it out](http://haselkern.github.io/Minecraft-ArmorStand)
This thing is pretty self explanatory. If you have any suggestions, feel free to fork this, open an issue or write in the [reddit thread](http://redd.it/2dyzfc). In Minecraft 1.8 Armorstands were introduced. Unfortunately, the syntax to summon one is quite confusing and not very intuitive, especially when you're trying to create an awesome pose. This tool provides a graphical interface, so that you can focus on the looks and not worry about code.
**Please note**: Some rotation values do not properly map to those in Minecraft. If you know how to fix that, please submit a pull request. If you would like to see a feature implemented, feel free to open an issue or submit a pull request.

BIN
images/haselkern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

156
index.htm
View file

@ -8,16 +8,16 @@
<link rel="stylesheet" href="js/colpick.css"> <link rel="stylesheet" href="js/colpick.css">
<link rel="icon" type="image/png" href="images/icon.png"> <link rel="icon" type="image/png" href="images/icon.png">
<link href='http://fonts.googleapis.com/css?family=Oswald:700' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Oswald:700' rel='stylesheet' type='text/css'>
<script src="js/three.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-71932800-1', 'auto'); ga('create', 'UA-71932800-2', 'auto');
ga('send', 'pageview'); ga('send', 'pageview');
</script> </script>
</head> </head>
<body> <body>
<script src="js/colpick.js"></script> <script src="js/colpick.js"></script>
@ -26,7 +26,6 @@
<div id="gl"></div> <div id="gl"></div>
<div class="right card"> <div class="right card">
<h1>MCPARKS MINECRAFT ARMORSTAND</h1> <h1>MCPARKS MINECRAFT ARMORSTAND</h1>
<center> <center>
<a href="https://github.com/haselkern/Minecraft-ArmorStand" target="_blank">Original Github Page</a> <a href="https://github.com/haselkern/Minecraft-ArmorStand" target="_blank">Original Github Page</a>
@ -36,17 +35,17 @@
<a href="https://github.com/RyanHecht/Minecraft-ArmorStand" target="_blank"><img src="images/github.png" alt="GitHub" title="GitHub" /></a> <a href="https://github.com/RyanHecht/Minecraft-ArmorStand" target="_blank"><img src="images/github.png" alt="GitHub" title="GitHub" /></a>
<a href="http://mcparks.us" target="_blank"><img width="64" height="64" src="images/mcparks.png" alt="MCParks" title="MCParks" /></a> <a href="http://mcparks.us" target="_blank"><img width="64" height="64" src="images/mcparks.png" alt="MCParks" title="MCParks" /></a>
</center> </center>
<br>
<span class="padding" style="cursor: pointer;" onclick="javascript:$('#troubleshooting').slideToggle();">
+ Troubleshooting
</span>
<div id="troubleshooting">
<b>This thing uses WebGL!</b> If you don't see anything on the left enable WebGL in your browser or visit the <a href="http://get.webgl.org/">official WebGL website</a> to troubleshoot problems.
</div>
</div> </div>
<div id="inputsection" class="padding"> <div class="padding underline">
<select id="mcversion">
<option value="1.11">Minecraft 1.11 and above</option>
<option value="1.9">Minecraft 1.9 &amp; 1.10</option>
<option value="1.8">Minecraft 1.8</option>
</select>
</div>
<div class="padding underline">
<label><input type="checkbox" name="invisible">Invisible</label><br> <label><input type="checkbox" name="invisible">Invisible</label><br>
<label><input type="checkbox" name="invulnerable">Invulnerable</label><br> <label><input type="checkbox" name="invulnerable">Invulnerable</label><br>
<label><input type="checkbox" name="persistencerequired">PersistenceRequired</label><br> <label><input type="checkbox" name="persistencerequired">PersistenceRequired</label><br>
@ -54,7 +53,10 @@
<label><input type="checkbox" name="nogravity">No Gravity</label><br> <label><input type="checkbox" name="nogravity">No Gravity</label><br>
<label><input type="checkbox" name="showarms">Show Arms</label><br> <label><input type="checkbox" name="showarms">Show Arms</label><br>
<label><input type="checkbox" name="small">Small</label><br> <label><input type="checkbox" name="small">Small</label><br>
<label><input type="checkbox" name="marker">Marker</label><br>
</div>
<div class="padding underline">
<table class="rotations"> <table class="rotations">
<tr> <tr>
<td>Position:</td> <td>Position:</td>
@ -107,44 +109,85 @@
</tr> </tr>
</table> </table>
</div> </div>
</div>
<select id="equipmode">
<option value="none">No Equipment</option> <div class="padding underline">
<option value="1.8">Minecraft 1.8- Equipment</option> <label><input type="checkbox" name="useequipment">Enable equipment</label><br>
<option value="1.9">Minecraft 1.9+ Equipment</option>
</select>
<div id="customequipment"> <div id="customequipment">
<div class="padding"> <p>
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.
</p>
<input type="text" class="equipment" name="equipHandRight" placeholder="Item in right 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" 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="Boots" list="list-shoes">
<div class="colorfield" id="shoecolor"></div> <datalist id="list-shoes">
<option value="chainmail_boots">
<option value="diamond_boots">
<option value="golden_boots">
<option value="iron_boots">
<option value="leather_boots">
</datalist>
<div class="colorfield" id="shoecolor"></div>
<input type="text" class="equipment" name="equipLeggings" placeholder="Leggings"> <input type="text" class="equipment" name="equipLeggings" placeholder="Leggings" list="list-leggings">
<div class="colorfield" id="leggingscolor"></div> <datalist id="list-leggings">
<option value="chainmail_leggings">
<option value="diamond_leggings">
<option value="golden_leggings">
<option value="iron_leggings">
<option value="leather_leggings">
</datalist>
<div class="colorfield" id="leggingscolor"></div>
<input type="text" class="equipment" name="equipChestplate" placeholder="Chestplate"> <input type="text" class="equipment" name="equipChestplate" placeholder="Chestplate" list="list-chestplate">
<div class="colorfield" id="chestplatecolor"></div> <datalist id="list-chestplate">
<option value="chainmail_chestplate">
<option value="diamond_chestplate">
<option value="golden_chestplate">
<option value="iron_chestplate">
<option value="leather_chestplate">
</datalist>
<div class="colorfield" id="chestplatecolor"></div>
<input type="text" class="equipment" name="equipHelmet" placeholder="Helmet"> <input type="text" class="equipment" name="equipHelmet" placeholder="Helmet" list="list-helmet">
<div class="colorfield" id="helmetcolor"></div> <datalist id="list-helmet">
<option value="chainmail_helmet">
<option value="diamond_helmet">
<option value="golden_helmet">
<option value="iron_helmet">
<option value="leather_helmet">
</datalist>
<div class="colorfield" id="helmetcolor"></div>
<br>Helmet specifies <br>Helmet specifies
<select id="equipCustomHeadMode"> <select id="equipCustomHeadMode">
<option value="item">Item Name</option> <option value="item">Item Name</option>
<option value="player">Player Name</option> <option value="player">Player Name</option>
<option value="url">Image URL</option> <option value="url">Image URL</option>
</select> <option value="givecode">Give Code</option>
</select>
<div id="minecraft-heads">
<br>
You can find lots of different heads here. Pick one and copy the <i>Give-Code</i> into the helmet field:
<br>
<a href="http://minecraft-heads.com/" target="_blank"><img src="http://minecraft-heads.com/images/banners/minecraft-heads_halfbanner_234x60.png" alt="minecraft-heads.com" /></a>
</div> </div>
</div> </div>
<br> </div>
<div class="padding underline">
<input type="text" name="customname" id="customname" placeholder="Custom name">
<label><input type="checkbox" name="showcustomname">Show custom name</label>
<br>
</div>
<div class="padding">
<!-- THANK YOU to reddit user Oozebull for this part. --> <!-- THANK YOU to reddit user Oozebull for this part. -->
<label><input type="checkbox" name="usedisabledslots">Lock Slot Interaction</label> <label><input type="checkbox" name="usedisabledslots">Lock Slot Interaction</label>
<div id="disabledslots" class="padding"> <div id="disabledslots">
<div> <div>
<span class="first">&nbsp;</span> <span class="first">&nbsp;</span>
<span class="sprite" style="background-position: 0px 0px"></span> <span class="sprite" style="background-position: 0px 0px"></span>
@ -179,16 +222,22 @@
<span><input id="pW" type="checkbox"></input></span> <span><input id="pW" type="checkbox"></input></span>
</div> </div>
</div> </div>
</div> </div>
<div id="code" class="code"></div> <div class="code">
<div id="codeinfo" class="padding"></div> <div id="code-copy-hint">click to copy</div>
<div id="code"></div>
</div>
<div id="codeinfo" class="padding">
<b>Please note:</b>
This command is too long to be executed from chat. You need to place it inside a command block. (see below)
</div>
</div> </div>
<div class="right card"> <div class="right card">
<span class="padding" style="cursor: pointer;" onclick="javascript:$('#getcommandblock').slideToggle();"> <span style="cursor: pointer;" onclick="javascript:$('#getcommandblock').slideToggle();">
+ Obtain a command block + Obtain a command block
</span> </span>
<br> <br>
@ -201,5 +250,20 @@
</div> </div>
</div> </div>
</div> </div>
<div class="right card">
<span class="" style="cursor: pointer;" onclick="javascript:$('#troubleshooting').slideToggle();">
+ Troubleshooting
</span>
<div id="troubleshooting">
<p>
<b>This thing uses WebGL!</b>
If you don't see anything on the left enable WebGL in your browser or visit the <a href="http://get.webgl.org/">official WebGL website</a> to troubleshoot problems.
</p>
</div>
</div>
</body> </body>
</html> </html>

View file

@ -31,6 +31,9 @@ var yPos = "~"
var zPos = "~" var zPos = "~"
//DATA -> Stuff that we'll use to generate the command. Fetched from the controls. //DATA -> Stuff that we'll use to generate the command. Fetched from the controls.
var mcVersion;
var invisible = false; var invisible = false;
var invulnerable = false; var invulnerable = false;
var persistencerequired = false; var persistencerequired = false;
@ -38,8 +41,9 @@ var noBasePlate = false;
var noGravity = false; var noGravity = false;
var showArms = false; var showArms = false;
var small = false; var small = false;
var marker = false;
var equipmentMode; var useEquipment;
var equipHandRight; var equipHandRight;
var equipHandLeft; var equipHandLeft;
var equipShoes; var equipShoes;
@ -52,6 +56,9 @@ var equipColorLeggings;
var equipColorChestplate; var equipColorChestplate;
var equipColorHelmet; var equipColorHelmet;
var customName;
var showCustomName;
var useDisabledSlots; var useDisabledSlots;
//The rotation values are all in degrees. //The rotation values are all in degrees.
@ -75,17 +82,53 @@ Point = {
y:null y:null
}; };
jQuery.fn.selectAndCopyText = function(){
// https://stackoverflow.com/a/9976413/1456971
this.find('input').each(function() {
if($(this).prev().length == 0 || !$(this).prev().hasClass('p_copy')) {
$('<p class="p_copy" style="position: absolute; z-index: -1;"></p>').insertBefore($(this));
}
$(this).prev().html($(this).val());
});
var doc = document;
var element = this[0];
if (doc.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
} else if (window.getSelection) {
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(element);
selection.removeAllRanges();
selection.addRange(range);
}
document.execCommand("copy");
};
$(document).ready(function(){ $(document).ready(function(){
//Init //Init
setup(); setup();
updateUI(); updateUI();
render(); render();
// Confirm exit
window.onbeforeunload = function(){
return "Changes will NOT be saved. Exit anyways?";
};
// Copy code on click
$(".code").click(function(){
$("#code").selectAndCopyText();
});
//Stuff to handle and update input //Stuff to handle and update input
$("input").on("input", function(){ $("input").on("input", function(){
handleInput(); handleInput();
}); });
$(':checkbox, #equipCustomHeadMode, #equipmode').change(function() { $(':checkbox, #equipCustomHeadMode, #equipmode, #mcversion').change(function() {
handleInput(); handleInput();
}); });
@ -259,6 +302,8 @@ function setup(){
// Write stuff from input into variables // Write stuff from input into variables
function handleInput(){ function handleInput(){
mcVersion = $("#mcversion").val();
invisible = getCheckBoxInput("invisible"); invisible = getCheckBoxInput("invisible");
invulnerable = getCheckBoxInput("invulnerable"); invulnerable = getCheckBoxInput("invulnerable");
persistencerequired = getCheckBoxInput("persistencerequired"); persistencerequired = getCheckBoxInput("persistencerequired");
@ -266,8 +311,9 @@ function handleInput(){
noGravity = getCheckBoxInput("nogravity"); noGravity = getCheckBoxInput("nogravity");
showArms = getCheckBoxInput("showarms"); showArms = getCheckBoxInput("showarms");
small = getCheckBoxInput("small"); small = getCheckBoxInput("small");
marker = getCheckBoxInput("marker");
equipmentMode = $("#equipmode").val(); // use direct jQuery for dropdowns useEquipment = getCheckBoxInput("useequipment");
equipHandRight = getInput("equipHandRight"); equipHandRight = getInput("equipHandRight");
equipHandLeft = getInput("equipHandLeft"); equipHandLeft = getInput("equipHandLeft");
equipShoes = getInput("equipShoes"); equipShoes = getInput("equipShoes");
@ -281,6 +327,9 @@ function handleInput(){
equipColorChestplate = $("#chestplatecolor").css("background-color"); equipColorChestplate = $("#chestplatecolor").css("background-color");
equipColorHelmet = $("#helmetcolor").css("background-color"); equipColorHelmet = $("#helmetcolor").css("background-color");
customName = getInput("customname");
showCustomName = getCheckBoxInput("showcustomname");
useDisabledSlots = getCheckBoxInput("usedisabledslots"); useDisabledSlots = getCheckBoxInput("usedisabledslots");
@ -327,18 +376,18 @@ function updateUI(){
else else
$("#inputarms").slideUp(); $("#inputarms").slideUp();
if(equipmentMode != "none"){ if(useEquipment){
$("#customequipment").slideDown(); $("#customequipment").slideDown();
if(equipmentMode == "1.9"){ // Hide left hand item input for minecraft 1.8
$("#equipHandLeft").show(); if(mcVersion == "1.8"){
}
else{
$("#equipHandLeft").hide(); $("#equipHandLeft").hide();
} }
else{
$("#equipHandLeft").show();
}
} }
else{ else
$("#customequipment").slideUp(); $("#customequipment").slideUp();
}
//Different colorinputs for armorparts //Different colorinputs for armorparts
if(isLeatherArmor(equipShoes)) if(isLeatherArmor(equipShoes))
@ -358,15 +407,27 @@ function updateUI(){
else else
$("#helmetcolor").slideUp(); $("#helmetcolor").slideUp();
// Link to minecraft-heads.com
if(equipCustomHeadMode == "givecode"){
$("#minecraft-heads").slideDown();
}
else{
$("#minecraft-heads").slideUp();
}
// Show disabled slots
if(useDisabledSlots) if(useDisabledSlots)
$("#disabledslots").slideDown(); $("#disabledslots").slideDown();
else else
$("#disabledslots").slideUp(); $("#disabledslots").slideUp();
// Generate code
$("#code").text(generateCode()); $("#code").text(generateCode());
if(generateCode().length > 100){ if(generateCode().length > 100){
$("#codeinfo").html("<b>Please note:</b> This command is too long to be executed from chat. You need to place it inside a command block. (see below)"); $("#codeinfo").slideDown();
}
else{
$("#codeinfo").slideUp();
} }
@ -393,10 +454,12 @@ function updateUI(){
} }
function generateCode(){ function generateCode(){
var code = "/summon ArmorStand "; var code = "/summon armor_stand ~ ~ ~ {";
code += xPos + " " + yPos + " " + zPos + " {";
// Old entity name
if(mcVersion == "1.8" || mcVersion == "1.9"){
code = "/summon ArmorStand ~ ~ ~ {";
}
var tags = []; var tags = [];
@ -415,41 +478,52 @@ function generateCode(){
tags.push("ShowArms:1b"); tags.push("ShowArms:1b");
if(small) if(small)
tags.push("Small:1b"); tags.push("Small:1b");
if(marker)
tags.push("Marker:1b");
//Sliders //Sliders
if(rotation != 0) if(rotation != 0)
tags.push("Rotation:["+rotation+"f]"); tags.push("Rotation:["+rotation+"f]");
//1.8 Equipment // Equipment
if(equipmentMode == "1.8"){ if(useEquipment){
var equip = []; // Old 1.8 Equipment format
if(mcVersion == "1.8"){
var armor = [];
equip.push(getHandRightItem()); armor.push(getHandRightItem());
equip.push(getShoesItem()); armor.push(getShoesItem());
equip.push(getLeggingsItem()); armor.push(getLeggingsItem());
equip.push(getChestplateItem()); armor.push(getChestplateItem());
equip.push(getHeadItem()); armor.push(getHeadItem());
tags.push("Equipment:["+equip.join(",")+"]"); tags.push("Equipment:["+armor.join(",")+"]");
}
// New 1.9+ Equipment format
else{
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(",")+"]");
}
} }
// 1.9 Equipment
else if(equipmentMode == "1.9"){
var armor = [];
armor.push(getShoesItem()); // Custom name
armor.push(getLeggingsItem()); if(customName != "" && customName != null)
armor.push(getChestplateItem()); tags.push("CustomName:\""+customName+"\"");
armor.push(getHeadItem()); if(showCustomName)
tags.push("CustomNameVisible:1b");
tags.push("ArmorItems:["+armor.join(",")+"]");
var hands = [];
hands.push(getHandRightItem());
hands.push(getHandLeftItem());
tags.push("HandItems:["+hands.join(",")+"]");
}
//DisabledSlots //DisabledSlots
if(useDisabledSlots){ if(useDisabledSlots){
@ -536,6 +610,39 @@ function getHeadItem(){
return '{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}'; return '{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}';
} }
// Parse give code
else if(equipCustomHeadMode == "givecode"){
// Give Code in this format: /give @p skull 1 3 {display:{Name:"Some Name"},SkullOwner:{Id:"a74719ce...
if(equipHelmet.indexOf("SkullOwner:{") >= 0){
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner"));
var parsed = "";
var bracketCounter = 0;
var bracketsStarted = false;
for(var i = 0; i < skullOwnerRaw.length; i++){
var c = skullOwnerRaw[i];
if(c == "{") bracketCounter++;
if(c == "}") bracketCounter--;
parsed += c;
if(bracketCounter == 0 && bracketsStarted) break;
if(c == ":") bracketsStarted = true;
}
return '{id:"skull",Count:1b,Damage:3b,tag:{'+parsed+'}}';
}
// Give Code in this format: /give @p skull 1 3 {SkullOwner:"playername"} (quotes optional)
else{
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner:"));
skullOwnerRaw = skullOwnerRaw.substring(0, skullOwnerRaw.indexOf("}"));
return '{id:"skull",Count:1b,Damage:3b,tag:{'+skullOwnerRaw+'}}';
}
}
} }
function calculateDisabledSlotsFlag() { function calculateDisabledSlotsFlag() {

35842
js/three.js

File diff suppressed because one or more lines are too long

View file

@ -30,6 +30,18 @@ a{
color: #000000; color: #000000;
} }
input[type="text"], select{
border: 1px solid #aaa;
border-radius: 3px;
padding: 0.5em;
}
input[type="text"]:not(:last-child){
margin-bottom: 0.5em;
}
#customname{
margin-bottom: 0;
}
#gl{ #gl{
width: 60%; width: 60%;
height: 100%; height: 100%;
@ -43,6 +55,7 @@ a{
box-shadow: 0 2px 4px #555555; box-shadow: 0 2px 4px #555555;
margin: 0.5em; margin: 0.5em;
border-radius: 3px; border-radius: 3px;
padding: 1em;
} }
.right{ .right{
@ -50,7 +63,11 @@ a{
} }
.padding{ .padding{
padding: 0.5em; padding: 1em;
}
.underline{
border-bottom: 1px dashed #ddd;
} }
.code{ .code{
@ -61,6 +78,13 @@ a{
border-radius: 3px; border-radius: 3px;
color: #ffffff; color: #ffffff;
} }
#code-copy-hint{
font-family: sans-serif;
font-style: italic;
font-size: 0.8em;
text-align: right;
opacity: 0.6;
}
#disabledslots{ #disabledslots{
display: block; display: block;