#1162: Add BlockData#rotate and BlockData#mirror

By: Jishuna <joshl5324@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2023-04-02 13:32:01 +10:00
parent ad8f95c3df
commit 257f5ad3e8

View file

@ -17,6 +17,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.INamable;
import net.minecraft.world.level.BlockAccessAir;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EnumBlockMirror;
import net.minecraft.world.level.block.EnumBlockRotation;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.IBlockDataHolder;
import net.minecraft.world.level.block.state.properties.BlockStateBoolean;
@ -30,6 +32,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockSupport;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.structure.Mirror;
import org.bukkit.block.structure.StructureRotation;
import org.bukkit.craftbukkit.CraftSoundGroup;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
@ -622,4 +626,14 @@ public class CraftBlockData implements BlockData {
public Material getPlacementMaterial() {
return CraftMagicNumbers.getMaterial(state.getBlock().asItem());
}
@Override
public void rotate(StructureRotation rotation) {
this.state = state.rotate(EnumBlockRotation.valueOf(rotation.name()));
}
@Override
public void mirror(Mirror mirror) {
this.state = state.mirror(EnumBlockMirror.valueOf(mirror.name()));
}
}