From 5c23262f159f3c7a927299be0f26df11486e2ac2 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 Apr 2016 12:57:19 +1000 Subject: [PATCH] Update physics on attached block when setting data of attachable blocks --- .../bukkit/craftbukkit/block/CraftBlockState.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 7da6218b7c..3261f24961 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.block; import net.minecraft.server.BlockPosition; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.Chunk; import org.bukkit.Material; import org.bukkit.World; @@ -10,11 +11,14 @@ import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.material.Attachable; import org.bukkit.material.MaterialData; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import java.util.List; +import net.minecraft.server.EnumDirection; +import net.minecraft.server.IBlockData; import net.minecraft.server.TileEntity; public class CraftBlockState implements BlockState { @@ -159,14 +163,21 @@ public class CraftBlockState implements BlockState { } } + BlockPosition pos = new BlockPosition(x, y, z); + IBlockData newBlock = CraftMagicNumbers.getBlock(getType()).fromLegacyData(getRawData()); block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics); world.getHandle().notify( - new BlockPosition(x, y, z), + pos, CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData()), - CraftMagicNumbers.getBlock(getType()).fromLegacyData(getRawData()), + newBlock, 3 ); + // Update levers etc + if (applyPhysics && getData() instanceof Attachable) { + world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock()); + } + return true; }