mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-19 19:59:37 +00:00
Can now teleport to the center of a chunkloaded area, with more or less reliability :p
This commit is contained in:
1 parent
2f6056bce4
commit
f1a79738f7
2 files changed
+48
-16
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.opis.data;
|
||||
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
@@ -15,20 +16,44 @@ public class EntityManager {
|
||||
int maxOffset = 16;
|
||||
boolean targetFound = false;
|
||||
|
||||
for (int xoffset = 0; xoffset <= maxOffset; xoffset++){
|
||||
for (int zoffset = 0; zoffset <= maxOffset; zoffset++){
|
||||
if (world.isAirBlock(coord.x + xoffset, coord.y, coord.z + zoffset) && world.isAirBlock(coord.x + xoffset, coord.y + 1, coord.z + zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x + xoffset, coord.y, coord.z + zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x - xoffset, coord.y, coord.z + zoffset) && world.isAirBlock(coord.x - xoffset, coord.y + 1, coord.z + zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x - xoffset, coord.y, coord.z + zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x + xoffset, coord.y, coord.z - zoffset) && world.isAirBlock(coord.x + xoffset, coord.y + 1, coord.z - zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x + xoffset, coord.y, coord.z - zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x - xoffset, coord.y, coord.z - zoffset) && world.isAirBlock(coord.x - xoffset, coord.y + 1, coord.z - zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x - xoffset, coord.y, coord.z - zoffset);
|
||||
if (coord.y > 0){
|
||||
for (int xoffset = 0; xoffset <= maxOffset; xoffset++){
|
||||
for (int zoffset = 0; zoffset <= maxOffset; zoffset++){
|
||||
if (world.isAirBlock(coord.x + xoffset, coord.y, coord.z + zoffset) && world.isAirBlock(coord.x + xoffset, coord.y + 1, coord.z + zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x + xoffset, coord.y, coord.z + zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x - xoffset, coord.y, coord.z + zoffset) && world.isAirBlock(coord.x - xoffset, coord.y + 1, coord.z + zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x - xoffset, coord.y, coord.z + zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x + xoffset, coord.y, coord.z - zoffset) && world.isAirBlock(coord.x + xoffset, coord.y + 1, coord.z - zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x + xoffset, coord.y, coord.z - zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x - xoffset, coord.y, coord.z - zoffset) && world.isAirBlock(coord.x - xoffset, coord.y + 1, coord.z - zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x - xoffset, coord.y, coord.z - zoffset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int y = 256;
|
||||
while (world.isAirBlock(coord.x, y, coord.z) ||
|
||||
world.getBlockId(coord.x, y, coord.z) == Block.vine.blockID
|
||||
)
|
||||
y--;
|
||||
|
||||
for (int xoffset = 0; xoffset <= maxOffset; xoffset++){
|
||||
for (int zoffset = 0; zoffset <= maxOffset; zoffset++){
|
||||
if (world.isAirBlock(coord.x + xoffset, y, coord.z + zoffset) && world.isAirBlock(coord.x + xoffset, y + 1, coord.z + zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x + xoffset, y, coord.z + zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x - xoffset, y, coord.z + zoffset) && world.isAirBlock(coord.x - xoffset, y + 1, coord.z + zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x - xoffset, y, coord.z + zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x + xoffset, y, coord.z - zoffset) && world.isAirBlock(coord.x + xoffset, y + 1, coord.z - zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x + xoffset, y, coord.z - zoffset);
|
||||
|
||||
if (world.isAirBlock(coord.x - xoffset, y, coord.z - zoffset) && world.isAirBlock(coord.x - xoffset, y + 1, coord.z - zoffset))
|
||||
return new CoordinatesBlock(coord.dim, coord.x - xoffset, y, coord.z - zoffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -13,6 +13,7 @@ import mapwriter.api.IMwDataProvider;
|
||||
import mapwriter.map.MapView;
|
||||
import mapwriter.map.mapmode.MapMode;
|
||||
import mcp.mobius.opis.data.ChunkManager;
|
||||
import mcp.mobius.opis.data.holders.CoordinatesBlock;
|
||||
import mcp.mobius.opis.data.holders.CoordinatesChunk;
|
||||
import mcp.mobius.opis.data.holders.TicketData;
|
||||
import mcp.mobius.opis.gui.events.MouseEvent;
|
||||
@@ -25,6 +26,7 @@ import mcp.mobius.opis.gui.widgets.ViewTable;
|
||||
import mcp.mobius.opis.gui.widgets.WidgetGeometry;
|
||||
import mcp.mobius.opis.network.Packet_ReqChunks;
|
||||
import mcp.mobius.opis.network.Packet_ReqChunksInDim;
|
||||
import mcp.mobius.opis.network.Packet_ReqTeleport;
|
||||
import mcp.mobius.opis.network.Packet_ReqTickets;
|
||||
import mcp.mobius.opis.network.Packet_UnregisterPlayer;
|
||||
|
||||
@@ -48,8 +50,13 @@ public class OverlayLoadedChunks implements IMwDataProvider {
|
||||
Row row = this.getRow(event.x, event.y);
|
||||
if (row != null){
|
||||
CoordinatesChunk coord = ((TicketData)row.getObject()).coord;
|
||||
this.mapView.setDimension(coord.dim);
|
||||
this.mapView.setViewCentre(coord.x, coord.z);
|
||||
|
||||
if (this.mapView.getX() != coord.x || this.mapView.getZ() != coord.z || this.mapView.getDimension() != coord.dim){
|
||||
this.mapView.setDimension(coord.dim);
|
||||
this.mapView.setViewCentre(coord.x, coord.z);
|
||||
} else {
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqTeleport.create(new CoordinatesBlock(coord)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,7 +148,7 @@ public class OverlayLoadedChunks implements IMwDataProvider {
|
||||
}
|
||||
|
||||
if (chunks.size() > 0)
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqChunks.create(dim, chunks));
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqChunks.create(dim, chunks));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user