From df8f80f9cb55fdcb32152e9cb61784823a9ff6e5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 6 Feb 2020 01:16:51 +0200 Subject: [PATCH] Add vending machines without sides --- .../habbo/habbohotel/items/ItemManager.java | 1 + .../InteractionNoSidesVendingMachine.java | 24 +++++++++++++++++++ .../InteractionVendingMachine.java | 6 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index cde2f0e3..4e6969e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -178,6 +178,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class)); this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class)); this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class)); + this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class)); this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java new file mode 100644 index 00000000..367d500e --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java @@ -0,0 +1,24 @@ +package com.eu.habbo.habbohotel.items.interactions; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.users.Habbo; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionNoSidesVendingMachine extends InteractionVendingMachine { + public InteractionNoSidesVendingMachine(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionNoSidesVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public RoomTile getRequiredTile(Habbo habbo, Room room) { + return habbo.getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), true); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 50d66b91..4ddc40bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -46,7 +46,7 @@ public class InteractionVendingMachine extends HabboItem { super.onClick(client, room, objects); if (client != null) { - RoomTile tile = getSquareInFront(room.getLayout(), this); + RoomTile tile = this.getRequiredTile(client.getHabbo(), room); if (tile != null) { if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { @@ -207,4 +207,8 @@ public class InteractionVendingMachine extends HabboItem { public void giveVendingMachineItem(Habbo habbo, Room room) { Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem())); } + + public RoomTile getRequiredTile(Habbo habbo, Room room) { + return getSquareInFront(room.getLayout(), this); + } }