Package com.bergerkiller.bukkit.common.bases

Examples of com.bergerkiller.bukkit.common.bases.IntVector3


    }
  }

  @Override
  public boolean isOnRails(Block railsBlock) {
    return blockSpace.containsKey(new IntVector3(railsBlock));
  }
View Full Code Here


        int k;
        // Go member by member, starting at the tail, ending at the head
        for (int i = 0; i < owner.size() - 1; i++) {
          MinecartMember<?> member = owner.get(i);
          MinecartMember<?> toMember = owner.get(i + 1);
          IntVector3 from = member.getBlockPos();
          IntVector3 to = toMember.getBlockPos();
          IntVector3 diff = to.subtract(from);

          // Map the member to blocks in between, except 'to'
          blockSpace.put(from, member);
          if (!member.isOnSlope()) {
            if (diff.x == 0 && diff.z == 0) {
              // Along y-axis
              for (k = 1; k < diff.y; k++) {
                blockSpace.put(from.add(0, k, 0), member);
              }
              for (k = -1; k > diff.y; k--) {
                blockSpace.put(from.add(0, k, 0), member);
              }
              continue;
            } else if (diff.y == 0 && diff.x == 0) {
              // Along z-axis
              for (k = 1; k < diff.z; k++) {
                blockSpace.put(from.add(0, 0, k), member);
              }
              for (k = -1; k > diff.z; k--) {
                blockSpace.put(from.add(0, 0, k), member);
              }
              continue;
            } else if (diff.y == 0 && diff.z == 0) {
              // Along x-axis
              for (k = 1; k < diff.x; k++) {
                blockSpace.put(from.add(k, 0, 0), member);
              }
              for (k = -1; k > diff.x; k--) {
                blockSpace.put(from.add(k, 0, 0), member);
              }
              continue;
            }
          }
          // Curve or other logic - use a Block Iterator for this
          TrackIterator iter = toMember.getRailTracker().getTrackIterator();
          if (iter.hasNext()) {
            // Skip the first block
            iter.next();

            // Go and find the other blocks
            final int maxLength = Math.abs(diff.x) + Math.abs(diff.y) + Math.abs(diff.z);
            for (k = 0; k < maxLength && iter.hasNext(); k++) {
              final Block block = iter.next();
              if (from.x == block.getX() && from.y == block.getY() && from.z == block.getZ()) {
                // Found the end block
                break;
              }
              // Put the member
              blockSpace.put(new IntVector3(block), member);
            }
          }
        }
        blockSpace.put(owner.tail().getBlockPos(), owner.tail());
      }

      // First clear the live active sign buffer of all members
      for (MinecartMember<?> member : owner) {
        member.getBlockTracker().liveActiveSigns.clear();
      }

      // Add all active signs to the block tracker of all members
      World world = owner.getWorld();
      for (Entry<IntVector3, MinecartMember<?>> entry : blockSpace.entrySet()) {
        IntVector3 pos = entry.getKey();
        for (RailType type : RailType.values()) {
          if (type.isRail(world, pos.x, pos.y, pos.z)) {
            Block block = pos.toBlock(world);
            List<Block> signs = entry.getValue().getBlockTracker().liveActiveSigns;
            Util.addSignsFromRails(signs, block, type.getSignColumnDirection(block));
          }
        }
      }
View Full Code Here

  }

  @Override
  public void onPostMove(MinecartMember<?> member) {
    final CommonMinecart<?> entity = member.getEntity();
    final IntVector3 block = member.getBlockPos();

    // First: check whether the Minecart is moving up this slope
    // If moving down, simply use the Sloped logic in the underlying super Class
    if (member.getDirectionTo() == this.getDirection().getOppositeFace()) {
      super.onPostMove(member);
      return;
    }

    double factor = 0.0;
    if (this.alongZ) {
      factor = this.getDirection().getModZ() * (block.midZ() - entity.loc.getZ());
    } else if (this.alongX) {
      factor = this.getDirection().getModX() * (block.midX() - entity.loc.getX());
    }
    double posYAdd = (0.5 - MathUtil.clamp(factor, 0.0, 0.5)) * 2.0;
    entity.loc.y.set(block.y + posYAdd);
    if (posYAdd >= 1.0) {
      // Go to the vertical rail
      entity.loc.y.add(1.0);
      entity.loc.x.set(block.midX());
      entity.loc.z.set(block.midZ());
      // Turn velocity to the vertical type
      entity.vel.y.set(entity.vel.xz.length());
      entity.vel.xz.setZero();
    }
  }
View Full Code Here

      handleLeave(mm, from);
    } else {
      List<DetectorRegion> list = regions.get(from);
      //Leave the regions if the to-location is not contained
      if (list != null) {
        IntVector3 toCoords = new IntVector3(to);
        for (DetectorRegion region : list) {
          if (!region.coordinates.contains(toCoords)) {
            region.remove(mm);
          }
        }
View Full Code Here

      if (world == null) {
        world = b.getWorld();
      } else if (world != b.getWorld()) {
        continue;
      }
      coords.add(new IntVector3(b));
    }
    return create(world, coords);
  }
View Full Code Here

  public DetectorSign sign1, sign2;
  public DetectorRegion region;

  public static DetectorSignPair read(DataInputStream stream) throws IOException {
    IntVector3 sign1 = IntVector3.read(stream);
    IntVector3 sign2 = IntVector3.read(stream);
    DetectorSignPair detector = new DetectorSignPair(sign1, sign2);
    detector.sign1.wasDown = stream.readBoolean();
    detector.sign2.wasDown = stream.readBoolean();
    return detector;
  }
View Full Code Here

import com.bergerkiller.bukkit.tc.storage.OfflineSign;

public class DetectorSign extends OfflineSign {

  public DetectorSign(DetectorSignPair detector, Block signBlock) {
    this(detector, new IntVector3(signBlock));
  }
View Full Code Here

  private String world;
  private World lastWorld;
  private Task task = null;

  public SpawnSign(Block block, long interval) {
    this(new IntVector3(block), block.getWorld().getName(), interval);
  }
View Full Code Here

    stream.writeLong(this.interval);
    stream.writeLong(this.getRemaining());
  }

  public static SpawnSign read(DataInputStream stream) throws IOException {
    IntVector3 coord = IntVector3.read(stream);
    String world = stream.readUTF();
    long interval = stream.readLong();
    SpawnSign sign = new SpawnSign(coord, world, interval);
    sign.lastSpawnTime = System.currentTimeMillis() - (interval - stream.readLong());
    return sign;
View Full Code Here

    empty.putValue("DeathTime", (short) 0);
    empty.putValue("AttackTime", (short) 0);
    empty.putListValues("Motion", velocity.getX(), velocity.getY(), velocity.getZ());
    setLocation(empty, WorldManager.getSpawnLocation(MyWorlds.getMainWorld()));
    final Object humanHandle = livingEntity.getHandle();
    IntVector3 coord = EntityHumanRef.spawnCoord.get(humanHandle);
    if (coord != null) {
      empty.putValue("SpawnWorld", EntityHumanRef.spawnWorld.get(humanHandle));
      empty.putValue("SpawnX", coord.x);
      empty.putValue("SpawnY", coord.y);
      empty.putValue("SpawnZ", coord.z);
View Full Code Here

TOP

Related Classes of com.bergerkiller.bukkit.common.bases.IntVector3

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.