!Fixed temp blocks, drops and default configs

This commit is contained in:
Indyuce 2020-04-04 15:50:32 +02:00
parent 400180f5a1
commit 4e189ac6e4
5 changed files with 29 additions and 20 deletions

View File

@ -88,6 +88,10 @@ public class BlockInfo {
return regen != null;
}
public boolean regenerates() {
return regen != null;
}
public RegenInfo getRegenerationInfo() {
return regen;
}

View File

@ -103,7 +103,7 @@ public class BlockListener implements Listener {
* apply drop tables
*/
if (info.hasDropTable()) {
Location dropLocation = getSafeDropLocation(block, true);
Location dropLocation = getSafeDropLocation(block, !(info.regenerates() && info.getRegenerationInfo().hasTemporaryBlock()));
for (ItemStack drop : called.getDrops())
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
block.getWorld().dropItemNaturally(dropLocation, drop);
@ -120,7 +120,6 @@ public class BlockListener implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGH)
public void b(BlockPlaceEvent event) {
event.getBlock().setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
@ -134,13 +133,12 @@ public class BlockListener implements Listener {
BlockFace direction = event.getDirection();
movedBlock = movedBlock.getRelative(direction, 2);
for (Block b : event.getBlocks()) {
for (Block b : event.getBlocks())
if (b.hasMetadata("player_placed")) {
movedBlock = b.getRelative(direction);
movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
}
}
}
@EventHandler
public void c2(BlockPistonRetractEvent event) {
@ -158,10 +156,12 @@ public class BlockListener implements Listener {
if (block.getType() == Material.AIR && self)
return block.getLocation();
Block relative;
for (BlockFace face : order)
if (!(relative = block.getRelative(face)).getType().isSolid())
return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.3));
for (BlockFace face : order) {
Block relative = block.getRelative(face);
if (!relative.getType().isSolid())
return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.6));
}
return block.getLocation();
}
}

View File

@ -90,7 +90,12 @@ public class RestrictionManager {
// recursive function to check for parent permissions
public boolean canMine(BlockType type) {
return mineable.contains(type) || (parent != null && parent.canMine(type));
String key = type.generateKey();
for (BlockType mineable : this.mineable)
if (mineable.generateKey().equals(key))
return true;
return parent != null && parent.canMine(type);
}
public Material getTool() {

View File

@ -20,20 +20,20 @@ exp-curve: mining
# Block Regen is currently only possible using custom mining.
on-mine:
emerald:
material: EMERALD_ORE
material: vanilla{type=EMERALD_ORE}
drop-table:
items:
- 'vanilla{type=EMERALD} 1 1-9'
vanilla-drops: false
regen:
time: 2000
temp-block: STONE
temp-block: vanilla{type=STONE}
triggers:
- 'exp{profession=mining;amount=32}'
diamond:
# The material you need to mine
material: DIAMOND_ORE
material: vanilla{type=DIAMOND_ORE}
# Refer to drop-tables.yml
# The drop table used by the block.
@ -63,4 +63,4 @@ on-mine:
# When using the temp-block option, make sure you choose
# one temp block and don't use it anywhere else in the
# configuration so that block regens do not affect each other
temp-block: STONE
temp-block: vanilla{type=STONE}

View File

@ -10,11 +10,11 @@ WOODEN_PICKAXE:
# What the tool can mine.
can-mine:
- COAL_ORE
- vanilla{type=COAL_ORE}
STONE_PICKAXE:
can-mine:
- IRON_ORE
- vanilla{type=IRON_ORE}
# The block break permissions the tool inherits.
# e.g a stone pickaxe can mine iron ores PLUS
@ -25,16 +25,16 @@ STONE_PICKAXE:
IRON_PICKAXE:
parent: STONE_PICKAXE
can-mine:
- GOLD_ORE
- vanilla{type=GOLD_ORE}
GOLDEN_PICKAXE:
parent: IRON_PICKAXE
can-mine:
- LAPIS_ORE
- vanilla{type=LAPIS_ORE}
DIAMOND_PICKAXE:
parent: GOLDEN_PICKAXE
can-mine:
- DIAMOND_ORE
- EMERALD_ORE
- REDSTONE_ORE
- vanilla{type=DIAMOND_ORE}
- vanilla{type=EMERALD_ORE}
- vanilla{type=REDSTONE_ORE}