forked from kaboomserver/extras
Push WIP physics code
This commit is contained in:
parent
81014126d0
commit
4d4d01893a
5 changed files with 44 additions and 58 deletions
|
@ -479,7 +479,6 @@ public class Main extends JavaPlugin {
|
|||
Material.OXEYE_DAISY,
|
||||
Material.BROWN_MUSHROOM,
|
||||
Material.RED_MUSHROOM,
|
||||
Material.FIRE,
|
||||
Material.WHEAT,
|
||||
Material.RAIL,
|
||||
Material.STONE_PRESSURE_PLATE,
|
||||
|
@ -541,6 +540,7 @@ public class Main extends JavaPlugin {
|
|||
|
||||
Collections.addAll(
|
||||
nonSolidWallMountedBlockList,
|
||||
Material.FIRE,
|
||||
Material.TORCH,
|
||||
Material.WALL_TORCH,
|
||||
Material.LADDER,
|
||||
|
@ -603,7 +603,9 @@ public class Main extends JavaPlugin {
|
|||
Material.HORN_CORAL_FAN,
|
||||
Material.HORN_CORAL_WALL_FAN,
|
||||
Material.TUBE_CORAL_FAN,
|
||||
Material.TUBE_CORAL_WALL_FAN
|
||||
Material.TUBE_CORAL_WALL_FAN,
|
||||
Material.CHORUS_FLOWER,
|
||||
Material.CHORUS_PLANT
|
||||
);
|
||||
|
||||
Collections.addAll(
|
||||
|
|
|
@ -51,27 +51,4 @@ class BlockCheck implements Listener {
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*class TileEntityCheck extends BukkitRunnable {
|
||||
private Main main;
|
||||
public TileEntityCheck(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for (final World world : Bukkit.getServer().getWorlds()) {
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
try {
|
||||
chunk.getTileEntities();
|
||||
} catch (Exception e) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
}.runTask(main);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -60,29 +60,28 @@ class BlockPhysics implements Listener {
|
|||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blockCount == 300) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
final Material material = event.getChangedType();
|
||||
final Material material = event.getSourceBlock().getType();
|
||||
|
||||
if (material == Material.FARMLAND) {
|
||||
event.setCancelled(true);
|
||||
} else if (material == Material.LAVA ||
|
||||
material == Material.WATER) {
|
||||
final Block block = event.getBlock();
|
||||
final Block block = event.getSourceBlock();
|
||||
final World world = block.getWorld();
|
||||
final int radius = 5;
|
||||
int blockCount = 0;
|
||||
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
|
@ -98,17 +97,17 @@ class BlockPhysics implements Listener {
|
|||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blockCount == 300) {
|
||||
block.setType(Material.AIR, false);
|
||||
}
|
||||
} else if (Main.nonSolidWallMountedBlockList.contains(material)) {
|
||||
final Block block = event.getBlock();
|
||||
} else if (Main.nonSolidBlockList.contains(material) ||
|
||||
material == Material.AIR ||
|
||||
material == Material.CAVE_AIR) {
|
||||
final Block block = event.getSourceBlock();
|
||||
final World world = block.getWorld();
|
||||
final int radius = 5;
|
||||
int blockCount = 0;
|
||||
|
@ -120,29 +119,25 @@ class BlockPhysics implements Listener {
|
|||
final Location blockLocation = new Location(world, block.getX() + x, block.getY() + y, block.getZ() + z);
|
||||
final Block coordBlock = world.getBlockAt(blockLocation);
|
||||
|
||||
if (coordBlock.getType() == material ||
|
||||
Main.nonSolidWallMountedBlockList.contains(coordBlock.getType())) {
|
||||
if (Main.nonSolidBlockList.contains(coordBlock.getType())) {
|
||||
blockCount++;
|
||||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
for (BlockFace face : BlockFace.values()) {
|
||||
if (Main.nonSolidBlockList.contains(block.getRelative(face).getType())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blockCount == 42) {
|
||||
Material materialReplacement = Material.AIR;
|
||||
|
||||
if (Main.nonSolidWaterBlockList.contains(material)) {
|
||||
materialReplacement = Material.WATER;
|
||||
}
|
||||
|
||||
block.setType(materialReplacement, false);
|
||||
}
|
||||
} else if (Main.nonSolidDoubleBlockList.contains(material)) {
|
||||
final Block block = event.getBlock();
|
||||
} /*else if (Main.nonSolidDoubleBlockList.contains(material)) {
|
||||
final Block block = event.getSourceBlock();
|
||||
|
||||
if (Main.nonSolidDoubleBlockList.contains(block.getRelative(BlockFace.DOWN).getType())) {
|
||||
event.setCancelled(true);
|
||||
|
@ -171,10 +166,11 @@ class BlockPhysics implements Listener {
|
|||
break;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
block.setType(materialReplacement, false);
|
||||
}
|
||||
} else if (Main.nonSolidSingularBlockList.contains(material)) {
|
||||
final Block block = event.getBlock();
|
||||
final Block block = event.getSourceBlock();
|
||||
|
||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR ||
|
||||
(Main.nonSolidWaterBlockList.contains(material) &&
|
||||
|
@ -191,9 +187,10 @@ class BlockPhysics implements Listener {
|
|||
materialReplacement = Material.WATER;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
block.setType(materialReplacement, false);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -69,7 +69,9 @@ class EntitySpawn implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onBlockDispense(BlockDispenseEvent event) {
|
||||
System.out.println("lol");
|
||||
try {
|
||||
event.getBlock().getState();
|
||||
event.getItem().getItemMeta();
|
||||
} catch (Exception exception) {
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -149,7 +150,14 @@ class PlayerConnection implements Listener {
|
|||
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
try {
|
||||
if (chunk.getTileEntities(false).length == 0);
|
||||
int data = 0;
|
||||
for (BlockState block : chunk.getTileEntities()) {
|
||||
data = data + block.getBlockData().getAsString().length();
|
||||
}
|
||||
|
||||
if (data > 1285579) {
|
||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue