Additional 1.16 material defs.

This commit is contained in:
wizjany 2020-06-26 00:52:29 -04:00
parent 8722322cd8
commit bffe5e76f2
5 changed files with 33 additions and 19 deletions

View File

@ -1,2 +1,2 @@
group=com.sk89q.worldguard
version=7.0.3
version=7.0.4-SNAPSHOT

View File

@ -244,7 +244,7 @@ public void onBlockBurn(BlockBurnEvent event) {
boolean allowed = false;
for (Block source : adjacent) {
if (source.getType() == Material.FIRE) {
if (Materials.isFire(source.getType())) {
found++;
if (Events.fireAndTestCancel(new BreakBlockEvent(event, create(source), target))) {
source.setType(Material.AIR);
@ -506,7 +506,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}
// Special handling of putting out fires
if (event.getAction() == Action.LEFT_CLICK_BLOCK && placed.getType() == Material.FIRE) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK && Materials.isFire(placed.getType())) {
if (Events.fireAndTestCancel(new BreakBlockEvent(event, create(event.getPlayer()), placed))) {
event.setUseInteractedBlock(Result.DENY);
break;

View File

@ -170,9 +170,9 @@ public void onPlaceBlock(final PlaceBlockEvent event) {
String what;
/* Flint and steel, fire charge, etc. */
if (type == Material.FIRE) {
if (Materials.isFire(type)) {
Block block = event.getCause().getFirstBlock();
boolean fire = block != null && block.getType() == Material.FIRE;
boolean fire = block != null && Materials.isFire(type);
boolean lava = block != null && Materials.isLava(block.getType());
List<StateFlag> flags = new ArrayList<>();
flags.add(Flags.BLOCK_PLACE);

View File

@ -320,7 +320,7 @@ public void onBlockBurn(BlockBurnEvent event) {
if (wcfg.fireSpreadDisableToggle) {
Block block = event.getBlock();
event.setCancelled(true);
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE);
checkAndDestroyFireAround(block.getWorld(), block.getX(), block.getY(), block.getZ());
return;
}
@ -329,7 +329,7 @@ public void onBlockBurn(BlockBurnEvent event) {
if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(block.getType()).getId())) {
event.setCancelled(true);
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE);
checkAndDestroyFireAround(block.getWorld(), block.getX(), block.getY(), block.getZ());
return;
}
}
@ -348,24 +348,24 @@ public void onBlockBurn(BlockBurnEvent event) {
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
if (!set.testState(null, Flags.FIRE_SPREAD)) {
checkAndDestroyAround(block.getWorld(), x, y, z, Material.FIRE);
checkAndDestroyFireAround(block.getWorld(), x, y, z);
event.setCancelled(true);
}
}
}
private void checkAndDestroyAround(World world, int x, int y, int z, Material required) {
checkAndDestroy(world, x, y, z + 1, required);
checkAndDestroy(world, x, y, z - 1, required);
checkAndDestroy(world, x, y + 1, z, required);
checkAndDestroy(world, x, y - 1, z, required);
checkAndDestroy(world, x + 1, y, z, required);
checkAndDestroy(world, x - 1, y, z, required);
private void checkAndDestroyFireAround(World world, int x, int y, int z) {
checkAndDestroyFire(world, x, y, z + 1);
checkAndDestroyFire(world, x, y, z - 1);
checkAndDestroyFire(world, x, y + 1, z);
checkAndDestroyFire(world, x, y - 1, z);
checkAndDestroyFire(world, x + 1, y, z);
checkAndDestroyFire(world, x - 1, y, z);
}
private void checkAndDestroy(World world, int x, int y, int z, Material required) {
if (world.getBlockAt(x, y, z).getType() == required) {
private void checkAndDestroyFire(World world, int x, int y, int z) {
if (Materials.isFire(world.getBlockAt(x, y, z).getType())) {
world.getBlockAt(x, y, z).setType(Material.AIR);
}
}

View File

@ -932,8 +932,7 @@ public static Material getBucketBlockMaterial(Material type) {
* @return true if a mushroom block
*/
public static boolean isMushroom(Material material) {
return material == Material.RED_MUSHROOM || material == Material.BROWN_MUSHROOM
|| material == Material.CRIMSON_FUNGUS || material == Material.WARPED_FUNGUS;
return material == Material.RED_MUSHROOM || material == Material.BROWN_MUSHROOM;
}
/**
@ -1414,6 +1413,10 @@ public static boolean isArmor(Material type) {
case GOLDEN_CHESTPLATE:
case GOLDEN_LEGGINGS:
case GOLDEN_BOOTS:
case NETHERITE_HELMET:
case NETHERITE_CHESTPLATE:
case NETHERITE_LEGGINGS:
case NETHERITE_BOOTS:
case TURTLE_HELMET:
case ELYTRA:
return true;
@ -1439,6 +1442,7 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case IRON_HOE:
case GOLDEN_HOE:
case DIAMOND_HOE:
case NETHERITE_HOE:
switch (targetMaterial) {
case GRASS_BLOCK:
case DIRT:
@ -1452,6 +1456,7 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case IRON_AXE:
case GOLDEN_AXE:
case DIAMOND_AXE:
case NETHERITE_AXE:
switch (targetMaterial) {
case OAK_LOG:
case DARK_OAK_LOG:
@ -1465,6 +1470,10 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case BIRCH_WOOD:
case SPRUCE_WOOD:
case JUNGLE_WOOD:
case CRIMSON_STEM:
case WARPED_STEM:
case CRIMSON_HYPHAE:
case WARPED_HYPHAE:
return true;
}
return false;
@ -1473,6 +1482,7 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case IRON_SHOVEL:
case GOLDEN_SHOVEL:
case DIAMOND_SHOVEL:
case NETHERITE_SHOVEL:
switch (targetMaterial) {
case GRASS_BLOCK:
case CAMPFIRE:
@ -1509,4 +1519,8 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
return false;
}
}
public static boolean isFire(Material type) {
return type == Material.FIRE || type == Material.SOUL_FIRE;
}
}