This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add sign spammer * remove unused imports * sort mixins and use javadoc comment * move javadoc above annotation
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/me/zeroeightsix/kami/mixin/client/MixinClientPlayNetworkHandler.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,48 @@ | ||
package me.zeroeightsix.kami.mixin.client; | ||
|
||
import me.zeroeightsix.kami.feature.module.SignSpammer; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.minecraft.network.Packet; | ||
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; | ||
import net.minecraft.network.packet.s2c.play.SignEditorOpenS2CPacket; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(ClientPlayNetworkHandler.class) | ||
public abstract class MixinClientPlayNetworkHandler { | ||
@Shadow | ||
public abstract void sendPacket(Packet<?> packet); | ||
|
||
@Inject( | ||
method = "onSignEditorOpen", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/client/network/ClientPlayerEntity;openEditSignScreen(Lnet/minecraft/block/entity/SignBlockEntity;)V" | ||
), | ||
cancellable = true, | ||
locals = LocalCapture.CAPTURE_FAILSOFT | ||
) | ||
private void onSignEditorOpen(SignEditorOpenS2CPacket packet, CallbackInfo ci, BlockEntity blockEntity) { | ||
// this variable is just here for some deduplication | ||
SignSpammer spammer = SignSpammer.INSTANCE; | ||
if (spammer.getEnabled()) { | ||
this.sendPacket( | ||
new UpdateSignC2SPacket( | ||
packet.getPos(), | ||
spammer.getLine1(), | ||
spammer.getLine2(), | ||
spammer.getLine3(), | ||
spammer.getLine4() | ||
) | ||
); | ||
blockEntity.markDirty(); | ||
// cancel to not open edit screen | ||
ci.cancel(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/me/zeroeightsix/kami/feature/module/SignSpammer.kt
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,22 @@ | ||
package me.zeroeightsix.kami.feature.module | ||
|
||
import io.github.fablabsmc.fablabs.api.fiber.v1.annotation.Setting | ||
|
||
/** | ||
* @see me.zeroeightsix.kami.mixin.client.MixinClientPlayNetworkHandler | ||
*/ | ||
@Module.Info( | ||
name = "SignSpammer", | ||
category = Module.Category.MISC, | ||
description = "Automatically fills newly placed signs" | ||
) | ||
object SignSpammer : Module() { | ||
@Setting | ||
var line1 = "" | ||
@Setting | ||
var line2 = "" | ||
@Setting | ||
var line3 = "" | ||
@Setting | ||
var line4 = "" | ||
} |
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