1 package net
.encode
.wurmesp
.feature
.hook
;
3 import com
.wurmonline
.client
.renderer
.GroundItemData
;
4 import com
.wurmonline
.client
.renderer
.PickableUnit
;
5 import com
.wurmonline
.client
.renderer
.cell
.CellRenderable
;
7 import java
.lang
.reflect
.Field
;
8 import java
.util
.logging
.Level
;
9 import net
.encode
.wurmesp
.Unit
;
10 import net
.encode
.wurmesp
.WurmEspMod
;
11 import net
.encode
.wurmesp
.util
.SoundUtils
;
12 import org
.gotti
.wurmunlimited
.modloader
.ReflectionUtil
;
14 public class GroundItemCellRenderableInit
16 public GroundItemCellRenderableInit() {
17 this.prepareHook("com.wurmonline.client.renderer.cell.GroundItemCellRenderable", "initialize", "()V", () -> (proxy
, method
, args
) -> {
18 method
.invoke(proxy
, args
);
19 Class
<?
> cls
= proxy
.getClass();
20 PickableUnit pUnit
= (PickableUnit
)proxy
;
21 GroundItemData item
= (GroundItemData
)ReflectionUtil
.getPrivateField((Object
)proxy
, (Field
)ReflectionUtil
.getField(cls
, (String
)"item"));
22 Unit unit
= new Unit(CellRenderable
.world
, item
.getId(), pUnit
, item
.getModelName().toString(), ((PickableUnit
)proxy
).getHoverName());
23 if (unit
.isSpecial()) {
24 WurmEspMod
.pickableUnits
.add(unit
);
25 if (WurmEspMod
.specials
&& WurmEspMod
.playsoundspecial
) {
26 SoundUtils
.playSound(WurmEspMod
.soundspecial
);
28 } else if (unit
.isSpotted()) {
29 WurmEspMod
.pickableUnits
.add(unit
);
30 if (WurmEspMod
.items
&& WurmEspMod
.playsounditem
) {
31 SoundUtils
.playSound(WurmEspMod
.sounditem
);
36 WurmEspMod
.logger
.log(Level
.INFO
, "[WurmEspMod] GroundItemCellRenderable.initialize hooked");