net.minecraft.entity.vehicle.MinecartEntity Java Examples
The following examples show how to use
net.minecraft.entity.vehicle.MinecartEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CarpetDispenserBehaviours.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack) { if (!CarpetExtraSettings.dispensersFillMinecarts) { return defaultBehaviour(source, stack); } else { BlockPos pos = source.getBlockPos().offset((Direction) source.getBlockState().get(DispenserBlock.FACING)); List<MinecartEntity> list = source.getWorld().<MinecartEntity>getEntities(MinecartEntity.class, new Box(pos), null); if (list.isEmpty()) { return defaultBehaviour(source, stack); } else { MinecartEntity minecart = list.get(0); minecart.remove(); AbstractMinecartEntity minecartEntity = AbstractMinecartEntity.create(minecart.world, minecart.getX(), minecart.getY(), minecart.getZ(), this.minecartType); minecartEntity.setVelocity(minecart.getVelocity()); minecartEntity.pitch = minecart.pitch; minecartEntity.yaw = minecart.yaw; minecart.world.spawnEntity(minecartEntity); stack.decrement(1); return stack; } } }