mirror of
https://github.com/EpicEricEE/ShopChest.git
synced 2024-11-30 14:33:36 +01:00
Fix hologram interaction in 1.8.x
This commit is contained in:
parent
6dcedc9bff
commit
198f83c738
@ -341,7 +341,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
Entity entity = e.getRightClicked();
|
Entity entity = e.getRightClicked();
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if (e.getHand() == EquipmentSlot.HAND) {
|
if (Utils.getMajorVersion() == 8 || e.getHand() == EquipmentSlot.HAND) {
|
||||||
if (entity instanceof ArmorStand) {
|
if (entity instanceof ArmorStand) {
|
||||||
ArmorStand armorStand = (ArmorStand) entity;
|
ArmorStand armorStand = (ArmorStand) entity;
|
||||||
if (Hologram.isPartOfHologram(armorStand)) {
|
if (Hologram.isPartOfHologram(armorStand)) {
|
||||||
@ -355,7 +355,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
PlayerInteractEvent interactEvent = new PlayerInteractEvent(p, Action.RIGHT_CLICK_BLOCK, Utils.getPreferredItemInHand(p), b, null, EquipmentSlot.HAND);
|
PlayerInteractEvent interactEvent = new PlayerInteractEvent(p, Action.RIGHT_CLICK_BLOCK, Utils.getPreferredItemInHand(p), b, null);
|
||||||
handleInteractEvent(interactEvent, false);
|
handleInteractEvent(interactEvent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,8 +388,9 @@ public class ShopInteractListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
PlayerInteractEvent interactEvent = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, Utils.getPreferredItemInHand(p), b, null, EquipmentSlot.HAND);
|
PlayerInteractEvent interactEvent = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, Utils.getPreferredItemInHand(p), b, null);
|
||||||
handleInteractEvent(interactEvent, false);
|
handleInteractEvent(interactEvent, false);
|
||||||
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class Hologram {
|
|||||||
} else {
|
} else {
|
||||||
if (plugin.getShopChestConfig().enable_hologram_interaction) {
|
if (plugin.getShopChestConfig().enable_hologram_interaction) {
|
||||||
loc = location.clone();
|
loc = location.clone();
|
||||||
loc.add(0, 1, 0);
|
loc.add(0, 0.4, 0);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -90,10 +90,10 @@ public class Hologram {
|
|||||||
entityArmorStandClass.getMethod("setNoGravity", boolean.class).invoke(entityArmorStand, true);
|
entityArmorStandClass.getMethod("setNoGravity", boolean.class).invoke(entityArmorStand, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Probably like an addEntity() method...
|
// Adds the entity to some lists so it can call interact events
|
||||||
Method b = nmsWorldServer.getClass().getDeclaredMethod("b", entityClass);
|
Method addEntityMethod = nmsWorldServer.getClass().getDeclaredMethod((Utils.getMajorVersion() == 8 ? "a" : "b"), entityClass);
|
||||||
b.setAccessible(true);
|
addEntityMethod.setAccessible(true);
|
||||||
b.invoke(nmsWorldServer, entityArmorStand);
|
addEntityMethod.invoke(nmsWorldServer, entityArmorStand);
|
||||||
|
|
||||||
Object uuid = entityClass.getMethod("getUniqueID").invoke(entityArmorStand);
|
Object uuid = entityClass.getMethod("getUniqueID").invoke(entityArmorStand);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user