use of org.bukkit.block.BlockFace in project BKCommonLib by bergerhealer.
the class EntityMoveHandler_1_13 method onBlockCollided.
// Called from getBlockCollisions_method
public boolean onBlockCollided(Block block) {
// Find out what direction the block is hit
BlockFace hitFace;
AxisAlignedBBHandle entityBounds = this.that.getBoundingBox();
if (entityBounds.getMaxY() > (block.getY() + 1.0)) {
hitFace = BlockFace.UP;
} else if (entityBounds.getMinY() < (double) block.getY()) {
hitFace = BlockFace.DOWN;
} else {
double dx = this.that.getLocX() - block.getX() - 0.5;
double dz = this.that.getLocZ() - block.getZ() - 0.5;
hitFace = FaceUtil.getDirection(dx, dz, false);
}
// Block collision event
return controller.onBlockCollision(block, hitFace);
}
use of org.bukkit.block.BlockFace in project BKCommonLib by bergerhealer.
the class EntityMoveHandler_1_14 method onBlockCollided.
// Called from getBlockCollisions_method
public boolean onBlockCollided(Block block) {
// Find out what direction the block is hit
BlockFace hitFace;
AxisAlignedBBHandle entityBounds = this.that.getBoundingBox();
if (entityBounds.getMaxY() > (block.getY() + 1.0)) {
hitFace = BlockFace.UP;
} else if (entityBounds.getMinY() < (double) block.getY()) {
hitFace = BlockFace.DOWN;
} else {
double dx = this.that.getLocX() - block.getX() - 0.5;
double dz = this.that.getLocZ() - block.getZ() - 0.5;
hitFace = FaceUtil.getDirection(dx, dz, false);
}
// Block collision event
return controller.onBlockCollision(block, hitFace);
}
use of org.bukkit.block.BlockFace in project Bukkit by Bukkit.
the class Lever method setFacingDirection.
/**
* Sets the direction this lever is pointing in
*/
public void setFacingDirection(BlockFace face) {
byte data = (byte) (getData() & 0x8);
BlockFace attach = getAttachedFace();
if (attach == BlockFace.DOWN) {
switch(face) {
case SOUTH:
case NORTH:
data |= 0x5;
break;
case EAST:
case WEST:
data |= 0x6;
break;
}
} else if (attach == BlockFace.UP) {
switch(face) {
case SOUTH:
case NORTH:
data |= 0x7;
break;
case EAST:
case WEST:
data |= 0x0;
break;
}
} else {
switch(face) {
case EAST:
data |= 0x1;
break;
case WEST:
data |= 0x2;
break;
case SOUTH:
data |= 0x3;
break;
case NORTH:
data |= 0x4;
break;
}
}
setData(data);
}
use of org.bukkit.block.BlockFace in project HawkEye by oliverwoodings.
the class SignEntry method interpretSqlData.
@Override
public void interpretSqlData(String data) {
if (data.indexOf("@") == -1)
return;
String[] arr = data.split("@");
// Parse wall sign or not
if (arr[0].equals("true"))
wallSign = true;
else
wallSign = false;
// Parse sign direction
for (BlockFace face : BlockFace.values()) if (face.toString().equalsIgnoreCase(arr[1]))
facing = face;
// Parse lines
if (arr.length != 3)
return;
BASE64Decoder decoder = new BASE64Decoder();
List<String> decoded = new ArrayList<String>();
String[] encLines = arr[2].split(",");
for (int i = 0; i < encLines.length; i++) {
try {
decoded.add(new String(decoder.decodeBuffer(encLines[i])));
} catch (IOException e) {
Util.severe("Unable to decode sign data from database");
}
}
lines = decoded.toArray(new String[0]);
}
use of org.bukkit.block.BlockFace in project WildernessTp by AcmeProject.
the class TeleportGoneWild method goWild.
private void goWild(Location loc) {
PaperLib.getChunkAtAsync(loc, true).thenAccept(chunk -> {
if (!TooCool2Teleport.microwave(who)) {
WildTP.debug("unmicrowaved leftovers.");
return;
}
WildTP.debug("Teleporting " + who.getName() + loc);
if (WildWarrantTax.bonelessIceScream(loc)) {
if (wc.whoYaGonaCall) {
WildTP.debug("Here come the §cfiremen§r!");
Block block = loc.getBlock();
block.setType(Material.AIR);
for (BlockFace flame : new BlockFace[] { BlockFace.UP, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST }) {
Block bed = block.getRelative(flame);
if (bed.getType() == Material.FIRE)
bed.setType(Material.AIR);
}
// How do we sleep while our beds are burning? //Ask St. John Vianney
}
} else if (wc.dr0p1n) {
WildTP.debug("Drop in feature enabled: Setting y=" + wc.dr0pFr0m);
loc.setY(wc.dr0pFr0m);
loc.setPitch(64);
OuchieListener.plsSaveDisDood(who);
}
if (!who.teleport(loc.clone().add(0.5, 0.5, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND)) {
WildTP.debug("teleport was canceled.");
return;
}
WildTP.debug(who.getName() + " Teleported to " + who.getLocation());
if (!bypass("cooldown")) {
WildTP.debug(who.getName() + " Adding to cooldown");
wc.checKar.addKewlzDown(who.getUniqueId());
WildTP.debug("Added to cooldown " + who.getUniqueId());
}
PostWildTeleportEvent postWildTeleportEvent = new PostWildTeleportEvent(who, wc);
Bukkit.getPluginManager().callEvent(postWildTeleportEvent);
});
}
Aggregations