當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。