mirror of
https://github.com/haselkern/Minecraft-ArmorStand.git
synced 2025-07-12 06:05:35 +00:00
Added a block on player head
It appears if there is input in the helmet field.
This commit is contained in:
parent
e706235c33
commit
b1c44f3822
1 changed files with 37 additions and 31 deletions
68
js/main.js
68
js/main.js
|
@ -10,6 +10,9 @@ var rotY = 0, rotX = 0;
|
||||||
var matWood = new THREE.MeshLambertMaterial({ color: 0x826841 });
|
var matWood = new THREE.MeshLambertMaterial({ color: 0x826841 });
|
||||||
//var matWood = new THREE.MeshLambertMaterial({ color: 0x826841, transparent: true, opacity: 0.5 }); //For testing the mesh alignment
|
//var matWood = new THREE.MeshLambertMaterial({ color: 0x826841, transparent: true, opacity: 0.5 }); //For testing the mesh alignment
|
||||||
var matStone = new THREE.MeshLambertMaterial({ color: 0xadadad });
|
var matStone = new THREE.MeshLambertMaterial({ color: 0xadadad });
|
||||||
|
var matTransparentStone = new THREE.MeshLambertMaterial({ color: 0xadadad });
|
||||||
|
matTransparentStone.opacity = 0.8;
|
||||||
|
matTransparentStone.transparent = true;
|
||||||
var viewCenter = new THREE.Vector3(0,0,0);
|
var viewCenter = new THREE.Vector3(0,0,0);
|
||||||
// Meshes
|
// Meshes
|
||||||
// The ones marked with //* are not real meshes, but contain a child (or more) which gets rendered.
|
// The ones marked with //* are not real meshes, but contain a child (or more) which gets rendered.
|
||||||
|
@ -17,6 +20,7 @@ var viewCenter = new THREE.Vector3(0,0,0);
|
||||||
var mBasePlate;
|
var mBasePlate;
|
||||||
var mBody; //*
|
var mBody; //*
|
||||||
var mHead; //*
|
var mHead; //*
|
||||||
|
var mSkull;
|
||||||
var mLegLeft; //*
|
var mLegLeft; //*
|
||||||
var mLegRight; //*
|
var mLegRight; //*
|
||||||
var mArmLeft; //*
|
var mArmLeft; //*
|
||||||
|
@ -38,7 +42,7 @@ var equipSword;
|
||||||
var equipShoes;
|
var equipShoes;
|
||||||
var equipLeggings;
|
var equipLeggings;
|
||||||
var equipChestplate;
|
var equipChestplate;
|
||||||
var equipHelmet;
|
var equipHelmet = "";
|
||||||
var equipCustomHeadMode;
|
var equipCustomHeadMode;
|
||||||
var equipColorShoes;
|
var equipColorShoes;
|
||||||
var equipColorLeggings;
|
var equipColorLeggings;
|
||||||
|
@ -80,8 +84,8 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
$(':checkbox, #equipCustomHeadMode').change(function() {
|
$(':checkbox, #equipCustomHeadMode').change(function() {
|
||||||
handleInput();
|
handleInput();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//Handle rotating with mouse
|
//Handle rotating with mouse
|
||||||
$("#gl")
|
$("#gl")
|
||||||
|
@ -106,7 +110,7 @@ $(document).ready(function(){
|
||||||
$("#inputarms").hide();
|
$("#inputarms").hide();
|
||||||
$("#customequipment").hide();
|
$("#customequipment").hide();
|
||||||
$("#disabledslots").hide();
|
$("#disabledslots").hide();
|
||||||
|
|
||||||
//Initialize colorpickers
|
//Initialize colorpickers
|
||||||
$('.colorfield').colpick({
|
$('.colorfield').colpick({
|
||||||
colorScheme:'light',
|
colorScheme:'light',
|
||||||
|
@ -128,7 +132,7 @@ function setup(){
|
||||||
renderer = new THREE.WebGLRenderer({ antialias: true, alpha:true });
|
renderer = new THREE.WebGLRenderer({ antialias: true, alpha:true });
|
||||||
renderer.setSize(width, height);
|
renderer.setSize(width, height);
|
||||||
$("#gl").append(renderer.domElement);
|
$("#gl").append(renderer.domElement);
|
||||||
|
|
||||||
|
|
||||||
scene = new THREE.Scene();
|
scene = new THREE.Scene();
|
||||||
armorstand = new THREE.Object3D();
|
armorstand = new THREE.Object3D();
|
||||||
|
@ -151,7 +155,7 @@ function setup(){
|
||||||
mmBaseDot.position.set(0,mBasePlate.position.y,10/16);
|
mmBaseDot.position.set(0,mBasePlate.position.y,10/16);
|
||||||
armorstandWrapper.add(mmBaseDot);
|
armorstandWrapper.add(mmBaseDot);
|
||||||
|
|
||||||
// To Generate the other body parts, we will use a mesh to display,
|
// To Generate the other body parts, we will use a mesh to display,
|
||||||
// and add it as a child to the object that serves as a pivot.
|
// and add it as a child to the object that serves as a pivot.
|
||||||
|
|
||||||
//Left Leg
|
//Left Leg
|
||||||
|
@ -226,14 +230,15 @@ function setup(){
|
||||||
mmNeck.position.set(0,3.5/16,0);
|
mmNeck.position.set(0,3.5/16,0);
|
||||||
/*
|
/*
|
||||||
We do not want the head, as it obstructs a whole lot of the view. We can implement this,
|
We do not want the head, as it obstructs a whole lot of the view. We can implement this,
|
||||||
once we've got an editor option to toggle it on and off.
|
once we've got an editor option to toggle it on and off.*/
|
||||||
var mmSkull = new THREE.Mesh(
|
mSkull = new THREE.Mesh(
|
||||||
new THREE.BoxGeometry(10/16, 10/16, 10/16),
|
new THREE.BoxGeometry(10/16, 10/16, 10/16),
|
||||||
matWood);
|
matTransparentStone);
|
||||||
mmSkull.position.set(0,5/16,0);*/
|
mSkull.position.set(0,5/16,0);
|
||||||
mHead = new THREE.Object3D();
|
mHead = new THREE.Object3D();
|
||||||
mHead.position.set(0,22/16,0); //Pivot Point
|
mHead.position.set(0,22/16,0); //Pivot Point
|
||||||
mHead.add(mmNeck);
|
mHead.add(mmNeck);
|
||||||
|
mHead.add(mSkull);
|
||||||
armorstand.add(mHead);
|
armorstand.add(mHead);
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,13 +252,13 @@ function setup(){
|
||||||
|
|
||||||
var pointLight = new THREE.PointLight(0xffffff);
|
var pointLight = new THREE.PointLight(0xffffff);
|
||||||
pointLight.position.set(0, 300, 200);
|
pointLight.position.set(0, 300, 200);
|
||||||
|
|
||||||
scene.add(pointLight);
|
scene.add(pointLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write stuff from input into variables
|
// Write stuff from input into variables
|
||||||
function handleInput(){
|
function handleInput(){
|
||||||
|
|
||||||
invisible = getCheckBoxInput("invisible");
|
invisible = getCheckBoxInput("invisible");
|
||||||
invulnerable = getCheckBoxInput("invulnerable");
|
invulnerable = getCheckBoxInput("invulnerable");
|
||||||
persistencerequired = getCheckBoxInput("persistencerequired");
|
persistencerequired = getCheckBoxInput("persistencerequired");
|
||||||
|
@ -269,7 +274,7 @@ function handleInput(){
|
||||||
equipChestplate = getInput("equipChestplate");
|
equipChestplate = getInput("equipChestplate");
|
||||||
equipHelmet = getInput("equipHelmet");
|
equipHelmet = getInput("equipHelmet");
|
||||||
equipCustomHeadMode = $("#equipCustomHeadMode").val();
|
equipCustomHeadMode = $("#equipCustomHeadMode").val();
|
||||||
|
|
||||||
equipColorShoes = $("#shoecolor").css("background-color");
|
equipColorShoes = $("#shoecolor").css("background-color");
|
||||||
equipColorLeggings = $("#leggingscolor").css("background-color");
|
equipColorLeggings = $("#leggingscolor").css("background-color");
|
||||||
equipColorChestplate = $("#chestplatecolor").css("background-color");
|
equipColorChestplate = $("#chestplatecolor").css("background-color");
|
||||||
|
@ -301,19 +306,19 @@ function getInput(name){
|
||||||
|
|
||||||
/** Changes stuff according to our input values */
|
/** Changes stuff according to our input values */
|
||||||
function updateUI(){
|
function updateUI(){
|
||||||
|
|
||||||
//Hide/Show different inputs
|
//Hide/Show different inputs
|
||||||
|
|
||||||
if(showArms)
|
if(showArms)
|
||||||
$("#inputarms").slideDown();
|
$("#inputarms").slideDown();
|
||||||
else
|
else
|
||||||
$("#inputarms").slideUp();
|
$("#inputarms").slideUp();
|
||||||
|
|
||||||
if(useCustomEquipment)
|
if(useCustomEquipment)
|
||||||
$("#customequipment").slideDown();
|
$("#customequipment").slideDown();
|
||||||
else
|
else
|
||||||
$("#customequipment").slideUp();
|
$("#customequipment").slideUp();
|
||||||
|
|
||||||
//Different colorinputs for armorparts
|
//Different colorinputs for armorparts
|
||||||
if(isLeatherArmor(equipShoes))
|
if(isLeatherArmor(equipShoes))
|
||||||
$("#shoecolor").slideDown();
|
$("#shoecolor").slideDown();
|
||||||
|
@ -331,13 +336,13 @@ function updateUI(){
|
||||||
$("#helmetcolor").slideDown();
|
$("#helmetcolor").slideDown();
|
||||||
else
|
else
|
||||||
$("#helmetcolor").slideUp();
|
$("#helmetcolor").slideUp();
|
||||||
|
|
||||||
|
|
||||||
if(useDisabledSlots)
|
if(useDisabledSlots)
|
||||||
$("#disabledslots").slideDown();
|
$("#disabledslots").slideDown();
|
||||||
else
|
else
|
||||||
$("#disabledslots").slideUp();
|
$("#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 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,10 +364,11 @@ function updateUI(){
|
||||||
armorstand.scale.set(0.6, 0.6, 0.6);
|
armorstand.scale.set(0.6, 0.6, 0.6);
|
||||||
else
|
else
|
||||||
armorstand.scale.set(1, 1, 1);
|
armorstand.scale.set(1, 1, 1);
|
||||||
|
|
||||||
//Set Visibility
|
//Set Visibility
|
||||||
mArmRight.visible = mArmLeft.visible = showArms;
|
mArmRight.visible = mArmLeft.visible = showArms;
|
||||||
mBasePlate.visible = !noBasePlate;
|
mBasePlate.visible = !noBasePlate;
|
||||||
|
mSkull.visible = equipHelmet != "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateCode(){
|
function generateCode(){
|
||||||
|
@ -421,28 +427,28 @@ function generateCode(){
|
||||||
equip.push("{}");
|
equip.push("{}");
|
||||||
|
|
||||||
if(equipHelmet != ""){
|
if(equipHelmet != ""){
|
||||||
|
|
||||||
// Use input as item
|
// Use input as item
|
||||||
if(equipCustomHeadMode == "item"){
|
if(equipCustomHeadMode == "item"){
|
||||||
equip.push("{id:\""+equipHelmet+"\",Count:1b"
|
equip.push("{id:\""+equipHelmet+"\",Count:1b"
|
||||||
+getLeatherColorString($("#helmetcolor"), isLeatherArmor(equipShoes))
|
+getLeatherColorString($("#helmetcolor"), isLeatherArmor(equipShoes))
|
||||||
+"}");
|
+"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use input as player name
|
// Use input as player name
|
||||||
else if(equipCustomHeadMode == "player"){
|
else if(equipCustomHeadMode == "player"){
|
||||||
equip.push("{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+equipHelmet+"\"}}");
|
equip.push("{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+equipHelmet+"\"}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use input as url
|
// Use input as url
|
||||||
// Best reference: http://redd.it/24quwx
|
// Best reference: http://redd.it/24quwx
|
||||||
else if(equipCustomHeadMode == "url"){
|
else if(equipCustomHeadMode == "url"){
|
||||||
var uuid = generateUUID();
|
var uuid = generateUUID();
|
||||||
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
|
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
|
||||||
|
|
||||||
equip.push('{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}');
|
equip.push('{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
equip.push("{}");
|
equip.push("{}");
|
||||||
|
@ -558,15 +564,15 @@ function generateUUID(){
|
||||||
|
|
||||||
function getDecimalRGB(rgb){
|
function getDecimalRGB(rgb){
|
||||||
//The string has the format 'rgb(r, g, b)'
|
//The string has the format 'rgb(r, g, b)'
|
||||||
|
|
||||||
//Remove whitespaces. Now formatted: 'rgb(r,g,b)'
|
//Remove whitespaces. Now formatted: 'rgb(r,g,b)'
|
||||||
rgb = rgb.replace(/ /g,"");
|
rgb = rgb.replace(/ /g,"");
|
||||||
|
|
||||||
var r = rgb.substring(4,rgb.indexOf(","));
|
var r = rgb.substring(4,rgb.indexOf(","));
|
||||||
var g = rgb.substring(rgb.indexOf(",")+1,rgb.lastIndexOf(","));
|
var g = rgb.substring(rgb.indexOf(",")+1,rgb.lastIndexOf(","));
|
||||||
var b = rgb.substring(rgb.lastIndexOf(",")+1, rgb.length-1);
|
var b = rgb.substring(rgb.lastIndexOf(",")+1, rgb.length-1);
|
||||||
|
|
||||||
|
|
||||||
return (r << 16) | (g << 8) | b;
|
return (r << 16) | (g << 8) | b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,4 +589,4 @@ function getLeatherColorString(element, condition){
|
||||||
return ",tag:{display:{color:"+rgb+"}}";
|
return ",tag:{display:{color:"+rgb+"}}";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue