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
=================
###[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="icon" type="image/png" href="images/icon.png">
<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>
(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),
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');
ga('create', 'UA-71932800-1', 'auto');
ga('send', 'pageview');
</script>
(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),
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');
ga('create', 'UA-71932800-2', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<script src="js/colpick.js"></script>
@ -26,7 +26,6 @@
<div id="gl"></div>
<div class="right card">
<h1>MCPARKS MINECRAFT ARMORSTAND</h1>
<center>
<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="http://mcparks.us" target="_blank"><img width="64" height="64" src="images/mcparks.png" alt="MCParks" title="MCParks" /></a>
</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 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="invulnerable">Invulnerable</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="showarms">Show Arms</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">
<tr>
<td>Position:</td>
@ -107,44 +109,85 @@
</tr>
</table>
</div>
<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>
<div class="padding underline">
<label><input type="checkbox" name="useequipment">Enable equipment</label><br>
<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.
</p>
<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="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">
<div class="colorfield" id="shoecolor"></div>
<input type="text" class="equipment" name="equipShoes" placeholder="Boots" list="list-shoes">
<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">
<div class="colorfield" id="leggingscolor"></div>
<input type="text" class="equipment" name="equipLeggings" placeholder="Leggings" list="list-leggings">
<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">
<div class="colorfield" id="chestplatecolor"></div>
<input type="text" class="equipment" name="equipChestplate" placeholder="Chestplate" list="list-chestplate">
<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">
<div class="colorfield" id="helmetcolor"></div>
<input type="text" class="equipment" name="equipHelmet" placeholder="Helmet" list="list-helmet">
<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
<select id="equipCustomHeadMode">
<option value="item">Item Name</option>
<option value="player">Player Name</option>
<option value="url">Image URL</option>
</select>
<br>Helmet specifies
<select id="equipCustomHeadMode">
<option value="item">Item Name</option>
<option value="player">Player Name</option>
<option value="url">Image URL</option>
<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>
<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. -->
<label><input type="checkbox" name="usedisabledslots">Lock Slot Interaction</label>
<div id="disabledslots" class="padding">
<div id="disabledslots">
<div>
<span class="first">&nbsp;</span>
<span class="sprite" style="background-position: 0px 0px"></span>
@ -179,16 +222,22 @@
<span><input id="pW" type="checkbox"></input></span>
</div>
</div>
</div>
<div id="code" class="code"></div>
<div id="codeinfo" class="padding"></div>
<div class="code">
<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 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
</span>
<br>
@ -201,5 +250,20 @@
</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>
</html>

View file

@ -31,6 +31,9 @@ var yPos = "~"
var zPos = "~"
//DATA -> Stuff that we'll use to generate the command. Fetched from the controls.
var mcVersion;
var invisible = false;
var invulnerable = false;
var persistencerequired = false;
@ -38,8 +41,9 @@ var noBasePlate = false;
var noGravity = false;
var showArms = false;
var small = false;
var marker = false;
var equipmentMode;
var useEquipment;
var equipHandRight;
var equipHandLeft;
var equipShoes;
@ -52,6 +56,9 @@ var equipColorLeggings;
var equipColorChestplate;
var equipColorHelmet;
var customName;
var showCustomName;
var useDisabledSlots;
//The rotation values are all in degrees.
@ -75,17 +82,53 @@ Point = {
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(){
//Init
setup();
updateUI();
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
$("input").on("input", function(){
handleInput();
});
$(':checkbox, #equipCustomHeadMode, #equipmode').change(function() {
$(':checkbox, #equipCustomHeadMode, #equipmode, #mcversion').change(function() {
handleInput();
});
@ -259,6 +302,8 @@ function setup(){
// Write stuff from input into variables
function handleInput(){
mcVersion = $("#mcversion").val();
invisible = getCheckBoxInput("invisible");
invulnerable = getCheckBoxInput("invulnerable");
persistencerequired = getCheckBoxInput("persistencerequired");
@ -266,8 +311,9 @@ function handleInput(){
noGravity = getCheckBoxInput("nogravity");
showArms = getCheckBoxInput("showarms");
small = getCheckBoxInput("small");
marker = getCheckBoxInput("marker");
equipmentMode = $("#equipmode").val(); // use direct jQuery for dropdowns
useEquipment = getCheckBoxInput("useequipment");
equipHandRight = getInput("equipHandRight");
equipHandLeft = getInput("equipHandLeft");
equipShoes = getInput("equipShoes");
@ -281,6 +327,9 @@ function handleInput(){
equipColorChestplate = $("#chestplatecolor").css("background-color");
equipColorHelmet = $("#helmetcolor").css("background-color");
customName = getInput("customname");
showCustomName = getCheckBoxInput("showcustomname");
useDisabledSlots = getCheckBoxInput("usedisabledslots");
@ -327,18 +376,18 @@ function updateUI(){
else
$("#inputarms").slideUp();
if(equipmentMode != "none"){
if(useEquipment){
$("#customequipment").slideDown();
if(equipmentMode == "1.9"){
$("#equipHandLeft").show();
}
else{
// Hide left hand item input for minecraft 1.8
if(mcVersion == "1.8"){
$("#equipHandLeft").hide();
}
else{
$("#equipHandLeft").show();
}
}
else{
else
$("#customequipment").slideUp();
}
//Different colorinputs for armorparts
if(isLeatherArmor(equipShoes))
@ -358,15 +407,27 @@ function updateUI(){
else
$("#helmetcolor").slideUp();
// Link to minecraft-heads.com
if(equipCustomHeadMode == "givecode"){
$("#minecraft-heads").slideDown();
}
else{
$("#minecraft-heads").slideUp();
}
// Show disabled slots
if(useDisabledSlots)
$("#disabledslots").slideDown();
else
$("#disabledslots").slideUp();
// Generate code
$("#code").text(generateCode());
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(){
var code = "/summon ArmorStand ";
code += xPos + " " + yPos + " " + zPos + " {";
var code = "/summon armor_stand ~ ~ ~ {";
// Old entity name
if(mcVersion == "1.8" || mcVersion == "1.9"){
code = "/summon ArmorStand ~ ~ ~ {";
}
var tags = [];
@ -415,41 +478,52 @@ function generateCode(){
tags.push("ShowArms:1b");
if(small)
tags.push("Small:1b");
if(marker)
tags.push("Marker:1b");
//Sliders
if(rotation != 0)
tags.push("Rotation:["+rotation+"f]");
//1.8 Equipment
if(equipmentMode == "1.8"){
var equip = [];
// Equipment
if(useEquipment){
// Old 1.8 Equipment format
if(mcVersion == "1.8"){
var armor = [];
equip.push(getHandRightItem());
equip.push(getShoesItem());
equip.push(getLeggingsItem());
equip.push(getChestplateItem());
equip.push(getHeadItem());
armor.push(getHandRightItem());
armor.push(getShoesItem());
armor.push(getLeggingsItem());
armor.push(getChestplateItem());
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());
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(",")+"]");
}
// Custom name
if(customName != "" && customName != null)
tags.push("CustomName:\""+customName+"\"");
if(showCustomName)
tags.push("CustomNameVisible:1b");
//DisabledSlots
if(useDisabledSlots){
@ -536,6 +610,39 @@ function getHeadItem(){
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() {

35842
js/three.js

File diff suppressed because one or more lines are too long

View file

@ -30,6 +30,18 @@ a{
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{
width: 60%;
height: 100%;
@ -43,6 +55,7 @@ a{
box-shadow: 0 2px 4px #555555;
margin: 0.5em;
border-radius: 3px;
padding: 1em;
}
.right{
@ -50,7 +63,11 @@ a{
}
.padding{
padding: 0.5em;
padding: 1em;
}
.underline{
border-bottom: 1px dashed #ddd;
}
.code{
@ -61,6 +78,13 @@ a{
border-radius: 3px;
color: #ffffff;
}
#code-copy-hint{
font-family: sans-serif;
font-style: italic;
font-size: 0.8em;
text-align: right;
opacity: 0.6;
}
#disabledslots{
display: block;