mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-07 03:00:29 +01:00
Stackable consistency, ender pearls not working, lava/water check fixes
This commit is contained in:
parent
3265fcc15c
commit
b281f61eef
@ -75,11 +75,11 @@ public class GeneratorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLava(Block block) {
|
private boolean isLava(Block block) {
|
||||||
return block.getType().equals(Materials.LAVA.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_LAVA.parseMaterial());
|
return block.getType().name().contains("LAVA");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWater(Block block) {
|
private boolean isWater(Block block) {
|
||||||
return block.getType().equals(Materials.WATER.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_WATER.parseMaterial());
|
return block.getType().name().contains("WATER");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGenerator(Block block) {
|
public boolean isGenerator(Block block) {
|
||||||
@ -98,122 +98,6 @@ public class GeneratorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//region GoodAndEvil his old code (garbage)
|
|
||||||
/*
|
|
||||||
if (block.getRelative(BlockFace.UP).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|
|
||||||
&& block.getRelative(BlockFace.UP).getType() != Materials.WATER.parseMaterial()) {
|
|
||||||
Block flowBlock = null;
|
|
||||||
|
|
||||||
if ((block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|
|
||||||
|| block.getRelative(BlockFace.EAST).getType() == Materials.WATER.parseMaterial())
|
|
||||||
&& (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_LAVA
|
|
||||||
.getPostMaterial()
|
|
||||||
|| block.getRelative(BlockFace.WEST).getType() == Materials.LAVA.parseMaterial())
|
|
||||||
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.EAST)
|
|
||||||
.getType() == Material.AIR
|
|
||||||
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
|
|
||||||
.getRelative(BlockFace.EAST)
|
|
||||||
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
|
|
||||||
if (!isFlowingTowardsBlock(block, BlockFace.NORTH, BlockFace.SOUTH)) {
|
|
||||||
return false;
|
|
||||||
} else if (!isFlowingTowardsBlock(block, BlockFace.SOUTH, BlockFace.NORTH)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
flowBlock = block.getRelative(BlockFace.EAST);
|
|
||||||
} else if ((block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_LAVA
|
|
||||||
.getPostMaterial() || block.getRelative(BlockFace.EAST).getType() == Materials.LAVA.parseMaterial())
|
|
||||||
&& (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_WATER
|
|
||||||
.getPostMaterial()
|
|
||||||
|| block.getRelative(BlockFace.WEST).getType() == Materials.WATER.parseMaterial())
|
|
||||||
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.WEST)
|
|
||||||
.getType() == Material.AIR
|
|
||||||
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
|
|
||||||
.getRelative(BlockFace.WEST)
|
|
||||||
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
|
|
||||||
if (!isFlowingTowardsBlock(block, BlockFace.NORTH, BlockFace.SOUTH)) {
|
|
||||||
return false;
|
|
||||||
} else if (!isFlowingTowardsBlock(block, BlockFace.SOUTH, BlockFace.NORTH)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
flowBlock = block.getRelative(BlockFace.WEST);
|
|
||||||
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_WATER
|
|
||||||
.getPostMaterial()
|
|
||||||
|| block.getRelative(BlockFace.NORTH).getType() == Materials.WATER.parseMaterial()))
|
|
||||||
&& (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_LAVA
|
|
||||||
.getPostMaterial()
|
|
||||||
|| block.getRelative(BlockFace.SOUTH).getType() == Materials.LAVA.parseMaterial())
|
|
||||||
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.NORTH)
|
|
||||||
.getType() == Material.AIR
|
|
||||||
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
|
|
||||||
.getRelative(BlockFace.NORTH)
|
|
||||||
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
|
|
||||||
if (!isFlowingTowardsBlock(block, BlockFace.WEST, BlockFace.EAST)) {
|
|
||||||
return false;
|
|
||||||
} else if (!isFlowingTowardsBlock(block, BlockFace.EAST, BlockFace.WEST)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
flowBlock = block.getRelative(BlockFace.NORTH);
|
|
||||||
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_LAVA
|
|
||||||
.getPostMaterial()
|
|
||||||
|| block.getRelative(BlockFace.NORTH).getType() == Materials.LAVA.parseMaterial()))
|
|
||||||
&& (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_WATER
|
|
||||||
.getPostMaterial()
|
|
||||||
|| block.getRelative(BlockFace.SOUTH).getType() == Materials.WATER.parseMaterial())
|
|
||||||
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.SOUTH)
|
|
||||||
.getType() == Material.AIR
|
|
||||||
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
|
|
||||||
.getRelative(BlockFace.SOUTH)
|
|
||||||
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
|
|
||||||
if (!isFlowingTowardsBlock(block, BlockFace.WEST, BlockFace.EAST)) {
|
|
||||||
return false;
|
|
||||||
} else if (!isFlowingTowardsBlock(block, BlockFace.EAST, BlockFace.WEST)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
flowBlock = block.getRelative(BlockFace.SOUTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flowBlock != null) {
|
|
||||||
return isFlowingBlock(flowBlock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isFlowingTowardsBlock(Block block, BlockFace blockFace1, BlockFace blockFace2) {
|
|
||||||
if (block.getRelative(blockFace1).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|
|
||||||
|| block.getRelative(blockFace1).getType() == Materials.WATER.parseMaterial()) {
|
|
||||||
if (isFlowingBlock(block.getRelative(blockFace1)) && (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D)
|
|
||||||
.getBlock().getRelative(blockFace1).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|
|
||||||
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace1)
|
|
||||||
.getType() == Materials.WATER.parseMaterial())) {
|
|
||||||
if (block.getRelative(blockFace2).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|
|
||||||
|| block.getRelative(blockFace2).getType() == Materials.WATER.parseMaterial()) {
|
|
||||||
if (isFlowingBlock(block.getRelative(blockFace2)) && (block.getLocation().clone()
|
|
||||||
.subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace2)
|
|
||||||
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|
|
||||||
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace2)
|
|
||||||
.getType() == Materials.WATER.parseMaterial())) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
*/
|
|
||||||
//endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -77,7 +77,7 @@ public class Teleport implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCause) {
|
if (isCause && event.getCause() != TeleportCause.ENDER_PEARL) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class Stackable {
|
|||||||
|
|
||||||
public Stackable(Location location, Material material) {
|
public Stackable(Location location, Material material) {
|
||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
this.location = location;
|
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
SkyBlock.getInstance().getSoundManager().playSound(location, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
SkyBlock.getInstance().getSoundManager().playSound(location, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||||
@ -40,7 +40,7 @@ public class Stackable {
|
|||||||
|
|
||||||
public Stackable(UUID uuid, Location location, Material material, int size) {
|
public Stackable(UUID uuid, Location location, Material material, int size) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.location = location;
|
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
@ -78,14 +78,14 @@ public class Stackable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addOne() {
|
public void addOne() {
|
||||||
this.size ++;
|
this.size++;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takeOne() {
|
public void takeOne() {
|
||||||
this.size --;
|
this.size--;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||||
this.save();
|
this.save();
|
||||||
@ -93,7 +93,6 @@ public class Stackable {
|
|||||||
|
|
||||||
private void updateDisplay() {
|
private void updateDisplay() {
|
||||||
if (this.size > 1) {
|
if (this.size > 1) {
|
||||||
this.removeDisplay();
|
|
||||||
this.createDisplay();
|
this.createDisplay();
|
||||||
this.display.setCustomName(this.getCustomName());
|
this.display.setCustomName(this.getCustomName());
|
||||||
this.display.setCustomNameVisible(true);
|
this.display.setCustomNameVisible(true);
|
||||||
@ -126,12 +125,10 @@ public class Stackable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find any stragglers
|
// Find any stragglers
|
||||||
for (Entity entity : this.location.getWorld().getNearbyEntities(this.location.clone().add(0.5, 0.55, 0.5), 0.1, 0.5, 0.1)) {
|
for (Entity entity : this.location.getWorld().getNearbyEntities(this.location.clone().add(0.5, 0.55, 0.5), 0.1, 0.5, 0.1))
|
||||||
if (entity instanceof ArmorStand && entity.isValid()) {
|
if (entity instanceof ArmorStand)
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
File configFile = new File(SkyBlock.getInstance().getDataFolder().toString() + "/island-data");
|
File configFile = new File(SkyBlock.getInstance().getDataFolder().toString() + "/island-data");
|
||||||
|
Loading…
Reference in New Issue
Block a user