private void verifyTileAt(CrystalNetworkTile te, WorldLocation loc) {
   UUID key = te.getUniqueID();
   WorldLocation prev = verifier.get(key);
   if (prev != null && !prev.equals(loc)) {
     te.getWorld().setBlockToAir(te.getX(), te.getY(), te.getZ());
     throw new InvalidLocationException(te, loc, prev);
   } else verifier.put(key, loc);
 }
示例#2
0
 public void writeToNBT(NBTTagCompound tag) {
   NBTTagList li = new NBTTagList();
   for (WorldLocation loc : data.keySet()) {
     NBTTagCompound data = new NBTTagCompound();
     loc.writeToNBT(data);
     li.appendTag(data);
   }
   tag.setTag("locs", li);
 }
 CrystalLink(WorldLocation l1, WorldLocation l2) {
   loc1 = l1;
   loc2 = l2;
   double dd = l1.getDistanceTo(l2);
   World world = l1.getWorld();
   for (int i = 0; i < dd; i++) {
     int x = MathHelper.floor_double(l1.xCoord + i * (l2.xCoord - l1.xCoord) / dd);
     int z = MathHelper.floor_double(l1.zCoord + i * (l2.zCoord - l1.zCoord) / dd);
     WorldChunk ch = new WorldChunk(world, new ChunkCoordIntPair(x >> 4, z >> 4));
     if (!chunks.contains(ch)) chunks.add(ch);
   }
 }
示例#4
0
 public void readFromNBT(NBTTagCompound tag) {
   NBTTagList li = tag.getTagList("locs", NBTTypes.COMPOUND.ID);
   for (Object o : li.tagList) {
     NBTTagCompound entry = (NBTTagCompound) o;
     WorldLocation src = WorldLocation.readFromNBT(entry);
     NBTTagList map = tag.getTagList("map", NBTTypes.COMPOUND.ID);
     for (Object o2 : li.tagList) {
       NBTTagCompound nbt = (NBTTagCompound) o2;
       WorldLocation tg = WorldLocation.readFromNBT(nbt);
       this.addLink(src, tg);
     }
   }
 }
示例#5
0
 public void readFromNBT(NBTTagCompound tag) {
   NBTTagList li = tag.getTagList("locs", NBTTypes.COMPOUND.ID);
   for (Object o : li.tagList) {
     NBTTagCompound data = (NBTTagCompound) o;
     WorldLocation loc = WorldLocation.readFromNBT(data);
     TileEntity te = loc.getTileEntity();
     try {
       V v = (V) te;
       this.data.put(loc, v);
     } catch (ClassCastException e) { // ugly, but no other way to test if te instanceof V
       ReikaJavaLibrary.pConsole("Tried to load a TileEntityCache from invalid NBT!");
     }
   }
 }
 public Collection<TileEntityCrystalPylon> getNearbyPylons(
     World world, int x, int y, int z, CrystalElement e, int range, boolean LOS) {
   TileEntityCache<TileEntityCrystalPylon> c = pylons.get(e);
   Collection<TileEntityCrystalPylon> li = new ArrayList();
   if (c != null) {
     for (WorldLocation loc : c.keySet()) {
       if (loc.dimensionID == world.provider.dimensionId && loc.getDistanceTo(x, y, z) <= range) {
         if (!LOS || PylonFinder.lineOfSight(world, x, y, z, loc.xCoord, loc.yCoord, loc.zCoord)) {
           li.add(c.get(loc));
         }
       }
     }
   }
   return li;
 }
 public Collection<TileEntityCrystalPylon> getAllNearbyPylons(
     World world, int x, int y, int z, double range) {
   Collection<TileEntityCrystalPylon> li = new ArrayList();
   for (CrystalElement e : pylons.keySet()) {
     TileEntityCache<TileEntityCrystalPylon> c = pylons.get(e);
     if (c != null) {
       for (WorldLocation loc : c.keySet()) {
         if (loc.dimensionID == world.provider.dimensionId
             && loc.getDistanceTo(x, y, z) <= range) {
           li.add(c.get(loc));
         }
       }
     }
   }
   return li;
 }
示例#8
0
 private void connect(WorldLocation src, WorldLocation tg) {
   HashMap<WorldLocation, Double> c = data.get(src);
   if (c == null) {
     c = new HashMap();
     data.put(src, c);
   }
   c.put(tg, tg.getDistanceTo(src));
 }
示例#9
0
 public void writeToNBT(NBTTagCompound tag) {
   NBTTagList li = new NBTTagList();
   for (WorldLocation src : data.keySet()) {
     NBTTagCompound entry = new NBTTagCompound();
     src.writeToNBT(entry);
     NBTTagList map = new NBTTagList();
     HashMap<WorldLocation, Double> dat = data.get(src);
     for (WorldLocation tg : dat.keySet()) {
       NBTTagCompound nbt = new NBTTagCompound();
       tg.writeToNBT(nbt);
       map.appendTag(nbt);
     }
     entry.setTag("map", map);
     li.appendTag(entry);
   }
   tag.setTag("locs", li);
 }
 @Override
 public String toString() {
   StringBuilder sb = new StringBuilder();
   sb.append(controller.toString());
   sb.append(" ");
   sb.append(controls);
   return sb.toString();
 }
 public void readFromNBT(NBTTagCompound NBT) {
   controls.readFromNBT(NBT);
   controller = WorldLocation.readFromNBT("control", NBT);
   maxX = NBT.getInteger("maxx");
   maxY = NBT.getInteger("maxy");
   maxZ = NBT.getInteger("maxz");
   minX = NBT.getInteger("minx");
   minY = NBT.getInteger("miny");
   minZ = NBT.getInteger("minz");
 }
 public void writeToNBT(NBTTagCompound NBT) {
   controls.writeToNBT(NBT);
   controller.writeToNBT("control", NBT);
   NBT.setInteger("maxx", maxX);
   NBT.setInteger("maxy", maxY);
   NBT.setInteger("maxz", maxZ);
   NBT.setInteger("minx", minX);
   NBT.setInteger("miny", minY);
   NBT.setInteger("minz", minZ);
 }
 @SideOnly(Side.CLIENT)
 public int getDisplayColorAtRelativePosition(World world, int x, int y, int z) {
   TileEntityControlRod rod = this.getControlRodAtRelativePosition(world, x, y, z);
   if (rod != null) {
     if (((TileEntityCPU) controller.getTileEntity()).getPower() >= this.getMinPower())
       return rod.isActive() ? 0x00ff00 : 0xff0000;
     else return 0xa0a0a0;
   }
   return 0x6a6a6a;
 }
 @Override
 public final int hashCode() {
   return loc1.hashCode() ^ loc2.hashCode();
 }