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.
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).
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.
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());
If(opChunk.isPresent()){
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.