Jump to content

chromecide

Members
  • Posts

    4
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://chromecide.com
  • Location
    Australia
  • Personal Text
    I am new!

chromecide's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. A Wireless Redstone script that includes a Transmitter, Receiver and channel support; Usage: Transmitter: var rsTransmitter; function init(event){ rsTransmitter = new WirelessRedstone.Transmitter(event, "My Channel Name"); } function redstone(event){ rsTransmitter.redstone(event); } Receiver: var rsReceiver; function init(event){ rsReceiver = new WirelessRedstone.Receiver(event, "My Channel Name"); } function broken(event){ rsReceiver.broken(event); } Script: Note: as of CustomNpcs_1.8.8_beta(17dec15) you cannot load external scripts, so you'll have to paste the following into the top of each ScriptedBlock you want to use this on. function RedstoneTransmitter(event, channel){ var world = event.block.getWorld(); this.block = event.block; this.channel = channel; var tempData = world.getTempdata(); var worldChannels = tempData.get("RedstoneChannels"); if(!worldChannels){ worldChannels = {}; } if(!worldChannels[this.channel]){ worldChannels[this.channel] = []; } tempData.put("RedstoneChannels", worldChannels); } RedstoneTransmitter.prototype.redstone = function(event) { var world = event.block.world; var worldChannels = world.getTempdata().get("RedstoneChannels"); if(!worldChannels){ worldChannels = {}; } var receiverList = worldChannels[this.channel]; if(receiverList.length>0){ for(var i=0;i<receiverList.length;i++){ var receiver = receiverList[i]; if(receiver){ receiver.redstone(event); } } } }; function RedstoneReceiver(event, channel){ var world = event.block.getWorld(); this.block = event.block; this.channel = channel; var tempData = world.getTempdata(); var worldChannels = tempData.get("RedstoneChannels"); if(!worldChannels){ worldChannels = {}; } if(!worldChannels[this.channel]){ worldChannels[this.channel] = []; } worldChannels[this.channel].push(this); tempData.put("RedstoneChannels", worldChannels); } RedstoneReceiver.prototype.redstone = function(event) { var world = this.block.getWorld(); this.block.setRedstonePower(event.power); }; RedstoneReceiver.prototype.broken = function(event) { var world = event.block.world; var worldChannels = world.getTempdata().get("RedstoneChannels"); if(!worldChannels){ worldChannels = {}; } var receiverList = worldChannels[this.channel]; if(receiverList.length>0){ for(var i=receiverList.length-1;i>=0;i--){ var receiver = receiverList[i]; if(receiver.block.getX()==this.block.getX() && receiver.block.getY()==this.block.getY() && receiver.block.getZ()==this.block.getZ()){ receiverList.splice(i, 1); } } } worldChannels[this.channel] = receiverList; world.getTempdata().put("RedstoneChannels", worldChannels); }; var WirelessRedstone = { Transmitter: RedstoneTransmitter, Receiver: RedstoneReceiver };
  2. I've added an optional third parameter "autoClose" to the SecretDoor Constructor. Used as follows: //Door with a stone brick trigger block, 2 wooden planks as the door blocks, that does not auto close var thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], false); //Door with a stone brick trigger block, 2 wooden planks as the door blocks, that auto closes after 2 seconds(40 Ticks); all of the following are equivelant var thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"]); var thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], true); var thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], 40); //Door with a stone brick trigger block, 2 wooden planks as the door blocks, that auto closes after 4 seconds(80 Ticks) var thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], 80); SecretDoor 1.1 // Secret Door Script for CustomNPCs // Tags: customnpcscript, Secret Door // usage: // var thisSecretDoor; // function init(event){ // /* // Door with a stone brick trigger block, 2 wooden planks as the door blocks, that does not auto close // */ // //thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], false); // /* // Door with a stone brick trigger block, 2 wooden planks as the door blocks, that auto closes after 2 seconds(40 Ticks); all of the following are equivelant // */ // //thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"]); // //thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], true); // //thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], 40); // /* // Door with a stone brick trigger block, 2 wooden planks as the door blocks, that auto closes after 4 seconds(80 Ticks) // */ // thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:planks", "minecraft:planks"], 80); // } // function interact(event){ // thisSecretDoor.interact(event); // } // function timer(event){ // thisSecretDoor.timer(event); // } function SecretDoor(initEvent, blockList, autoClose){ switch((typeof autoClose)){ case 'boolean': if(autoClose===true){ autoClose = 40; //2 seconds }else{ autoClose=0; } break; case 'number': if(autoClose<0){ autoClose = 0; } break; default: autoClose = 40; //~2 seconds break; } var block = this.block = initEvent.block; this.blockList = blockList; this.autoClose = autoClose; this.block.setModel(this.block.getWorld().createItem(blockList[0], 0, 1)); this.x = Math.floor(block.getX()); this.y = Math.floor(block.getY()); this.z = Math.floor(block.getZ()); this.isOpen = false; this.close(); } SecretDoor.prototype.open = function(){ var world = this.block.getWorld(); this.block.executeCommand("/playsound tile.piston.in @a[r=10] "+this.x+" "+this.y+" "+this.z); for(var i=1;i<this.blockList.length;i++){ var blockY = this.y - i; world.setBlock(this.x, blockY, this.z, "minecraft:air", 0); } this.isOpen = true; if(this.autoClose) //start(or create if it doesn't exist) the "auto-close" timer (id 0, 40 ticks, don't repeat) this.block.getTimers().start(0, this.autoClose, false); }; SecretDoor.prototype.close = function() { var world = this.block.getWorld(); this.block.executeCommand("/playsound tile.piston.out @a[r=10] "+this.x+" "+this.y+" "+this.z); for(var i=1;i<this.blockList.length;i++){ var blockY = this.y - i; world.setBlock(this.x, blockY, this.z, this.blockList[i], 0); } this.isOpen = false; }; SecretDoor.prototype.interact = function(event) { if(this.isOpen===true){ this.close(); }else{ this.open(); } }; SecretDoor.prototype.timer = function(event) { switch(event.id){ case 0:// "auto close" this.close(); break; } };
  3. Secret Door Script for the Minecraft 1.8.8 version of CustomNPCs This script, when added to a ScriptedBlock will create a secret door that is activated by right clicking the ScriptedBlock. The ScriptedBlock must be placed as the block above the Secret Door. The blocks used for the door are supplied as an array to the SecretDoor constructor. The first item in the array is used for the ScriptedBlock itself. /* Secret Door Script for CustomNPCs usage: var thisSecretDoor; function init(event){ thisSecretDoor = new SecretDoor(event, ["minecraft:stonebrick", "minecraft:stonebrick", "minecraft:stonebrick"]); } function interact(event){ thisSecretDoor.interact(event); } */ function SecretDoor(initEvent, blockList){ var block = this.block = initEvent.block; this.blockList = blockList; this.block.setModel(this.block.getWorld().createItem(blockList[0], 0, 1)); this.x = Math.floor(block.getX()); this.y = Math.floor(block.getY()); this.z = Math.floor(block.getZ()); this.isOpen = false; this.close(); } SecretDoor.prototype.open = function(){ var world = this.block.getWorld(); this.block.executeCommand("/playsound tile.piston.in @a[r=10] "+this.x+" "+this.y+" "+this.z); for(var i=1;i<this.blockList.length;i++){ var blockY = this.y - i; world.setBlock(this.x, blockY, this.z, "minecraft:air", 0); } this.isOpen = true; }; SecretDoor.prototype.close = function() { var world = this.block.getWorld(); this.block.executeCommand("/playsound tile.piston.out @a[r=10] "+this.x+" "+this.y+" "+this.z); for(var i=1;i<this.blockList.length;i++){ var blockY = this.y - i; world.setBlock(this.x, blockY, this.z, this.blockList[i], 0); } this.isOpen = false; }; SecretDoor.prototype.interact = function(event) { if(this.isOpen===true){ this.close(); }else{ this.open(); } };
  4. Would this work? player.worldObj.getBiomeGenForCoords(player.getPosition()).biomeName
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.