Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/ch/njol/skript/expressions/ExprBlockData.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.njol.skript.expressions;

import ch.njol.skript.Skript;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
Expand All @@ -11,6 +10,7 @@
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.BlockDisplay;
import org.bukkit.entity.FallingBlock;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

Expand All @@ -29,8 +29,7 @@
public class ExprBlockData extends SimplePropertyExpression<Object, BlockData> {

static {
String types = Skript.isRunningMinecraft(1, 19, 4) ? "blocks/displays" : "blocks";
register(ExprBlockData.class, BlockData.class, "block[ ]data", types);
register(ExprBlockData.class, BlockData.class, "block[ ]data", "blocks/displays/entities");
}

@Override
Expand All @@ -39,6 +38,8 @@ public class ExprBlockData extends SimplePropertyExpression<Object, BlockData> {
return block.getBlockData();
if (object instanceof BlockDisplay blockDisplay)
return blockDisplay.getBlock();
if (object instanceof FallingBlock fallingBlock)
return fallingBlock.getBlockData();
return null;

}
Expand All @@ -59,6 +60,8 @@ public void change(Event event, Object @Nullable [] delta, ChangeMode mode) {
block.setBlockData(blockData);
} else if (object instanceof BlockDisplay blockDisplay) {
blockDisplay.setBlock(blockData);
} else if (object instanceof FallingBlock fallingBlock) {
fallingBlock.setBlockData(blockData);
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/skript/tests/syntaxes/expressions/ExprBlockData.sk
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ test "block data":
assert "%{_data}%" contains "campfire", "lit=false" and "waterlogged=true" with "block data for campfire did not match"

set block at {_b} to air

test "falling block block data":
spawn a falling block at test-location:
set {_e} to entity
assert block data of {_e} is stone[] with "Falling block should default to stone"
set block data of {_e} to sand[]
assert block data of {_e} is sand[] with "Falling block should update to sand"
clear entity within {_e}