Skip to content

Commit

Permalink
Nuke events instead of trying to intercept them
Browse files Browse the repository at this point in the history
  • Loading branch information
Protonull committed Oct 1, 2024
1 parent 5da6f91 commit 68f92e6
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 73 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ dependencies {
// Make sure the branch is the correct Minecraft version!
compileOnly("red.jackf.jackfredlib:jackfredlib:0.10.2+1.21.1")

// Find the version set at "where-is-it_version" at: https://github.com/JackFred2/ChestTracker/blob/1.21.1/gradle.properties
// Make sure the branch is the correct Minecraft version!
modCompileOnly("red.jackf:whereisit:2.6.3+1.21.1")

// https://modrinth.com/mod/modmenu/version/11.0.2
modLocalRuntime("maven.modrinth:modmenu:3ib3Uvvv")

Expand Down

This file was deleted.

This file was deleted.

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) -> {}
);
}
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) -> {}
);
}
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());
}
}
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
}
}

This file was deleted.

5 changes: 3 additions & 2 deletions src/main/resources/civchesttracker.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"cruft.DoNotRegisterHypixelProviderMixin",

"illegal.DoNotListenForBlockBreaksMixin",
"illegal.DoNotRegisterBlockBreakListenerMixin",
"illegal.DoNotRegisterBlockPlaceListenerMixin",
"illegal.NukeAfterPlayerDestroyBlockMixin",
"illegal.NukeAfterPlayerPlaceBlockMixin",
"illegal.NukeConnectedBlocksGrabberMixin",
"illegal.NukeInteractionTrackerImplMixin",

"InventoryContextButtonsMixin",
Expand Down

0 comments on commit 68f92e6

Please sign in to comment.