82327c1d |
1 | /* |
2 | * Decompiled with CFR 0.151. |
3 | * |
4 | * Could not load the following classes: |
5 | * com.wurmonline.client.renderer.GroundItemData |
6 | * org.gotti.wurmunlimited.modloader.ReflectionUtil |
7 | */ |
8 | package net.encode.wurmesp.feature.hook; |
9 | |
10 | import java.lang.reflect.Field; |
11 | import java.util.logging.Level; |
12 | |
13 | import org.gotti.wurmunlimited.modloader.ReflectionUtil; |
14 | |
15 | import com.wurmonline.client.renderer.GroundItemData; |
16 | |
17 | import net.encode.wurmesp.Unit; |
18 | import net.encode.wurmesp.WurmEspMod; |
19 | |
20 | public class GroundItemCellRenderableRemove |
21 | extends Hook { |
22 | public GroundItemCellRenderableRemove() { |
23 | this.prepareHook("com.wurmonline.client.renderer.cell.GroundItemCellRenderable", "removed", "(Z)V", () -> (proxy, method, args) -> { |
24 | method.invoke(proxy, args); |
25 | Class<?> cls = proxy.getClass(); |
26 | GroundItemData item = (GroundItemData)ReflectionUtil.getPrivateField((Object)proxy, (Field)ReflectionUtil.getField(cls, (String)"item")); |
27 | for (Unit unit : WurmEspMod.pickableUnits) { |
28 | if (unit.getId() != item.getId()) continue; |
29 | WurmEspMod.toRemove.add(unit); |
30 | } |
31 | for (Unit unit : WurmEspMod.toRemove) { |
32 | if (unit.getId() != item.getId()) continue; |
33 | WurmEspMod.pickableUnits.remove(unit); |
34 | } |
35 | WurmEspMod.toRemove.clear(); |
36 | return null; |
37 | }); |
38 | WurmEspMod.logger.log(Level.INFO, "[WurmEspMod] GroundItemCellRenderable.removed hooked"); |
39 | } |
40 | } |
41 | |