Пример #1
0
  @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);
    }
  }
Пример #2
0
 @Override
 public BlockFace getAttachedFace(short data) {
   if (data == 0x0) {
     return BlockFace.TOP;
   } else if (data == 0x1) {
     return BlockFace.BOTTOM;
   } else {
     return BlockFaces.NSWE.get(data - 2);
   }
 }
Пример #3
0
 @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);
   }
 }
Пример #4
0
 @Override
 public BlockFace getAttachedFace(short data) {
   return BlockFaces.NSWE.get(data - 2);
 }