当前位置: 首页>>代码示例>>Java>>正文


Java Vector3d类代码示例

本文整理汇总了Java中com.flowpowered.math.vector.Vector3d的典型用法代码示例。如果您正苦于以下问题:Java Vector3d类的具体用法?Java Vector3d怎么用?Java Vector3d使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Vector3d类属于com.flowpowered.math.vector包,在下文中一共展示了Vector3d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemUse

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
@Override
public boolean onItemUse(ItemStack itemStack, Player player, HandType currHand, BlockSnapshot clickedBlock,
        Direction side, Vector3d hitPoint) {
    CustomWorld world = WorldManager.toCustomWorld(player.getWorld());
    Vector3d pos;
    if (hitPoint == null) {
        pos = clickedBlock.getPosition().add(side.asBlockOffset()).toDouble().add(0.5, 0, 0.5);
    } else {
        pos = clickedBlock.getPosition().toDouble().add(hitPoint);
    }
    TurtleEntity turtle = new TurtleEntity(player.getWorld());
    turtle.setPosition(pos);
    Vector3d r = player.getHeadRotation();
    turtle.setRotation(new Vector3d(r.getX(), r.getY() + 180, r.getZ()));
    if (world.spawnEntity(turtle)) {
        if (player.gameMode().get() != GameModes.CREATIVE) {
            itemStack.setQuantity(itemStack.getQuantity() - 1);
            if (itemStack.getQuantity() == 0) {
                itemStack = null;
            }
            player.setItemInHand(currHand, itemStack);
        }
    }
    return false;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:26,代码来源:ItemTurtle.java

示例2: teleport

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
public boolean teleport(final World world, final Vector3d vector){
	if (this.getVehicle().isPresent()){
		final Entity horse = this.getVehicle().get();
		if (horse.toContainer().getView(DataQuery.of("UnsafeData")).isPresent()){
			if (horse.toContainer().getView(DataQuery.of("UnsafeData")).get().getString(DataQuery.of("OwnerUUID")).isPresent()){
				UUID owner = UUID.fromString(horse.toContainer().getView(DataQuery.of("UnsafeData")).get().getString(DataQuery.of("OwnerUUID")).get());
				if (this.getUniqueId().equals(owner)){
					this.setVehicle(null);
					horse.transferToWorld(world, vector);
					
					if (this.setLocation(world.getLocation(vector))) {
						this.setVehicle(horse);
						return true;
					}
				}
			}
		}
	}
	
	return this.setLocation(world.getLocation(vector));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:22,代码来源:EPlayer.java

示例3: getEPlayers

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
public Map<Player, Integer> getEPlayers(int distance) {
	Map<Player, Integer> list = new HashMap<Player, Integer>();
	distance = Math.max((distance ^ 2) - 1, 0);
	Vector3d vect = this.getLocation().getPosition();
	for (Player player : this.plugin.getEServer().getOnlinePlayers()) {
		if (!this.equals(player) && this.getWorld().equals(player.getWorld())) {
			//if (player.isHidden(player)) {
				Integer delta = (int) Math.floor(player.getLocation().getPosition().distance(vect));
				if (delta < distance) {
					list.put(player, delta);
				}
			//}
		}
	}
	return list;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:17,代码来源:EPlayer.java

示例4: PipeBlock

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
public PipeBlock() {
    this.pane = ItemStack.of(ItemTypes.STAINED_GLASS_PANE, 1);
    Vector3d rotX = new Vector3d(90, 0, 0);
    Vector3d rotY = new Vector3d(0, 90, 0);
    this.entityStruct = new MultiEntityStructure.Builder()
            .define(Direction.DOWN.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(true, Axis.Z, new Vector3f(0.5, 0.2, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotX))
            .define(Direction.UP.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(true, Axis.Z, new Vector3f(0.5, 0.7375, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotX))
            .define(Direction.NORTH.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.Z, new Vector3f(0.5, 0.2, 0.2)),
                    ArmorStand.class, stand -> setupArmorStand(stand, null))
            .define(Direction.SOUTH.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.Z, new Vector3f(0.5, 0.2, 0.8)),
                    ArmorStand.class, stand -> setupArmorStand(stand, null))
            .define(Direction.EAST.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.X, new Vector3f(0.8, 0.2, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotY))
            .define(Direction.WEST.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.X, new Vector3f(0.2, 0.2, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotY))
            .build();
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:26,代码来源:PipeBlock.java

示例5: commandSpawnMob

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
private CompletableFuture<Boolean> commandSpawnMob(final EPlayer player, EntityTemplate format, int amount, Vector3d location) {
	for(int cpt=0; cpt < amount; cpt++) {
		Entity entity = player.getWorld().createEntityNaturally(format.getType(), location);
		format.apply(entity, player.get());
		
		player.getWorld().spawnEntity(
				entity,
				Cause.source(this.plugin)
					.owner(player.get())
					.notifier(player.get())
					.build());
	}
	
	EEMessages.SPAWNMOB_MOB.sender()
		.replace("{amount}", String.valueOf(amount))
		.replace("{entity}", StringUtils.capitalize(format.getName()))
		.sendTo(player);
	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:20,代码来源:EESpawnMob.java

示例6: groundEntity

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
private static Handler groundEntity()
{
    return mount -> {
        double speed = mount.currentSpeed();
        Vector3d rotation = mount.player.getHeadRotation();
        Vector3d velocity = rotationToVelocity(mount.player.getRotation(), speed, 0).add(0, mount.vehicle.getVelocity().getY(), 0);
        Vector3d ahead = direction(rotation).mul(1, 0, 1);
        Optional<PassableProperty> passable = mount.vehicle.getLocation().add(ahead).getProperty(PassableProperty.class);

        if (!passable.map(AbstractProperty::getValue).orElse(true) && canJump(mount.vehicle))
        {
            velocity = velocity.add(0, 0.15 + (speed * 0.15), 0);
        }

        mount.vehicle.setVelocity(velocity);
        mount.vehicle.setRotation(rotation);
    };
}
 
开发者ID:dags-,项目名称:Mounts,代码行数:19,代码来源:Mount.java

示例7: getPickaxeRot

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
private Vector3d getPickaxeRot() {
    Direction facing = Utils.rotationToDirection(this.rotation.getY());
    if (facing == Direction.NORTH) {
        return new Vector3d(0, 180, 0);
    }
    if (facing == Direction.EAST) {
        return new Vector3d(0, 270, 0);
    }
    if (facing == Direction.SOUTH) {
        return Vector3d.ZERO;
    }
    if (facing == Direction.WEST) {
        return new Vector3d(0, 90, 0);
    }
    return this.rotation;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:17,代码来源:TurtleEntity.java

示例8: modifyArray

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
private static void modifyArray(JsonObject parent, String name, Vector3d defaultValue, Vector3d modification, BinaryOperator<Vector3d> operator) {
    JsonElement supposedArray = parent.get(name);
    JsonArray array = supposedArray != null && supposedArray.isJsonArray() ? supposedArray.getAsJsonArray() : new JsonArray();

    if(array.size() < 3) {
        array = new JsonArray();

        array.add(new JsonPrimitive(defaultValue.getX()));
        array.add(new JsonPrimitive(defaultValue.getY()));
        array.add(new JsonPrimitive(defaultValue.getZ()));
    }

    Vector3d found = new Vector3d(array.get(0).getAsDouble(), array.get(1).getAsDouble(), array.get(2).getAsDouble());
    Vector3d result = operator.apply(found, modification);

    array = new JsonArray();

    array.add(new JsonPrimitive(result.getX()));
    array.add(new JsonPrimitive(result.getY()));
    array.add(new JsonPrimitive(result.getZ()));

    parent.add(name, array);
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:24,代码来源:SimpleCustomBlockRegistry.java

示例9: createDummyArmorStand

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
static ArmorStand createDummyArmorStand(Block block) {
    World world = block.getWorld()
            .orElseThrow(() -> new IllegalStateException("Could not access the world this block resides in."));
    Vector3d armorStandPosition = block.getPosition().toDouble().add(Vector3d.ONE.mul(0.5));
    ArmorStand armorStand = (ArmorStand) world.createEntity(EntityTypes.ARMOR_STAND, armorStandPosition);

    armorStand.offer(Keys.IS_SILENT, true);
    armorStand.offer(Keys.INVISIBLE, true);
    armorStand.offer(Keys.ARMOR_STAND_MARKER, true);
    armorStand.offer(Keys.HAS_GRAVITY, false);
    armorStand.offer(Keys.PERSISTS, true);
    armorStand.offer(Keys.IS_SILENT, true);
    armorStand.setHeadRotation(Vector3d.ZERO);
    armorStand.setRotation(Vector3d.ZERO);

    return armorStand;
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:18,代码来源:CustomBlockDefinition.java

示例10: getBackgroundFeature

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
private GUIFeature getBackgroundFeature(GUIBackground background) {
    TextureId id = background.getTextureId();

    return GUIFeature.builder()
            .id(id.toString())
            .model(GUIModel.builder()
                    .plugin(pluginContainer.getInstance()
                            .orElseThrow(() -> new IllegalStateException("Could not access the plugin instance.")))
                    .textureId(id)
                    .textureSize(Vector2d.from(getInventoryTextureWidth(), getInventoryTextureHeight(highPrioritySlots.length)))
                    .textureOffset(Vector3d.from(0, 0, -100))
                    .uvRegion(Vector4d.from(
                            background.getUvTopLeft().getX(),
                            background.getUvTopLeft().getY(),
                            background.getUvTopLeft().getX() + getInventoryTextureWidth(),
                            background.getUvTopLeft().getY() + getInventoryTextureHeight(highPrioritySlots.length)
                    ))
                    .build())
            .build();
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:21,代码来源:SimpleCustomInventoryDefinitionBuilder.java

示例11: getModelTranslation

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
public Vector3d getModelTranslation() {
    // The texture must have a 1;1 aspect ratio, so it is expanded
    Vector2d uvRegionSize = getUvRegionSize();
    Vector2d result2d = Vector2d.ZERO;

    // First, align with the upper left corner of the inventory slot
    result2d = result2d.add(uvRegionSize);
    result2d = result2d.sub(Vector2d.from(INVENTORY_TEXTURE_SLOT_SIZE));
    result2d = result2d.div(2);

    // Apply custom offset
    Vector3d result3d = result2d.toVector3().add(this.textureOffset);

    // Finally, flip the Y coordinate, because it's inverse in minecraft
    result3d = result3d.mul(1, -1, 1);

    return result3d;
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:19,代码来源:GUIModel.java

示例12: serialize

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
public static JsonObject serialize(Vector3d vector3d) {
    return JsonBuilder.object()
            .add("x", vector3d.getX())
            .add("y", vector3d.getY())
            .add("z", vector3d.getZ())
            .build();
}
 
开发者ID:lucko,项目名称:helper,代码行数:8,代码来源:VectorSerializers.java

示例13: deserialize3d

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
public static Vector3d deserialize3d(JsonElement element) {
    return new Vector3d(
            element.getAsJsonObject().get("x").getAsDouble(),
            element.getAsJsonObject().get("y").getAsDouble(),
            element.getAsJsonObject().get("z").getAsDouble()
    );
}
 
开发者ID:lucko,项目名称:helper,代码行数:8,代码来源:VectorSerializers.java

示例14: loadConfigValues

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
private void loadConfigValues() {
    try {
        log_opened_crates = config.getNode("LOG_OPENED_CRATES").getBoolean(false);
        check_updates = config.getNode("CHECK_UPDATES").getBoolean(true);
        hologram_offset = config.getNode("HOLOGRAM_OFFSET").getValue(TypeToken.of(Vector3d.class), new Vector3d(0.5, -1.2, 0.5));
    } catch (ObjectMappingException e) {
        logger.warn("Exception loading config values!", e);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:10,代码来源:GWMCrates.java

示例15: sendPacketWithinDistance

import com.flowpowered.math.vector.Vector3d; //导入依赖的package包/类
@Override
public void sendPacketWithinDistance(Packet packet, Location<World> location, double distance) {
    net.minecraft.network.Packet mcPacket = (net.minecraft.network.Packet)packet;
    Vector3d vec = location.getPosition();
    double distanceSquared = distance * distance;

    for(Player player : location.getExtent().getPlayers()) {
        double d = player.getLocation().getPosition().distanceSquared(vec);
        if(d > distanceSquared) continue;

        ((EntityPlayerMP)player).connection.sendPacket(mcPacket);
    }
}
 
开发者ID:Guichaguri,项目名称:PacketControl,代码行数:14,代码来源:PacketControlService.java


注:本文中的com.flowpowered.math.vector.Vector3d类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。