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

@ -83,6 +83,45 @@
<label><input type="checkbox" name="equipCustomHead">Use Helmet as player name for custom head</label> <label><input type="checkbox" name="equipCustomHead">Use Helmet as player name for custom head</label>
</div> </div>
</div> </div>
<br>
<!-- 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>
@ -92,34 +131,17 @@
</div> </div>
<div id="card"> <div id="card">
<span class="padding" style="cursor: pointer;" onclick="javascript:$('#tipsntricks').slideToggle();"> <span class="padding" style="cursor: pointer;" onclick="javascript:$('#getcommandblock').slideToggle();">
+ Tips and Tricks for your Armor Stand + Obtain a command block
</span> </span>
<br> <br>
<div id="tipsntricks"> <div id="getcommandblock">
<div class="padding"> <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: 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>
<div class="code"> <div class="code">
/give @p command_block /give @p command_block
</div> </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>
</div> </div>
</body> </body>

56
main.js
View file

@ -40,6 +40,8 @@ var equipChestplate;
var equipHelmet; var equipHelmet;
var equipCustomHead; var equipCustomHead;
var useDisabledSlots;
//The rotation values are all in degrees. //The rotation values are all in degrees.
var head = new THREE.Vector3(0,0,0); var head = new THREE.Vector3(0,0,0);
var body = new THREE.Vector3(0,0,0); var body = new THREE.Vector3(0,0,0);
@ -93,8 +95,12 @@ $(document).ready(function(){
}); });
//Hide elements //Hide elements
$("#tipsntricks").hide(); $("#getcommandblock").hide();
$("#troubleshooting").hide(); $("#troubleshooting").hide();
$("#inputarms").hide();
$("#customequipment").hide();
$("#disabledslots").hide();
}); });
function setup(){ function setup(){
@ -244,6 +250,8 @@ function handleInput(){
equipHelmet = getInput("equipHelmet"); equipHelmet = getInput("equipHelmet");
equipCustomHead = getCheckBoxInput("equipCustomHead"); equipCustomHead = getCheckBoxInput("equipCustomHead");
useDisabledSlots = getCheckBoxInput("usedisabledslots");
body.set(getRangeInput("bodyX"), getRangeInput("bodyY"), getRangeInput("bodyZ")); body.set(getRangeInput("bodyX"), getRangeInput("bodyY"), getRangeInput("bodyZ"));
head.set(getRangeInput("headX"), getRangeInput("headY"), getRangeInput("headZ")); head.set(getRangeInput("headX"), getRangeInput("headY"), getRangeInput("headZ"));
@ -270,16 +278,21 @@ function getInput(name){
function updateUI(){ function updateUI(){
//Hide/Show different inputs //Hide/Show different inputs
if(showArms) if(showArms)
$("#inputarms").show(); $("#inputarms").slideDown();
else else
$("#inputarms").hide(); $("#inputarms").slideUp();
if(useCustomEquipment) if(useCustomEquipment)
$("#customequipment").show(); $("#customequipment").slideDown();
else else
$("#customequipment").hide(); $("#customequipment").slideUp();
if(useDisabledSlots)
$("#disabledslots").slideDown();
else
$("#disabledslots").slideUp();
$("#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 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(",")+"]"); tags.push("Equipment:["+equip.join(",")+"]");
} }
//DisabledSlots
if(useDisabledSlots){
tags.push("DisabledSlots:"+calculateDisabledSlotsFlag());
}
//Now the pose //Now the pose
var pose = []; var pose = [];
if(!isZero(body)) if(!isZero(body))
@ -385,6 +403,32 @@ function generateCode(){
return code; 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){ function isZero(vector){
return vector.x == 0 && vector.y == 0 && vector.z == 0; return vector.x == 0 && vector.y == 0 && vector.z == 0;
} }

View file

@ -66,3 +66,27 @@ a{
#customequipment input[type=text]{ #customequipment input[type=text]{
width: 100%; 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;
}