Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 02f1e61

Browse files
committed
0.6.0 - KillEffects Lightning
1 parent b1345b8 commit 02f1e61

File tree

6 files changed

+113
-19
lines changed

6 files changed

+113
-19
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ My personal RusherHack tweaks plugin
99
- Durability101 (Armor HUD) - Durability101 Mod
1010
- RepairPriority (AutoArmor) - Prioritize low durability armor with mending
1111
- GoldenPriority (AutoArmor) - Prioritize one piece of golden armor for piglins
12-
- Priority Binds (AutoArmor) - Key binds for priority setting toggles
12+
- Priority Binds (AutoArmor) - Key binds for priority setting toggles
13+
- Lightning (KillEffects) - Show a client side lightning effect when a player dies

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ minecraft_version=1.20.4
77
parchment_version=2024.04.14
88

99
# Plugin Properties
10-
plugin_version=0.5.0
10+
plugin_version=0.6.0
1111
maven_group=com.shaybox.rusher
1212
archives_base_name=shays-rusher-plugin
Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
package com.shaybox.rusher;
22

3-
import com.shaybox.rusher.tweaks.*;
3+
import com.shaybox.rusher.modules.KillEffects;
4+
import com.shaybox.rusher.tweaks.ArmorPriority;
5+
import com.shaybox.rusher.tweaks.Durability101;
6+
import com.shaybox.rusher.tweaks.NightVision;
7+
import com.shaybox.rusher.tweaks.PauseOnUse;
48
import org.rusherhack.client.api.RusherHackAPI;
9+
import org.rusherhack.client.api.feature.module.IModule;
10+
import org.rusherhack.client.api.feature.module.ToggleableModule;
511
import org.rusherhack.client.api.plugin.Plugin;
612
import org.rusherhack.core.event.IEventBus;
713
import org.rusherhack.core.event.listener.EventListener;
14+
import org.rusherhack.core.feature.IFeatureManager;
815

916
@SuppressWarnings("unused")
1017
public class Main extends Plugin {
1118

19+
/* ModuleManager & Modules */
20+
private final IFeatureManager<IModule> moduleManager = RusherHackAPI.getModuleManager();
21+
private final ToggleableModule killEffects = new KillEffects();
22+
1223
/* EventBus & Listeners */
1324
private final IEventBus eventBus = RusherHackAPI.getEventBus();
1425
private final EventListener armorPriority = new ArmorPriority();
@@ -18,18 +29,19 @@ public class Main extends Plugin {
1829

1930
@Override
2031
public void onLoad() {
21-
eventBus.subscribe(armorPriority);
22-
eventBus.subscribe(durability101);
23-
eventBus.subscribe(nightVision);
24-
eventBus.subscribe(pauseOnUse);
32+
this.moduleManager.registerFeature(this.killEffects);
33+
this.eventBus.subscribe(this.armorPriority);
34+
this.eventBus.subscribe(this.durability101);
35+
this.eventBus.subscribe(this.nightVision);
36+
this.eventBus.subscribe(this.pauseOnUse);
2537
}
2638

2739
@Override
2840
public void onUnload() {
29-
eventBus.unsubscribe(armorPriority);
30-
eventBus.unsubscribe(durability101);
31-
eventBus.unsubscribe(nightVision);
32-
eventBus.unsubscribe(pauseOnUse);
41+
this.eventBus.unsubscribe(this.armorPriority);
42+
this.eventBus.unsubscribe(this.durability101);
43+
this.eventBus.unsubscribe(this.nightVision);
44+
this.eventBus.unsubscribe(this.pauseOnUse);
3345
}
3446

3547
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.shaybox.rusher.modules;
2+
3+
import net.minecraft.client.Minecraft;
4+
import net.minecraft.network.protocol.Packet;
5+
import net.minecraft.network.protocol.game.ClientboundDamageEventPacket;
6+
import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
7+
import net.minecraft.world.damagesource.DamageSource;
8+
import net.minecraft.world.damagesource.DamageTypes;
9+
import net.minecraft.world.entity.Entity;
10+
import net.minecraft.world.entity.EntityType;
11+
import net.minecraft.world.entity.LightningBolt;
12+
import net.minecraft.world.entity.player.Player;
13+
import org.rusherhack.client.api.events.network.EventPacket;
14+
import org.rusherhack.client.api.feature.module.ModuleCategory;
15+
import org.rusherhack.client.api.feature.module.ToggleableModule;
16+
import org.rusherhack.core.event.subscribe.Subscribe;
17+
import org.rusherhack.core.setting.BooleanSetting;
18+
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
22+
public class KillEffects extends ToggleableModule {
23+
24+
/* Minecraft */
25+
private final Minecraft minecraft = Minecraft.getInstance();
26+
27+
/* RusherHackAPI Managers & Settings */
28+
private final BooleanSetting self = new BooleanSetting("Self", "Only when you kill", false);
29+
30+
/* Previous State */
31+
private final Map<Entity, Entity> playerAttacker = new HashMap<>();
32+
33+
/* Initialize */
34+
public KillEffects() {
35+
super("KillEffects", ModuleCategory.RENDER);
36+
this.registerSettings(this.self);
37+
}
38+
39+
@SuppressWarnings("unused")
40+
@Subscribe
41+
private void onPacket(EventPacket.Receive event) {
42+
Packet<?> packet = event.getPacket();
43+
44+
if (packet instanceof ClientboundDamageEventPacket damagePacket) {
45+
assert this.minecraft.level != null;
46+
47+
DamageSource source = damagePacket.getSource(this.minecraft.level);
48+
if (!source.is(DamageTypes.PLAYER_ATTACK)) return;
49+
50+
Entity entity = this.minecraft.level.getEntity(damagePacket.entityId());
51+
if (entity instanceof Player) {
52+
Entity attacker = this.minecraft.level.getEntity(damagePacket.sourceCauseId());
53+
this.playerAttacker.put(entity, attacker);
54+
}
55+
} else if (packet instanceof ClientboundEntityEventPacket entityPacket) {
56+
assert this.minecraft.level != null;
57+
58+
byte eventId = entityPacket.getEventId();
59+
if (eventId != 3) return;
60+
61+
Entity entity = entityPacket.getEntity(this.minecraft.level);
62+
boolean isPlayer = entity instanceof Player;
63+
if (!isPlayer) return;
64+
65+
Entity attacker = this.playerAttacker.get(entity);
66+
if (attacker == null) return;
67+
else this.playerAttacker.remove(entity);
68+
69+
/* Only show lightning when the local player is the attacker */
70+
if (this.self.getValue() && attacker != this.minecraft.player) return;
71+
72+
LightningBolt lightning = new LightningBolt(EntityType.LIGHTNING_BOLT, this.minecraft.level);
73+
lightning.setPos(entity.position());
74+
this.minecraft.level.addEntity(lightning);
75+
}
76+
}
77+
78+
}

src/main/java/com/shaybox/rusher/tweaks/ArmorPriority.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public boolean isListening() {
8585
);
8686
}
8787

88-
@Subscribe
8988
@SuppressWarnings("unused")
89+
@Subscribe
9090
private void onUpdate(EventUpdate event) {
9191
if (minecraft.screen != null) return;
9292

@@ -145,18 +145,18 @@ private void onPlayerUpdate(EventPlayerUpdate event) {
145145

146146
int itemDamage = itemStack.getDamageValue();
147147
int armorDamage = armorStack.getDamageValue();
148-
if (itemDamage > armorDamage) swapSlotId(player, slot, armorSlotId);
148+
if (itemDamage > armorDamage) swapSlotArmorId(slot, armorSlotId);
149149
});
150150
}
151151
}
152152

153153
if (prioritizeGolden) {
154154
this.repairPriority.setValue(false);
155155

156-
for (Item goldArmor : this.goldenArmorPriority)
156+
for (Item goldenArmor : this.goldenArmorPriority)
157157
player.inventoryMenu.slots.stream()
158-
.filter(slot -> slot.getItem().getItem() instanceof Equipable e && e == goldArmor)
159-
.filter(slot -> { /* Only one piece of gold armor */
158+
.filter(slot -> slot.getItem().getItem() instanceof Equipable e && e == goldenArmor)
159+
.filter(slot -> { /* Only one piece of golden armor */
160160
for (Item item : this.goldenArmorPriority)
161161
if (inventory.armor.stream().map(ItemStack::getItem).toList().contains(item))
162162
return false;
@@ -166,7 +166,7 @@ private void onPlayerUpdate(EventPlayerUpdate event) {
166166
Equipable equipable = (Equipable) slot.getItem().getItem();
167167
EquipmentSlot equipmentSlot = equipable.getEquipmentSlot();
168168
int armorSlotId = InventoryUtils.getInventorySlot(equipmentSlot);
169-
this.swapSlotId(player, slot, armorSlotId);
169+
this.swapSlotArmorId(slot, armorSlotId);
170170
});
171171
}
172172
} else if (isPaused) {
@@ -175,7 +175,7 @@ private void onPlayerUpdate(EventPlayerUpdate event) {
175175
}
176176
}
177177

178-
private void swapSlotId(LocalPlayer player, Slot slot, int armorSlotId) {
178+
private void swapSlotArmorId(Slot slot, int armorSlotId) {
179179
InventoryUtils.clickSlot(slot.index, false);
180180
InventoryUtils.clickSlot(armorSlotId, false);
181181
InventoryUtils.clickSlot(slot.index, false);

src/main/resources/rusherhack-plugin.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
"ShayBox"
88
],
99
"Minecraft-Versions": [
10+
"1.20.6",
11+
"1.20.5",
1012
"1.20.4",
1113
"1.20.3",
1214
"1.20.2",
13-
"1.20.1"
15+
"1.20.1",
16+
"1.12.2"
1417
]
1518
}

0 commit comments

Comments
 (0)