Skip to content

Instantly share code, notes, and snippets.

@mworzala
Created April 15, 2024 03:32
Show Gist options
  • Save mworzala/edd357c211432d63e81896874675cf6a to your computer and use it in GitHub Desktop.
Save mworzala/edd357c211432d63e81896874675cf6a to your computer and use it in GitHub Desktop.
package net.hollowcube.mapmaker.map.command.utility;
import com.google.inject.Inject;
import net.hollowcube.command.CommandContext;
import net.hollowcube.command.dsl.CommandDsl;
import net.hollowcube.mapmaker.map.block.vanilla.DripleafBlock;
import net.hollowcube.mapmaker.perm.PermManager;
import net.hollowcube.mapmaker.perm.PlatformPerm;
import net.minestom.server.entity.Player;
import org.jetbrains.annotations.NotNull;
public class FixTheDripleafCommand extends CommandDsl {
@Inject
public FixTheDripleafCommand(@NotNull PermManager permManager) {
super("fixthedripleaf");
setCondition(permManager.createPlatformCondition2(PlatformPerm.MAP_ADMIN));
addSyntax(playerOnly(this::fixTheDripleaf));
}
private void fixTheDripleaf(@NotNull Player player, @NotNull CommandContext context) {
var instance = player.getInstance();
var dimensionHeight = instance.getDimensionType().getHeight();
player.sendMessage("Fixing the dripleaf!!!");
int fixed = 0;
for (var chunk : instance.getChunks()) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = -64; y < dimensionHeight; y++) {
var block = chunk.getBlock(x, y, z);
if (block.name().equals("minecraft:big_dripleaf")) {
chunk.setBlock(x, y, z, block.withHandler(DripleafBlock.INSTANCE));
fixed++;
}
}
}
}
}
player.sendMessage("Fixed " + fixed + " dripleaf blocks!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment