Replace buffer.flip
This commit is contained in:
parent
11f28fef53
commit
cd3798a1e2
|
@ -2,12 +2,36 @@ package net.PeytonPlayz585;
|
||||||
|
|
||||||
public class Location {
|
public class Location {
|
||||||
|
|
||||||
public int x,y,z;
|
private double x,y,z;
|
||||||
|
|
||||||
public Location(int x, int y, int z) {
|
public Location(int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location(double x, double y, double z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location(float x, float y, float z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getX() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getY() {
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getZ() {
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,36 @@
|
||||||
package net.PeytonPlayz585;
|
package net.PeytonPlayz585;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.PeytonPlayzt585.entity.CreatureType;
|
import net.PeytonPlayzt585.entity.CreatureType;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.src.Block;
|
import net.minecraft.src.Block;
|
||||||
import net.minecraft.src.Chunk;
|
import net.minecraft.src.Chunk;
|
||||||
import net.minecraft.src.Entity;
|
import net.minecraft.src.Entity;
|
||||||
|
import net.minecraft.src.EntityLiving;
|
||||||
|
import net.minecraft.src.EntityPlayer;
|
||||||
import net.minecraft.src.IProgressUpdate;
|
import net.minecraft.src.IProgressUpdate;
|
||||||
import net.minecraft.src.WorldProvider;
|
import net.minecraft.src.WorldProvider;
|
||||||
|
|
||||||
public class World {
|
public class World {
|
||||||
|
|
||||||
public static Block getBlockAt(int var1, int var2, int var3) {
|
public static Block getBlockAt(Location location) {
|
||||||
return Block.blocksList[MinecraftServer.worldMngr.getBlockId(var1, var2, var3)];
|
return Block.blocksList[MinecraftServer.worldMngr.getBlockId((int)location.getX(), (int)location.getY(), (int)location.getZ())];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk getChunkFromBlockCoords(int var1, int var2) {
|
public static Chunk getChunkFromBlockCoords(Location location) {
|
||||||
return MinecraftServer.worldMngr.getChunkFromBlockCoords(var1, var2);
|
return MinecraftServer.worldMngr.getChunkFromBlockCoords((int)location.getX(), (int)location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk getChunkFromChunkCoords(int var1, int var2) {
|
public static Chunk getChunkFromChunkCoords(Location location) {
|
||||||
return MinecraftServer.worldMngr.getChunkFromChunkCoords(var1, var2);
|
return MinecraftServer.worldMngr.getChunkFromChunkCoords((int)location.getX(), (int)location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChunkLoaded(int var1, int var2) {
|
public static boolean isChunkLoaded(Location location) {
|
||||||
Chunk chunk = getChunkFromChunkCoords(var1, var2);
|
Chunk chunk = getChunkFromChunkCoords(location);
|
||||||
if(chunk == null) {
|
if(chunk == null) {
|
||||||
chunk = getChunkFromBlockCoords(var1, var2);
|
chunk = getChunkFromBlockCoords(location);
|
||||||
|
|
||||||
if(chunk == null) {
|
if(chunk == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -34,30 +39,42 @@ public class World {
|
||||||
return chunk.func_347_a();
|
return chunk.func_347_a();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean loadChunk(int x, int y, boolean var1) {
|
public static boolean loadChunk(Location location, boolean var1) {
|
||||||
Chunk chunk = MinecraftServer.worldMngr.A.loadChunk(x, y);
|
Chunk chunk = MinecraftServer.worldMngr.A.loadChunk((int)location.getX(), (int)location.getZ());
|
||||||
if(chunk == null) {
|
if(chunk == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spawnCreature(CreatureType type, double x, double y, double z) {
|
public static void spawnCreature(CreatureType type, Location location) {
|
||||||
Entity entity = type.nameToEntity(type.name());
|
Entity entity = type.nameToEntity(type.name());
|
||||||
entity.func_107_c(x, y, z, MinecraftServer.worldMngr.rand.nextFloat() * 360.0F, 0.0F);
|
entity.func_107_c(location.getX(), location.getY(), location.getZ(), MinecraftServer.worldMngr.rand.nextFloat() * 360.0F, 0.0F);
|
||||||
MinecraftServer.worldMngr.entityJoinedWorld(entity);
|
MinecraftServer.worldMngr.entityJoinedWorld(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spawnCreature(CreatureType type, float x, float y, float z) {
|
public static List<Entity> getEntities() {
|
||||||
Entity entity = type.nameToEntity(type.name());
|
List<Entity> list = new ArrayList<Entity>();
|
||||||
entity.func_107_c(x, y, z, MinecraftServer.worldMngr.rand.nextFloat() * 360.0F, 0.0F);
|
for(int i = 0; i > MinecraftServer.worldMngr.field_815_a.size(); i++) {
|
||||||
MinecraftServer.worldMngr.entityJoinedWorld(entity);
|
Entity entity = (Entity)MinecraftServer.worldMngr.field_815_a.get(i);
|
||||||
|
if(entity != null) {
|
||||||
|
list.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spawnCreature(CreatureType type, int x, int y, int z) {
|
public static List<EntityLiving> getLivingEntities() {
|
||||||
Entity entity = type.nameToEntity(type.name());
|
List<EntityLiving> list = new ArrayList<EntityLiving>();
|
||||||
entity.func_107_c(x, y, z, MinecraftServer.worldMngr.rand.nextFloat() * 360.0F, 0.0F);
|
for(int i = 0; i > MinecraftServer.worldMngr.field_815_a.size(); i++) {
|
||||||
MinecraftServer.worldMngr.entityJoinedWorld(entity);
|
Entity entity = (Entity)MinecraftServer.worldMngr.field_815_a.get(i);
|
||||||
|
if(entity != null) {
|
||||||
|
if(entity instanceof EntityLiving) {
|
||||||
|
list.add((EntityLiving)entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getSpawnLocation() {
|
public static Location getSpawnLocation() {
|
||||||
|
@ -67,10 +84,10 @@ public class World {
|
||||||
return new Location(x, y, z);
|
return new Location(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSpawnLocation(int x, int y, int z) {
|
public static void setSpawnLocation(Location location) {
|
||||||
MinecraftServer.worldMngr.spawnX = x;
|
MinecraftServer.worldMngr.spawnX = (int) location.getX();
|
||||||
MinecraftServer.worldMngr.spawnY = y;
|
MinecraftServer.worldMngr.spawnY = (int) location.getY();
|
||||||
MinecraftServer.worldMngr.spawnZ = z;
|
MinecraftServer.worldMngr.spawnZ = (int) location.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getWorldTime() {
|
public static long getWorldTime() {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.PeytonPlayz585.events.chunk;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface ChunkLoadEvent {
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package net.PeytonPlayz585.events.chunk;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface ChunkUnloadEvent {
|
||||||
|
|
||||||
|
}
|
|
@ -180,7 +180,8 @@ public class NetworkManager {
|
||||||
ByteBuffer stream = ByteBuffer.allocate(cap);
|
ByteBuffer stream = ByteBuffer.allocate(cap);
|
||||||
|
|
||||||
stream.put(b);
|
stream.put(b);
|
||||||
stream.flip();
|
stream.limit(stream.position());
|
||||||
|
stream.rewind();
|
||||||
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
|
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
|
||||||
while(stream.hasRemaining()) {
|
while(stream.hasRemaining()) {
|
||||||
stream.mark();
|
stream.mark();
|
||||||
|
@ -274,6 +275,10 @@ public class NetworkManager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isConnectionOpen() && !this.isTerminating) {
|
||||||
|
this.networkShutdown("Lost connection!");
|
||||||
|
}
|
||||||
|
|
||||||
if(this.isTerminating && this.readPackets.isEmpty()) {
|
if(this.isTerminating && this.readPackets.isEmpty()) {
|
||||||
this.netHandler.handleErrorMessage(this.terminationReason);
|
this.netHandler.handleErrorMessage(this.terminationReason);
|
||||||
|
@ -310,6 +315,10 @@ public class NetworkManager {
|
||||||
static void sendNetworkPacket(NetworkManager var0) {
|
static void sendNetworkPacket(NetworkManager var0) {
|
||||||
var0.sendPacket();
|
var0.sendPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isConnectionOpen() {
|
||||||
|
return networkSocket.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
static Thread getReadThread(NetworkManager var0) {
|
static Thread getReadThread(NetworkManager var0) {
|
||||||
return var0.readThread;
|
return var0.readThread;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user