mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
Fixed blockstates resetting when normal blocks were regenerated using custom mining
This commit is contained in:
parent
0662f460f2
commit
240fad3f34
@ -7,6 +7,7 @@ import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
||||
|
||||
public interface BlockType {
|
||||
void place(Location loc, RegeneratingBlock regenerating);
|
||||
void regen(Location loc, RegeneratingBlock regenerating);
|
||||
|
||||
/**
|
||||
* Generates a key used to store the BlockInfo instance in the manager map,
|
||||
|
@ -1,13 +1,12 @@
|
||||
package net.Indyuce.mmocore.api.block;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class SkullBlockType implements BlockType {
|
||||
private final String value;
|
||||
@ -37,6 +36,15 @@ public class SkullBlockType implements BlockType {
|
||||
MMOLib.plugin.getVersion().getWrapper().setSkullValue(loc.getBlock(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regen(Location loc, RegeneratingBlock block) {
|
||||
// This makes sure that if a skull loses it's original rotation
|
||||
// it can revert back to it when the base block is regenerated
|
||||
loc.getBlock().setBlockData(block.getBlockData());
|
||||
MMOLib.plugin.getVersion().getWrapper().setSkullValue(loc.getBlock(), value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String generateKey() {
|
||||
return "vanilla-skull-" + value;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.api.block;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -48,6 +49,12 @@ public class VanillaBlockType implements BlockType {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regen(Location loc, RegeneratingBlock block) {
|
||||
// Sets the original blocks old data (only when regenerating)
|
||||
loc.getBlock().setBlockData(block.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateKey() {
|
||||
return "vanilla-block-" + type.name();
|
||||
|
@ -124,6 +124,7 @@ public class CustomBlockManager extends MMOManager {
|
||||
// Get the chunk and load it async if needed.
|
||||
PaperLib.getChunkAtAsync(infoLocation).whenComplete((chunk, ex) -> {
|
||||
info.getRegeneratingBlock().getBlock().place(infoLocation, info);
|
||||
info.getRegeneratingBlock().getBlock().regen(infoLocation, info);
|
||||
info.getLocation().getBlock().getState().update();
|
||||
if (!shutdown)
|
||||
active.remove(info);
|
||||
|
Loading…
Reference in New Issue
Block a user