First Commit
[esp.git] / src / net / encode / wurmesp / feature / hook / GroundItemCellRenderableInit.java
CommitLineData
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 */
9package net.encode.wurmesp.feature.hook;
10
11import com.wurmonline.client.renderer.GroundItemData;
12import com.wurmonline.client.renderer.PickableUnit;
13import com.wurmonline.client.renderer.cell.CellRenderable;
14
15import java.lang.reflect.Field;
16import java.util.logging.Level;
17import net.encode.wurmesp.Unit;
18import net.encode.wurmesp.WurmEspMod;
19import net.encode.wurmesp.util.SoundUtils;
20import org.gotti.wurmunlimited.modloader.ReflectionUtil;
21
22public class GroundItemCellRenderableInit
23extends 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