Skip to content

Commit

Permalink
7.1.8.41: Fix setting path to TileEntity, fix #38
Browse files Browse the repository at this point in the history
  • Loading branch information
Verclene committed May 7, 2016
1 parent 444fe64 commit 2394a21
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/main/java/net/blacklab/lmr/util/helper/CommonHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import com.mojang.authlib.GameProfile;

import net.blacklab.lmr.LittleMaidReengaged;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
Expand Down Expand Up @@ -101,18 +103,22 @@ public static boolean setPathToTile(EntityLiving pEntity, TileEntity pTarget, bo
float lspeed = 1.0F;
// 向きに合わせて距離を調整
int i = (pTarget.getPos().getY() == MathHelper.floor_double(pEntity.posY) && flag) ? 2 : 1;
switch (pEntity.worldObj.getBlockState(new BlockPos(pTarget.getPos().getX(), pTarget.getPos().getY(), pTarget.getPos().getZ())).getValue(BlockDirectional.FACING)) {
case SOUTH:
return lpn.tryMoveToXYZ(pTarget.getPos().getX(), pTarget.getPos().getY(), pTarget.getPos().getZ() + i, lspeed);
case NORTH:
return lpn.tryMoveToXYZ(pTarget.getPos().getX(), pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);
case EAST:
return lpn.tryMoveToXYZ(pTarget.getPos().getX() + 1, pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);
case WEST:
return lpn.tryMoveToXYZ(pTarget.getPos().getX() - i, pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);
default:
return lpn.tryMoveToXYZ(pTarget.getPos().getX(), pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);
try {
switch (pEntity.worldObj.getBlockState(pTarget.getPos()).getValue(BlockHorizontal.FACING)) {
case SOUTH:
return lpn.tryMoveToXYZ(pTarget.getPos().getX(), pTarget.getPos().getY(), pTarget.getPos().getZ() + i, lspeed);
case NORTH:
return lpn.tryMoveToXYZ(pTarget.getPos().getX(), pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);
case EAST:
return lpn.tryMoveToXYZ(pTarget.getPos().getX() + 1, pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);
case WEST:
return lpn.tryMoveToXYZ(pTarget.getPos().getX() - i, pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);
}
} catch (IllegalArgumentException exception) {
LittleMaidReengaged.Debug("Failed to get direction of tile. Maybe non-vanilla chest?");
}
return lpn.tryMoveToXYZ(pTarget.getPos().getX(), pTarget.getPos().getY(), pTarget.getPos().getZ(), lspeed);

}

/**
Expand Down

0 comments on commit 2394a21

Please sign in to comment.