mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-25 20:22:23 +00:00
Add dimension check for long-distance travel anchor teleport (#92)
* Add dimension check for long-distance travel anchor teleport * Update comment * Key on dimension ID instead of World object
This commit is contained in:
1 parent
4fdfc808ad
commit
378b32726b
3 files changed
+10
-10
No files matched your search
@@ -2,12 +2,10 @@ package crazypants.enderio.teleport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -37,6 +35,8 @@ import com.enderio.core.common.vecmath.Matrix4d;
|
||||
import com.enderio.core.common.vecmath.VecmathUtil;
|
||||
import com.enderio.core.common.vecmath.Vector2d;
|
||||
import com.enderio.core.common.vecmath.Vector3d;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -64,13 +64,13 @@ public class TravelController {
|
||||
public static final TravelController instance = new TravelController();
|
||||
|
||||
/**
|
||||
* Server-side only list of valid travel destinations (travel anchors and active telepads).
|
||||
* Server-side only set multimap of dimension ID to valid travel destinations (travel anchors and active telepads).
|
||||
*
|
||||
* <p>
|
||||
* This is used by {@code PacketLongDistanceTravelEvent} to try to find travel destinations that are out of client
|
||||
* render range.
|
||||
*/
|
||||
public Set<BlockCoord> travelDestinations = new HashSet<>();
|
||||
public SetMultimap<Integer, BlockCoord> travelDestinations = MultimapBuilder.hashKeys().hashSetValues().build();
|
||||
|
||||
private Random rand = new Random();
|
||||
|
||||
@@ -317,7 +317,7 @@ public class TravelController {
|
||||
// Otherwise, you could trigger the message for any travel anchor on the entire server.
|
||||
double maxMessageDistance = 1.25 * source.getMaxDistanceTravelled();
|
||||
boolean displayOutOfRangeMessage = false;
|
||||
for (BlockCoord p : travelDestinations) {
|
||||
for (BlockCoord p : travelDestinations.get(player.worldObj.provider.dimensionId)) {
|
||||
Vector3d block = new Vector3d(p.x + 0.5, p.y + 0.5, p.z + 0.5);
|
||||
block.sub(eye);
|
||||
double distance = block.length();
|
||||
|
||||
@@ -337,19 +337,19 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
public void validate() {
|
||||
super.validate();
|
||||
if (isTravelSource()) {
|
||||
TravelController.instance.travelDestinations.add(getLocation());
|
||||
TravelController.instance.travelDestinations.put(worldObj.provider.dimensionId, getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
TravelController.instance.travelDestinations.remove(getLocation());
|
||||
TravelController.instance.travelDestinations.remove(worldObj.provider.dimensionId, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
TravelController.instance.travelDestinations.remove(getLocation());
|
||||
TravelController.instance.travelDestinations.remove(worldObj.provider.dimensionId, getLocation());
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
}
|
||||
this.master = this;
|
||||
this.isMaster = true;
|
||||
TravelController.instance.travelDestinations.add(getLocation());
|
||||
TravelController.instance.travelDestinations.put(worldObj.provider.dimensionId, getLocation());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
telepad.updateNeighborTEs();
|
||||
}
|
||||
}
|
||||
TravelController.instance.travelDestinations.remove(getLocation());
|
||||
TravelController.instance.travelDestinations.remove(worldObj.provider.dimensionId, getLocation());
|
||||
}
|
||||
|
||||
private List<BlockCoord> getSurroundingCoords() {
|
||||
|
||||
Reference in new issue
Block a user