mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
!Fixed an issue with skulls and drops
This commit is contained in:
parent
4e189ac6e4
commit
19ad204814
@ -7,6 +7,7 @@ import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
|||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
import net.mmogroup.mmolib.MMOLib;
|
||||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||||
|
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||||
|
|
||||||
public class SkullBlockType implements BlockType {
|
public class SkullBlockType implements BlockType {
|
||||||
private final String value;
|
private final String value;
|
||||||
@ -27,9 +28,10 @@ public class SkullBlockType implements BlockType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void place(Location loc, RegeneratingBlock block) {
|
public void place(Location loc, RegeneratingBlock block) {
|
||||||
|
loc.getBlock().setType(VersionMaterial.PLAYER_HEAD.toMaterial());
|
||||||
|
|
||||||
// save skull orientation if replaced block is a player head
|
// save skull orientation if replaced block is a player head
|
||||||
if (MMOCoreUtils.isPlayerHead(loc.getBlock().getType()) && MMOLib.plugin.getVersion().isStrictlyHigher(1, 12))
|
if (MMOCoreUtils.isPlayerHead(block.getBlockData().getMaterial()) && MMOLib.plugin.getVersion().isStrictlyHigher(1, 12))
|
||||||
loc.getBlock().setBlockData(block.getBlockData());
|
loc.getBlock().setBlockData(block.getBlockData());
|
||||||
|
|
||||||
MMOLib.plugin.getNMS().setSkullValue(loc.getBlock(), value);
|
MMOLib.plugin.getNMS().setSkullValue(loc.getBlock(), value);
|
||||||
|
@ -151,9 +151,12 @@ public class DefaultMMOLoader extends MMOLoader {
|
|||||||
@Override
|
@Override
|
||||||
public BlockType loadBlockType(MMOLineConfig config) {
|
public BlockType loadBlockType(MMOLineConfig config) {
|
||||||
|
|
||||||
|
if (config.getKey().equalsIgnoreCase("vanilla"))
|
||||||
|
return new VanillaBlockType(config);
|
||||||
|
|
||||||
if (config.getKey().equalsIgnoreCase("skull") || config.getKey().equals("head") || config.getKey().equals("playerhead"))
|
if (config.getKey().equalsIgnoreCase("skull") || config.getKey().equals("head") || config.getKey().equals("playerhead"))
|
||||||
return new SkullBlockType(config);
|
return new SkullBlockType(config);
|
||||||
|
|
||||||
return new VanillaBlockType(config);
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ public class BlockListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calls the event and listen for cancel & for drops changes... also
|
* calls the event and listen for cancel & for drops changes... also
|
||||||
* allows to apply tool durability & enchants to drops, etc.
|
* allows to apply tool durability & enchants to drops, etc.
|
||||||
@ -103,7 +104,7 @@ public class BlockListener implements Listener {
|
|||||||
* apply drop tables
|
* apply drop tables
|
||||||
*/
|
*/
|
||||||
if (info.hasDropTable()) {
|
if (info.hasDropTable()) {
|
||||||
Location dropLocation = getSafeDropLocation(block, !(info.regenerates() && info.getRegenerationInfo().hasTemporaryBlock()));
|
Location dropLocation = getSafeDropLocation(block, !block.getType().isSolid() || !(info.regenerates() && info.getRegenerationInfo().hasTemporaryBlock()));
|
||||||
for (ItemStack drop : called.getDrops())
|
for (ItemStack drop : called.getDrops())
|
||||||
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
|
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
|
||||||
block.getWorld().dropItemNaturally(dropLocation, drop);
|
block.getWorld().dropItemNaturally(dropLocation, drop);
|
||||||
|
@ -19,6 +19,7 @@ import net.Indyuce.mmocore.MMOCore;
|
|||||||
import net.Indyuce.mmocore.api.block.BlockInfo;
|
import net.Indyuce.mmocore.api.block.BlockInfo;
|
||||||
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
||||||
import net.Indyuce.mmocore.api.block.BlockType;
|
import net.Indyuce.mmocore.api.block.BlockType;
|
||||||
|
import net.Indyuce.mmocore.api.block.SkullBlockType;
|
||||||
import net.Indyuce.mmocore.api.block.VanillaBlockType;
|
import net.Indyuce.mmocore.api.block.VanillaBlockType;
|
||||||
import net.Indyuce.mmocore.api.droptable.condition.Condition;
|
import net.Indyuce.mmocore.api.droptable.condition.Condition;
|
||||||
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
|
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
|
||||||
@ -48,7 +49,7 @@ public class CustomBlockManager extends MMOManager {
|
|||||||
private final List<Function<Block, BlockType>> blockTypes = new ArrayList<>();
|
private final List<Function<Block, BlockType>> blockTypes = new ArrayList<>();
|
||||||
|
|
||||||
public CustomBlockManager() {
|
public CustomBlockManager() {
|
||||||
registerBlockType(block -> MMOCoreUtils.isPlayerHead(block.getType()) ? new VanillaBlockType(block) : null);
|
registerBlockType(block -> MMOCoreUtils.isPlayerHead(block.getType()) ? new SkullBlockType(block) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerBlockType(Function<Block, BlockType> function) {
|
public void registerBlockType(Function<Block, BlockType> function) {
|
||||||
|
@ -19,6 +19,25 @@ exp-curve: mining
|
|||||||
# configure drop tables with MMOItems.
|
# configure drop tables with MMOItems.
|
||||||
# Block Regen is currently only possible using custom mining.
|
# Block Regen is currently only possible using custom mining.
|
||||||
on-mine:
|
on-mine:
|
||||||
|
|
||||||
|
# Config example showing how you can bind drops and experience
|
||||||
|
# to custom player heads based on the skull texture.
|
||||||
|
diamond-skull:
|
||||||
|
# Diamond ore skull texture
|
||||||
|
material: 'skull{value="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2EzYmI4NWRlYzEzMjlmZTgyOWNjNmNkY2QzNGUxYmQ2MGVlODMyZjU3MjYyOTY1MWYxNGI1ZTE0NTU1ZGJiMSJ9fX0="}'
|
||||||
|
drop-table:
|
||||||
|
items:
|
||||||
|
- 'vanilla{type=DIAMOND} 1 1-4'
|
||||||
|
vanilla-drops: false
|
||||||
|
regen:
|
||||||
|
time: 20
|
||||||
|
# Stone block skull texture
|
||||||
|
temp-block: 'skull{value="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTU0ODE4MjMzYzgxMTg3M2U4NWY1YTRlYTQ0MjliNzVmMjNiNmFlMGVhNmY1ZmMwZjdiYjQyMGQ3YzQ3MSJ9fX0="}'
|
||||||
|
triggers:
|
||||||
|
- 'exp{profession=mining;amount=20}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
emerald:
|
emerald:
|
||||||
material: vanilla{type=EMERALD_ORE}
|
material: vanilla{type=EMERALD_ORE}
|
||||||
drop-table:
|
drop-table:
|
||||||
|
@ -15,6 +15,8 @@ WOODEN_PICKAXE:
|
|||||||
STONE_PICKAXE:
|
STONE_PICKAXE:
|
||||||
can-mine:
|
can-mine:
|
||||||
- vanilla{type=IRON_ORE}
|
- vanilla{type=IRON_ORE}
|
||||||
|
# MMOItems custom blocks with ID 1
|
||||||
|
- mmoitems{id=1}
|
||||||
|
|
||||||
# The block break permissions the tool inherits.
|
# The block break permissions the tool inherits.
|
||||||
# e.g a stone pickaxe can mine iron ores PLUS
|
# e.g a stone pickaxe can mine iron ores PLUS
|
||||||
@ -26,6 +28,8 @@ IRON_PICKAXE:
|
|||||||
parent: STONE_PICKAXE
|
parent: STONE_PICKAXE
|
||||||
can-mine:
|
can-mine:
|
||||||
- vanilla{type=GOLD_ORE}
|
- vanilla{type=GOLD_ORE}
|
||||||
|
# Custom skull with diamond ore texture
|
||||||
|
- skull{value="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2EzYmI4NWRlYzEzMjlmZTgyOWNjNmNkY2QzNGUxYmQ2MGVlODMyZjU3MjYyOTY1MWYxNGI1ZTE0NTU1ZGJiMSJ9fX0="}
|
||||||
|
|
||||||
GOLDEN_PICKAXE:
|
GOLDEN_PICKAXE:
|
||||||
parent: IRON_PICKAXE
|
parent: IRON_PICKAXE
|
||||||
|
Loading…
Reference in New Issue
Block a user