Update for Spout entity changes

Dieser Commit ist enthalten in:
zml2008 2013-02-02 14:03:09 -08:00
Ursprung ef62a60fff
Commit 67178da4d3
4 geänderte Dateien mit 20 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -28,6 +28,7 @@ import org.spout.api.entity.Entity;
import org.spout.api.geo.LoadOption; import org.spout.api.geo.LoadOption;
import org.spout.api.geo.World; import org.spout.api.geo.World;
import org.spout.api.geo.discrete.Point; import org.spout.api.geo.discrete.Point;
import org.spout.api.math.QuaternionMath;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
@ -66,8 +67,7 @@ public class SpoutEntity extends LocalEntity {
Entity e = world.createAndSpawnEntity(pos, mainComponent, LoadOption.LOAD_ONLY); // Blocks should already be pasted by time entitieos are brought in Entity e = world.createAndSpawnEntity(pos, mainComponent, LoadOption.LOAD_ONLY); // Blocks should already be pasted by time entitieos are brought in
if (e != null) { if (e != null) {
e.getTransform().setPitch(loc.getPitch()); e.getScene().setRotation(QuaternionMath.rotation(loc.getPitch(), loc.getYaw(), 0));
e.getTransform().setYaw(loc.getYaw());
for (Class<? extends Component> clazz : Iterables.skip(components, 1)) { for (Class<? extends Component> clazz : Iterables.skip(components, 1)) {
e.add(clazz); e.add(clazz);
} }

Datei anzeigen

@ -31,10 +31,12 @@ import com.sk89q.worldedit.cui.CUIEvent;
import org.spout.api.Client; import org.spout.api.Client;
import org.spout.api.chat.style.ChatStyle; import org.spout.api.chat.style.ChatStyle;
import org.spout.api.component.impl.TransformComponent; import org.spout.api.component.impl.SceneComponent;
import org.spout.api.geo.discrete.Point; import org.spout.api.geo.discrete.Point;
import org.spout.api.inventory.ItemStack; import org.spout.api.inventory.ItemStack;
import org.spout.api.entity.Player; import org.spout.api.entity.Player;
import org.spout.api.math.QuaternionMath;
import org.spout.api.math.Vector3;
import org.spout.vanilla.api.inventory.Slot; import org.spout.vanilla.api.inventory.Slot;
import org.spout.vanilla.plugin.component.inventory.PlayerInventory; import org.spout.vanilla.plugin.component.inventory.PlayerInventory;
import org.spout.vanilla.plugin.component.living.neutral.Human; import org.spout.vanilla.plugin.component.living.neutral.Human;
@ -72,19 +74,19 @@ public class SpoutPlayer extends LocalPlayer {
@Override @Override
public WorldVector getPosition() { public WorldVector getPosition() {
Point loc = player.getTransform().getPosition(); Point loc = player.getScene().getPosition();
return new WorldVector(SpoutUtil.getLocalWorld(loc.getWorld()), return new WorldVector(SpoutUtil.getLocalWorld(loc.getWorld()),
loc.getX(), loc.getY(), loc.getZ()); loc.getX(), loc.getY(), loc.getZ());
} }
@Override @Override
public double getPitch() { public double getPitch() {
return player.getTransform().getPitch(); return player.getScene().getRotation().getYaw();
} }
@Override @Override
public double getYaw() { public double getYaw() {
return player.getTransform().getYaw(); return player.getScene().getRotation().getYaw();
} }
@Override @Override
@ -124,10 +126,9 @@ public class SpoutPlayer extends LocalPlayer {
@Override @Override
public void setPosition(Vector pos, float pitch, float yaw) { public void setPosition(Vector pos, float pitch, float yaw) {
TransformComponent component = player.getTransform(); SceneComponent component = player.getScene();
player.teleport(SpoutUtil.toPoint(player.getWorld(), pos)); player.teleport(SpoutUtil.toPoint(player.getWorld(), pos));
component.setPitch(pitch); component.setRotation(QuaternionMath.rotation(pitch, yaw, component.getRotation().getRoll()));
component.setYaw(yaw);
} }
@Override @Override

Datei anzeigen

@ -34,7 +34,7 @@ import org.spout.api.geo.World;
import org.spout.api.geo.cuboid.Block; import org.spout.api.geo.cuboid.Block;
import org.spout.api.geo.discrete.Point; import org.spout.api.geo.discrete.Point;
import org.spout.api.material.block.BlockFace; import org.spout.api.material.block.BlockFace;
import org.spout.api.math.MathHelper; import org.spout.api.math.GenericMath;
import org.spout.api.math.Vector3; import org.spout.api.math.Vector3;
import org.spout.api.entity.Player; import org.spout.api.entity.Player;
@ -91,9 +91,9 @@ public class SpoutUtil {
public static Point center(Point loc) { public static Point center(Point loc) {
return new Point( return new Point(
loc.getWorld(), loc.getWorld(),
MathHelper.floor(loc.getX()) + 0.5F, GenericMath.floor(loc.getX()) + 0.5F,
MathHelper.floor(loc.getY()) + 0.5F, GenericMath.floor(loc.getY()) + 0.5F,
MathHelper.floor(loc.getZ()) + 0.5F GenericMath.floor(loc.getZ()) + 0.5F
); );
} }
@ -110,6 +110,7 @@ public class SpoutUtil {
} }
public static Location toLocation(Entity ent) { public static Location toLocation(Entity ent) {
return new Location(getLocalWorld(ent.getWorld()), toVector(ent.getTransform().getPosition()), ent.getTransform().getYaw(), ent.getTransform().getPitch()); return new Location(getLocalWorld(ent.getWorld()), toVector(ent.getScene().getPosition()),
ent.getScene().getRotation().getYaw(), ent.getScene().getRotation().getPitch());
} }
} }

Datei anzeigen

@ -23,8 +23,6 @@ package com.sk89q.worldedit.spout;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.BiomeType; import com.sk89q.worldedit.BiomeType;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -41,7 +39,6 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import org.spout.api.component.Component; import org.spout.api.component.Component;
import org.spout.api.entity.Entity; import org.spout.api.entity.Entity;
import org.spout.api.event.cause.PluginCause;
import org.spout.api.generator.biome.BiomeGenerator; import org.spout.api.generator.biome.BiomeGenerator;
import org.spout.api.geo.LoadOption; import org.spout.api.geo.LoadOption;
import org.spout.api.geo.World; import org.spout.api.geo.World;
@ -49,19 +46,17 @@ import org.spout.api.geo.cuboid.Chunk;
import org.spout.api.inventory.ItemStack; import org.spout.api.inventory.ItemStack;
import org.spout.api.material.BlockMaterial; import org.spout.api.material.BlockMaterial;
import org.spout.api.material.Material; import org.spout.api.material.Material;
import org.spout.api.math.Vector3;
import org.spout.vanilla.plugin.component.substance.Item;
import org.spout.vanilla.plugin.component.substance.Painting; import org.spout.vanilla.plugin.component.substance.Painting;
import org.spout.vanilla.plugin.component.substance.XPOrb; import org.spout.vanilla.plugin.component.substance.XPOrb;
import org.spout.vanilla.plugin.component.substance.object.Item;
import org.spout.vanilla.plugin.component.substance.object.Tnt; import org.spout.vanilla.plugin.component.substance.object.Tnt;
import org.spout.vanilla.plugin.component.substance.object.projectile.Arrow; import org.spout.vanilla.plugin.component.substance.object.projectile.Arrow;
import org.spout.vanilla.plugin.component.substance.object.vehicle.Boat; import org.spout.vanilla.plugin.component.substance.object.vehicle.Boat;
import org.spout.vanilla.plugin.component.substance.object.vehicle.Minecart;
import org.spout.vanilla.api.material.VanillaMaterial; import org.spout.vanilla.api.material.VanillaMaterial;
import org.spout.vanilla.plugin.component.substance.object.vehicle.minecart.Minecart;
import org.spout.vanilla.plugin.material.VanillaMaterials; import org.spout.vanilla.plugin.material.VanillaMaterials;
import org.spout.vanilla.plugin.world.generator.normal.object.tree.TreeObject; import org.spout.vanilla.plugin.world.generator.normal.object.tree.TreeObject;
import org.spout.vanilla.plugin.world.generator.normal.object.tree.SmallTreeObject; import org.spout.vanilla.plugin.world.generator.normal.object.tree.SmallTreeObject;
import org.spout.vanilla.plugin.world.generator.object.VanillaObjects;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@ -561,7 +556,7 @@ public class SpoutWorld extends LocalWorld {
for (Entity ent : world.getAll()) { for (Entity ent : world.getAll()) {
if (radius != -1 if (radius != -1
&& origin.distanceSq(SpoutUtil.toVector(ent.getTransform().getPosition())) > radiusSq) { && origin.distanceSq(SpoutUtil.toVector(ent.getScene().getPosition())) > radiusSq) {
continue; continue;
} }
@ -805,7 +800,7 @@ public class SpoutWorld extends LocalWorld {
continue; continue;
} }
for (Entity ent : chunk.getEntities()) { for (Entity ent : chunk.getEntities()) {
if (region.contains(SpoutUtil.toVector(ent.getTransform().getPosition()))) { if (region.contains(SpoutUtil.toVector(ent.getScene().getPosition()))) {
Collection<Class<? extends Component>> revisedComponents = Collections2.transform(ent.values(), new Function<Component, Class<? extends Component>>() { Collection<Class<? extends Component>> revisedComponents = Collections2.transform(ent.values(), new Function<Component, Class<? extends Component>>() {
@Override @Override
public Class<? extends Component> apply(@Nullable Component component) { public Class<? extends Component> apply(@Nullable Component component) {