-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nuke events instead of trying to intercept them
- Loading branch information
Showing
9 changed files
with
98 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
...va/uk/protonull/civ/chesttracker/mixins/illegal/DoNotRegisterBlockBreakListenerMixin.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
...va/uk/protonull/civ/chesttracker/mixins/illegal/DoNotRegisterBlockPlaceListenerMixin.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...n/java/uk/protonull/civ/chesttracker/mixins/illegal/NukeAfterPlayerDestroyBlockMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package uk.protonull.civ.chesttracker.mixins.illegal; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import red.jackf.chesttracker.impl.events.AfterPlayerDestroyBlock; | ||
import uk.protonull.civ.chesttracker.utilities.VoidEvent; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
@Mixin(AfterPlayerDestroyBlock.class) | ||
public interface NukeAfterPlayerDestroyBlockMixin { | ||
@Shadow(remap = false) | ||
Event<AfterPlayerDestroyBlock> EVENT = new VoidEvent<>( | ||
(cbs) -> {} | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
...ain/java/uk/protonull/civ/chesttracker/mixins/illegal/NukeAfterPlayerPlaceBlockMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package uk.protonull.civ.chesttracker.mixins.illegal; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import red.jackf.chesttracker.impl.events.AfterPlayerPlaceBlock; | ||
import uk.protonull.civ.chesttracker.utilities.VoidEvent; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
@Mixin(AfterPlayerPlaceBlock.class) | ||
public interface NukeAfterPlayerPlaceBlockMixin { | ||
@Shadow(remap = false) | ||
Event<AfterPlayerPlaceBlock> EVENT = new VoidEvent<>( | ||
(level, pos, state, placed) -> {} | ||
); | ||
} |
34 changes: 34 additions & 0 deletions
34
...in/java/uk/protonull/civ/chesttracker/mixins/illegal/NukeConnectedBlocksGrabberMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package uk.protonull.civ.chesttracker.mixins.illegal; | ||
|
||
import java.util.List; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import red.jackf.whereisit.api.search.ConnectedBlocksGrabber; | ||
import uk.protonull.civ.chesttracker.utilities.VoidEvent; | ||
|
||
@Mixin(ConnectedBlocksGrabber.class) | ||
public interface NukeConnectedBlocksGrabberMixin { | ||
@Shadow(remap = false) | ||
Event<ConnectedBlocksGrabber> EVENT = new VoidEvent<>( | ||
(positions, pos, level, state) -> {} | ||
); | ||
|
||
/** | ||
* @author Protonull | ||
* @reason Always only return the provided position. | ||
*/ | ||
@Overwrite | ||
static List<BlockPos> getConnected( | ||
final @NotNull Level level, | ||
final @NotNull BlockState state, | ||
final @NotNull BlockPos pos | ||
) { | ||
return List.of(pos.immutable()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/uk/protonull/civ/chesttracker/utilities/VoidEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package uk.protonull.civ.chesttracker.utilities; | ||
|
||
import java.util.Objects; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@SuppressWarnings("NonExtendableApiUsage") | ||
public final class VoidEvent<T> extends Event<T> { | ||
public VoidEvent() { | ||
|
||
} | ||
|
||
public VoidEvent( | ||
final @NotNull T voidHandler | ||
) { | ||
this.invoker = Objects.requireNonNull(voidHandler); | ||
} | ||
|
||
@Override | ||
public void register( | ||
final @NotNull T listener | ||
) { | ||
// Do nothing | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
src/main/java/uk/protonull/civ/chesttracker/utilities/VoidEvents.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters