@Override public void save(NBTTagCompound nbt) { NBTTagList nbtList = new NBTTagList(); for (IInterPoleWire c : connections) { NBTTagCompound tag = new NBTTagCompound(); c.save(tag); nbtList.appendTag(tag); } nbt.setTag("connect", nbtList); nbt.setInteger("mode", connectionsBlocked); }
@Override public void iterate() { if (update) { update = false; for (IInterPoleWire c : connections) { c.setWorld(getParent().getWorldObj()); } refreshList(); } if (parent.getWorldObj().isRemote) return; for (IInterPoleWire c : connections) { if (c.getStart() == this) { c.iterate(); } } }
@Override public boolean canConnectWire(int tier, IElectricPole to, boolean isManual) { if (to == this) return false; if (tier != 0) return false; VecDouble vec = new VecDouble(getParent()).add(new VecDouble(to.getParent()).getOpposite()); if (vec.mag() > 16) return false; for (IInterPoleWire i : connections) { if (i.vecStart().equals(new VecInt(getParent()))) { if (i.vecEnd().equals(new VecInt(to.getParent()))) { return false; } } } if (isManual && (connectionsBlocked >= 2)) { return false; } else if (!isManual && (connectionsBlocked >= 1)) { return false; } return (connections.size() <= 6); }
@Override public void disconnectAll() { update = true; ArrayList<IInterPoleWire> list = new ArrayList<IInterPoleWire>(); list.addAll(connections); for (IInterPoleWire con : list) { if (con.getWorld() == null) { if (parent == null) continue; con.setWorld(parent.getWorldObj()); } if (con.getStart() != null) con.getStart().onDisconnect(con); if (con.getEnd() != null) con.getEnd().onDisconnect(con); } }