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

View File

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

View File

@ -320,7 +320,7 @@ public void onBlockBurn(BlockBurnEvent event) {
if (wcfg.fireSpreadDisableToggle) { if (wcfg.fireSpreadDisableToggle) {
Block block = event.getBlock(); Block block = event.getBlock();
event.setCancelled(true); event.setCancelled(true);
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE); checkAndDestroyFireAround(block.getWorld(), block.getX(), block.getY(), block.getZ());
return; return;
} }
@ -329,7 +329,7 @@ public void onBlockBurn(BlockBurnEvent event) {
if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(block.getType()).getId())) { if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(block.getType()).getId())) {
event.setCancelled(true); event.setCancelled(true);
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE); checkAndDestroyFireAround(block.getWorld(), block.getX(), block.getY(), block.getZ());
return; return;
} }
} }
@ -348,24 +348,24 @@ public void onBlockBurn(BlockBurnEvent event) {
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation())); WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
if (!set.testState(null, Flags.FIRE_SPREAD)) { if (!set.testState(null, Flags.FIRE_SPREAD)) {
checkAndDestroyAround(block.getWorld(), x, y, z, Material.FIRE); checkAndDestroyFireAround(block.getWorld(), x, y, z);
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
private void checkAndDestroyAround(World world, int x, int y, int z, Material required) { private void checkAndDestroyFireAround(World world, int x, int y, int z) {
checkAndDestroy(world, x, y, z + 1, required); checkAndDestroyFire(world, x, y, z + 1);
checkAndDestroy(world, x, y, z - 1, required); checkAndDestroyFire(world, x, y, z - 1);
checkAndDestroy(world, x, y + 1, z, required); checkAndDestroyFire(world, x, y + 1, z);
checkAndDestroy(world, x, y - 1, z, required); checkAndDestroyFire(world, x, y - 1, z);
checkAndDestroy(world, x + 1, y, z, required); checkAndDestroyFire(world, x + 1, y, z);
checkAndDestroy(world, x - 1, y, z, required); checkAndDestroyFire(world, x - 1, y, z);
} }
private void checkAndDestroy(World world, int x, int y, int z, Material required) { private void checkAndDestroyFire(World world, int x, int y, int z) {
if (world.getBlockAt(x, y, z).getType() == required) { if (Materials.isFire(world.getBlockAt(x, y, z).getType())) {
world.getBlockAt(x, y, z).setType(Material.AIR); 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 * @return true if a mushroom block
*/ */
public static boolean isMushroom(Material material) { public static boolean isMushroom(Material material) {
return material == Material.RED_MUSHROOM || material == Material.BROWN_MUSHROOM return material == Material.RED_MUSHROOM || material == Material.BROWN_MUSHROOM;
|| material == Material.CRIMSON_FUNGUS || material == Material.WARPED_FUNGUS;
} }
/** /**
@ -1414,6 +1413,10 @@ public static boolean isArmor(Material type) {
case GOLDEN_CHESTPLATE: case GOLDEN_CHESTPLATE:
case GOLDEN_LEGGINGS: case GOLDEN_LEGGINGS:
case GOLDEN_BOOTS: case GOLDEN_BOOTS:
case NETHERITE_HELMET:
case NETHERITE_CHESTPLATE:
case NETHERITE_LEGGINGS:
case NETHERITE_BOOTS:
case TURTLE_HELMET: case TURTLE_HELMET:
case ELYTRA: case ELYTRA:
return true; return true;
@ -1439,6 +1442,7 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case IRON_HOE: case IRON_HOE:
case GOLDEN_HOE: case GOLDEN_HOE:
case DIAMOND_HOE: case DIAMOND_HOE:
case NETHERITE_HOE:
switch (targetMaterial) { switch (targetMaterial) {
case GRASS_BLOCK: case GRASS_BLOCK:
case DIRT: case DIRT:
@ -1452,6 +1456,7 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case IRON_AXE: case IRON_AXE:
case GOLDEN_AXE: case GOLDEN_AXE:
case DIAMOND_AXE: case DIAMOND_AXE:
case NETHERITE_AXE:
switch (targetMaterial) { switch (targetMaterial) {
case OAK_LOG: case OAK_LOG:
case DARK_OAK_LOG: case DARK_OAK_LOG:
@ -1465,6 +1470,10 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case BIRCH_WOOD: case BIRCH_WOOD:
case SPRUCE_WOOD: case SPRUCE_WOOD:
case JUNGLE_WOOD: case JUNGLE_WOOD:
case CRIMSON_STEM:
case WARPED_STEM:
case CRIMSON_HYPHAE:
case WARPED_HYPHAE:
return true; return true;
} }
return false; return false;
@ -1473,6 +1482,7 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case IRON_SHOVEL: case IRON_SHOVEL:
case GOLDEN_SHOVEL: case GOLDEN_SHOVEL:
case DIAMOND_SHOVEL: case DIAMOND_SHOVEL:
case NETHERITE_SHOVEL:
switch (targetMaterial) { switch (targetMaterial) {
case GRASS_BLOCK: case GRASS_BLOCK:
case CAMPFIRE: case CAMPFIRE:
@ -1509,4 +1519,8 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
return false; return false;
} }
} }
public static boolean isFire(Material type) {
return type == Material.FIRE || type == Material.SOUL_FIRE;
}
} }