| 1 | package net.encode.wurmesp.feature.hook; |
| 2 | |
| 3 | import java.util.logging.Level; |
| 4 | |
| 5 | import com.wurmonline.client.renderer.PickableUnit; |
| 6 | |
| 7 | import net.encode.wurmesp.Unit; |
| 8 | import net.encode.wurmesp.WurmEspMod; |
| 9 | |
| 10 | public class MobileModelRenderableRemove |
| 11 | extends Hook { |
| 12 | public MobileModelRenderableRemove() { |
| 13 | this.prepareHook("com.wurmonline.client.renderer.cell.MobileModelRenderable", "removed", "(Z)V", () -> (proxy, method, args) -> { |
| 14 | method.invoke(proxy, args); |
| 15 | PickableUnit item = (PickableUnit)proxy; |
| 16 | for (Unit unit : WurmEspMod.pickableUnits) { |
| 17 | if (unit.getId() != item.getId()) continue; |
| 18 | WurmEspMod.toRemove.add(unit); |
| 19 | } |
| 20 | for (Unit unit : WurmEspMod.toRemove) { |
| 21 | if (unit.getId() != item.getId()) continue; |
| 22 | WurmEspMod.pickableUnits.remove(unit); |
| 23 | } |
| 24 | WurmEspMod.toRemove.clear(); |
| 25 | return null; |
| 26 | }); |
| 27 | WurmEspMod.logger.log(Level.INFO, "[WurmEspMod] MobileModelRenderable.removed hooked"); |
| 28 | } |
| 29 | } |
| 30 | |