Getting a list of loaded Blocks

Avatar

By michaelpt9 11 January 2020 21:50

Member · 154 comments

Is ther ea possibility to get a list of loaded blocks or any kind of getting the position of a specific block type?

Last edited by michaelpt9 (11 January 2020 21:58)


ScriptAPI fucktard.

Avatar

By Coccocoa 11 January 2020 22:37

Member · 495 comments

You can use blockesp and select the id


Helo fratm

Avatar

By Coccocoa 11 January 2020 22:54

Member · 495 comments
michaelpt9 wrote
Coccocoa wrote

You can use blockesp and select the id

Did you read the thread? Also, did you notice that this is in the "Scripts" Section?

Scripts section is where you post scripts, l0l


Helo fratm

Avatar

By michaelpt9 11 January 2020 23:01

Member · 154 comments
Coccocoa wrote
michaelpt9 wrote
Coccocoa wrote

You can use blockesp and select the id

Did you read the thread? Also, did you notice that this is in the "Scripts" Section?

Scripts section is where you post scripts, l0l

You're right, but if I askes in the Support section, this being related to ScriptAPI wouldn't be as obvious, as you overlooked / shat on


ScriptAPI fucktard.

Avatar

By Coccocoa 11 January 2020 23:20

Member · 495 comments
michaelpt9 wrote
Coccocoa wrote
michaelpt9 wrote

Did you read the thread? Also, did you notice that this is in the "Scripts" Section?

Scripts section is where you post scripts, l0l

You're right, but if I askes in the Support section, this being related to ScriptAPI wouldn't be as obvious, as you overlooked / shat on

Just post on support and say "in scriptapi how I can do…'


Helo fratm

Avatar

By Nvaros 12 January 2020 16:46

Member · 61 comments

idk but

var scriptName = "BlockList";
var scriptAuthor = "You";
var scriptVersion = 1.0;

function BlockList() {

	var BlockPos = Java.type('net.minecraft.util.BlockPos');
	var Block = Java.type('net.minecraft.block.Block');
	var CheckBlockID = value.createBlock("Block", 1);
	var CheckRange = value.createFloat("CheckRange", 10.0, 5, 50); // Too high value will lag
	var BlockID;
	var arrBlockX = [];
	var arrBlockY = [];
	var arrBlockZ = [];
	var BPos;
	var BGet;
	var BName;
	var BlockCount;

	this.getName = function() {
        return "CheckBlock";
    };

   
    this.getDescription = function() {
        return "Checks for a certain block type and outputs their position";
    };

    
    this.getCategory = function() {
        return "Misc";
    };
	
	this.addValues = function(values) {
		values.add(CheckBlockID);
		values.add(CheckRange);	
	}

	this.onEnable = function() {
	
		arrBlockX = [];
		arrBlockY = [];
		arrBlockZ = [];
		
		BlockCount = 0;
		BlockID = CheckBlockID.get();
		BName = Block.getBlockById(BlockID).getLocalizedName();
		
		for(var x = -CheckRange.get(); x <= CheckRange.get(); x++) {
			for(var y = -CheckRange.get(); y <= CheckRange.get(); y++) {
				for(var z = -CheckRange.get(); z <= CheckRange.get(); z++) {
					BPos = new BlockPos(mc.thePlayer.posX + x, mc.thePlayer.posY + y, mc.thePlayer.posZ + z);
					BGet = mc.theWorld.getBlockState(BPos).getBlock();
					
					if (BGet.getBlockState().getBlock() == Block.getBlockById(BlockID) && Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)) <= CheckRange.get()) {
						
						BlockCount++;
						arrBlockX.push(BPos.getX());
						arrBlockY.push(BPos.getY());
						arrBlockZ.push(BPos.getZ());
					}	
				}
			}
		}
		
		chat.print("There are §a" + BlockCount + " §rblocks of §a" + BName + " §rwithin a distance of §a" + CheckRange.get() + " §rblocks:")
		
		for (var k = 0; k < BlockCount; k++) {
		chat.print(arrBlockX[k] + " | " + arrBlockY[k] + " | " + arrBlockZ[k]);
		}
	}
	

    this.onDisable = function() {
		
    };

	this.onUpdate = function() {
		commandManager.executeCommand(".t CheckBlock");
    };
	   
}

var blocklist = new BlockList();
var blocklistClient;

function onEnable() {
    blocklistClient = moduleManager.registerModule(blocklist);
}

function onDisable() {
    moduleManager.unregisterModule(blocklistClient);
}

you'd need some sort of real time timer to prevent lag for larger distances

Last edited by Nvaros (12 January 2020 17:48)

Avatar

By michaelpt9 1 March 2020 17:36

Member · 154 comments
Nvaros wrote

idk but

var scriptName = "BlockList";
var scriptAuthor = "You";
var scriptVersion = 1.0;

(...)
function onEnable() {
    blocklistClient = moduleManager.registerModule(blocklist);
}

function onDisable() {
    moduleManager.unregisterModule(blocklistClient);
}

you'd need some sort of real time timer to prevent lag for larger distances

Thanks. Really good.


ScriptAPI fucktard.