Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. fun pushFrame(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, stack: ItemStack, pushFacing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): EnumActionResult {
  2. val placeFacing = pushFacing
  3. val placeOnPos = pos.offset(placeFacing, -1)
  4. val placeOnState = world.getBlockState(placeOnPos)
  5. val newFramePos = pos.offset(pushFacing)
  6. if (canPlaceFrame(world, newFramePos, placeFacing, player, stack)) {
  7. world.setBlockToAir(pos)
  8. val result = if (placeOnState.getSelectedBoundingBox(world, placeOnPos) != Block.NULL_AABB && placeOnState.material != Material.AIR) {
  9. stack.onItemUse(player, world, placeOnPos, hand, placeFacing, hitX, hitY, hitZ)
  10. } else {
  11. stack.onItemUse(player, world, pos, hand, placeFacing, hitX, hitY, hitZ)
  12. }
  13. if (result == EnumActionResult.SUCCESS) {
  14. world.setBlockState(newFramePos, state)
  15. val attachables = getAttachables(world, pos)
  16. for (attachable in attachables) {
  17. attachable.attachment?.let {
  18. attachable.attachment = BlockAttachment(world, newFramePos, it.facing)
  19. }
  20. }
  21. } else {
  22. world.setBlockState(pos, state)
  23. }
  24. return result
  25. } else {
  26. return EnumActionResult.PASS
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement