Use Material rather than legacy int/data when specifying block break effect type (#1829)

This commit is contained in:
Jordan 2022-06-22 12:50:09 +01:00 committed by GitHub
parent e3f2d5f737
commit d498996cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 2 deletions

View File

@ -50,6 +50,7 @@ import com.sk89q.worldedit.world.RegenOptions;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes; import com.sk89q.worldedit.world.weather.WeatherTypes;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
@ -415,6 +416,15 @@ public class BukkitWorld extends AbstractWorld {
return true; return true;
} }
//FAWE start - allow block break effect of non-legacy blocks
@Override
public boolean playBlockBreakEffect(Vector3 position, BlockType type) {
World world = getWorld();
world.playEffect(BukkitAdapter.adapt(world, position), Effect.STEP_SOUND, BukkitAdapter.adapt(type));
return true;
}
//FAWE end
@Override @Override
public WeatherType getWeather() { public WeatherType getWeather() {
if (getWorld().isThundering()) { if (getWorld().isThundering()) {

View File

@ -132,6 +132,13 @@ public class WorldWrapper extends AbstractWorld {
return parent.playEffect(position, type, data); return parent.playEffect(position, type, data);
} }
//FAWE start - allow block break effect of non-legacy blocks
@Override
public boolean playBlockBreakEffect(Vector3 position, BlockType type) {
return parent.playBlockBreakEffect(position, type);
}
//FAWE end
@Override @Override
public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) { public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
return parent.queueBlockBreakEffect(server, position, blockType, priority); return parent.queueBlockBreakEffect(server, position, blockType, priority);

View File

@ -107,6 +107,13 @@ public abstract class AbstractWorld implements World {
return false; return false;
} }
//FAWE start - allow block break effect of non-legacy blocks
@Override
public boolean playBlockBreakEffect(Vector3 position, BlockType type) {
return false;
}
//FAWE end
@Override @Override
public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) { public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
if (taskId == -1) { if (taskId == -1) {
@ -185,10 +192,11 @@ public abstract class AbstractWorld implements World {
this.priority = priority; this.priority = priority;
} }
@SuppressWarnings("deprecation") //FAWE start - allow block break effect of non-legacy blocks
public void play() { public void play() {
playEffect(position, 2001, blockType.getLegacyId()); playBlockBreakEffect(position, blockType);
} }
//FAWE end
@Override @Override
public int compareTo(@Nullable QueuedEffect other) { public int compareTo(@Nullable QueuedEffect other) {

View File

@ -348,6 +348,17 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
*/ */
boolean playEffect(Vector3 position, int type, int data); boolean playEffect(Vector3 position, int type, int data);
//FAWE start - allow block break effect of non-legacy blocks
/**
* Play a block break effect.
*
* @param position the position
* @param type the effect block type
* @return true if the effect was played
*/
boolean playBlockBreakEffect(Vector3 position, BlockType type);
//FAWE end
/** /**
* Queue a block break effect. * Queue a block break effect.
* *