[HELP] Porting Bukkit plugin

I’m trying to port a Bukkit plugin to a Sponge, but I have zero experience at Sponge or Minecraft modding. For now I’ve done something but I’m far away from ready. My problem at the moment is this line:

Chunk tChunk = loc.getWorld().getChunkAt(x, z);

How do I manage to do this on Sponge? I also need help for porting this plugin, I think it’s too much for me. The plugin is WorldBorder and I can make a gitHub repository for files I’ve already edited.

Well, it’s basically the same exact thing. Stuff is just capitalized slightly different.

Ah, Location is a parameterized type. The usual type is Location<World>, but the parameter constraint is merely Location<E extends Extent>, and method names reflect this. Thus, you’re looking for loc.getExtent().getChunk(x, y, z).

1 Like

Thanks for the reply, but getExtent() does not have getChunk()…

Could you post the line where you set loc?

Extents contain chunks sometimes. Try checking if it’s an instance of a world, and if so, cast it to a world and then get the chunk.

Remember to store it as Location<World> and not just Location.

Sorry about late answer, don’t had time for this project until now.

Okay I got it working by using Location<World> location = loc; and then used that variable. There’s just so much to do and I can’t even tell what I’m doing.

There is the source of the original Bukkit plugin if someone more experienced can say if it’s best for me just to forget this whole thing.

1 Like

if you just want something to do world borders, nucleus can do per dimension borders

Maybe, but as far as I know nucleus can’t do a round world border and that’s the thing I need.

This is how i would do it.

Location<? extends Extent> loc;
Chunk chunk;
If(loc.getExtent() instanceof Chunk){
    chunk = (Chunk)loc.getExtent();
World world = loc.getExtent();
Optional<Chunk> opChunk = world.getChunkAtBlock(loc.getBlockPos());
    return opChunk.get();
//Chunk is not loaded

Im on mobile at the moment so i can not test it. I may also be combining old sponge api to new sponge api. Im just remembering how the sponge api is used

Well, he’s already said he already has a world, so this doesn’t need to be more complicated. Second, this wouldn’t compile - I believe you missed an else block there.