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

Lock Certain Slots

This commit is contained in:
haselkern 2014-08-20 18:05:01 +02:00
parent 2295f5744b
commit 11f1eb6d57
4 changed files with 122 additions and 32 deletions

BIN
ic/slots.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

View file

@ -17,7 +17,7 @@
<div id="card">
<h1>MINECRAFT ARMOR STAND</h1>
<h1>MINECRAFT ARMOR STAND</h1>
<div class="padding">
<center>
<a href="https://github.com/haselkern/Minecraft-ArmorStand" target="_blank"><img src="ic/github.png" alt="GitHub" title="GitHub" /></a>
@ -33,16 +33,16 @@
</div>
</div>
<div id="inputsection" class="padding">
<div id="inputsection" class="padding">
<label><input type="checkbox" name="invisible">Invisible</label><br>
<label><input type="checkbox" name="invulnerable">Invulnerable</label><br>
<label><input type="checkbox" name="nobaseplate">No Base Plate</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>
Rotation: <input type="range" name="rotation" min="0" max="360" value="0">
Rotation: <input type="range" name="rotation" min="0" max="360" value="0">
<div class="evenly">
<span>Head:</span><input type="range" name="headX" min="0" max="360" value="0"><input type="range" name="headY" min="0" max="360" value="0"><input type="range" name="headZ" min="0" max="360" value="0">
@ -83,8 +83,47 @@
<label><input type="checkbox" name="equipCustomHead">Use Helmet as player name for custom head</label>
</div>
</div>
<br>
</div>
<!-- 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>
<span class="first">&nbsp;</span>
<span class="sprite" style="background-position: 0px 0px"></span>
<span class="sprite" style="background-position: 0px -16px"></span>
<span class="sprite" style="background-position: 0px -32px"></span>
<span class="sprite" style="background-position: 0px -48px"></span>
<span class="sprite" style="background-position: 0px -64px"></span>
</div>
<div>
<span class="first">Remove</span>
<span><input id="dH" type="checkbox"></input></span>
<span><input id="dC" type="checkbox"></input></span>
<span><input id="dL" type="checkbox"></input></span>
<span><input id="dB" type="checkbox"></input></span>
<span><input id="dW" type="checkbox"></input></span>
</div>
<div>
<span class="first">Replace</span>
<span><input id="rH" type="checkbox"></input></span>
<span><input id="rC" type="checkbox"></input></span>
<span><input id="rL" type="checkbox"></input></span>
<span><input id="rB" type="checkbox"></input></span>
<span><input id="rW" type="checkbox"></input></span>
</div>
<div>
<span class="first">Place</span>
<span><input id="pH" type="checkbox"></input></span>
<span><input id="pC" type="checkbox"></input></span>
<span><input id="pL" type="checkbox"></input></span>
<span><input id="pB" type="checkbox"></input></span>
<span><input id="pW" type="checkbox"></input></span>
</div>
</div>
</div>
<div id="code" class="code"></div>
<div id="codeinfo" class="padding"></div>
@ -92,35 +131,18 @@
</div>
<div id="card">
<span class="padding" style="cursor: pointer;" onclick="javascript:$('#tipsntricks').slideToggle();">
+ Tips and Tricks for your Armor Stand
<span class="padding" style="cursor: pointer;" onclick="javascript:$('#getcommandblock').slideToggle();">
+ Obtain a command block
</span>
<br>
<div id="tipsntricks">
<div id="getcommandblock">
<div class="padding">
If your command is longer than 100 characters, it needs to be executed with a <b>command block</b>. Obtain one by typing:
</div>
<div class="code">
/give @p command_block
</div>
<div class="padding">
<br>
If you are a mapmaker you might not want players to take items out of the armor stand. If you want to lock all slots, replace n with 1 (or 0 if you want to unlock it).<br>
If you want to <b>disable specific slots</b>, you have to add the numbers in following table up, and replace n with your result.
<table>
<tr><td>Boots</td> <td>2</td></tr>
<tr><td>Leggings</td> <td>4</td></tr>
<tr><td>Chestplate</td> <td>8</td></tr>
<tr><td>Helmet/Block</td><td>16</td></tr>
<tr><td>Sword/Block</td> <td>Not working :(</td></tr>
</table>
</div>
<div class="code">
/entitydata @e[r=2,ArmorStand] {DisabledSlots:n}
</div>
</div>
</div>
</body>
</html>
</html>

56
main.js
View file

@ -40,6 +40,8 @@ var equipChestplate;
var equipHelmet;
var equipCustomHead;
var useDisabledSlots;
//The rotation values are all in degrees.
var head = new THREE.Vector3(0,0,0);
var body = new THREE.Vector3(0,0,0);
@ -93,8 +95,12 @@ $(document).ready(function(){
});
//Hide elements
$("#tipsntricks").hide();
$("#getcommandblock").hide();
$("#troubleshooting").hide();
$("#inputarms").hide();
$("#customequipment").hide();
$("#disabledslots").hide();
});
function setup(){
@ -244,6 +250,8 @@ function handleInput(){
equipHelmet = getInput("equipHelmet");
equipCustomHead = getCheckBoxInput("equipCustomHead");
useDisabledSlots = getCheckBoxInput("usedisabledslots");
body.set(getRangeInput("bodyX"), getRangeInput("bodyY"), getRangeInput("bodyZ"));
head.set(getRangeInput("headX"), getRangeInput("headY"), getRangeInput("headZ"));
@ -270,16 +278,21 @@ function getInput(name){
function updateUI(){
//Hide/Show different inputs
if(showArms)
$("#inputarms").show();
$("#inputarms").slideDown();
else
$("#inputarms").hide();
$("#inputarms").slideUp();
if(useCustomEquipment)
$("#customequipment").show();
$("#customequipment").slideDown();
else
$("#customequipment").hide();
$("#customequipment").slideUp();
if(useDisabledSlots)
$("#disabledslots").slideDown();
else
$("#disabledslots").slideUp();
$("#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 tips and tricks below.)");
$("#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)");
}
@ -359,6 +372,11 @@ function generateCode(){
tags.push("Equipment:["+equip.join(",")+"]");
}
//DisabledSlots
if(useDisabledSlots){
tags.push("DisabledSlots:"+calculateDisabledSlotsFlag());
}
//Now the pose
var pose = [];
if(!isZero(body))
@ -385,6 +403,32 @@ function generateCode(){
return code;
}
function calculateDisabledSlotsFlag() {
var dH = $("#dH").is(":checked") ? 1 << (4) : 0;
var dC = $("#dC").is(":checked") ? 1 << (3) : 0;
var dL = $("#dL").is(":checked") ? 1 << (2) : 0;
var dB = $("#dB").is(":checked") ? 1 << (1) : 0;
var dW = $("#dW").is(":checked") ? 1 << (0) : 0;
var dR = dH + dC + dL + dB + dW;
var rH = $("#rH").is(":checked") ? 1 << (4 + 8) : 0;
var rC = $("#rC").is(":checked") ? 1 << (3 + 8) : 0;
var rL = $("#rL").is(":checked") ? 1 << (2 + 8) : 0;
var rB = $("#rB").is(":checked") ? 1 << (1 + 8) : 0;
var rW = $("#rW").is(":checked") ? 1 << (0 + 8) : 0;
var rR = rH + rC + rL + rB + rW;
var pH = $("#pH").is(":checked") ? 1 << (4 + 16) : 0;
var pC = $("#pC").is(":checked") ? 1 << (3 + 16) : 0;
var pL = $("#pL").is(":checked") ? 1 << (2 + 16) : 0;
var pB = $("#pB").is(":checked") ? 1 << (1 + 16) : 0;
var pW = $("#pW").is(":checked") ? 1 << (0 + 16) : 0;
var pR = pH + pC + pL + pB + pW;
var result = dR + rR + pR;
return result;
}
function isZero(vector){
return vector.x == 0 && vector.y == 0 && vector.z == 0;
}

View file

@ -65,4 +65,28 @@ a{
#customequipment input[type=text]{
width: 100%;
}
#disabledslots{
display: block;
}
#disabledslots .first{
width: 60px;
display: inline-block;
clear: left;
}
#disabledslots span{
width: 16px;
height: 16px;
display: inline-block;
}
#disabledslots .sprite{
background-repeat: no-repeat;
background-image: url("ic/slots.png");
width: 16px;
height: 16px;
display: inline-block;
}