Skip to content
Permalink
Browse files

Fixed XPStorer looking in the wrong spot for the chest.

  • Loading branch information...
me4502 committed Oct 18, 2016
1 parent c2b495a commit 6480d3b3d27e6b42fe5a545de8c1b824f6a74b36
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/main/java/com/sk89q/craftbook/mechanics/XPStorer.java
@@ -178,7 +178,7 @@ public void onPing(SelfTriggerPingEvent event) {
if (!autonomousMode) return;
if(!EventUtil.passesFilter(event)) return;

if(!SignUtil.isSign(event.getBlock())) return;
if(!SignUtil.isSign(event.getBlock()) && block.isSame(SignUtil.getBackBlock(event.getBlock()))) return;

ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());

@@ -202,7 +202,7 @@ public void onThink(SelfTriggerThinkEvent event) {

int xp = 0;

for (Entity entity : LocationUtil.getNearbyEntities(event.getBlock().getLocation(), new Vector(radius,radius,radius))) {
for (Entity entity : LocationUtil.getNearbyEntities(SignUtil.getBackBlock(event.getBlock()).getLocation(), new Vector(radius,radius,radius))) {
if (entity instanceof ExperienceOrb && entity.getTicksLived() > 20) {
xp += ((ExperienceOrb) entity).getExperience();
entity.remove();
@@ -212,8 +212,8 @@ public void onThink(SelfTriggerThinkEvent event) {
int max = Integer.MAX_VALUE;
Inventory inventory = null;

if (InventoryUtil.doesBlockHaveInventory(event.getBlock().getRelative(BlockFace.UP))) {
inventory = ((InventoryHolder) event.getBlock().getState()).getInventory();
if (InventoryUtil.doesBlockHaveInventory(SignUtil.getBackBlock(event.getBlock()).getRelative(BlockFace.UP))) {
inventory = ((InventoryHolder) SignUtil.getBackBlock(event.getBlock()).getRelative(BlockFace.UP).getState()).getInventory();
if (requireBottle) {
max = 0;
for (ItemStack stack : inventory.getContents()) {
@@ -234,10 +234,10 @@ public void onThink(SelfTriggerThinkEvent event) {
ItemStack bottles = new ItemStack(Material.EXP_BOTTLE, Math.min(tempBottles, 64));
if (inventory != null) {
for (ItemStack leftover : inventory.addItem(bottles).values()) {
event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), leftover);
event.getBlock().getWorld().dropItemNaturally(LocationUtil.getCenterOfBlock(SignUtil.getBackBlock(event.getBlock())), leftover);
}
} else {
event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), bottles);
event.getBlock().getWorld().dropItemNaturally(LocationUtil.getCenterOfBlock(SignUtil.getBackBlock(event.getBlock())), bottles);
}

tempBottles -= 64;
@@ -249,7 +249,7 @@ public void onThink(SelfTriggerThinkEvent event) {

int remainingXP = xp - bottleCount * xpPerBottle;
if (remainingXP > 0) {
ExperienceOrb orb = (ExperienceOrb) event.getBlock().getWorld().spawnEntity(event.getBlock().getLocation(), EntityType.EXPERIENCE_ORB);
ExperienceOrb orb = (ExperienceOrb) event.getBlock().getWorld().spawnEntity(LocationUtil.getCenterOfBlock(SignUtil.getBackBlock(event.getBlock())), EntityType.EXPERIENCE_ORB);
orb.setExperience(remainingXP);
}
}

0 comments on commit 6480d3b

Please sign in to comment.
You can’t perform that action at this time.