Compare commits

..

7 Commits

Author SHA1 Message Date
PeytonPlayz595
9d5a1e7d1b Merge branch 'main' of https://github.com/PeytonPlayz595/Alpha-v1.2.6 2024-04-25 22:22:33 -04:00
PeytonPlayz595
cd3798a1e2 Replace buffer.flip 2024-04-25 22:22:21 -04:00
PeytonPlayz595
ef193f1f72
Update README.md 2024-04-25 21:38:03 -04:00
PeytonPlayz595
3d36cfc586
Update README.md 2024-04-25 21:37:23 -04:00
PeytonPlayz595
0391d3dc15
Update README.md 2024-04-25 21:36:22 -04:00
PeytonPlayz595
9cef1d2e40
Update README.md 2024-04-25 21:35:16 -04:00
PeytonPlayz595
c4939efe6a
Update README.md 2024-04-25 21:34:16 -04:00
6 changed files with 111 additions and 30 deletions

View File

@ -21,11 +21,19 @@ The textures are compiled into `resources.mc` using [laxdude](https://github.com
As of right now there is no system to compile an offline download, so you will have to manually copy and paste the javascript from `web/js/app.js` into the HTML file, for the `resources.mc` just encode the file using [Base64](https://www.base64encode.org/) and paste it into the assets div. As of right now there is no system to compile an offline download, so you will have to manually copy and paste the javascript from `web/js/app.js` into the HTML file, for the `resources.mc` just encode the file using [Base64](https://www.base64encode.org/) and paste it into the assets div.
# Multiplayer # Multiplayer
Multiplayer has been successfully rewritten and thoroughly tested. It seems to be pretty stable but it had to be removed due to a glitch in Singleplayer's chunk loading, the issue lies within Alpha's multiplayer code somewhere and I am unable to pinpoint the exact cause of the issue so until I am able to figure it out, multiplayer will not be avalible. Steps to setup a multiplayer server:
If you are really impatient and cannot wait then go through the commit history and find commit 62af5c9 titled "oops" and download the offline download from there, **THIS VERSION IS BUGGED AND CHUNK LOADING IN SINGLEPLAYER IS EXTREMELY BROKEN, SOME (IF NOT MOST) CHUNKS MAY NOT EVEN SAVE AT ALL!** 1. Make sure have to have Java 8 (or higher) installed.
2. Download the [Alpha.jar](https://github.com/PeytonPlayz595/Alpha-v1.2.6/blob/main/minecraft_server/Alpha.jar)
3. Run the server by using `java -jar Alpha.jar`
4. Make sure to have the latest version of NodeJS installed
5. Download or clone my [ws-tcp-bridge repo](https://github.com/PeytonPlayz595/ws-tcp-bridge/) and extract it into a folder
6. CD into the folder of the extracted repo
7. Proxy the Minecraft server to WebSockets by running `node ws-tcp-bridge --websocket <WebSocket_Port> --minecraft localhost:<Minecraft_Port>`
If you do decide to use this version (not recommended) just download the Alpha v1.2.6 server software from web archive and use websockify to proxy it to websockets. Note: Replace "<WebSocket_Port>" with the port you want clients to use when connecting to the server, replace "<Minecraft_Port>" with the port you are hosting the Minecraft Server on.
WebSockify will probably work better but I'm not gonna write a guide for you, if you want to use it you're gonna have to figure it out yourself.
# Texture Packs # Texture Packs
This is pretty much self explanitory, just make sure that the texture pack has the same file structure as in `resources/`, and then add the files to a ZIP archive, if a texture pack does not work then most likely it is not for this version of Minecraft. You're probably gonna have to make your own texture pack because texture packs for Alpha are very rare these days. This is pretty much self explanitory, just make sure that the texture pack has the same file structure as in `resources/`, and then add the files to a ZIP archive, if a texture pack does not work then most likely it is not for this version of Minecraft. You're probably gonna have to make your own texture pack because texture packs for Alpha are very rare these days.

View File

@ -2,7 +2,7 @@ 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;
@ -10,4 +10,28 @@ public class Location {
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;
}
} }

View File

@ -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() {

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); 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();
@ -275,6 +276,10 @@ public class NetworkManager {
} }
} }
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);
} }
@ -311,6 +316,10 @@ public class NetworkManager {
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;
} }