Compare commits
7 Commits
11f28fef53
...
9d5a1e7d1b
Author | SHA1 | Date | |
---|---|---|---|
|
9d5a1e7d1b | ||
|
cd3798a1e2 | ||
|
ef193f1f72 | ||
|
3d36cfc586 | ||
|
0391d3dc15 | ||
|
9cef1d2e40 | ||
|
c4939efe6a |
14
README.md
14
README.md
|
@ -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.
|
||||
|
||||
# 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
|
||||
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.
|
||||
|
|
|
@ -2,12 +2,36 @@ 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;
|
||||
this.y = y;
|
||||
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;
|
||||
|
||||
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() {
|
||||
|
|
|
@ -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);
|
||||
|
||||
stream.put(b);
|
||||
stream.flip();
|
||||
stream.limit(stream.position());
|
||||
stream.rewind();
|
||||
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
|
||||
while(stream.hasRemaining()) {
|
||||
stream.mark();
|
||||
|
@ -274,6 +275,10 @@ public class NetworkManager {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isConnectionOpen() && !this.isTerminating) {
|
||||
this.networkShutdown("Lost connection!");
|
||||
}
|
||||
|
||||
if(this.isTerminating && this.readPackets.isEmpty()) {
|
||||
this.netHandler.handleErrorMessage(this.terminationReason);
|
||||
|
@ -310,6 +315,10 @@ public class NetworkManager {
|
|||
static void sendNetworkPacket(NetworkManager var0) {
|
||||
var0.sendPacket();
|
||||
}
|
||||
|
||||
boolean isConnectionOpen() {
|
||||
return networkSocket.isConnected();
|
||||
}
|
||||
|
||||
static Thread getReadThread(NetworkManager var0) {
|
||||
return var0.readThread;
|
||||
|
|
Loading…
Reference in New Issue
Block a user