FastAsyncWorldEdit

FastAsyncWorldEdit

245k Downloads

Methods overridden in custom extent do not work (API)

Closed this issue ยท 4 comments

commented

Server Implementation

Paper

Server Version

1.21.7

Describe the bug

When I create my class SignExtent and overriding the setBlocks, relplaceBlocks methods, then the methods in SignExtent do not work when using the //set, //replace commands

I checked using breakpoints, and from them I realized that the EditSessionEvent event is triggered, but the SignExtent methods are not called

Listener:

@Subscribe
public void onEditSessionChange(EditSessionEvent event){
    if (event.getWorld() == null)
        return;

    event.setExtent(new SignExtent(event.getExtent(), BukkitAdapter.adapt(event.getWorld())));
}

private static class SignExtent extends AbstractDelegateExtent {
    private final World world;
    public SignExtent(@NotNull Extent extent, @NotNull World world) {
        super(extent);
        this.world = world;
    }

    public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException {
        ItemDisplayUtils.removeItemDisplayFromSign(BukkitAdapter.adapt(world, pos).add(0.5,0.5,0.5));
        return super.setBlock(pos, block);
    }

    public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
        ItemDisplayUtils.removeItemDisplayFromSign(BukkitAdapter.adapt(world, BlockVector3.at(x,y,z)).add(0.5,0.5,0.5));
        return super.setBlock(x, y, z, block);
    }

    public <B extends BlockStateHolder<B>> int setBlocks(final Region region, final B block) throws MaxChangedBlocksException {
        return super.setBlocks(region, block);
    }

    public int setBlocks(final Region region, final Pattern pattern) throws MaxChangedBlocksException {
        Console.warn("work!");
        return super.setBlocks(region, pattern);
    }

    public <B extends BlockStateHolder<B>> int replaceBlocks(final Region region, final Set<BaseBlock> filter, final B replacement) throws MaxChangedBlocksException {
        return super.replaceBlocks(region, filter, replacement);
    }

    public int replaceBlocks(final Region region, final Set<BaseBlock> filter, final Pattern pattern) throws MaxChangedBlocksException {
        return super.replaceBlocks(region, filter, pattern);
    }

    public int replaceBlocks(final Region region, final Mask mask, final Pattern pattern) throws MaxChangedBlocksException {
        return super.replaceBlocks(region, mask, pattern);
    }

    public int setBlocks(final Set<BlockVector3> vset, final Pattern pattern) {
        return super.setBlocks(vset, pattern);
    }
}

WorldEditListener register:
Fawe.instance().getWorldEdit().getEventBus().register(new WorldEditListener());

To Reproduce

  1. Used the code above
  2. Launched FAWE 2.13.1 with Modrinth
  3. Tried to execute the command //set 0
  4. None of the overridden methods worked

Expected behaviour

I expected one of the methods to work and I will add my actions for it

Screenshots / Videos

No response

Error log (if applicable)

No response

Fawe Debugpaste

https://athion.net/ISPaster/paste/view/95d1c7386b124de28f51a0b885152631

Fawe Version

FastAsyncWorldEdit-Paper-2.13.1

Checklist

Anything else?

No response

commented

You'll want to use a processor for set/replace - these are not done block-by-block to prevent slow edits.

commented

Okay, I got it, but I still don't understand how to solve my problem correctly.
I need to check each block for the presence of an entity when //set and //replace.
Can you help me with this, because I don't see how to do it

commented

Methods overridden in my custom class SignExtent from AbstractDelegateExtent do not work. I think it may be a bug in FAWE, because the same methods in WE work fine.

commented

You'll want to use a processor for set/replace - these are not done block-by-block to prevent slow edits.

Are there any alternatives to do this?