@Override public void setAttachedFace(Block block, BlockFace attachedFace, Cause<?> cause) { if (attachedFace == BlockFace.BOTTOM) { // Attached to the ground block.setData(0x1, cause); // This below bit is completely wrong - rotation is not stored in the block data // It is stored in the block component instead // It should be set to 0x1, but it needs to be fully tested first // Skull type needs to be set somewhere too, most likely in the block component // TODO: Finish this off... /* short data = 0; Object source = cause.getSource(); if (source instanceof Entity) { Vector3 direction = block.getPosition().subtract(((Entity) source).getTransform().getPosition()); float rotation = direction.rotationTo(Vector3.RIGHT).getYaw(); rotation = rotation / 360f * 16f; data = (short) rotation; } if (block.setMaterial(this, data)) { block.queueUpdate(EffectRange.THIS); } */ } else { // Attached to a wall block.setData(BlockFaces.NSWE.indexOf(attachedFace, 0) + 2, cause); } }
@Override public void setAttachedFace(Block block, BlockFace attachedFace) { if (attachedFace == BlockFace.BOTTOM) { Source source = block.getSource(); short data = 0; if (source instanceof Entity) { Vector3 direction = block.getPosition().subtract(((Entity) source).getTransform().getPosition()); float rotation = direction.rotationTo(Vector3.RIGHT).getYaw(); rotation = rotation / 360f * 16f; data = (short) rotation; } block.setMaterial(VanillaMaterials.SIGN_POST, data).queueUpdate(EffectRange.THIS); } else { // get the data for this face short data = (short) (BlockFaces.NSWE.indexOf(attachedFace, 0) + 2); block.setMaterial(VanillaMaterials.WALL_SIGN, data).queueUpdate(EffectRange.THIS); } }