Containers.java
net.minecraft.world.Containers
信息
- 全限定名:net.minecraft.world.Containers
- 类型:public class
- 包:net.minecraft.world
- 源码路径:src/main/java/net/minecraft/world/Containers.java
- 起始行号:L13
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static void dropContents(Level level, BlockPos pos, Container container) @ L14
- 方法名:dropContents
- 源码定位:L14
- 返回类型:void
- 修饰符:public static
参数:
- level: Level
- pos: BlockPos
- container: Container
说明:
TODO
public static void dropContents(Level level, Entity entity, Container container) @ L18
- 方法名:dropContents
- 源码定位:L18
- 返回类型:void
- 修饰符:public static
参数:
- level: Level
- entity: Entity
- container: Container
说明:
TODO
private static void dropContents(Level level, double x, double y, double z, Container container) @ L22
- 方法名:dropContents
- 源码定位:L22
- 返回类型:void
- 修饰符:private static
参数:
- level: Level
- x: double
- y: double
- z: double
- container: Container
说明:
TODO
public static void dropContents(Level level, BlockPos pos, NonNullList<ItemStack> list) @ L28
- 方法名:dropContents
- 源码定位:L28
- 返回类型:void
- 修饰符:public static
参数:
- level: Level
- pos: BlockPos
- list: NonNullList
说明:
TODO
public static void dropItemStack(Level level, double x, double y, double z, ItemStack itemStack) @ L32
- 方法名:dropItemStack
- 源码定位:L32
- 返回类型:void
- 修饰符:public static
参数:
- level: Level
- x: double
- y: double
- z: double
- itemStack: ItemStack
说明:
TODO
public static void updateNeighboursAfterDestroy(BlockState state, Level level, BlockPos pos) @ L51
- 方法名:updateNeighboursAfterDestroy
- 源码定位:L51
- 返回类型:void
- 修饰符:public static
参数:
- state: BlockState
- level: Level
- pos: BlockPos
说明:
TODO
代码
public class Containers {
public static void dropContents(Level level, BlockPos pos, Container container) {
dropContents(level, pos.getX(), pos.getY(), pos.getZ(), container);
}
public static void dropContents(Level level, Entity entity, Container container) {
dropContents(level, entity.getX(), entity.getY(), entity.getZ(), container);
}
private static void dropContents(Level level, double x, double y, double z, Container container) {
for (int i = 0; i < container.getContainerSize(); i++) {
dropItemStack(level, x, y, z, container.getItem(i));
}
}
public static void dropContents(Level level, BlockPos pos, NonNullList<ItemStack> list) {
list.forEach(itemStack -> dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), itemStack));
}
public static void dropItemStack(Level level, double x, double y, double z, ItemStack itemStack) {
double size = EntityType.ITEM.getWidth();
double centerRange = 1.0 - size;
double halfSize = size / 2.0;
RandomSource random = level.getRandom();
double xo = Math.floor(x) + random.nextDouble() * centerRange + halfSize;
double yo = Math.floor(y) + random.nextDouble() * centerRange;
double zo = Math.floor(z) + random.nextDouble() * centerRange + halfSize;
while (!itemStack.isEmpty()) {
ItemEntity entity = new ItemEntity(level, xo, yo, zo, itemStack.split(random.nextInt(21) + 10));
float pow = 0.05F;
entity.setDeltaMovement(
random.triangle(0.0, 0.11485000171139836), random.triangle(0.2, 0.11485000171139836), random.triangle(0.0, 0.11485000171139836)
);
level.addFreshEntity(entity);
}
}
public static void updateNeighboursAfterDestroy(BlockState state, Level level, BlockPos pos) {
level.updateNeighbourForOutputSignal(pos, state.getBlock());
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ItemEntity()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: