mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #34 - Add dynamic lights, fix vanilla world seeds
This commit is contained in:
@ -70,6 +70,8 @@ public class SingleplayerServerController implements ISaveFormat {
|
||||
public static final ClientIntegratedServerNetworkManager localPlayerNetworkManager = new ClientIntegratedServerNetworkManager(PLAYER_CHANNEL);
|
||||
private static final List<String> openLANChannels = new ArrayList();
|
||||
|
||||
private static final IPCPacketManager packetManagerInstance = new IPCPacketManager();
|
||||
|
||||
private SingleplayerServerController() {
|
||||
}
|
||||
|
||||
@ -247,7 +249,7 @@ public class SingleplayerServerController implements ISaveFormat {
|
||||
if(packetData.channel.equals(SingleplayerServerController.IPC_CHANNEL)) {
|
||||
IPCPacketBase ipc;
|
||||
try {
|
||||
ipc = IPCPacketManager.IPCDeserialize(packetData.contents);
|
||||
ipc = packetManagerInstance.IPCDeserialize(packetData.contents);
|
||||
}catch(IOException ex) {
|
||||
throw new RuntimeException("Failed to deserialize IPC packet", ex);
|
||||
}
|
||||
@ -402,7 +404,7 @@ public class SingleplayerServerController implements ISaveFormat {
|
||||
public static void sendIPCPacket(IPCPacketBase ipc) {
|
||||
byte[] pkt;
|
||||
try {
|
||||
pkt = IPCPacketManager.IPCSerialize(ipc);
|
||||
pkt = packetManagerInstance.IPCSerialize(ipc);
|
||||
}catch (IOException ex) {
|
||||
throw new RuntimeException("Failed to serialize IPC packet", ex);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
/**
|
||||
@ -38,6 +39,7 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
|
||||
private GuiButton worldConvert = null;
|
||||
private GuiButton worldBackup = null;
|
||||
private long worldSeed;
|
||||
private boolean oldRNG;
|
||||
private NBTTagCompound levelDat;
|
||||
|
||||
private String worldName;
|
||||
@ -47,6 +49,7 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
|
||||
this.worldName = worldName;
|
||||
this.levelDat = levelDat;
|
||||
this.worldSeed = levelDat.getCompoundTag("Data").getLong("RandomSeed");
|
||||
this.oldRNG = levelDat.getCompoundTag("Data").getInteger("eaglerVersionSerial") == 0;
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
@ -62,7 +65,11 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
|
||||
this.drawDefaultBackground();
|
||||
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.title", worldName), this.width / 2, this.height / 5 - 35, 16777215);
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.seed") + " " + worldSeed, this.width / 2, this.height / 5 + 62, 0xAAAAFF);
|
||||
if(oldRNG) {
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.seed") + " " + worldSeed + " " + EnumChatFormatting.RED + "(pre-u34)", this.width / 2, this.height / 5 + 62, 0xAAAAFF);
|
||||
}else {
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.seed") + " " + worldSeed, this.width / 2, this.height / 5 + 62, 0xAAAAFF);
|
||||
}
|
||||
|
||||
int toolTipColor = 0xDDDDAA;
|
||||
if(worldRecreate.isMouseOver()) {
|
||||
@ -85,8 +92,13 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
|
||||
this.mc.displayGuiScreen(selectWorld);
|
||||
}else if(par1GuiButton.id == 1) {
|
||||
GuiCreateWorld cw = new GuiCreateWorld(selectWorld);
|
||||
cw.func_146318_a(new WorldInfo(this.levelDat.getCompoundTag("Data")));
|
||||
this.mc.displayGuiScreen(cw);
|
||||
WorldInfo inf = new WorldInfo(this.levelDat.getCompoundTag("Data"));
|
||||
cw.func_146318_a(inf);
|
||||
if(inf.isOldEaglercraftRandom()) {
|
||||
this.mc.displayGuiScreen(new GuiScreenOldSeedWarning(cw));
|
||||
}else {
|
||||
this.mc.displayGuiScreen(cw);
|
||||
}
|
||||
}else if(par1GuiButton.id == 2) {
|
||||
this.mc.displayGuiScreen(new GuiRenameWorld(this.selectWorld, this.worldName, true));
|
||||
}else if(par1GuiButton.id == 3) {
|
||||
|
@ -0,0 +1,48 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.sp.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class GuiScreenOldSeedWarning extends GuiScreen {
|
||||
|
||||
private final GuiScreen cont;
|
||||
|
||||
public GuiScreenOldSeedWarning(GuiScreen cont) {
|
||||
this.cont = cont;
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 6 + 96, I18n.format("singleplayer.oldseedwarning.ok")));
|
||||
}
|
||||
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
this.drawDefaultBackground();
|
||||
this.drawCenteredString(fontRendererObj, I18n.format("singleplayer.oldseedwarning.title"), this.width / 2, 70, 11184810);
|
||||
this.drawCenteredString(fontRendererObj, I18n.format("singleplayer.oldseedwarning.msg1"), this.width / 2, 90, 16777215);
|
||||
this.drawCenteredString(fontRendererObj, I18n.format("singleplayer.oldseedwarning.msg2"), this.width / 2, 105, 16777215);
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id == 0) {
|
||||
this.mc.displayGuiScreen(cont);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,11 +25,11 @@ public class IPCPacketManager {
|
||||
|
||||
public static final HashMap<Integer, Supplier<IPCPacketBase>> mappings = new HashMap();
|
||||
|
||||
public static final IPCInputStream IPC_INPUT_STREAM = new IPCInputStream();
|
||||
public static final IPCOutputStream IPC_OUTPUT_STREAM = new IPCOutputStream();
|
||||
public final IPCInputStream IPC_INPUT_STREAM = new IPCInputStream();
|
||||
public final IPCOutputStream IPC_OUTPUT_STREAM = new IPCOutputStream();
|
||||
|
||||
public static final DataInputStream IPC_DATA_INPUT_STREAM = new DataInputStream(IPC_INPUT_STREAM);
|
||||
public static final DataOutputStream IPC_DATA_OUTPUT_STREAM = new DataOutputStream(IPC_OUTPUT_STREAM);
|
||||
public final DataInputStream IPC_DATA_INPUT_STREAM = new DataInputStream(IPC_INPUT_STREAM);
|
||||
public final DataOutputStream IPC_DATA_OUTPUT_STREAM = new DataOutputStream(IPC_OUTPUT_STREAM);
|
||||
|
||||
static {
|
||||
mappings.put(IPCPacket00StartServer.ID, IPCPacket00StartServer::new);
|
||||
@ -60,7 +60,7 @@ public class IPCPacketManager {
|
||||
mappings.put(IPCPacketFFProcessKeepAlive.ID, IPCPacketFFProcessKeepAlive::new);
|
||||
}
|
||||
|
||||
public static byte[] IPCSerialize(IPCPacketBase pkt) throws IOException {
|
||||
public byte[] IPCSerialize(IPCPacketBase pkt) throws IOException {
|
||||
|
||||
IPC_OUTPUT_STREAM.feedBuffer(new byte[pkt.size() + 1], pkt.getClass().getSimpleName());
|
||||
IPC_OUTPUT_STREAM.write(pkt.id());
|
||||
@ -69,7 +69,7 @@ public class IPCPacketManager {
|
||||
return IPC_OUTPUT_STREAM.returnBuffer();
|
||||
}
|
||||
|
||||
public static IPCPacketBase IPCDeserialize(byte[] pkt) throws IOException {
|
||||
public IPCPacketBase IPCDeserialize(byte[] pkt) throws IOException {
|
||||
|
||||
IPC_INPUT_STREAM.feedBuffer(pkt);
|
||||
int i = IPC_INPUT_STREAM.read();
|
||||
|
@ -60,6 +60,8 @@ public class EaglerIntegratedServerWorker {
|
||||
|
||||
private static final Map<String, IntegratedServerPlayerNetworkManager> openChannels = new HashMap();
|
||||
|
||||
private static final IPCPacketManager packetManagerInstance = new IPCPacketManager();
|
||||
|
||||
private static void processAsyncMessageQueue() {
|
||||
List<IPCPacketData> pktList = ServerPlatformSingleplayer.recieveAllPacket();
|
||||
if(pktList != null) {
|
||||
@ -69,7 +71,7 @@ public class EaglerIntegratedServerWorker {
|
||||
if(packetData.channel.equals(SingleplayerServerController.IPC_CHANNEL)) {
|
||||
IPCPacketBase ipc;
|
||||
try {
|
||||
ipc = IPCPacketManager.IPCDeserialize(packetData.contents);
|
||||
ipc = packetManagerInstance.IPCDeserialize(packetData.contents);
|
||||
}catch(IOException ex) {
|
||||
throw new RuntimeException("Failed to deserialize IPC packet", ex);
|
||||
}
|
||||
@ -422,7 +424,7 @@ public class EaglerIntegratedServerWorker {
|
||||
public static void sendIPCPacket(IPCPacketBase ipc) {
|
||||
byte[] pkt;
|
||||
try {
|
||||
pkt = IPCPacketManager.IPCSerialize(ipc);
|
||||
pkt = packetManagerInstance.IPCSerialize(ipc);
|
||||
}catch (IOException ex) {
|
||||
throw new RuntimeException("Failed to serialize IPC packet", ex);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerIntegratedServerWorker;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerSaveFormat;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
@ -66,6 +67,9 @@ public class WorldConverterEPK {
|
||||
NBTTagCompound worldDatNBT = CompressedStreamTools.readCompressed(new EaglerInputStream(b));
|
||||
worldDatNBT.getCompoundTag("Data").setString("LevelName", newName);
|
||||
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
|
||||
if(has152Format) {
|
||||
WorldInfo.initEaglerVersion(worldDatNBT.getCompoundTag("Data"));
|
||||
}
|
||||
EaglerOutputStream tmp = new EaglerOutputStream();
|
||||
CompressedStreamTools.writeCompressed(worldDatNBT, tmp);
|
||||
b = tmp.toByteArray();
|
||||
|
@ -20,6 +20,7 @@ import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerChunkLoader;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerIntegratedServerWorker;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerSaveFormat;
|
||||
import net.minecraft.world.chunk.storage.RegionFile;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@ -98,9 +99,9 @@ public class WorldConverterMCA {
|
||||
gameRulesNBT.setString("colorCodes", s);
|
||||
gameRulesNBT.setString("doSignEditing", s);
|
||||
worldDatNBT.getCompoundTag("Data").setTag("GameRules", gameRulesNBT);
|
||||
|
||||
worldDatNBT.getCompoundTag("Data").setString("LevelName", newName);
|
||||
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
|
||||
WorldInfo.initEaglerVersion(worldDatNBT.getCompoundTag("Data"));
|
||||
EaglerOutputStream bo = new EaglerOutputStream();
|
||||
CompressedStreamTools.writeCompressed(worldDatNBT, bo);
|
||||
b = bo.toByteArray();
|
||||
|
Reference in New Issue
Block a user