Replace buffer.flip

This commit is contained in:
PeytonPlayz595 2024-04-25 22:22:21 -04:00
parent 11f28fef53
commit cd3798a1e2
5 changed files with 100 additions and 27 deletions

View File

@ -2,7 +2,7 @@ package net.PeytonPlayz585;
public class Location {
public int x,y,z;
private double x,y,z;
public Location(int x, int y, int z) {
this.x = x;
@ -10,4 +10,28 @@ public class Location {
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;
}
}

View File

@ -1,31 +1,36 @@
package net.PeytonPlayz585;
import java.util.ArrayList;
import java.util.List;
import net.PeytonPlayzt585.entity.CreatureType;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.Block;
import net.minecraft.src.Chunk;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IProgressUpdate;
import net.minecraft.src.WorldProvider;
public class World {
public static Block getBlockAt(int var1, int var2, int var3) {
return Block.blocksList[MinecraftServer.worldMngr.getBlockId(var1, var2, var3)];
public static Block getBlockAt(Location location) {
return Block.blocksList[MinecraftServer.worldMngr.getBlockId((int)location.getX(), (int)location.getY(), (int)location.getZ())];
}
public static Chunk getChunkFromBlockCoords(int var1, int var2) {
return MinecraftServer.worldMngr.getChunkFromBlockCoords(var1, var2);
public static Chunk getChunkFromBlockCoords(Location location) {
return MinecraftServer.worldMngr.getChunkFromBlockCoords((int)location.getX(), (int)location.getZ());
}
public static Chunk getChunkFromChunkCoords(int var1, int var2) {
return MinecraftServer.worldMngr.getChunkFromChunkCoords(var1, var2);
public static Chunk getChunkFromChunkCoords(Location location) {
return MinecraftServer.worldMngr.getChunkFromChunkCoords((int)location.getX(), (int)location.getZ());
}
public static boolean isChunkLoaded(int var1, int var2) {
Chunk chunk = getChunkFromChunkCoords(var1, var2);
public static boolean isChunkLoaded(Location location) {
Chunk chunk = getChunkFromChunkCoords(location);
if(chunk == null) {
chunk = getChunkFromBlockCoords(var1, var2);
chunk = getChunkFromBlockCoords(location);
if(chunk == null) {
return false;
@ -34,30 +39,42 @@ public class World {
return chunk.func_347_a();
}
public static boolean loadChunk(int x, int y, boolean var1) {
Chunk chunk = MinecraftServer.worldMngr.A.loadChunk(x, y);
public static boolean loadChunk(Location location, boolean var1) {
Chunk chunk = MinecraftServer.worldMngr.A.loadChunk((int)location.getX(), (int)location.getZ());
if(chunk == null) {
return false;
}
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.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);
}
public static void spawnCreature(CreatureType type, float x, float y, float z) {
Entity entity = type.nameToEntity(type.name());
entity.func_107_c(x, y, z, MinecraftServer.worldMngr.rand.nextFloat() * 360.0F, 0.0F);
MinecraftServer.worldMngr.entityJoinedWorld(entity);
public static List<Entity> getEntities() {
List<Entity> list = new ArrayList<Entity>();
for(int i = 0; i > MinecraftServer.worldMngr.field_815_a.size(); i++) {
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) {
Entity entity = type.nameToEntity(type.name());
entity.func_107_c(x, y, z, MinecraftServer.worldMngr.rand.nextFloat() * 360.0F, 0.0F);
MinecraftServer.worldMngr.entityJoinedWorld(entity);
public static List<EntityLiving> getLivingEntities() {
List<EntityLiving> list = new ArrayList<EntityLiving>();
for(int i = 0; i > MinecraftServer.worldMngr.field_815_a.size(); i++) {
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() {
@ -67,10 +84,10 @@ public class World {
return new Location(x, y, z);
}
public static void setSpawnLocation(int x, int y, int z) {
MinecraftServer.worldMngr.spawnX = x;
MinecraftServer.worldMngr.spawnY = y;
MinecraftServer.worldMngr.spawnZ = z;
public static void setSpawnLocation(Location location) {
MinecraftServer.worldMngr.spawnX = (int) location.getX();
MinecraftServer.worldMngr.spawnY = (int) location.getY();
MinecraftServer.worldMngr.spawnZ = (int) location.getZ();
}
public static long getWorldTime() {

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -180,7 +180,8 @@ public class NetworkManager {
ByteBuffer stream = ByteBuffer.allocate(cap);
stream.put(b);
stream.flip();
stream.limit(stream.position());
stream.rewind();
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
while(stream.hasRemaining()) {
stream.mark();
@ -275,6 +276,10 @@ public class NetworkManager {
}
}
if(!isConnectionOpen() && !this.isTerminating) {
this.networkShutdown("Lost connection!");
}
if(this.isTerminating && this.readPackets.isEmpty()) {
this.netHandler.handleErrorMessage(this.terminationReason);
}
@ -311,6 +316,10 @@ public class NetworkManager {
var0.sendPacket();
}
boolean isConnectionOpen() {
return networkSocket.isConnected();
}
static Thread getReadThread(NetworkManager var0) {
return var0.readThread;
}