-
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.
- Loading branch information
Showing
6 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ain/java/uk/protonull/civ/chesttracker/mixins/illegal/AlwaysReturnNoBlockSourceMixin.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,20 @@ | ||
package uk.protonull.civ.chesttracker.mixins.illegal; | ||
|
||
import java.util.Optional; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import red.jackf.chesttracker.api.ClientBlockSource; | ||
import red.jackf.chesttracker.impl.providers.InteractionTrackerImpl; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
@Mixin(InteractionTrackerImpl.class) | ||
public abstract class AlwaysReturnNoBlockSourceMixin { | ||
/** | ||
* @author Protonull | ||
* @reason Always return an empty optional. | ||
*/ | ||
@Overwrite(remap = false) | ||
public Optional<ClientBlockSource> getLastBlockSource() { | ||
return Optional.empty(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...va/uk/protonull/civ/chesttracker/mixins/illegal/DoNotRegisterBlockBreakListenerMixin.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.mixins.illegal; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import red.jackf.chesttracker.impl.events.AfterPlayerDestroyBlock; | ||
import red.jackf.chesttracker.impl.memory.MemoryIntegrity; | ||
import uk.protonull.civ.chesttracker.utilities.VoidEvents; | ||
|
||
@SuppressWarnings({"UnstableApiUsage"}) | ||
@Mixin(MemoryIntegrity.class) | ||
public abstract class DoNotRegisterBlockBreakListenerMixin { | ||
@Redirect( | ||
method = "setup", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lred/jackf/chesttracker/impl/events/AfterPlayerDestroyBlock;EVENT:Lnet/fabricmc/fabric/api/event/Event;" | ||
), | ||
remap = false | ||
) | ||
private static Event<AfterPlayerDestroyBlock> ctt$redirect$preventRegistration() { | ||
return VoidEvents.AFTER_PLAYER_DESTROY_BLOCK; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...va/uk/protonull/civ/chesttracker/mixins/illegal/DoNotRegisterBlockPlaceListenerMixin.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.mixins.illegal; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import red.jackf.chesttracker.impl.events.AfterPlayerPlaceBlock; | ||
import red.jackf.chesttracker.impl.providers.ProviderHandler; | ||
import uk.protonull.civ.chesttracker.utilities.VoidEvents; | ||
|
||
@SuppressWarnings({"UnstableApiUsage"}) | ||
@Mixin(ProviderHandler.class) | ||
public abstract class DoNotRegisterBlockPlaceListenerMixin { | ||
@Redirect( | ||
method = "setupEvents", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lred/jackf/chesttracker/impl/events/AfterPlayerPlaceBlock;EVENT:Lnet/fabricmc/fabric/api/event/Event;" | ||
), | ||
remap = false | ||
) | ||
protected Event<AfterPlayerPlaceBlock> ctt$redirect$preventRegistration() { | ||
return VoidEvents.AFTER_PLAYER_PLACE_BLOCK; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...java/uk/protonull/civ/chesttracker/mixins/illegal/DoNotRegisterUseBlockListenerMixin.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,24 @@ | ||
package uk.protonull.civ.chesttracker.mixins.illegal; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.player.UseBlockCallback; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import red.jackf.chesttracker.impl.providers.InteractionTrackerImpl; | ||
import uk.protonull.civ.chesttracker.utilities.VoidEvents; | ||
|
||
@Mixin(InteractionTrackerImpl.class) | ||
public abstract class DoNotRegisterUseBlockListenerMixin { | ||
@Redirect( | ||
method = "setup", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/fabricmc/fabric/api/event/player/UseBlockCallback;EVENT:Lnet/fabricmc/fabric/api/event/Event;" | ||
), | ||
remap = false | ||
) | ||
private static Event<UseBlockCallback> ctt$redirect$preventRegistration() { | ||
return VoidEvents.USE_BLOCK_CALLBACK; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/uk/protonull/civ/chesttracker/utilities/VoidEvents.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,30 @@ | ||
package uk.protonull.civ.chesttracker.utilities; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.player.UseBlockCallback; | ||
import red.jackf.chesttracker.impl.events.AfterPlayerDestroyBlock; | ||
import red.jackf.chesttracker.impl.events.AfterPlayerPlaceBlock; | ||
|
||
@SuppressWarnings({"UnstableApiUsage", "NonExtendableApiUsage"}) | ||
public final class VoidEvents { | ||
public static final Event<UseBlockCallback> USE_BLOCK_CALLBACK = new Event<>() { | ||
@Override | ||
public void register(final UseBlockCallback listener) { | ||
// Do nothing | ||
} | ||
}; | ||
|
||
public static final Event<AfterPlayerPlaceBlock> AFTER_PLAYER_PLACE_BLOCK = new Event<>() { | ||
@Override | ||
public void register(final AfterPlayerPlaceBlock listener) { | ||
// Do nothing | ||
} | ||
}; | ||
|
||
public static final Event<AfterPlayerDestroyBlock> AFTER_PLAYER_DESTROY_BLOCK = new Event<>() { | ||
@Override | ||
public void register(final AfterPlayerDestroyBlock listener) { | ||
// Do nothing | ||
} | ||
}; | ||
} |
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