82327c1d |
1 | /* |
2 | * Decompiled with CFR 0.151. |
3 | * |
4 | * Could not load the following classes: |
5 | * com.wurmonline.client.renderer.GroundItemData |
6 | * com.wurmonline.client.renderer.PickableUnit |
7 | * org.gotti.wurmunlimited.modloader.ReflectionUtil |
8 | */ |
9 | package net.encode.wurmesp.feature.hook; |
10 | |
11 | import com.wurmonline.client.renderer.GroundItemData; |
12 | import com.wurmonline.client.renderer.PickableUnit; |
13 | import com.wurmonline.client.renderer.cell.CellRenderable; |
14 | |
15 | import java.lang.reflect.Field; |
16 | import java.util.logging.Level; |
17 | import net.encode.wurmesp.Unit; |
18 | import net.encode.wurmesp.WurmEspMod; |
19 | import net.encode.wurmesp.util.SoundUtils; |
20 | import org.gotti.wurmunlimited.modloader.ReflectionUtil; |
21 | |
22 | public class GroundItemCellRenderableInit |
23 | extends Hook { |
24 | public GroundItemCellRenderableInit() { |
25 | this.prepareHook("com.wurmonline.client.renderer.cell.GroundItemCellRenderable", "initialize", "()V", () -> (proxy, method, args) -> { |
26 | method.invoke(proxy, args); |
27 | Class<?> cls = proxy.getClass(); |
28 | PickableUnit pUnit = (PickableUnit)proxy; |
29 | GroundItemData item = (GroundItemData)ReflectionUtil.getPrivateField((Object)proxy, (Field)ReflectionUtil.getField(cls, (String)"item")); |
30 | Unit unit = new Unit(CellRenderable.world, item.getId(), pUnit, item.getModelName().toString(), ((PickableUnit)proxy).getHoverName()); |
31 | if (unit.isSpecial()) { |
32 | WurmEspMod.pickableUnits.add(unit); |
33 | if (WurmEspMod.specials && WurmEspMod.playsoundspecial) { |
34 | SoundUtils.playSound(WurmEspMod.soundspecial); |
35 | } |
36 | } else if (unit.isSpotted()) { |
37 | WurmEspMod.pickableUnits.add(unit); |
38 | if (WurmEspMod.items && WurmEspMod.playsounditem) { |
39 | SoundUtils.playSound(WurmEspMod.sounditem); |
40 | } |
41 | } |
42 | return null; |
43 | }); |
44 | WurmEspMod.logger.log(Level.INFO, "[WurmEspMod] GroundItemCellRenderable.initialize hooked"); |
45 | } |
46 | } |
47 | |