From 428b80afc61d6fb2d5a0a1b484784ecd45129a8e Mon Sep 17 00:00:00 2001 From: zumbiepig <121742281+zumbiepig@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:41:29 -0800 Subject: [PATCH] Starlike v0.3.1 --- .github/workflows/build.yml | 50 +-- SIGNED_CLIENT.env | 7 +- .../resources/OfflineDownloadTemplate.txt | 284 +++++++++++------- .../resources/assets/eagler/CREDITS.txt | 7 + .../assets/minecraft/texts/splashes.txt | 48 ++- javascript/favicon.png | Bin 2297 -> 0 bytes javascript/index.html | 219 +++++++++++--- .../client/settings/GameSettings.java | 6 +- src/game/java/net/minecraft/init/Items.java | 7 +- .../net/minecraft/inventory/Container.java | 3 +- .../minecraft/inventory/ContainerBeacon.java | 3 +- .../inventory/ContainerEnchantment.java | 5 +- .../inventory/ContainerMerchant.java | 3 +- .../minecraft/inventory/ContainerPlayer.java | 3 +- .../minecraft/inventory/ContainerRepair.java | 5 +- .../inventory/ContainerWorkbench.java | 3 +- .../java/net/minecraft/util/BlockPos.java | 6 + .../java/net/minecraft/util/EnumFacing.java | 2 +- src/game/java/net/minecraft/world/World.java | 196 ++++++------ .../java/net/minecraft/world/chunk/Chunk.java | 55 ++-- .../eaglercraft/v1_8/EaglercraftVersion.java | 4 +- .../guis/inventory/BackpackInventory.java | 69 +++++ .../guis/inventory/ContainerSmithing.java | 5 +- .../minecraft/init/ItemsStarlike.java | 4 + .../minecraft/init/RecipesStarlike.java | 4 +- .../minecraft/items/ItemBackpack.java | 40 +++ 26 files changed, 723 insertions(+), 315 deletions(-) delete mode 100644 javascript/favicon.png create mode 100644 src/main/java/net/starlikeclient/minecraft/guis/inventory/BackpackInventory.java create mode 100644 src/main/java/net/starlikeclient/minecraft/items/ItemBackpack.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2159d105..b3c57b4b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,31 +21,26 @@ jobs: run: ./gradlew generateJavaScript - name: Compile assets.epk run: bash ./CompileEPK.sh - - name: Generate offline download - standard - if: github.ref != 'refs/heads/main' + - name: Generate offline download run: bash ./MakeOfflineDownload.sh - - name: Generate offline download - signed - if: github.ref == 'refs/heads/main' + - name: Prepare web files run: | - source ./SIGNED_CLIENT.env && - SIGNED_CLIENT_INPUT="${{ vars.SIGNED_CLIENT_INPUT }}${{ secrets.SIGNED_CLIENT_SECRET }}" && - echo "$SIGNED_CLIENT_INPUT" | bash ./MakeSignedClient.sh && - echo "$SIGNED_CLIENT_INPUT" | bash ./MakeSignedClient.sh + mkdir -p ${{ runner.temp }}/gh-pages + cp -t ${{ runner.temp }}/gh-pages \ + javascript/assets.epk \ + javascript/classes.js \ + javascript/classes.js.map \ + javascript/index.html + cp javascript/Starlike_Client_Offline.html ${{ runner.temp }}/gh-pages/offline.html - name: Upload web files continue-on-error: true uses: actions/upload-artifact@v4 with: name: web - path: | - javascript/assets.epk - javascript/classes.js - javascript/classes.js.map - javascript/favicon.png - javascript/index.html + path: ${{ runner.temp }}/gh-pages/ retention-days: 1 compression-level: 9 - - name: Upload offline download - standard - if: github.ref != 'refs/heads/main' + - name: Upload offline download continue-on-error: true uses: actions/upload-artifact@v4 with: @@ -53,34 +48,13 @@ jobs: path: javascript/Starlike_Client_Offline.html retention-days: 1 compression-level: 9 - - name: Upload offline download - signed - if: github.ref == 'refs/heads/main' - continue-on-error: true - uses: actions/upload-artifact@v4 - with: - name: offline_signed - path: javascript/Starlike_Client_Offline_Signed.html - retention-days: 1 - compression-level: 9 - - name: Prepare GitHub Pages - if: github.ref == 'refs/heads/main' - run: | - mkdir -p ${{ runner.temp }}/gh-pages - cp -t ${{ runner.temp }}/gh-pages \ - javascript/assets.epk \ - javascript/classes.js \ - javascript/classes.js.map \ - javascript/favicon.png \ - javascript/index.html - cp javascript/Starlike_Client_Offline_Signed.html ${{ runner.temp }}/gh-pages/offline.html - cp javascript/Starlike_Client_Offline_Signed.html.dat ${{ runner.temp }}/gh-pages/latest_update.dat - name: Deploy to GitHub Pages if: github.ref == 'refs/heads/main' uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ${{ runner.temp }}/gh-pages - cname: starlikeclient.com + cname: starlike.zumbiepig.dev force_orphan: true user_name: 'github-actions[bot]' user_email: '41898282+github-actions[bot]@users.noreply.github.com' diff --git a/SIGNED_CLIENT.env b/SIGNED_CLIENT.env index 9edfbe16..3ba9ab31 100644 --- a/SIGNED_CLIENT.env +++ b/SIGNED_CLIENT.env @@ -1,3 +1,4 @@ -SIGNED_CLIENT_INTEGER="300" -SIGNED_CLIENT_VERSION="0.3.0" -SIGNED_CLIENT_CHANGELOG="Find the changelog in the Discord server!" +SIGNED_CLIENT_INTEGER="301" +SIGNED_CLIENT_VERSION="0.3.1" +SIGNED_CLIENT_CHANGELOG="View the changelog in the Discord server" + diff --git a/desktopRuntime/resources/OfflineDownloadTemplate.txt b/desktopRuntime/resources/OfflineDownloadTemplate.txt index d1a8eba6..6d92a559 100644 --- a/desktopRuntime/resources/OfflineDownloadTemplate.txt +++ b/desktopRuntime/resources/OfflineDownloadTemplate.txt @@ -1,101 +1,183 @@ - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - -Starlike Client - - - - - - - + + + + + + + + + + + + + +Starlike Client + + + + + + +++ + + diff --git a/src/game/java/net/minecraft/client/settings/GameSettings.java b/src/game/java/net/minecraft/client/settings/GameSettings.java index 7082cad5..5af4e3ad 100644 --- a/src/game/java/net/minecraft/client/settings/GameSettings.java +++ b/src/game/java/net/minecraft/client/settings/GameSettings.java @@ -344,7 +344,7 @@ public class GameSettings { * + GUI scale */ public int guiScale = 3; - public int particleSetting; + public int particleSetting = 2; public String language; public boolean forceUnicodeFont; public boolean hudFps = true; @@ -354,7 +354,7 @@ public class GameSettings { public boolean hudStats = false; public boolean hud24h = false; public boolean chunkFix = true; - public boolean fog = true; + public boolean fog = false; public int fxaa = 0; public boolean shaders = false; public boolean shadersAODisable = false; @@ -365,7 +365,7 @@ public class GameSettings { public boolean hasHiddenPhishWarning = false; public boolean enableProfanityFilter = false; - public boolean hasShownProfanityFilter = false; + public boolean hasShownProfanityFilter = true; public float touchControlOpacity = 1.0f; public boolean hideDefaultUsernameWarning = false; diff --git a/src/game/java/net/minecraft/init/Items.java b/src/game/java/net/minecraft/init/Items.java index 6f186794..e119af1d 100644 --- a/src/game/java/net/minecraft/init/Items.java +++ b/src/game/java/net/minecraft/init/Items.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemMap; import net.minecraft.item.ItemPotion; import net.minecraft.item.ItemShears; import net.minecraft.util.ResourceLocation; +import net.starlikeclient.minecraft.items.ItemBackpack; import net.starlikeclient.minecraft.items.ItemChisel; /** @@ -253,7 +254,9 @@ public class Items { public static ItemArmor netherite_chestplate; public static ItemArmor netherite_leggings; public static ItemArmor netherite_boots; - public static ItemChisel chisel; + public static ItemChisel chisel; + //public static ItemBackpack leather_backpack; + static void doBootstrap() { if (!Bootstrap.isRegistered()) { @@ -477,6 +480,8 @@ public class Items { netherite_leggings = (ItemArmor) getRegisteredItem("starlike:netherite_leggings"); netherite_boots = (ItemArmor) getRegisteredItem("starlike:netherite_boots"); chisel = (ItemChisel) getRegisteredItem("starlike:chisel"); + //leather_backpack = (ItemBackpack) getRegisteredItem("starlike:leather_backpack"); + } } diff --git a/src/game/java/net/minecraft/inventory/Container.java b/src/game/java/net/minecraft/inventory/Container.java index 386f1d23..ffa81699 100644 --- a/src/game/java/net/minecraft/inventory/Container.java +++ b/src/game/java/net/minecraft/inventory/Container.java @@ -344,7 +344,8 @@ public abstract class Container { inventoryplayer.setItemStack((ItemStack) null); if (!playerIn.worldObj.isRemote) { - ((EntityPlayerMP) playerIn).playerNetServerHandler.sendPacket(new S30PacketWindowItems(playerIn.inventoryContainer.windowId, playerIn.inventoryContainer.getInventory())); + ((EntityPlayerMP) playerIn).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + playerIn.inventoryContainer.windowId, playerIn.inventoryContainer.getInventory())); } } } diff --git a/src/game/java/net/minecraft/inventory/ContainerBeacon.java b/src/game/java/net/minecraft/inventory/ContainerBeacon.java index 606b7dd5..012c61f6 100644 --- a/src/game/java/net/minecraft/inventory/ContainerBeacon.java +++ b/src/game/java/net/minecraft/inventory/ContainerBeacon.java @@ -88,7 +88,8 @@ public class ContainerBeacon extends Container { if (!entityplayer.inventory.addItemStackToInventory(itemstack)) { entityplayer.dropPlayerItemWithRandomChoice(itemstack, false); } - ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems(entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); } } } diff --git a/src/game/java/net/minecraft/inventory/ContainerEnchantment.java b/src/game/java/net/minecraft/inventory/ContainerEnchantment.java index 79f9578e..783d3a87 100644 --- a/src/game/java/net/minecraft/inventory/ContainerEnchantment.java +++ b/src/game/java/net/minecraft/inventory/ContainerEnchantment.java @@ -12,10 +12,10 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S30PacketWindowItems; import net.minecraft.stats.StatList; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import net.minecraft.network.play.server.S30PacketWindowItems; /** * + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source @@ -203,7 +203,8 @@ public class ContainerEnchantment extends Container { } } } - ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems(entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); } } diff --git a/src/game/java/net/minecraft/inventory/ContainerMerchant.java b/src/game/java/net/minecraft/inventory/ContainerMerchant.java index 2f003ebd..a75a0b50 100644 --- a/src/game/java/net/minecraft/inventory/ContainerMerchant.java +++ b/src/game/java/net/minecraft/inventory/ContainerMerchant.java @@ -94,7 +94,8 @@ public class ContainerMerchant extends Container { } } - ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems(entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); } } diff --git a/src/game/java/net/minecraft/inventory/ContainerPlayer.java b/src/game/java/net/minecraft/inventory/ContainerPlayer.java index 26a3b2a8..369c5b21 100644 --- a/src/game/java/net/minecraft/inventory/ContainerPlayer.java +++ b/src/game/java/net/minecraft/inventory/ContainerPlayer.java @@ -121,7 +121,8 @@ public class ContainerPlayer extends Container { this.craftResult.setInventorySlotContents(0, (ItemStack) null); if (!entityplayer.worldObj.isRemote) { - ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems(entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); } } diff --git a/src/game/java/net/minecraft/inventory/ContainerRepair.java b/src/game/java/net/minecraft/inventory/ContainerRepair.java index 110a362a..9a893ec2 100644 --- a/src/game/java/net/minecraft/inventory/ContainerRepair.java +++ b/src/game/java/net/minecraft/inventory/ContainerRepair.java @@ -17,9 +17,9 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S30PacketWindowItems; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import net.minecraft.network.play.server.S30PacketWindowItems; /** * + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source @@ -155,7 +155,8 @@ public class ContainerRepair extends Container { } } } - ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems(entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); } } diff --git a/src/game/java/net/minecraft/inventory/ContainerWorkbench.java b/src/game/java/net/minecraft/inventory/ContainerWorkbench.java index 98a1843d..9f6ee874 100644 --- a/src/game/java/net/minecraft/inventory/ContainerWorkbench.java +++ b/src/game/java/net/minecraft/inventory/ContainerWorkbench.java @@ -96,7 +96,8 @@ public class ContainerWorkbench extends Container { } } } - ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems(entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); } } diff --git a/src/game/java/net/minecraft/util/BlockPos.java b/src/game/java/net/minecraft/util/BlockPos.java index 943ba9cd..0cfd2a12 100644 --- a/src/game/java/net/minecraft/util/BlockPos.java +++ b/src/game/java/net/minecraft/util/BlockPos.java @@ -58,6 +58,12 @@ public class BlockPos extends Vec3i { public int getZ() { return this.z; } + + public void setPos(int i, int j, int k) { + this.x = i; + this.y = j; + this.z = k; + } } /** diff --git a/src/game/java/net/minecraft/util/EnumFacing.java b/src/game/java/net/minecraft/util/EnumFacing.java index bb04e6bf..9908e951 100644 --- a/src/game/java/net/minecraft/util/EnumFacing.java +++ b/src/game/java/net/minecraft/util/EnumFacing.java @@ -165,7 +165,7 @@ public enum EnumFacing implements IStringSerializable { /** * + All facings in D-U-N-S-W-E order */ - private static final EnumFacing[] VALUES = new EnumFacing[6]; + public static final EnumFacing[] VALUES = new EnumFacing[6]; /** * + All Facings with horizontal axis in order S-W-N-E */ diff --git a/src/game/java/net/minecraft/world/World.java b/src/game/java/net/minecraft/world/World.java index e7b9fea1..e0a63c50 100644 --- a/src/game/java/net/minecraft/world/World.java +++ b/src/game/java/net/minecraft/world/World.java @@ -418,123 +418,137 @@ public abstract class World implements IBlockAccess { } public boolean checkLight(BlockPos pos) { - boolean flag = false; - if (!this.provider.getHasNoSky()) { - flag |= this.checkLightFor(EnumSkyBlock.SKY, pos); + if (provider.getHasNoSky()) { + return this.checkLightFor(EnumSkyBlock.BLOCK, pos); } - - flag = flag | this.checkLightFor(EnumSkyBlock.BLOCK, pos); - return flag; + return this.checkLightFor(EnumSkyBlock.SKY, pos) | this.checkLightFor(EnumSkyBlock.BLOCK, pos); } public boolean checkLightFor(EnumSkyBlock lightType, BlockPos pos) { if (!this.isAreaLoaded(pos, 17, false)) { return false; + } + + int queueSize = 0; + int currentIndex = 0; + + int baseX = pos.getX(); + int baseY = pos.getY(); + int baseZ = pos.getZ(); + + int currentLight = this.getLightFor(lightType, pos); + int computedLight = this.getRawLight(pos, lightType); + if (computedLight == currentLight) { + return true; + } + + if (computedLight > currentLight) { + this.lightUpdateBlockList[queueSize++] = 133152; } else { - int i = 0; - int j = 0; - int k = this.getLightFor(lightType, pos); - int l = this.getRawLight(pos, lightType); - int i1 = pos.getX(); - int j1 = pos.getY(); - int k1 = pos.getZ(); - if (l > k) { - this.lightUpdateBlockList[j++] = 133152; - } else if (l < k) { - this.lightUpdateBlockList[j++] = 133152 | k << 18; + this.lightUpdateBlockList[queueSize++] = 133152 | currentLight << 18; - while (i < j) { - int l1 = this.lightUpdateBlockList[i++]; - int i2 = (l1 & 63) - 32 + i1; - int j2 = (l1 >> 6 & 63) - 32 + j1; - int k2 = (l1 >> 12 & 63) - 32 + k1; - int l2 = l1 >> 18 & 15; - BlockPos blockpos = new BlockPos(i2, j2, k2); - int i3 = this.getLightFor(lightType, blockpos); - if (i3 == l2) { - this.setLightFor(lightType, blockpos, 0); - if (l2 > 0) { - int j3 = MathHelper.abs_int(i2 - i1); - int k3 = MathHelper.abs_int(j2 - j1); - int l3 = MathHelper.abs_int(k2 - k1); - if (j3 + k3 + l3 < 17) { - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + while (currentIndex < queueSize) { + int packed = this.lightUpdateBlockList[currentIndex++]; + int relX = (packed & 63) - 32; + int relY = ((packed >> 6) & 63) - 32; + int relZ = ((packed >> 12) & 63) - 32; + int light = packed >> 18 & 15; - EnumFacing[] facings = EnumFacing._VALUES; - for (int m = 0; m < facings.length; ++m) { - EnumFacing enumfacing = facings[m]; - int i4 = i2 + enumfacing.getFrontOffsetX(); - int j4 = j2 + enumfacing.getFrontOffsetY(); - int k4 = k2 + enumfacing.getFrontOffsetZ(); - blockpos$mutableblockpos.func_181079_c(i4, j4, k4); - int l4 = Math.max(1, - this.getBlockState(blockpos$mutableblockpos).getBlock().getLightOpacity()); - i3 = this.getLightFor(lightType, blockpos$mutableblockpos); - if (i3 == l2 - l4 && j < this.lightUpdateBlockList.length) { - this.lightUpdateBlockList[j++] = i4 - i1 + 32 | j4 - j1 + 32 << 6 - | k4 - k1 + 32 << 12 | l2 - l4 << 18; - } + int worldX = relX + baseX; + int worldY = relY + baseY; + int worldZ = relZ + baseZ; + + BlockPos blockPos = new BlockPos(worldX, worldY, worldZ); + int currentBlockLight = this.getLightFor(lightType, blockPos); + + if (currentBlockLight == light) { + this.setLightFor(lightType, blockPos, 0); + + if (light > 0) { + int manhattan = Math.abs(relX) + Math.abs(relY) + Math.abs(relZ); + if (manhattan < 17) { + BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); + EnumFacing[] facings = EnumFacing.values(); + + for (EnumFacing facing : facings) { + int adjX = worldX + facing.getFrontOffsetX(); + int adjY = worldY + facing.getFrontOffsetY(); + int adjZ = worldZ + facing.getFrontOffsetZ(); + + mutablePos.func_181079_c(adjX, adjY, adjZ); + + int opacity = Math.max(1, this.getBlockState(mutablePos).getBlock().getLightOpacity()); + int neighborLight = this.getLightFor(lightType, mutablePos); + + if (neighborLight == light - opacity && queueSize < this.lightUpdateBlockList.length) { + this.lightUpdateBlockList[queueSize++] = ((adjX - baseX + 32) & 63) + | ((adjY - baseY + 32) & 63) << 6 | ((adjZ - baseZ + 32) & 63) << 12 + | (light - opacity) << 18; } } } } } - - i = 0; } - while (i < j) { - int i5 = this.lightUpdateBlockList[i++]; - int j5 = (i5 & 63) - 32 + i1; - int k5 = (i5 >> 6 & 63) - 32 + j1; - int l5 = (i5 >> 12 & 63) - 32 + k1; - BlockPos blockpos1 = new BlockPos(j5, k5, l5); - int i6 = this.getLightFor(lightType, blockpos1); - int j6 = this.getRawLight(blockpos1, lightType); - if (j6 != i6) { - this.setLightFor(lightType, blockpos1, j6); - if (j6 > i6) { - int k6 = Math.abs(j5 - i1); - int l6 = Math.abs(k5 - j1); - int i7 = Math.abs(l5 - k1); - boolean flag = j < this.lightUpdateBlockList.length - 6; - if (k6 + l6 + i7 < 17 && flag) { - if (this.getLightFor(lightType, blockpos1.west()) < j6) { - this.lightUpdateBlockList[j++] = j5 - 1 - i1 + 32 + (k5 - j1 + 32 << 6) - + (l5 - k1 + 32 << 12); - } + currentIndex = 0; + } - if (this.getLightFor(lightType, blockpos1.east()) < j6) { - this.lightUpdateBlockList[j++] = j5 + 1 - i1 + 32 + (k5 - j1 + 32 << 6) - + (l5 - k1 + 32 << 12); - } + while (currentIndex < queueSize) { + int packed = this.lightUpdateBlockList[currentIndex++]; + int relX = (packed & 63) - 32; + int relY = ((packed >> 6) & 63) - 32; + int relZ = ((packed >> 12) & 63) - 32; - if (this.getLightFor(lightType, blockpos1.down()) < j6) { - this.lightUpdateBlockList[j++] = j5 - i1 + 32 + (k5 - 1 - j1 + 32 << 6) - + (l5 - k1 + 32 << 12); - } + int worldX = relX + baseX; + int worldY = relY + baseY; + int worldZ = relZ + baseZ; - if (this.getLightFor(lightType, blockpos1.up()) < j6) { - this.lightUpdateBlockList[j++] = j5 - i1 + 32 + (k5 + 1 - j1 + 32 << 6) - + (l5 - k1 + 32 << 12); - } + BlockPos blockPos = new BlockPos(worldX, worldY, worldZ); + int currentBlockLight = this.getLightFor(lightType, blockPos); + int computedBlockLight = this.getRawLight(blockPos, lightType); - if (this.getLightFor(lightType, blockpos1.north()) < j6) { - this.lightUpdateBlockList[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) - + (l5 - 1 - k1 + 32 << 12); - } + if (computedBlockLight != currentBlockLight) { + this.setLightFor(lightType, blockPos, computedBlockLight); - if (this.getLightFor(lightType, blockpos1.south()) < j6) { - this.lightUpdateBlockList[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) - + (l5 + 1 - k1 + 32 << 12); - } + if (computedBlockLight > currentBlockLight) { + int manhattan = Math.abs(relX) + Math.abs(relY) + Math.abs(relZ); + if (manhattan < 17 && queueSize < this.lightUpdateBlockList.length - 6) { + if (this.getLightFor(lightType, blockPos.west()) < computedBlockLight) { + this.lightUpdateBlockList[queueSize++] = ((worldX - 1 - baseX + 32) & 63) + | ((worldY - baseY + 32) & 63) << 6 | ((worldZ - baseZ + 32) & 63) << 12; + } + + if (this.getLightFor(lightType, blockPos.east()) < computedBlockLight) { + this.lightUpdateBlockList[queueSize++] = ((worldX + 1 - baseX + 32) & 63) + | ((worldY - baseY + 32) & 63) << 6 | ((worldZ - baseZ + 32) & 63) << 12; + } + + if (this.getLightFor(lightType, blockPos.down()) < computedBlockLight) { + this.lightUpdateBlockList[queueSize++] = ((worldX - baseX + 32) & 63) + | ((worldY - 1 - baseY + 32) & 63) << 6 | ((worldZ - baseZ + 32) & 63) << 12; + } + + if (this.getLightFor(lightType, blockPos.up()) < computedBlockLight) { + this.lightUpdateBlockList[queueSize++] = ((worldX - baseX + 32) & 63) + | ((worldY + 1 - baseY + 32) & 63) << 6 | ((worldZ - baseZ + 32) & 63) << 12; + } + + if (this.getLightFor(lightType, blockPos.north()) < computedBlockLight) { + this.lightUpdateBlockList[queueSize++] = ((worldX - baseX + 32) & 63) + | ((worldY - baseY + 32) & 63) << 6 | ((worldZ - 1 - baseZ + 32) & 63) << 12; + } + + if (this.getLightFor(lightType, blockPos.south()) < computedBlockLight) { + this.lightUpdateBlockList[queueSize++] = ((worldX - baseX + 32) & 63) + | ((worldY - baseY + 32) & 63) << 6 | ((worldZ + 1 - baseZ + 32) & 63) << 12; } } } } - - return true; } + + return true; } /** diff --git a/src/game/java/net/minecraft/world/chunk/Chunk.java b/src/game/java/net/minecraft/world/chunk/Chunk.java index 2b9e71e9..1738864d 100644 --- a/src/game/java/net/minecraft/world/chunk/Chunk.java +++ b/src/game/java/net/minecraft/world/chunk/Chunk.java @@ -198,6 +198,22 @@ public class Chunk { return j >= this.heightMap[k << 4 | i]; } + /** + * Checks light levels for a block and its neighbors + * + * @param centerPos The position of the block to check + */ + private void checkLightForBlockAndNeighbors(BlockPos centerPos) { + for (EnumFacing facing : EnumFacing.values()) { + BlockPos neighborPos = centerPos.offset(facing); + if (worldObj.getBlockState(neighborPos).getBlock().getLightValue() > 0) { + worldObj.checkLight(neighborPos); + } + } + + worldObj.checkLight(centerPos); + } + /** * + Checks the height of a block next to a sky-visible block and schedules a * lighting update as necessary. @@ -226,36 +242,33 @@ public class Chunk { * generation. */ public void enqueueRelightChecks() { - BlockPos blockpos = new BlockPos(this.xPosition << 4, 0, this.zPosition << 4); + final BlockPos chunkStart = new BlockPos(xPosition << 4, 0, zPosition << 4); + final int MAX_QUEUE_SIZE = 4096; + final int SECTION_SIZE = 16; - for (int i = 0; i < 8; ++i) { - if (this.queuedLightChecks >= 4096) { + for (int section = 0; section < 8; section++) { + if (queuedLightChecks >= MAX_QUEUE_SIZE) { return; } - int j = this.queuedLightChecks % 16; - int k = this.queuedLightChecks / 16 % 16; - int l = this.queuedLightChecks / 256; - ++this.queuedLightChecks; + int ySection = queuedLightChecks % SECTION_SIZE; + int xOffset = (queuedLightChecks / SECTION_SIZE) % SECTION_SIZE; + int zOffset = queuedLightChecks / 256; + queuedLightChecks++; - EnumFacing[] facings = EnumFacing._VALUES; - for (int i1 = 0; i1 < 16; ++i1) { - BlockPos blockpos1 = blockpos.add(k, (j << 4) + i1, l); - boolean flag = i1 == 0 || i1 == 15 || k == 0 || k == 15 || l == 0 || l == 15; - if (this.storageArrays[j] == null && flag || this.storageArrays[j] != null - && this.storageArrays[j].getBlockByExtId(k, i1, l).getMaterial() == Material.air) { - for (int m = 0; m < facings.length; ++m) { - BlockPos blockpos2 = blockpos1.offset(facings[m]); - if (this.worldObj.getBlockState(blockpos2).getBlock().getLightValue() > 0) { - this.worldObj.checkLight(blockpos2); - } - } + for (int y = 0; y < SECTION_SIZE; y++) { + BlockPos columnPos = chunkStart.add(xOffset, (ySection << 4) + y, zOffset); - this.worldObj.checkLight(blockpos1); + boolean isBorder = y == 0 || y == 15 || xOffset == 0 || xOffset == 15 || zOffset == 0 || zOffset == 15; + + boolean needsRelight = (storageArrays[ySection] == null && isBorder) || (storageArrays[ySection] != null + && storageArrays[ySection].getBlockByExtId(xOffset, y, zOffset).getMaterial() == Material.air); + + if (needsRelight) { + checkLightForBlockAndNeighbors(columnPos); } } } - } /** diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java index 40d21f11..344c09c2 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java @@ -9,7 +9,7 @@ public class EaglercraftVersion { /// Customize these to fit your fork: public static final String projectForkName = "Starlike Client"; - public static final String projectForkVersion = "0.3.0"; + public static final String projectForkVersion = "0.3.1"; public static final String projectForkVendor = "SpeedSlicer and zumbiepig"; public static final String projectForkURL = ""; @@ -32,7 +32,7 @@ public class EaglercraftVersion { public static final boolean enableUpdateService = true; public static final String updateBundlePackageName = "dev.zumbiepig.starlikeclient.client"; - public static final int updateBundlePackageVersionInt = 300; // (0.2.1 would be 000201 or just 201) + public static final int updateBundlePackageVersionInt = 301; // (0.2.1 would be 000201 or just 201) public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName; diff --git a/src/main/java/net/starlikeclient/minecraft/guis/inventory/BackpackInventory.java b/src/main/java/net/starlikeclient/minecraft/guis/inventory/BackpackInventory.java new file mode 100644 index 00000000..3c55b421 --- /dev/null +++ b/src/main/java/net/starlikeclient/minecraft/guis/inventory/BackpackInventory.java @@ -0,0 +1,69 @@ +package net.starlikeclient.minecraft.guis.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.starlikeclient.minecraft.items.ItemBackpack; + +public class BackpackInventory extends InventoryBasic { + private final ItemStack backpackItem; + + public BackpackInventory(ItemStack backpackItem) { + super("Backpack", false, 32); + this.backpackItem = backpackItem; + loadInventoryFromNBT(); + } + + @Override + public void markDirty() { + saveInventoryToNBT(); + super.markDirty(); + } + + @Override + public void closeInventory(EntityPlayer player) { + saveInventoryToNBT(); + super.closeInventory(player); + ItemBackpack.onInventoryClosed(); + } + + public void loadInventoryFromNBT() { + if (backpackItem != null && backpackItem.hasTagCompound()) { + NBTTagCompound nbt = backpackItem.getTagCompound(); + NBTTagList itemList = nbt.getTagList("BackpackItems", 10); + + for (int i = 0; i < itemList.tagCount(); i++) { + NBTTagCompound slotTag = itemList.getCompoundTagAt(i); + int slot = slotTag.getByte("Slot") & 255; + ItemStack stack = ItemStack.loadItemStackFromNBT(slotTag); + if (slot >= 0 && slot < getSizeInventory()) { + setInventorySlotContents(slot, stack); + } + } + } + } + + public void saveInventoryToNBT() { + if (backpackItem == null) return; + + NBTTagCompound nbt = backpackItem.hasTagCompound() ? + backpackItem.getTagCompound() : new NBTTagCompound(); + + NBTTagList itemList = new NBTTagList(); + + for (int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if (stack != null) { + NBTTagCompound slotTag = new NBTTagCompound(); + slotTag.setByte("Slot", (byte)i); + stack.writeToNBT(slotTag); + itemList.appendTag(slotTag); + } + } + + nbt.setTag("BackpackItems", itemList); + backpackItem.setTagCompound(nbt); + } +} \ No newline at end of file diff --git a/src/main/java/net/starlikeclient/minecraft/guis/inventory/ContainerSmithing.java b/src/main/java/net/starlikeclient/minecraft/guis/inventory/ContainerSmithing.java index 7741591e..33436e31 100644 --- a/src/main/java/net/starlikeclient/minecraft/guis/inventory/ContainerSmithing.java +++ b/src/main/java/net/starlikeclient/minecraft/guis/inventory/ContainerSmithing.java @@ -10,10 +10,10 @@ import net.minecraft.inventory.InventoryBasic; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.play.server.S30PacketWindowItems; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.starlikeclient.minecraft.guis.crafting.SmithingManager; -import net.minecraft.network.play.server.S30PacketWindowItems; public class ContainerSmithing extends Container { private final IInventory smithingInventory; @@ -112,7 +112,8 @@ public class ContainerSmithing extends Container { } } } - ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems(entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S30PacketWindowItems( + entityplayer.inventoryContainer.windowId, entityplayer.inventoryContainer.getInventory())); } } diff --git a/src/main/java/net/starlikeclient/minecraft/init/ItemsStarlike.java b/src/main/java/net/starlikeclient/minecraft/init/ItemsStarlike.java index b2120b33..1cc5a657 100644 --- a/src/main/java/net/starlikeclient/minecraft/init/ItemsStarlike.java +++ b/src/main/java/net/starlikeclient/minecraft/init/ItemsStarlike.java @@ -23,6 +23,7 @@ import net.starlikeclient.minecraft.blocks.BlockDeepslate; import net.starlikeclient.minecraft.blocks.BlockMosaic; import net.starlikeclient.minecraft.blocks.BlockSmithing; import net.starlikeclient.minecraft.blocks.BlockSteelGrate; +import net.starlikeclient.minecraft.items.ItemBackpack; import net.starlikeclient.minecraft.items.ItemChisel; public class ItemsStarlike { @@ -806,6 +807,7 @@ public class ItemsStarlike { (new ItemArmor(ItemArmor.ArmorMaterial.NETHERITE, 5, 3)).setUnlocalizedName("netherite_boots") .setCreativeTab(CreativeTabs.tabStarlike)); Item.registerItem(1053, (String) "starlike:chisel", (new ItemChisel()).setUnlocalizedName("chisel")); + Item.registerItem(1054, (String) "starlike:leather_backpack", (new ItemBackpack()).setUnlocalizedName("leather_backpack")); //autogenerateregisterblock Item.registerItemBlock(Blocks.tuff_tiles); @@ -966,6 +968,7 @@ public class ItemsStarlike { Item.registerItemBlock(Blocks.decorated_acacia_log); Item.registerItemBlock(Blocks.chiseled_deep_ocean_bricks); Item.registerItemBlock(Blocks.andesite_bricks); + } public static void renderItems(RenderItem e) { @@ -1021,6 +1024,7 @@ public class ItemsStarlike { e.registerItem(Items.netherite_leggings, "starlike:netherite_leggings"); e.registerItem(Items.netherite_boots, "starlike:netherite_boots"); e.registerItem(Items.chisel, "starlike:chisel"); + //e.registerItem(Items.leather_backpack, "starlike:leather_backpack"); //autogeneraterenderitem e.registerBlock(Blocks.tuff_tiles, "starlike:tuff_tiles"); diff --git a/src/main/java/net/starlikeclient/minecraft/init/RecipesStarlike.java b/src/main/java/net/starlikeclient/minecraft/init/RecipesStarlike.java index 3fd9ec3b..81430de3 100644 --- a/src/main/java/net/starlikeclient/minecraft/init/RecipesStarlike.java +++ b/src/main/java/net/starlikeclient/minecraft/init/RecipesStarlike.java @@ -60,7 +60,7 @@ public class RecipesStarlike { new ItemStack(Items.netherite_scrap, 1), new ItemStack(Items.netherite_scrap, 1), new ItemStack(Items.gold_ingot, 1), new ItemStack(Items.gold_ingot, 1), new ItemStack(Items.gold_ingot, 1), new ItemStack(Items.gold_ingot, 1) }); - e.addRecipe(new ItemStack(Items.chisel, 1), new Object[] { " #", " / ", "/ ", Character.valueOf('#'), + e.addRecipe(new ItemStack(Items.chisel, 1), new Object[] { "#", "/", "/", Character.valueOf('#'), Items.steel, Character.valueOf('/'), Items.stick }); e.addRecipe(new ItemStack(Blocks.smithing_table), new Object[] { "//", "##", "##", Character.valueOf('/'), Items.iron_ingot, Character.valueOf('#'), Blocks.planks }); @@ -152,4 +152,4 @@ public class RecipesStarlike { e.addSmithingRecipe(new ItemStack(Items.diamond_leggings), new ItemStack(Items.netherite_leggings)); e.addSmithingRecipe(new ItemStack(Items.diamond_boots), new ItemStack(Items.netherite_boots)); } -} \ No newline at end of file +} diff --git a/src/main/java/net/starlikeclient/minecraft/items/ItemBackpack.java b/src/main/java/net/starlikeclient/minecraft/items/ItemBackpack.java new file mode 100644 index 00000000..1600ea78 --- /dev/null +++ b/src/main/java/net/starlikeclient/minecraft/items/ItemBackpack.java @@ -0,0 +1,40 @@ +package net.starlikeclient.minecraft.items; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.starlikeclient.minecraft.guis.inventory.BackpackInventory; + +public class ItemBackpack extends Item { + private static BackpackInventory openInventory; + + public ItemBackpack() { + this.setUnlocalizedName("backpack"); + this.setCreativeTab(CreativeTabs.tabMisc); + this.maxStackSize = 1; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + if (!world.isRemote) { + System.out.println("Opening backpack..."); + + openInventory = new BackpackInventory(itemStack); + + player.displayGUIChest(openInventory); + + System.out.println("Backpack opened."); + } + return itemStack; + } + + // Add this method to handle inventory closing + public static void onInventoryClosed() { + if (openInventory != null) { + openInventory.saveInventoryToNBT(); + openInventory = null; + } + } +} \ No newline at end of file+
The eaglercraft client.
+