Skip to content

Package net.minecraft.world.item.context

Part 1/1


BlockPlaceContext

  • Full name: net.minecraft.world.item.context.BlockPlaceContext
  • Package: net.minecraft.world.item.context
  • Source: commonnet/minecraft/world/item/context/BlockPlaceContext.java
  • Type: class
  • Modifiers: public
  • Extends: UseOnContext

net.minecraft.world.item.context.BlockPlaceContext#at(BlockPlaceContext,BlockPos,Direction)

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:31
  • Modifiers: public static
  • Return: BlockPlaceContext

คืออะไร

ดำเนินการ at ตาม implementation ของ BlockPlaceContext

ทำงานยังไง

เรียกต่อ: getLevel(), getPlayer(), getHand(), getItemInHand(), getX(), getStepX(), getY(), getStepY(). สร้างออบเจ็กต์: BlockPlaceContext, BlockHitResult, Vec3.

Parameters

  • BlockPlaceContext blockPlaceContext
  • BlockPos blockPos
  • Direction direction

ตัวอย่างใช้งาน

BlockPlaceContext blockPlaceContext = ...;
BlockPos blockPos = ...;
Direction direction = ...;
BlockPlaceContext result = BlockPlaceContext.at(blockPlaceContext, blockPos, direction);

net.minecraft.world.item.context.BlockPlaceContext#BlockPlaceContext(Level,Player,InteractionHand,ItemStack,BlockHitResult)

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:25
  • Modifiers: public
  • Kind: constructor

คืออะไร

สร้างออบเจ็กต์ BlockPlaceContext ด้วยพารามิเตอร์ที่ระบุ

ทำงานยังไง

แก้ state: relativePos, replaceClicked. เรียกต่อ: getBlockPos(), relative(), getDirection(), getBlockState(), canBeReplaced().

Parameters

  • Level level
  • Player player
  • InteractionHand interactionHand
  • ItemStack itemStack
  • BlockHitResult blockHitResult

ตัวอย่างใช้งาน

Level level = ...;
Player player = ...;
InteractionHand interactionHand = ...;
ItemStack itemStack = ...;
BlockHitResult blockHitResult = ...;
BlockPlaceContext instance = new BlockPlaceContext(level, player, interactionHand, itemStack, blockHitResult);

net.minecraft.world.item.context.BlockPlaceContext#BlockPlaceContext(Player,InteractionHand,ItemStack,BlockHitResult)

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:17
  • Modifiers: public
  • Kind: constructor

คืออะไร

สร้างออบเจ็กต์ BlockPlaceContext ด้วยพารามิเตอร์ที่ระบุ

ทำงานยังไง

เรียกต่อ: level().

Parameters

  • Player player
  • InteractionHand interactionHand
  • ItemStack itemStack
  • BlockHitResult blockHitResult

ตัวอย่างใช้งาน

Player player = ...;
InteractionHand interactionHand = ...;
ItemStack itemStack = ...;
BlockHitResult blockHitResult = ...;
BlockPlaceContext instance = new BlockPlaceContext(player, interactionHand, itemStack, blockHitResult);

net.minecraft.world.item.context.BlockPlaceContext#BlockPlaceContext(UseOnContext)

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:21
  • Modifiers: public
  • Kind: constructor

คืออะไร

สร้างออบเจ็กต์ BlockPlaceContext ด้วยพารามิเตอร์ที่ระบุ

ทำงานยังไง

เรียกต่อ: getLevel(), getPlayer(), getHand(), getItemInHand(), getHitResult().

Parameters

  • UseOnContext useOnContext

ตัวอย่างใช้งาน

UseOnContext useOnContext = ...;
BlockPlaceContext instance = new BlockPlaceContext(useOnContext);

net.minecraft.world.item.context.BlockPlaceContext#canPlace()

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:53
  • Modifiers: public
  • Return: boolean

คืออะไร

ตรวจสอบว่าสามารถ Place

ทำงานยังไง

เรียกต่อ: getLevel(), getBlockState(), getClickedPos(), canBeReplaced(). คืนค่า: this.replaceClicked || this.getLevel().getBlockState(this.getClickedPos()).canBeReplaced(this).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

BlockPlaceContext instance = ...;
boolean result = instance.canPlace();

net.minecraft.world.item.context.BlockPlaceContext#getClickedPos()

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:48
  • Modifiers: public
  • Return: BlockPos

คืออะไร

อ่านค่า Clicked Pos

ทำงานยังไง

คืนค่า: this.replaceClicked ? super.getClickedPos() : this.relativePos.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

BlockPlaceContext instance = ...;
BlockPos result = instance.getClickedPos();

net.minecraft.world.item.context.BlockPlaceContext#getNearestLookingDirection()

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:61
  • Modifiers: public
  • Return: Direction

คืออะไร

อ่านค่า Nearest Looking Direction

ทำงานยังไง

เรียกต่อ: orderedByNearest(), getPlayer(). คืนค่า: Direction.orderedByNearest(this.getPlayer())[0].

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

BlockPlaceContext instance = ...;
Direction result = instance.getNearestLookingDirection();

net.minecraft.world.item.context.BlockPlaceContext#getNearestLookingDirections()

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:69
  • Modifiers: public
  • Return: Direction[]

คืออะไร

อ่านค่า Nearest Looking Directions

ทำงานยังไง

ตรวจเงื่อนไขด้วย if ; มีการวนลูป. เรียกต่อ: orderedByNearest(), getPlayer(), getClickedFace(), getOpposite(), arraycopy(). มีจุด return อย่างน้อย 2 จุด.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

BlockPlaceContext instance = ...;
Direction[] result = instance.getNearestLookingDirections();

net.minecraft.world.item.context.BlockPlaceContext#getNearestLookingVerticalDirection()

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:65
  • Modifiers: public
  • Return: Direction

คืออะไร

อ่านค่า Nearest Looking Vertical Direction

ทำงานยังไง

เรียกต่อ: getFacingAxis(), getPlayer(). คืนค่า: Direction.getFacingAxis(this.getPlayer(), Direction.Axis.Y).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

BlockPlaceContext instance = ...;
Direction result = instance.getNearestLookingVerticalDirection();

net.minecraft.world.item.context.BlockPlaceContext#replacingClickedOnBlock()

  • Origin: common
  • Source: net/minecraft/world/item/context/BlockPlaceContext.java:57
  • Modifiers: public
  • Return: boolean

คืออะไร

ดำเนินการ replacingClickedOnBlock ตาม implementation ของ BlockPlaceContext

ทำงานยังไง

คืนค่า: this.replaceClicked.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

BlockPlaceContext instance = ...;
boolean result = instance.replacingClickedOnBlock();

DirectionalPlaceContext

  • Full name: net.minecraft.world.item.context.DirectionalPlaceContext
  • Package: net.minecraft.world.item.context
  • Source: commonnet/minecraft/world/item/context/DirectionalPlaceContext.java
  • Type: class
  • Modifiers: public
  • Extends: BlockPlaceContext

net.minecraft.world.item.context.DirectionalPlaceContext#canPlace()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:24
  • Modifiers: public
  • Return: boolean

คืออะไร

ตรวจสอบว่าสามารถ Place

ทำงานยังไง

เรียกต่อ: getLevel(), getBlockState(), getHitResult(), getBlockPos(), canBeReplaced(). คืนค่า: this.getLevel().getBlockState(this.getHitResult().getBlockPos()).canBeReplaced(this).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
boolean result = instance.canPlace();

net.minecraft.world.item.context.DirectionalPlaceContext#DirectionalPlaceContext(Level,BlockPos,Direction,ItemStack,Direction)

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:14
  • Modifiers: public
  • Kind: constructor

คืออะไร

สร้างออบเจ็กต์ DirectionalPlaceContext ด้วยพารามิเตอร์ที่ระบุ

ทำงานยังไง

แก้ state: direction. เรียกต่อ: atBottomCenterOf(). สร้างออบเจ็กต์: BlockHitResult.

Parameters

  • Level level
  • BlockPos blockPos
  • Direction direction
  • ItemStack itemStack
  • Direction direction2

ตัวอย่างใช้งาน

Level level = ...;
BlockPos blockPos = ...;
Direction direction = ...;
ItemStack itemStack = ...;
Direction direction2 = ...;
DirectionalPlaceContext instance = new DirectionalPlaceContext(level, blockPos, direction, itemStack, direction2);

net.minecraft.world.item.context.DirectionalPlaceContext#getClickedPos()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:19
  • Modifiers: public
  • Return: BlockPos

คืออะไร

อ่านค่า Clicked Pos

ทำงานยังไง

เรียกต่อ: getHitResult(), getBlockPos(). คืนค่า: this.getHitResult().getBlockPos().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
BlockPos result = instance.getClickedPos();

net.minecraft.world.item.context.DirectionalPlaceContext#getHorizontalDirection()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:58
  • Modifiers: public
  • Return: Direction

คืออะไร

อ่านค่า Horizontal Direction

ทำงานยังไง

เรียกต่อ: getAxis(). คืนค่า: this.direction.getAxis() == Direction.Axis.Y ? Direction.NORTH : this.direction.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
Direction result = instance.getHorizontalDirection();

net.minecraft.world.item.context.DirectionalPlaceContext#getNearestLookingDirection()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:34
  • Modifiers: public
  • Return: Direction

คืออะไร

อ่านค่า Nearest Looking Direction

ทำงานยังไง

คืนค่า: Direction.DOWN.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
Direction result = instance.getNearestLookingDirection();

net.minecraft.world.item.context.DirectionalPlaceContext#getNearestLookingDirections()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:39
  • Modifiers: public
  • Return: Direction[]

คืออะไร

อ่านค่า Nearest Looking Directions

ทำงานยังไง

แยกกรณีด้วย switch. มีจุด return อย่างน้อย 6 จุด.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
Direction[] result = instance.getNearestLookingDirections();

net.minecraft.world.item.context.DirectionalPlaceContext#getRotation()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:68
  • Modifiers: public
  • Return: float

คืออะไร

อ่านค่า Rotation

ทำงานยังไง

เรียกต่อ: get2DDataValue(). คืนค่า: this.direction.get2DDataValue() * 90.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
float result = instance.getRotation();

net.minecraft.world.item.context.DirectionalPlaceContext#isSecondaryUseActive()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:63
  • Modifiers: public
  • Return: boolean

คืออะไร

ตรวจสอบสถานะ Secondary Use Active

ทำงานยังไง

คืนค่า: false.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
boolean result = instance.isSecondaryUseActive();

net.minecraft.world.item.context.DirectionalPlaceContext#replacingClickedOnBlock()

  • Origin: common
  • Source: net/minecraft/world/item/context/DirectionalPlaceContext.java:29
  • Modifiers: public
  • Return: boolean

คืออะไร

ดำเนินการ replacingClickedOnBlock ตาม implementation ของ DirectionalPlaceContext

ทำงานยังไง

เรียกต่อ: canPlace(). คืนค่า: this.canPlace().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

DirectionalPlaceContext instance = ...;
boolean result = instance.replacingClickedOnBlock();

UseOnContext

  • Full name: net.minecraft.world.item.context.UseOnContext
  • Package: net.minecraft.world.item.context
  • Source: commonnet/minecraft/world/item/context/UseOnContext.java
  • Type: class
  • Modifiers: public

net.minecraft.world.item.context.UseOnContext#getClickedFace()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:41
  • Modifiers: public
  • Return: Direction

คืออะไร

อ่านค่า Clicked Face

ทำงานยังไง

เรียกต่อ: getDirection(). คืนค่า: this.hitResult.getDirection().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
Direction result = instance.getClickedFace();

net.minecraft.world.item.context.UseOnContext#getClickedPos()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:37
  • Modifiers: public
  • Return: BlockPos

คืออะไร

อ่านค่า Clicked Pos

ทำงานยังไง

เรียกต่อ: getBlockPos(). คืนค่า: this.hitResult.getBlockPos().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
BlockPos result = instance.getClickedPos();

net.minecraft.world.item.context.UseOnContext#getClickLocation()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:45
  • Modifiers: public
  • Return: Vec3

คืออะไร

อ่านค่า Click Location

ทำงานยังไง

เรียกต่อ: getLocation(). คืนค่า: this.hitResult.getLocation().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
Vec3 result = instance.getClickLocation();

net.minecraft.world.item.context.UseOnContext#getHand()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:62
  • Modifiers: public
  • Return: InteractionHand

คืออะไร

อ่านค่า Hand

ทำงานยังไง

คืนค่า: this.hand.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
InteractionHand result = instance.getHand();

net.minecraft.world.item.context.UseOnContext#getHitResult()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:33
  • Modifiers: protected final
  • Return: BlockHitResult

คืออะไร

อ่านค่า Hit Result

ทำงานยังไง

คืนค่า: this.hitResult.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

@Override
protected BlockHitResult getHitResult() {
    return super.getHitResult();
}

net.minecraft.world.item.context.UseOnContext#getHorizontalDirection()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:70
  • Modifiers: public
  • Return: Direction

คืออะไร

อ่านค่า Horizontal Direction

ทำงานยังไง

แก้ state: player. เรียกต่อ: getDirection(). คืนค่า: this.player == null ? Direction.NORTH : this.player.getDirection().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
Direction result = instance.getHorizontalDirection();

net.minecraft.world.item.context.UseOnContext#getItemInHand()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:53
  • Modifiers: public
  • Return: ItemStack

คืออะไร

อ่านค่า Item In Hand

ทำงานยังไง

คืนค่า: this.itemStack.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
ItemStack result = instance.getItemInHand();

net.minecraft.world.item.context.UseOnContext#getLevel()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:66
  • Modifiers: public
  • Return: Level

คืออะไร

อ่านค่า Level

ทำงานยังไง

คืนค่า: this.level.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
Level result = instance.getLevel();

net.minecraft.world.item.context.UseOnContext#getPlayer()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:57
  • Modifiers: public
  • Return: Player

คืออะไร

อ่านค่า Player

ทำงานยังไง

คืนค่า: this.player.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
Player result = instance.getPlayer();

net.minecraft.world.item.context.UseOnContext#getRotation()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:78
  • Modifiers: public
  • Return: float

คืออะไร

อ่านค่า Rotation

ทำงานยังไง

แก้ state: player. เรียกต่อ: getYRot(). คืนค่า: this.player == null ? 0.0F : this.player.getYRot().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
float result = instance.getRotation();

net.minecraft.world.item.context.UseOnContext#isInside()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:49
  • Modifiers: public
  • Return: boolean

คืออะไร

ตรวจสอบสถานะ Inside

ทำงานยังไง

คืนค่า: this.hitResult.isInside().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
boolean result = instance.isInside();

net.minecraft.world.item.context.UseOnContext#isSecondaryUseActive()

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:74
  • Modifiers: public
  • Return: boolean

คืออะไร

ตรวจสอบสถานะ Secondary Use Active

ทำงานยังไง

คืนค่า: this.player != null && this.player.isSecondaryUseActive().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

UseOnContext instance = ...;
boolean result = instance.isSecondaryUseActive();

net.minecraft.world.item.context.UseOnContext#UseOnContext(Level,Player,InteractionHand,ItemStack,BlockHitResult)

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:25
  • Modifiers: public
  • Kind: constructor

คืออะไร

สร้างออบเจ็กต์ UseOnContext ด้วยพารามิเตอร์ที่ระบุ

ทำงานยังไง

แก้ state: player, hand, hitResult, itemStack, level.

Parameters

  • Level level
  • Player player
  • InteractionHand interactionHand
  • ItemStack itemStack
  • BlockHitResult blockHitResult

ตัวอย่างใช้งาน

Level level = ...;
Player player = ...;
InteractionHand interactionHand = ...;
ItemStack itemStack = ...;
BlockHitResult blockHitResult = ...;
UseOnContext instance = new UseOnContext(level, player, interactionHand, itemStack, blockHitResult);

net.minecraft.world.item.context.UseOnContext#UseOnContext(Player,InteractionHand,BlockHitResult)

  • Origin: common
  • Source: net/minecraft/world/item/context/UseOnContext.java:21
  • Modifiers: public
  • Kind: constructor

คืออะไร

สร้างออบเจ็กต์ UseOnContext ด้วยพารามิเตอร์ที่ระบุ

ทำงานยังไง

เรียกต่อ: level(), getItemInHand().

Parameters

  • Player player
  • InteractionHand interactionHand
  • BlockHitResult blockHitResult

ตัวอย่างใช้งาน

Player player = ...;
InteractionHand interactionHand = ...;
BlockHitResult blockHitResult = ...;
UseOnContext instance = new UseOnContext(player, interactionHand, blockHitResult);