Arclight icon indicating copy to clipboard operation
Arclight copied to clipboard

fix(core): prevent firing the event if the to block is < 0

Open danorris709 opened this issue 1 year ago • 2 comments

Fixes https://github.com/IzzelAliz/Arclight/issues/627 (tested by @nicholasrobertm and confirmed to work)

danorris709 avatar Sep 18 '22 20:09 danorris709

I have a slight feeling this would conflict with mods like Twilight Forest that do work below 0.

Shybella avatar Sep 18 '22 20:09 Shybella

This should not be the proper fix. I would prefer just wrap the notifyBlockUpdate call in CraftBlockState:

public boolean update(boolean force, boolean applyPhysics) {
        if (!this.isPlaced()) {
            return true;
        } else {
            CraftBlock block = this.getBlock();
            if (block.getType() != this.getType() && !force) {
                return false;
            } else {
                net.minecraft.block.BlockState newBlock = this.data;
                if (block.setTypeAndData(newBlock, applyPhysics)) // wrap with if
                this.world.getHandle().notifyBlockUpdate(this.position, block.getNMS(), newBlock, 3);
                return true;
            }
        }
    }

IzzelAliz avatar Sep 19 '22 05:09 IzzelAliz

Please test if it's working.

IzzelAliz avatar Oct 03 '22 02:10 IzzelAliz

Please test if it's working.

Works fine, tysm!

nicholasrobertm avatar Oct 03 '22 23:10 nicholasrobertm