Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun pushFrame(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, stack: ItemStack, pushFacing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): EnumActionResult {
- val placeFacing = pushFacing
- val placeOnPos = pos.offset(placeFacing, -1)
- val placeOnState = world.getBlockState(placeOnPos)
- val newFramePos = pos.offset(pushFacing)
- if (canPlaceFrame(world, newFramePos, placeFacing, player, stack)) {
- world.setBlockToAir(pos)
- val result = if (placeOnState.getSelectedBoundingBox(world, placeOnPos) != Block.NULL_AABB && placeOnState.material != Material.AIR) {
- stack.onItemUse(player, world, placeOnPos, hand, placeFacing, hitX, hitY, hitZ)
- } else {
- stack.onItemUse(player, world, pos, hand, placeFacing, hitX, hitY, hitZ)
- }
- if (result == EnumActionResult.SUCCESS) {
- world.setBlockState(newFramePos, state)
- val attachables = getAttachables(world, pos)
- for (attachable in attachables) {
- attachable.attachment?.let {
- attachable.attachment = BlockAttachment(world, newFramePos, it.facing)
- }
- }
- } else {
- world.setBlockState(pos, state)
- }
- return result
- } else {
- return EnumActionResult.PASS
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement