Skip to content

1.7 - 1.20.4 util that allows you to change blocks at blazing fast speeds

License

Notifications You must be signed in to change notification settings

TheGaming999/BlockChanger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 

Repository files navigation

BlockChanger

A single class that offers very fast block placement methods from NMS using static final method handles, inheritance, and abstraction, designed to support multiple versions (1.7.10 - 1.20.4) and minimize the overhead of reflection as much as possible. Currently, only the first three methods from the thread below are supported.

Please refer to this thread for more information: (https://www.spigotmc.org/threads/methods-for-changing-massive-amount-of-blocks-up-to-14m-blocks-s.395868/)

Setup

Just import the class to your project.

Usage

// player location as an example.
Player player = ...
BlockChanger.setBlock(player.getLocation(), Material.GOLD_BLOCK);
BlockChanger.setBlock(player.getLocation(), new ItemStack(Material.GOLD_BLOCK));

// Usage of async methods is the same as the regular methods.
// Type 1: Set block by NMS World method (nmsWorld#setTypeAndData) (80-90K blocks per second)
BlockChanger.setBlockAsynchronously(player.getLocation(), new ItemStack(Material.STONE), false);
// Type 2: Set block by NMS Chunk method (nmsChunk#setType) (2.19M blocks per second)
BlockChanger.setChunkBlockAsynchronously(player.getLocation(), new ItemStack(Material.DIRT), false);
// Type 3: Set block by NMS ChunkSection method (nmsChunkSection#setType) (7.9M blocks per second)
BlockChanger.setSectionBlockAsynchronously(player.getLocation(), new ItemStack(Material.GOLD_ORE), false);

// cornerA and cornerB are locations.
// This method returns a CompletableFuture<Void>, which gets completed once all blocks are set.
BlockChanger.setCuboidAsynchronously(cornerA, cornerB, new ItemStack(Material.DIAMOND_BLOCK), false)
.thenRun(() -> {
	// gets executed after cuboid has been filled entirely
	Bukkit.broadcastMessage("COMPLETED!");
});

// Fastest method (setSection).
BlockChanger.setSectionCuboidAsynchronously(corner1, corner2, new ItemStack(Material.GLASS), false)
.thenRunAsync(() -> {
	Bukkit.broadcastMessage("COMPLETED!");
});

BlockChanger. // see all the methods

ToDo

  • Method to update lighting?

License

FOSSA Status

About

1.7 - 1.20.4 util that allows you to change blocks at blazing fast speeds

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages