Skip to content

Commit

Permalink
Compat with BKC and R0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bergerkiller committed Dec 13, 2012
1 parent 6be3d72 commit b420a99
Show file tree
Hide file tree
Showing 29 changed files with 170 additions and 176 deletions.
2 changes: 1 addition & 1 deletion src/com/bergerkiller/bukkit/tc/Station.java
Expand Up @@ -152,7 +152,7 @@ private double calcDiagonalLength() {
if (rr == null || rr.getDirection() != railDirection) {
break;
}
tlength += MathUtil.halfRootOfTwo;
tlength += MathUtil.HALFROOTOFTWO;
}

// Update the length
Expand Down
6 changes: 3 additions & 3 deletions src/com/bergerkiller/bukkit/tc/TCListener.java
Expand Up @@ -2,13 +2,13 @@

import java.util.ArrayList;

import net.minecraft.server.EntityMinecart;
import net.minecraft.server.v1_4_5.EntityMinecart;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.util.LongHash;
import org.bukkit.craftbukkit.v1_4_5.util.LongHash;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -491,7 +491,7 @@ public void onEntityDamage(EntityDamageEvent event) {
public void ignoreOutputLever(Block lever) {
// Ignore signs that are attached to the block the lever is attached to
Block att = BlockUtil.getAttachedBlock(lever);
for (BlockFace face : FaceUtil.attachedFaces) {
for (BlockFace face : FaceUtil.ATTACHEDFACES) {
Block signblock = att.getRelative(face);
if (MaterialUtil.ISSIGN.get(signblock) && BlockUtil.getAttachedFace(signblock) == face.getOppositeFace()) {
if (ignoredSigns.isEmpty()) {
Expand Down
1 change: 0 additions & 1 deletion src/com/bergerkiller/bukkit/tc/TrainCarts.java
Expand Up @@ -41,7 +41,6 @@
import com.bergerkiller.bukkit.common.utils.WorldUtil;

public class TrainCarts extends PluginBase {

/*
* Settings
*/
Expand Down
8 changes: 5 additions & 3 deletions src/com/bergerkiller/bukkit/tc/Util.java
Expand Up @@ -5,6 +5,8 @@
import java.util.Collection;
import java.util.List;

import net.minecraft.server.v1_4_5.Item;

import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
Expand All @@ -28,9 +30,9 @@ public class Util {
public static final MaterialTypeProperty ISVERTRAIL = new MaterialTypeProperty(Material.LADDER);

public static void setItemMaxSize(Material material, int maxstacksize) {
setItemMaxSize(net.minecraft.server.Item.byId[material.getId()], maxstacksize);
setItemMaxSize(Item.byId[material.getId()], maxstacksize);
}
public static void setItemMaxSize(net.minecraft.server.Item item, int maxstacksize) {
public static void setItemMaxSize(Item item, int maxstacksize) {
SafeField.set(item, "maxStackSize", maxstacksize);
}

Expand Down Expand Up @@ -79,7 +81,7 @@ public static boolean hasAttachedSigns(final Block middle) {
public static boolean addAttachedSigns(final Block middle, final Collection<Block> rval) {
boolean found = false;
Block b;
for (BlockFace face : FaceUtil.axis) {
for (BlockFace face : FaceUtil.AXIS) {
b = middle.getRelative(face);
if (b.getTypeId() == Material.WALL_SIGN.getId()) {
if (BlockUtil.getAttachedFace(b) == face.getOppositeFace()) {
Expand Down
4 changes: 2 additions & 2 deletions src/com/bergerkiller/bukkit/tc/controller/MinecartGroup.java
Expand Up @@ -15,8 +15,8 @@
import java.util.Set;
import java.util.logging.Level;

import net.minecraft.server.EntityPlayer;
import net.minecraft.server.IInventory;
import net.minecraft.server.v1_4_5.EntityPlayer;
import net.minecraft.server.v1_4_5.IInventory;

import org.bukkit.Chunk;
import org.bukkit.Location;
Expand Down
69 changes: 34 additions & 35 deletions src/com/bergerkiller/bukkit/tc/controller/MinecartMember.java
Expand Up @@ -10,23 +10,23 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

import net.minecraft.server.EntityMinecart;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.IInventory;
import net.minecraft.server.ItemStack;
import net.minecraft.server.LocaleI18n;
import net.minecraft.server.World;
import net.minecraft.server.EntityItem;
import net.minecraft.server.v1_4_5.Entity;
import net.minecraft.server.v1_4_5.EntityMinecart;
import net.minecraft.server.v1_4_5.EntityPlayer;
import net.minecraft.server.v1_4_5.ItemStack;
import net.minecraft.server.v1_4_5.LocaleI18n;
import net.minecraft.server.v1_4_5.PlayerInventory;
import net.minecraft.server.v1_4_5.World;
import net.minecraft.server.v1_4_5.EntityItem;

import org.bukkit.Chunk;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.craftbukkit.v1_4_5.inventory.CraftInventory;
import org.bukkit.craftbukkit.v1_4_5.inventory.CraftInventoryPlayer;
import org.bukkit.entity.Item;
import org.bukkit.entity.Minecart;
import org.bukkit.inventory.Inventory;
Expand All @@ -48,7 +48,6 @@
import com.bergerkiller.bukkit.tc.signactions.SignAction;
import com.bergerkiller.bukkit.tc.signactions.SignActionType;
import com.bergerkiller.bukkit.tc.storage.OfflineGroupManager;
import com.bergerkiller.bukkit.common.natives.IInventoryMerged;
import com.bergerkiller.bukkit.common.reflection.classes.EntityMinecartRef;
import com.bergerkiller.bukkit.common.utils.BlockUtil;
import com.bergerkiller.bukkit.common.utils.CommonUtil;
Expand Down Expand Up @@ -94,8 +93,8 @@ protected MinecartMember(EntityMinecart source) {

protected MinecartMember(World world, double x, double y, double z, int type) {
super(world, x, y, z, type);
this.prevcx = MathUtil.locToChunk(this.locX);
this.prevcz = MathUtil.locToChunk(this.locZ);
this.prevcx = MathUtil.toChunk(this.locX);
this.prevcz = MathUtil.toChunk(this.locZ);
this.direction = FaceUtil.yawToFace(this.yaw);
this.directionFrom = this.directionTo = FaceUtil.yawToFace(this.yaw, false);
}
Expand Down Expand Up @@ -139,7 +138,7 @@ public void onPhysicsPostMove(double speedFactor) throws MemberMissingException,
Inventory inv = this.getInventory();
org.bukkit.inventory.ItemStack stack;
Item item;
for (net.minecraft.server.Entity e : this.getNearbyEntities(2)) {
for (Entity e : this.getNearbyEntities(2)) {
if (e instanceof EntityItem) {
item = (Item) e.getBukkitEntity();
if (EntityUtil.isIgnored(item)) continue;
Expand Down Expand Up @@ -516,13 +515,13 @@ public double getMovedDistanceXZ() {
public double getMovedDistance() {
return MathUtil.length(this.getMovedX(), this.getMovedY(), this.getMovedZ());
}
public double distance(net.minecraft.server.Entity e) {
public double distance(Entity e) {
return MathUtil.distance(this.getX(), this.getY(), this.getZ(), e.locX, e.locY, e.locZ);
}
public double distance(Location l) {
return MathUtil.distance(this.getX(), this.getY(), this.getZ(), l.getX(), l.getY(), l.getZ());
}
public double distanceXZ(net.minecraft.server.Entity e) {
public double distanceXZ(Entity e) {
return MathUtil.distance(this.getX(), this.getZ(), e.locX, e.locZ);
}
public double distanceXZ(Location l) {
Expand All @@ -531,13 +530,13 @@ public double distanceXZ(Location l) {
public double distanceXZ(Block block) {
return MathUtil.distance(this.getX(), this.getZ(), 0.5 + block.getX(), 0.5 + block.getZ());
}
public double distanceSquared(net.minecraft.server.Entity e) {
public double distanceSquared(Entity e) {
return MathUtil.distanceSquared(this.getX(), this.getY(), this.getZ(), e.locX, e.locY, e.locZ);
}
public double distanceSquared(Location l) {
return MathUtil.distanceSquared(this.getX(), this.getY(), this.getZ(), l.getX(), l.getY(), l.getZ());
}
public double distanceXZSquared(net.minecraft.server.Entity e) {
public double distanceXZSquared(Entity e) {
return MathUtil.distanceSquared(this.getX(), this.getZ(), e.locX, e.locZ);
}
public double distanceXZSquared(Location l) {
Expand All @@ -554,17 +553,17 @@ public boolean isNearOf(MinecartMember member) {
}
return true;
}
public List<net.minecraft.server.Entity> getNearbyEntities(double radius) {
public List<Entity> getNearbyEntities(double radius) {
return this.getNearbyEntities(radius, radius, radius);
}
@SuppressWarnings("unchecked")
public List<net.minecraft.server.Entity> getNearbyEntities(double x, double y, double z) {
public List<Entity> getNearbyEntities(double x, double y, double z) {
return this.world.getEntities(this, this.boundingBox.grow(x, y, z));
}
public Vector getOffset(IntVector3 to) {
return new Vector(to.x - this.getX(), to.y - this.getY(), to.z - this.getZ());
}
public Vector getOffset(Entity to) {
public Vector getOffset(org.bukkit.entity.Entity to) {
return getOffset(to.getLocation());
}
public Vector getOffset(MinecartMember to) {
Expand Down Expand Up @@ -682,10 +681,10 @@ public boolean hasMoved() {
public boolean isTurned() {
return FaceUtil.isSubCardinal(this.direction);
}
public boolean isHeadingTo(net.minecraft.server.Entity entity) {
public boolean isHeadingTo(Entity entity) {
return this.isHeadingTo(entity.getBukkitEntity());
}
public boolean isHeadingTo(Entity entity) {
public boolean isHeadingTo(org.bukkit.entity.Entity entity) {
return this.isHeadingTo(entity.getLocation());
}
public boolean isHeadingTo(IntVector3 location) {
Expand Down Expand Up @@ -771,17 +770,17 @@ public boolean isSingle() {
public boolean hasPassenger() {
return this.passenger != null;
}
public Entity getPassenger() {
public org.bukkit.entity.Entity getPassenger() {
return this.passenger == null ? null : this.passenger.getBukkitEntity();
}
public Inventory getInventory() {
return new CraftInventory(this);
}
public Inventory getPlayerInventory() {
public org.bukkit.inventory.PlayerInventory getPlayerInventory() {
if (this.hasPlayerPassenger()) {
return new CraftInventoryPlayer(((EntityPlayer) this.passenger).inventory);
} else {
return new CraftInventory(new IInventoryMerged(new IInventory[0]));
return new CraftInventoryPlayer(new PlayerInventory(null));
}
}
public boolean hasPlayerPassenger() {
Expand Down Expand Up @@ -834,10 +833,10 @@ public boolean hasItems() {
/*
* Actions
*/
public void pushSideways(Entity entity) {
public void pushSideways(org.bukkit.entity.Entity entity) {
this.pushSideways(entity, TrainCarts.pushAwayForce);
}
public void pushSideways(Entity entity, double force) {
public void pushSideways(org.bukkit.entity.Entity entity, double force) {
float yaw = FaceUtil.faceToYaw(this.direction);
float lookat = MathUtil.getLookAtYaw(this.getBukkitEntity(), entity) - yaw;
lookat = MathUtil.wrapAngle(lookat);
Expand All @@ -847,7 +846,7 @@ public void pushSideways(Entity entity, double force) {
Vector vel = MathUtil.getDirection(yaw, 0).multiply(force);
entity.setVelocity(vel);
}
public void push(Entity entity, double force) {
public void push(org.bukkit.entity.Entity entity, double force) {
Vector offset = this.getOffset(entity);
MathUtil.setVectorLength(offset, force);
entity.setVelocity(entity.getVelocity().add(offset));
Expand Down Expand Up @@ -896,10 +895,10 @@ public boolean isTeleportImmune() {
return this.teleportImmunityTick > 0;
}

public boolean isCollisionIgnored(Entity entity) {
public boolean isCollisionIgnored(org.bukkit.entity.Entity entity) {
return isCollisionIgnored(NativeUtil.getNative(entity));
}
public boolean isCollisionIgnored(net.minecraft.server.Entity entity) {
public boolean isCollisionIgnored(Entity entity) {
if (entity instanceof MinecartMember) {
return this.isCollisionIgnored((MinecartMember) entity);
}
Expand All @@ -911,18 +910,18 @@ public boolean isCollisionIgnored(MinecartMember member) {
return this.collisionIgnoreTimes.containsKey(member.uniqueId) ||
member.collisionIgnoreTimes.containsKey(this.uniqueId);
}
public void ignoreCollision(Entity entity, int ticktime) {
public void ignoreCollision(org.bukkit.entity.Entity entity, int ticktime) {
this.ignoreCollision(NativeUtil.getNative(entity), ticktime);
}
public void ignoreCollision(net.minecraft.server.Entity entity, int ticktime) {
public void ignoreCollision(Entity entity, int ticktime) {
collisionIgnoreTimes.put(entity.uniqueId, new AtomicInteger(ticktime));
}
public void eject() {
this.getMinecart().eject();
}
public void eject(final Location to) {
if (this.passenger != null) {
final Entity passenger = this.passenger.getBukkitEntity();
final org.bukkit.entity.Entity passenger = this.passenger.getBukkitEntity();
this.passenger.setPassengerOf(null);
CommonUtil.nextTick(new Runnable() {
public void run() {
Expand All @@ -935,7 +934,7 @@ public boolean connect(MinecartMember with) {
return this.getGroup().connect(this, with);
}

public void setItem(int index, net.minecraft.server.ItemStack item) {
public void setItem(int index, ItemStack item) {
super.setItem(index, item);
this.update();
}
Expand Down
Expand Up @@ -23,10 +23,10 @@
import com.bergerkiller.bukkit.tc.events.MemberConvertEvent;
import com.bergerkiller.bukkit.tc.storage.OfflineGroupManager;

import net.minecraft.server.Entity;
import net.minecraft.server.EntityMinecart;
import net.minecraft.server.EntityTrackerEntry;
import net.minecraft.server.World;
import net.minecraft.server.v1_4_5.Entity;
import net.minecraft.server.v1_4_5.EntityMinecart;
import net.minecraft.server.v1_4_5.EntityTrackerEntry;
import net.minecraft.server.v1_4_5.World;

public abstract class MinecartMemberStore extends NativeMinecartMember {

Expand Down
Expand Up @@ -11,7 +11,7 @@
import com.bergerkiller.bukkit.common.utils.MathUtil;
import com.bergerkiller.bukkit.tc.TrainCarts;

import net.minecraft.server.*;
import net.minecraft.server.v1_4_5.*;

@SuppressWarnings({"unchecked", "rawtypes"})
public class MinecartMemberTrackerEntry extends EntityTrackerEntry {
Expand Down

0 comments on commit b420a99

Please sign in to comment.