From b1c7e93b9777d025abee9028dceac113e6fdf2c8 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:49:00 -0400 Subject: [PATCH] Rewrote Entire Project Rewrote the entire project using Lax1dude's OpenGL Emulator from his project "Eaglercraft" --- .../com/mojang/minecraft/gui/GuiMods.java | 40 - .../com/mojang/minecraft/gui/GuiMore.java | 40 - .../com/mojang/minecraft/gui/GuiOptifine.java | 40 - .../mojang/minecraft/gui/LevelNameScreen.java | 85 - .../minecraft/level/tile/DirtBlock.java | 20 - .../com/mojang/minecraft/net/PacketType.java | 86 - .../mojang/minecraft/render/RenderEngine.java | 149 -- .../mojang/minecraft/render/TextureBase.java | 14 - .../minecraft/render/TextureLocation.java | 43 - src/main/java/com/mojang/util/MathHelper.java | 43 - .../lwjgl/KeyboardConstants.java | 268 --- .../java/net/PeytonPlayz585/lwjgl/LWJGL.java | 586 ----- .../net/PeytonPlayz585/lwjgl/LWJGLUtils.java | 82 - .../net/PeytonPlayz585/lwjgl/ModeBuffer.java | 58 - .../PeytonPlayz585/lwjgl/PlatformInput.java | 507 ----- .../PeytonPlayz585/main/MinecraftMain.java | 192 -- src/main/java/org/lwjgl/BufferUtils.java | 23 - src/main/java/org/lwjgl/input/Keyboard.java | 193 -- src/main/java/org/lwjgl/input/Mouse.java | 98 - src/main/java/org/lwjgl/opengl/Display.java | 56 - src/main/java/org/lwjgl/opengl/GL11.java | 7 - .../java/com/mojang/minecraft/ChatLine.java | 0 .../java/com/mojang/minecraft/Entity.java | 8 +- .../com/mojang/minecraft/GameSettings.java | 70 +- .../java/com/mojang/minecraft/KeyBinding.java | 0 .../java/com/mojang/minecraft/Minecraft.java | 232 +- .../minecraft/MovingObjectPosition.java | 0 .../mojang/minecraft/ProgressBarDisplay.java | 11 +- .../com/mojang/minecraft/SessionData.java | 131 +- .../mojang/minecraft/SkinDownloadThread.java | 51 + .../mojang/minecraft/SleepForeverThread.java | 0 .../mojang/minecraft/StopGameException.java | 0 .../java/com/mojang/minecraft/Timer.java | 0 .../minecraft/gamemode/CreativeGameMode.java | 0 .../mojang/minecraft/gamemode/GameMode.java | 0 .../minecraft/gamemode/SurvivalGameMode.java | 7 +- .../minecraft/gui/BlockSelectScreen.java | 7 +- .../java/com/mojang/minecraft/gui/Button.java | 0 .../mojang/minecraft/gui/ChatInputScreen.java | 7 +- .../mojang/minecraft/gui/ControlsScreen.java | 0 .../com/mojang/minecraft/gui/ErrorScreen.java | 0 .../mojang/minecraft/gui/FontRenderer.java | 31 +- .../mojang/minecraft/gui/GameOverScreen.java | 6 +- .../minecraft/gui/GenerateLevelScreen.java | 0 .../com/mojang/minecraft/gui/GuiScreen.java | 22 +- .../com/mojang/minecraft/gui/HUDScreen.java | 11 +- .../mojang/minecraft/gui/OptionButton.java | 0 .../mojang/minecraft/gui/OptionsScreen.java | 5 - .../com/mojang/minecraft/gui/PauseScreen.java | 15 + .../java/com/mojang/minecraft/gui/Screen.java | 2 + .../java/com/mojang/minecraft/item/Arrow.java | 8 +- .../java/com/mojang/minecraft/item/Item.java | 8 +- .../com/mojang/minecraft/item/ItemModel.java | 0 .../com/mojang/minecraft/item/PrimedTnt.java | 8 +- .../mojang/minecraft/item/TakeEntityAnim.java | 5 +- .../mojang/minecraft/level/BlockMap$Slot.java | 0 .../com/mojang/minecraft/level/BlockMap.java | 5 +- .../com/mojang/minecraft/level/Level.java | 0 .../com/mojang/minecraft/level/LevelIO.java | 0 .../level/LevelObjectInputStream.java | 0 .../mojang/minecraft/level/MobSpawner.java | 0 .../minecraft/level/NextTickListEntry.java | 0 .../minecraft/level/SyntheticClass.java | 0 .../level/generator/LevelGenerator.java | 0 .../level/generator/noise/CombinedNoise.java | 0 .../level/generator/noise/Noise.java | 0 .../level/generator/noise/OctaveNoise.java | 0 .../level/generator/noise/PerlinNoise.java | 0 .../minecraft/level/liquid/LiquidType.java | 0 .../mojang/minecraft/level/tile/Block.java | 0 .../minecraft/level/tile/BookshelfBlock.java | 10 - .../minecraft/level/tile/DirtBlock.java | 10 + .../minecraft/level/tile/FlowerBlock.java | 8 - .../minecraft/level/tile/GlassBlock.java | 3 - .../minecraft/level/tile/GrassBlock.java | 6 +- .../minecraft/level/tile/LeavesBaseBlock.java | 0 .../minecraft/level/tile/LeavesBlock.java | 0 .../minecraft/level/tile/LiquidBlock.java | 0 .../minecraft/level/tile/MetalBlock.java | 10 - .../minecraft/level/tile/MushroomBlock.java | 9 - .../mojang/minecraft/level/tile/OreBlock.java | 6 - .../minecraft/level/tile/SandBlock.java | 10 - .../minecraft/level/tile/SaplingBlock.java | 8 - .../minecraft/level/tile/SlabBlock.java | 8 +- .../minecraft/level/tile/SpongeBlock.java | 10 - .../level/tile/StillLiquidBlock.java | 0 .../minecraft/level/tile/StoneBlock.java | 8 +- .../mojang/minecraft/level/tile/TNTBlock.java | 10 - .../minecraft/level/tile/Tile$SoundType.java | 0 .../minecraft/level/tile/WoodBlock.java | 8 +- .../com/mojang/minecraft/mob/Creeper$1.java | 0 .../com/mojang/minecraft/mob/Creeper.java | 0 .../com/mojang/minecraft/mob/HumanoidMob.java | 8 +- .../java/com/mojang/minecraft/mob/Mob.java | 19 +- .../java/com/mojang/minecraft/mob/Pig.java | 0 .../mojang/minecraft/mob/QuadrupedMob.java | 0 .../com/mojang/minecraft/mob/Sheep$1.java | 0 .../java/com/mojang/minecraft/mob/Sheep.java | 9 +- .../com/mojang/minecraft/mob/Skeleton$1.java | 0 .../com/mojang/minecraft/mob/Skeleton.java | 0 .../java/com/mojang/minecraft/mob/Spider.java | 0 .../java/com/mojang/minecraft/mob/Zombie.java | 0 .../java/com/mojang/minecraft/mob/ai/AI.java | 0 .../com/mojang/minecraft/mob/ai/BasicAI.java | 0 .../minecraft/mob/ai/BasicAttackAI.java | 0 .../mojang/minecraft/mob/ai/JumpAttackAI.java | 0 .../mojang/minecraft/model/AnimalModel.java | 0 .../mojang/minecraft/model/CreeperModel.java | 0 .../mojang/minecraft/model/HumanoidModel.java | 0 .../com/mojang/minecraft/model/Model.java | 0 .../mojang/minecraft/model/ModelManager.java | 0 .../com/mojang/minecraft/model/ModelPart.java | 12 +- .../com/mojang/minecraft/model/PigModel.java | 0 .../mojang/minecraft/model/SheepFurModel.java | 0 .../mojang/minecraft/model/SheepModel.java | 0 .../mojang/minecraft/model/SkeletonModel.java | 0 .../mojang/minecraft/model/SpiderModel.java | 0 .../mojang/minecraft/model/TexturedQuad.java | 0 .../com/mojang/minecraft/model/Vec3D.java | 0 .../com/mojang/minecraft/model/Vertex.java | 0 .../mojang/minecraft/model/ZombieModel.java | 0 .../mojang/minecraft/net/NetworkPlayer.java | 62 +- .../mojang/minecraft/net/PositionUpdate.java | 0 .../minecraft/net/SkinDownloadThread.java | 46 + .../mojang/minecraft/particle/Particle.java | 0 .../minecraft/particle/ParticleManager.java | 8 +- .../minecraft/particle/SmokeParticle.java | 0 .../minecraft/particle/TerrainParticle.java | 0 .../minecraft/particle/WaterDropParticle.java | 0 .../java/com/mojang/minecraft/phys/AABB.java | 0 .../mojang/minecraft/player/InputHandler.java | 0 .../minecraft/player/InputHandlerImpl.java | 0 .../mojang/minecraft/player/Inventory.java | 0 .../com/mojang/minecraft/player/Player$1.java | 0 .../com/mojang/minecraft/player/Player.java | 30 +- .../com/mojang/minecraft/render/Chunk.java | 0 .../render/ChunkDirtyDistanceComparator.java | 0 .../render/ChunkDistanceComparator.java | 0 .../com/mojang/minecraft/render/Frustrum.java | 0 .../mojang/minecraft/render/FrustrumImpl.java | 10 +- .../mojang/minecraft/render/HeldBlock.java | 0 .../minecraft/render/LevelRenderer.java | 45 +- .../com/mojang/minecraft/render/Renderer.java | 6 +- .../minecraft/render/ShapeRenderer.java | 65 +- .../minecraft/render/TextureManager.java | 117 + .../minecraft/render/texture/TextureFX.java | 0 .../render/texture/TextureLavaFX.java | 0 .../render/texture/TextureWaterFX.java | 0 .../java/com/mojang/util/MathHelper.java | 30 + .../java/de/jarnbjo/ogg/BasicStream.java | 0 .../java/de/jarnbjo/ogg/CachedUrlStream.java | 0 .../jarnbjo/ogg/EndOfOggStreamException.java | 0 .../java/de/jarnbjo/ogg/FileStream.java | 0 .../java/de/jarnbjo/ogg/LogicalOggStream.java | 0 .../de/jarnbjo/ogg/LogicalOggStreamImpl.java | 0 .../de/jarnbjo/ogg/OggFormatException.java | 0 .../java/de/jarnbjo/ogg/OggPage.java | 0 .../de/jarnbjo/ogg/OnDemandUrlStream.java | 0 .../de/jarnbjo/ogg/PhysicalOggStream.java | 0 .../de/jarnbjo/ogg/UncachedUrlStream.java | 0 .../util/audio/FadeableAudioInputStream.java | 0 .../de/jarnbjo/util/io/BitInputStream.java | 0 .../util/io/ByteArrayBitInputStream.java | 0 .../java/de/jarnbjo/util/io/HuffmanNode.java | 0 .../java/de/jarnbjo/vorbis/AudioPacket.java | 0 .../java/de/jarnbjo/vorbis/CodeBook.java | 0 .../java/de/jarnbjo/vorbis/CommentHeader.java | 0 .../java/de/jarnbjo/vorbis/Floor.java | 0 .../java/de/jarnbjo/vorbis/Floor0.java | 0 .../java/de/jarnbjo/vorbis/Floor1.java | 0 .../java/de/jarnbjo/vorbis/Floor1.java~1~ | 0 .../jarnbjo/vorbis/IdentificationHeader.java | 0 .../java/de/jarnbjo/vorbis/Mapping.java | 0 .../java/de/jarnbjo/vorbis/Mapping0.java | 0 .../java/de/jarnbjo/vorbis/MdctFloat.java | 0 .../java/de/jarnbjo/vorbis/Mode.java | 0 .../java/de/jarnbjo/vorbis/Residue.java | 0 .../java/de/jarnbjo/vorbis/Residue0.java | 0 .../java/de/jarnbjo/vorbis/Residue1.java | 0 .../java/de/jarnbjo/vorbis/Residue2.java | 0 .../java/de/jarnbjo/vorbis/SetupHeader.java | 0 .../java/de/jarnbjo/vorbis/Util.java | 0 .../jarnbjo/vorbis/VorbisAudioFileReader.java | 0 .../jarnbjo/vorbis/VorbisFormatException.java | 0 .../java/de/jarnbjo/vorbis/VorbisStream.java | 0 .../glemu/FixedFunctionShader.java | 2 +- .../net/PeytonPlayz585/glemu/GLObjectMap.java | 0 .../PeytonPlayz585/glemu/vector/Matrix.java | 0 .../PeytonPlayz585/glemu/vector/Matrix2f.java | 0 .../PeytonPlayz585/glemu/vector/Matrix3f.java | 0 .../PeytonPlayz585/glemu/vector/Matrix4f.java | 0 .../glemu/vector/Quaternion.java | 0 .../glemu/vector/ReadableVector.java | 0 .../glemu/vector/ReadableVector2f.java | 0 .../glemu/vector/ReadableVector3f.java | 0 .../glemu/vector/ReadableVector4f.java | 0 .../PeytonPlayz585/glemu/vector/Vector.java | 0 .../PeytonPlayz585/glemu/vector/Vector2f.java | 0 .../PeytonPlayz585/glemu/vector/Vector3f.java | 0 .../PeytonPlayz585/glemu/vector/Vector4f.java | 0 .../glemu/vector/WritableVector2f.java | 0 .../glemu/vector/WritableVector3f.java | 0 .../glemu/vector/WritableVector4f.java | 0 .../net/PeytonPlayz585/math/MathHelper.java | 29 + .../eaglercraft/AssetRepository.java} | 9 +- .../net/lax1dude/eaglercraft}/Base64.java | 2 +- .../net/lax1dude/eaglercraft}/BaseNCodec.java | 4 +- .../java/net/lax1dude/eaglercraft/Client.java | 138 ++ .../lax1dude/eaglercraft/EaglerImage.java} | 15 +- .../lax1dude/eaglercraft/EarlyLoadScreen.java | 180 ++ .../lax1dude/eaglercraft}/GLAllocation.java | 18 +- .../lax1dude/eaglercraft}/GeneralDigest.java | 2 +- .../net/lax1dude/eaglercraft}/SHA1Digest.java | 2 +- .../lax1dude/eaglercraft/TestFilesystem.java | 121 + .../adapter/EaglerAdapterImpl2.java | 1976 +++++++++++++++++ .../eaglercraft/adapter/Tessellator.java | 349 +++ .../adapter/teavm/BufferConverter.java | 34 + .../adapter/teavm/IDBObjectStorePatched.java | 79 + .../adapter/teavm/IndexedDBFilesystem.java | 427 ++++ .../teavm/WebGL2RenderingContext.java | 4 +- .../adapter}/teavm/WebGLQuery.java | 4 +- .../adapter}/teavm/WebGLVertexArray.java | 4 +- .../org/lwjgl/opengl/EaglerAdapterGL30.java} | 81 +- src/teavm/java/org/lwjgl/opengl/GL11.java | 5 + .../org/lwjgl/opengl}/RealOpenGLEnums.java | 2 +- 225 files changed, 4083 insertions(+), 3275 deletions(-) delete mode 100644 src/main/java/com/mojang/minecraft/gui/GuiMods.java delete mode 100644 src/main/java/com/mojang/minecraft/gui/GuiMore.java delete mode 100644 src/main/java/com/mojang/minecraft/gui/GuiOptifine.java delete mode 100644 src/main/java/com/mojang/minecraft/gui/LevelNameScreen.java delete mode 100644 src/main/java/com/mojang/minecraft/level/tile/DirtBlock.java delete mode 100644 src/main/java/com/mojang/minecraft/net/PacketType.java delete mode 100644 src/main/java/com/mojang/minecraft/render/RenderEngine.java delete mode 100644 src/main/java/com/mojang/minecraft/render/TextureBase.java delete mode 100644 src/main/java/com/mojang/minecraft/render/TextureLocation.java delete mode 100644 src/main/java/com/mojang/util/MathHelper.java delete mode 100644 src/main/java/net/PeytonPlayz585/lwjgl/KeyboardConstants.java delete mode 100644 src/main/java/net/PeytonPlayz585/lwjgl/LWJGL.java delete mode 100644 src/main/java/net/PeytonPlayz585/lwjgl/LWJGLUtils.java delete mode 100644 src/main/java/net/PeytonPlayz585/lwjgl/ModeBuffer.java delete mode 100644 src/main/java/net/PeytonPlayz585/lwjgl/PlatformInput.java delete mode 100644 src/main/java/net/PeytonPlayz585/main/MinecraftMain.java delete mode 100644 src/main/java/org/lwjgl/BufferUtils.java delete mode 100644 src/main/java/org/lwjgl/input/Keyboard.java delete mode 100644 src/main/java/org/lwjgl/input/Mouse.java delete mode 100644 src/main/java/org/lwjgl/opengl/Display.java delete mode 100644 src/main/java/org/lwjgl/opengl/GL11.java rename src/{main => teavm}/java/com/mojang/minecraft/ChatLine.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/Entity.java (94%) rename src/{main => teavm}/java/com/mojang/minecraft/GameSettings.java (69%) rename src/{main => teavm}/java/com/mojang/minecraft/KeyBinding.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/Minecraft.java (85%) rename src/{main => teavm}/java/com/mojang/minecraft/MovingObjectPosition.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/ProgressBarDisplay.java (89%) rename src/{main => teavm}/java/com/mojang/minecraft/SessionData.java (97%) create mode 100644 src/teavm/java/com/mojang/minecraft/SkinDownloadThread.java rename src/{main => teavm}/java/com/mojang/minecraft/SleepForeverThread.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/StopGameException.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/Timer.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gamemode/CreativeGameMode.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gamemode/GameMode.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gamemode/SurvivalGameMode.java (92%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/BlockSelectScreen.java (90%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/Button.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/ChatInputScreen.java (89%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/ControlsScreen.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/ErrorScreen.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/FontRenderer.java (84%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/GameOverScreen.java (82%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/GenerateLevelScreen.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/GuiScreen.java (80%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/HUDScreen.java (92%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/OptionButton.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/OptionsScreen.java (86%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/PauseScreen.java (73%) rename src/{main => teavm}/java/com/mojang/minecraft/gui/Screen.java (96%) rename src/{main => teavm}/java/com/mojang/minecraft/item/Arrow.java (92%) rename src/{main => teavm}/java/com/mojang/minecraft/item/Item.java (88%) rename src/{main => teavm}/java/com/mojang/minecraft/item/ItemModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/item/PrimedTnt.java (90%) rename src/{main => teavm}/java/com/mojang/minecraft/item/TakeEntityAnim.java (81%) rename src/{main => teavm}/java/com/mojang/minecraft/level/BlockMap$Slot.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/BlockMap.java (95%) rename src/{main => teavm}/java/com/mojang/minecraft/level/Level.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/LevelIO.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/LevelObjectInputStream.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/MobSpawner.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/NextTickListEntry.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/SyntheticClass.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/generator/LevelGenerator.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/generator/noise/CombinedNoise.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/generator/noise/Noise.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/generator/noise/OctaveNoise.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/generator/noise/PerlinNoise.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/liquid/LiquidType.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/Block.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/BookshelfBlock.java (58%) create mode 100644 src/teavm/java/com/mojang/minecraft/level/tile/DirtBlock.java rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/FlowerBlock.java (90%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/GlassBlock.java (86%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/GrassBlock.java (79%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/LeavesBaseBlock.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/LeavesBlock.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/LiquidBlock.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/MetalBlock.java (55%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/MushroomBlock.java (70%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/OreBlock.java (71%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/SandBlock.java (82%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/SaplingBlock.java (79%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/SlabBlock.java (84%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/SpongeBlock.java (79%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/StillLiquidBlock.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/StoneBlock.java (53%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/TNTBlock.java (81%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/Tile$SoundType.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/level/tile/WoodBlock.java (67%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Creeper$1.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Creeper.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/HumanoidMob.java (85%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Mob.java (92%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Pig.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/QuadrupedMob.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Sheep$1.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Sheep.java (88%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Skeleton$1.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Skeleton.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Spider.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/Zombie.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/ai/AI.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/ai/BasicAI.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/ai/BasicAttackAI.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/mob/ai/JumpAttackAI.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/AnimalModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/CreeperModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/HumanoidModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/Model.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/ModelManager.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/ModelPart.java (92%) rename src/{main => teavm}/java/com/mojang/minecraft/model/PigModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/SheepFurModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/SheepModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/SkeletonModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/SpiderModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/TexturedQuad.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/Vec3D.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/Vertex.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/model/ZombieModel.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/net/NetworkPlayer.java (74%) rename src/{main => teavm}/java/com/mojang/minecraft/net/PositionUpdate.java (100%) create mode 100644 src/teavm/java/com/mojang/minecraft/net/SkinDownloadThread.java rename src/{main => teavm}/java/com/mojang/minecraft/particle/Particle.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/particle/ParticleManager.java (77%) rename src/{main => teavm}/java/com/mojang/minecraft/particle/SmokeParticle.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/particle/TerrainParticle.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/particle/WaterDropParticle.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/phys/AABB.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/player/InputHandler.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/player/InputHandlerImpl.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/player/Inventory.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/player/Player$1.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/player/Player.java (78%) rename src/{main => teavm}/java/com/mojang/minecraft/render/Chunk.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/render/ChunkDirtyDistanceComparator.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/render/ChunkDistanceComparator.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/render/Frustrum.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/render/FrustrumImpl.java (94%) rename src/{main => teavm}/java/com/mojang/minecraft/render/HeldBlock.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/render/LevelRenderer.java (87%) rename src/{main => teavm}/java/com/mojang/minecraft/render/Renderer.java (95%) rename src/{main => teavm}/java/com/mojang/minecraft/render/ShapeRenderer.java (69%) create mode 100644 src/teavm/java/com/mojang/minecraft/render/TextureManager.java rename src/{main => teavm}/java/com/mojang/minecraft/render/texture/TextureFX.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/render/texture/TextureLavaFX.java (100%) rename src/{main => teavm}/java/com/mojang/minecraft/render/texture/TextureWaterFX.java (100%) create mode 100644 src/teavm/java/com/mojang/util/MathHelper.java rename src/{main => teavm}/java/de/jarnbjo/ogg/BasicStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/CachedUrlStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/EndOfOggStreamException.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/FileStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/LogicalOggStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/LogicalOggStreamImpl.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/OggFormatException.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/OggPage.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/OnDemandUrlStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/PhysicalOggStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/ogg/UncachedUrlStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/util/audio/FadeableAudioInputStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/util/io/BitInputStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/util/io/ByteArrayBitInputStream.java (100%) rename src/{main => teavm}/java/de/jarnbjo/util/io/HuffmanNode.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/AudioPacket.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/CodeBook.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/CommentHeader.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Floor.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Floor0.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Floor1.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Floor1.java~1~ (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/IdentificationHeader.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Mapping.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Mapping0.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/MdctFloat.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Mode.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Residue.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Residue0.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Residue1.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Residue2.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/SetupHeader.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/Util.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/VorbisAudioFileReader.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/VorbisFormatException.java (100%) rename src/{main => teavm}/java/de/jarnbjo/vorbis/VorbisStream.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java (99%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/GLObjectMap.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Matrix.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Quaternion.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Vector.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Vector2f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Vector3f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/Vector4f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java (100%) rename src/{main => teavm}/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java (100%) create mode 100644 src/teavm/java/net/PeytonPlayz585/math/MathHelper.java rename src/{main/java/net/PeytonPlayz585/minecraft/MinecraftClient.java => teavm/java/net/lax1dude/eaglercraft/AssetRepository.java} (95%) rename src/{main/java/net/PeytonPlayz585/minecraft => teavm/java/net/lax1dude/eaglercraft}/Base64.java (99%) rename src/{main/java/net/PeytonPlayz585/minecraft => teavm/java/net/lax1dude/eaglercraft}/BaseNCodec.java (99%) create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/Client.java rename src/{main/java/net/PeytonPlayz585/minecraft/MinecraftImage.java => teavm/java/net/lax1dude/eaglercraft/EaglerImage.java} (64%) create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java rename src/{main/java/net/PeytonPlayz585/minecraft => teavm/java/net/lax1dude/eaglercraft}/GLAllocation.java (63%) rename src/{main/java/net/PeytonPlayz585/minecraft => teavm/java/net/lax1dude/eaglercraft}/GeneralDigest.java (97%) rename src/{main/java/net/PeytonPlayz585/minecraft => teavm/java/net/lax1dude/eaglercraft}/SHA1Digest.java (99%) create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/TestFilesystem.java create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IDBObjectStorePatched.java create mode 100644 src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IndexedDBFilesystem.java rename src/{main/java/net/PeytonPlayz585 => teavm/java/net/lax1dude/eaglercraft/adapter}/teavm/WebGL2RenderingContext.java (96%) rename src/{main/java/net/PeytonPlayz585 => teavm/java/net/lax1dude/eaglercraft/adapter}/teavm/WebGLQuery.java (61%) rename src/{main/java/net/PeytonPlayz585 => teavm/java/net/lax1dude/eaglercraft/adapter}/teavm/WebGLVertexArray.java (63%) rename src/{main/java/net/PeytonPlayz585/minecraft/GlStateManager.java => teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java} (93%) create mode 100644 src/teavm/java/org/lwjgl/opengl/GL11.java rename src/{main/java/net/PeytonPlayz585/lwjgl => teavm/java/org/lwjgl/opengl}/RealOpenGLEnums.java (99%) diff --git a/src/main/java/com/mojang/minecraft/gui/GuiMods.java b/src/main/java/com/mojang/minecraft/gui/GuiMods.java deleted file mode 100644 index 85292ea..0000000 --- a/src/main/java/com/mojang/minecraft/gui/GuiMods.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.mojang.minecraft.gui; - -import com.mojang.minecraft.Minecraft; - -public class GuiMods extends GuiScreen { - GuiScreen parent = null; - String title = "Optifine"; - - public GuiMods(GuiScreen parent) { - this.parent = parent; - } - - public final void onOpen() { - this.buttons.add(new OptionButton(1, this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 + 24 * (0 >> 1), minecraft.settings.getSetting(11))); - this.buttons.add(new OptionButton(2, this.width / 2 - 155 + 1 % 2 * 160, this.height / 6 + 24 * (1 >> 1), minecraft.settings.getSetting(12))); - this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done")); - } - - public final void onButtonClick(Button var1) { - if(var1.id == 1) { - minecraft.settings.toggleSetting(11, 0); - var1.text = minecraft.settings.getSetting(11); - } - - if(var1.id == 2) { - minecraft.settings.toggleSetting(12, 0); - var1.text = minecraft.settings.getSetting(12); - } - - if(var1.id == 200) { - minecraft.setCurrentScreen(parent); - } - } - - public final void render(int var1, int var2) { - drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624); - drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215); - super.render(var1, var2); - } -} diff --git a/src/main/java/com/mojang/minecraft/gui/GuiMore.java b/src/main/java/com/mojang/minecraft/gui/GuiMore.java deleted file mode 100644 index f216795..0000000 --- a/src/main/java/com/mojang/minecraft/gui/GuiMore.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.mojang.minecraft.gui; - -import com.mojang.minecraft.Minecraft; - -public class GuiMore extends GuiScreen { - GuiScreen parent = null; - String title; - - public GuiMore(GuiScreen parent) { - this.parent = parent; - this.title = "More Options..."; - } - - public final void onOpen() { - this.buttons.add(new Button(50, this.width / 2 - 100, this.height / 6 + 0 + 12, "Mods")); - this.buttons.add(new Button(100, this.width / 2 - 100, this.height / 6 + 25 + 12, "Optifine")); - this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done")); - } - - public final void onButtonClick(Button var1) { - - if(var1.id == 50) { - minecraft.setCurrentScreen(new GuiMods(this)); - } - - if(var1.id == 100) { - minecraft.setCurrentScreen(new GuiOptifine(this)); - } - - if(var1.id == 200) { - minecraft.setCurrentScreen(parent); - } - } - - public final void render(int var1, int var2) { - drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624); - drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215); - super.render(var1, var2); - } -} diff --git a/src/main/java/com/mojang/minecraft/gui/GuiOptifine.java b/src/main/java/com/mojang/minecraft/gui/GuiOptifine.java deleted file mode 100644 index 05bdcff..0000000 --- a/src/main/java/com/mojang/minecraft/gui/GuiOptifine.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.mojang.minecraft.gui; - -import com.mojang.minecraft.Minecraft; - -public class GuiOptifine extends GuiScreen { - GuiScreen parent = null; - String title = "Optifine"; - - public GuiOptifine(GuiScreen parent) { - this.parent = parent; - } - - public final void onOpen() { - this.buttons.add(new OptionButton(1, this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 + 24 * (0 >> 1), minecraft.settings.getSetting(8))); - this.buttons.add(new OptionButton(2, this.width / 2 - 155 + 1 % 2 * 160, this.height / 6 + 24 * (1 >> 1), minecraft.settings.getSetting(9))); - this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done")); - } - - public final void onButtonClick(Button var1) { - if(var1.id == 1) { - minecraft.settings.toggleSetting(8, 0); - var1.text = minecraft.settings.getSetting(8); - } - - if(var1.id == 2) { - minecraft.settings.toggleSetting(9, 0); - var1.text = minecraft.settings.getSetting(9); - } - - if(var1.id == 200) { - minecraft.setCurrentScreen(parent); - } - } - - public final void render(int var1, int var2) { - drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624); - drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215); - super.render(var1, var2); - } -} diff --git a/src/main/java/com/mojang/minecraft/gui/LevelNameScreen.java b/src/main/java/com/mojang/minecraft/gui/LevelNameScreen.java deleted file mode 100644 index 3c7ee76..0000000 --- a/src/main/java/com/mojang/minecraft/gui/LevelNameScreen.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.mojang.minecraft.gui; - -import com.mojang.minecraft.Minecraft; -import com.mojang.minecraft.gui.Button; -import com.mojang.minecraft.gui.GuiScreen; -import org.lwjgl.input.Keyboard; - -public final class LevelNameScreen extends GuiScreen { - - private GuiScreen parent; - private String title = "Enter level name:"; - private int id; - private String name; - private int counter = 0; - - - public LevelNameScreen(GuiScreen var1, String var2, int var3) { - this.parent = var1; - this.id = var3; - this.name = var2; - if(this.name.equals("-")) { - this.name = ""; - } - - } - - public final void onOpen() { - this.buttons.clear(); - Keyboard.enableRepeatEvents(true); - this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 120, "Save")); - this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 144, "Cancel")); - ((Button)this.buttons.get(0)).active = this.name.trim().length() > 1; - } - - public final void onClose() { - Keyboard.enableRepeatEvents(false); - } - - public final void tick() { - ++this.counter; - } - - protected final void onButtonClick(Button var1) { - if(var1.active) { - if(var1.id == 0 && this.name.trim().length() > 1) { - Minecraft var10000 = this.minecraft; - int var10001 = this.id; - String var2 = this.name.trim(); - int var3 = var10001; - Minecraft var4 = var10000; - var10000.levelIo.saveOnline(var4.level, var4.host, var4.session.username, var4.session.sessionId, var2, var3); - this.minecraft.setCurrentScreen((GuiScreen)null); - this.minecraft.grabMouse(); - } - - if(var1.id == 1) { - this.minecraft.setCurrentScreen(this.parent); - } - - } - } - - protected final void onKeyPress(char var1, int var2) { - if(var2 == 14 && this.name.length() > 0) { - this.name = this.name.substring(0, this.name.length() - 1); - } - - if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_\'*!\"#%/()=+?[]{}<>".indexOf(var1) >= 0 && this.name.length() < 64) { - this.name = this.name + var1; - } - - ((Button)this.buttons.get(0)).active = this.name.trim().length() > 1; - } - - public final void render(int var1, int var2) { - drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624); - drawCenteredString(this.fontRenderer, this.title, this.width / 2, 40, 16777215); - int var3 = this.width / 2 - 100; - int var4 = this.height / 2 - 10; - drawBox(var3 - 1, var4 - 1, var3 + 200 + 1, var4 + 20 + 1, -6250336); - drawBox(var3, var4, var3 + 200, var4 + 20, -16777216); - drawString(this.fontRenderer, this.name + (this.counter / 6 % 2 == 0?"_":""), var3 + 4, var4 + 6, 14737632); - super.render(var1, var2); - } -} diff --git a/src/main/java/com/mojang/minecraft/level/tile/DirtBlock.java b/src/main/java/com/mojang/minecraft/level/tile/DirtBlock.java deleted file mode 100644 index fa0b366..0000000 --- a/src/main/java/com/mojang/minecraft/level/tile/DirtBlock.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mojang.minecraft.level.tile; - -import java.util.Random; - -import com.mojang.minecraft.Minecraft; -import com.mojang.minecraft.level.tile.Block; - -public final class DirtBlock extends Block { - - protected DirtBlock(int var1, int var2) { - super(3, 2); - } - - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.DIRT.id; - } -} diff --git a/src/main/java/com/mojang/minecraft/net/PacketType.java b/src/main/java/com/mojang/minecraft/net/PacketType.java deleted file mode 100644 index 9d3ca6f..0000000 --- a/src/main/java/com/mojang/minecraft/net/PacketType.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.mojang.minecraft.net; - -public class PacketType -{ - private PacketType(Class ... classes) - { - opcode = (byte)(nextOpcode++); - packets[opcode] = this; - params = new Class[classes.length]; - - int length = 0; - - for(int classNumber = 0; classNumber < classes.length; classNumber++) - { - Class class_ = classes[classNumber]; - - params[classNumber] = class_; - - if(class_ == Long.TYPE) - { - length += 8; - } else if(class_ == Integer.TYPE) { - length += 4; - } else if(class_ == Short.TYPE) { - length += 2; - } else if(class_ == Byte.TYPE) { - ++length; - } else if(class_ == Float.TYPE) { - length += 4; - } else if(class_ == Double.TYPE) { - length += 8; - } else if(class_ == byte[].class) { - length += 1024; - } else if(class_ == String.class) { - length += 64; - } - } - - this.length = length; - } - - public static final PacketType[] packets = new PacketType[256]; - - public static final PacketType IDENTIFICATION = new PacketType(new Class[] {Byte.TYPE, String.class, String.class, Byte.TYPE}); - public static final PacketType LEVEL_INIT; - public static final PacketType LEVEL_DATA; - public static final PacketType LEVEL_FINALIZE; - public static final PacketType PLAYER_SET_BLOCK; - public static final PacketType BLOCK_CHANGE; - public static final PacketType SPAWN_PLAYER; - public static final PacketType POSITION_ROTATION; - public static final PacketType POSITION_ROTATION_UPDATE; - public static final PacketType POSITION_UPDATE; - public static final PacketType ROTATION_UPDATE; - public static final PacketType DESPAWN_PLAYER; - public static final PacketType CHAT_MESSAGE; - public static final PacketType DISCONNECT; - public static final PacketType UPDATE_PLAYER_TYPE; - - public int length; - private static int nextOpcode; - public byte opcode; - public Class[] params; - - static - { - new PacketType(new Class[0]); - - LEVEL_INIT = new PacketType(new Class[0]); - LEVEL_DATA = new PacketType(new Class[] {Short.TYPE, byte[].class, Byte.TYPE}); - LEVEL_FINALIZE = new PacketType(new Class[] {Short.TYPE, Short.TYPE, Short.TYPE}); - PLAYER_SET_BLOCK = new PacketType(new Class[] {Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE}); - BLOCK_CHANGE = new PacketType(new Class[] {Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE}); - SPAWN_PLAYER = new PacketType(new Class[] {Byte.TYPE, String.class, Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE}); - POSITION_ROTATION = new PacketType(new Class[] {Byte.TYPE, Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE}); - POSITION_ROTATION_UPDATE = new PacketType(new Class[] {Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE}); - POSITION_UPDATE = new PacketType(new Class[] {Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE}); - ROTATION_UPDATE = new PacketType(new Class[] {Byte.TYPE, Byte.TYPE, Byte.TYPE}); - DESPAWN_PLAYER = new PacketType(new Class[] {Byte.TYPE}); - CHAT_MESSAGE = new PacketType(new Class[] {Byte.TYPE, String.class}); - DISCONNECT = new PacketType(new Class[] {String.class}); - UPDATE_PLAYER_TYPE = new PacketType(new Class[] {Byte.TYPE}); - - nextOpcode = 0; - } -} diff --git a/src/main/java/com/mojang/minecraft/render/RenderEngine.java b/src/main/java/com/mojang/minecraft/render/RenderEngine.java deleted file mode 100644 index 85ed2f0..0000000 --- a/src/main/java/com/mojang/minecraft/render/RenderEngine.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.mojang.minecraft.render; - -import java.util.ArrayList; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.util.HashMap; - -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; - -import com.mojang.minecraft.GameSettings; -import com.mojang.minecraft.Minecraft; -import com.mojang.minecraft.render.texture.TextureFX; - -import net.PeytonPlayz585.lwjgl.LWJGLUtils; -import net.PeytonPlayz585.minecraft.GLAllocation; -import net.PeytonPlayz585.minecraft.MinecraftImage; - -public class RenderEngine { - - public RenderEngine() { - textureMap = new HashMap(); - textureNameToImageMap = new HashMap(); - singleIntBuffer = BufferUtils.createIntBuffer(1); - imageDataB1 = BufferUtils.createByteBuffer(0x100000); - imageDataB2 = BufferUtils.createByteBuffer(0x100000); - textureList = new ArrayList(); - options = Minecraft.settings; - } - - public int getTexture(String s) { - TextureBase texturebase = new TextureBase(); - Integer integer = (Integer) textureMap.get(s); - if (integer != null) { - return integer.intValue(); - } - try { - singleIntBuffer.clear(); - GLAllocation.generateTextureNames(singleIntBuffer); - int i = singleIntBuffer.get(0); - if(s.equals("/terrain.png")) { - useMipmaps = true; - } - setupTexture(readTextureImage(texturebase.func_6481_a(s)), i); - useMipmaps = false; - textureMap.put(s, Integer.valueOf(i)); - return i; - } catch (IOException ioexception) { - throw new RuntimeException("!!"); - } - } - - public void setupTexture(MinecraftImage bufferedimage, int i) { - bindTexture(i); - if (useMipmaps) { - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, GL11.GL_NEAREST_MIPMAP_LINEAR); - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, GL11.GL_NEAREST /* GL_LINEAR */); - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, GL11.GL_TEXTURE_MAX_LEVEL, 4); - } else { - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */); - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */); - } - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */); - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */); - - int j = bufferedimage.w; - int k = bufferedimage.h; - int ai[] = bufferedimage.data; - byte abyte0[] = new byte[j * k * 4]; - for (int l = 0; l < ai.length; l++) { - int j1 = ai[l] >> 24 & 0xff; - int l1 = ai[l] >> 16 & 0xff; - int j2 = ai[l] >> 8 & 0xff; - int l2 = ai[l] >> 0 & 0xff; - if (options != null && options.anaglyph) { - int j3 = (l1 * 30 + j2 * 59 + l2 * 11) / 100; - int l3 = (l1 * 30 + j2 * 70) / 100; - int j4 = (l1 * 30 + l2 * 70) / 100; - l1 = j3; - j2 = l3; - l2 = j4; - } - abyte0[l * 4 + 0] = (byte) l1; - abyte0[l * 4 + 1] = (byte) j2; - abyte0[l * 4 + 2] = (byte) l2; - abyte0[l * 4 + 3] = (byte) j1; - } - imageDataB1.clear(); - imageDataB1.put(abyte0); - imageDataB1.position(0).limit(abyte0.length); - GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */, - 5121 /* GL_UNSIGNED_BYTE */, imageDataB1); - if (useMipmaps) { - for (int i1 = 1; i1 <= 4; i1++) { - int k1 = j >> i1 - 1; - int i2 = j >> i1; - int k2 = k >> i1; - imageDataB2.clear(); - for (int i3 = 0; i3 < i2; i3++) { - for (int k3 = 0; k3 < k2; k3++) { - int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4); - int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4); - int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4); - int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4); - int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5)); - imageDataB2.putInt((i3 + k3 * i2) * 4, j5); - } - - } - - GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */, - 5121 /* GL_UNSIGNED_BYTE */, imageDataB2); - ByteBuffer tmp = imageDataB1; - imageDataB1 = imageDataB2; - imageDataB2 = tmp; - } - - } - } - - public void bindTexture(int i) { - if (i < 0) { - return; - } else { - GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, i); - return; - } - } - - private int averageColor(int i, int j) { - int k = (i & 0xff000000) >> 24 & 0xff; - int l = (j & 0xff000000) >> 24 & 0xff; - return ((k + l >> 1) << 24) + ((i & 0xfefefe) + (j & 0xfefefe) >> 1); - } - - private MinecraftImage readTextureImage(byte[] inputstream) throws IOException { - return LWJGLUtils.loadPNG(inputstream); - } - - public static boolean useMipmaps = false; - private HashMap textureMap; - private HashMap textureNameToImageMap; - private IntBuffer singleIntBuffer; - private ByteBuffer imageDataB1; - private ByteBuffer imageDataB2; - private java.util.List textureList; - private GameSettings options; -} diff --git a/src/main/java/com/mojang/minecraft/render/TextureBase.java b/src/main/java/com/mojang/minecraft/render/TextureBase.java deleted file mode 100644 index 139c045..0000000 --- a/src/main/java/com/mojang/minecraft/render/TextureBase.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mojang.minecraft.render; - -import org.lwjgl.opengl.GL11; - -public class TextureBase { - - public TextureBase() { - //This overrides the default Java constructor insuring non-instability - } - - public byte[] func_6481_a(String s) { - return GL11.loadResourceBytes(s); - } -} diff --git a/src/main/java/com/mojang/minecraft/render/TextureLocation.java b/src/main/java/com/mojang/minecraft/render/TextureLocation.java deleted file mode 100644 index de52afe..0000000 --- a/src/main/java/com/mojang/minecraft/render/TextureLocation.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.mojang.minecraft.render; - -import java.util.ArrayList; - -public class TextureLocation { - - private String path; - private int glObject; - - public TextureLocation(String path) { - this.path = path; - this.glObject = -1; - locations.add(this); - } - - public static void freeTextures() { - for (TextureLocation l : locations) { - l.glObject = -1; - } - } - - public int getTexturePointer() { - RenderEngine r = new RenderEngine(); - if (glObject == -1) { - glObject = r.getTexture(path); - if (glObject == -1) { - System.err.println("could not load: " + path); - } - } - return glObject; - } - - public void bindTexture() { - RenderEngine r = new RenderEngine(); - int i = getTexturePointer(); - if(i != -1) { - r.bindTexture(i); - } - } - - private static final ArrayList locations = new ArrayList(); - -} \ No newline at end of file diff --git a/src/main/java/com/mojang/util/MathHelper.java b/src/main/java/com/mojang/util/MathHelper.java deleted file mode 100644 index ede92ea..0000000 --- a/src/main/java/com/mojang/util/MathHelper.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.mojang.util; - -import com.mojang.minecraft.Minecraft; - -public final class MathHelper { - - private static float[] SIN_TABLE = new float[65536]; - private static float[] SIN_TABLE_FAST = new float[4096]; - - public static final float sin(float var0) { - if(Minecraft.settings.ofFastMath) { - return SIN_TABLE_FAST[(int)(var0 * 651.8986F) & 4095]; - } else { - return SIN_TABLE[(int)(var0 * 10430.378F) & '\uffff']; - } - } - - public static final float cos(float var0) { - if(Minecraft.settings.ofFastMath) { - return SIN_TABLE_FAST[(int)((var0 + ((float)Math.PI / 2F)) * 651.8986F) & 4095]; - } else { - return SIN_TABLE[(int)(var0 * 10430.378F + 16384.0F) & '\uffff']; - } - } - - public static final float sqrt(float var0) { - return (float)Math.sqrt((double)var0); - } - - static { - for(int var0 = 0; var0 < 65536; ++var0) { - SIN_TABLE[var0] = (float)Math.sin((double)var0 * 3.141592653589793D * 2.0D / 65536.0D); - } - - for (int j = 0; j < 4096; ++j) { - SIN_TABLE_FAST[j] = (float)Math.sin((double)(((float)j + 0.5F) / 4096.0F * ((float)Math.PI * 2F))); - } - - for (int l = 0; l < 360; l += 90) { - SIN_TABLE_FAST[(int)((float)l * 11.377778F) & 4095] = (float)Math.sin((double)((float)l * 0.017453292F)); - } - } -} diff --git a/src/main/java/net/PeytonPlayz585/lwjgl/KeyboardConstants.java b/src/main/java/net/PeytonPlayz585/lwjgl/KeyboardConstants.java deleted file mode 100644 index c1592de..0000000 --- a/src/main/java/net/PeytonPlayz585/lwjgl/KeyboardConstants.java +++ /dev/null @@ -1,268 +0,0 @@ -package net.PeytonPlayz585.lwjgl; - -import org.lwjgl.input.Keyboard; - -/** - * Copyright (c) 2022 LAX1DUDE. All Rights Reserved. - * - * WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES - * NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED - * TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE - * SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR. - * - * NOT FOR COMMERCIAL OR MALICIOUS USE - * - * (please read the 'LICENSE' file this repo's root directory for more info) - * - */ -public class KeyboardConstants { - - private static final String[] keyboardNames = new String[256]; - private static final int[] keyboardGLFWToMinecraft = new int[384]; - private static final int[] keyboardMinecraftToGLFW = new int[256]; - private static final int[] keyboardBrowserToMinecraft = new int[384 * 4]; - private static final int[] keyboardMinecraftToBrowser = new int[256]; - private static final char[] keyboardChars = new char[256]; - - private static final int GLFW_KEY_SPACE = 32, GLFW_KEY_APOSTROPHE = 39, GLFW_KEY_COMMA = 44, GLFW_KEY_MINUS = 45, - GLFW_KEY_PERIOD = 46, GLFW_KEY_SLASH = 47, GLFW_KEY_0 = 48, GLFW_KEY_1 = 49, GLFW_KEY_2 = 50, - GLFW_KEY_3 = 51, GLFW_KEY_4 = 52, GLFW_KEY_5 = 53, GLFW_KEY_6 = 54, GLFW_KEY_7 = 55, GLFW_KEY_8 = 56, - GLFW_KEY_9 = 57, GLFW_KEY_SEMICOLON = 59, GLFW_KEY_EQUAL = 61, GLFW_KEY_A = 65, GLFW_KEY_B = 66, - GLFW_KEY_C = 67, GLFW_KEY_D = 68, GLFW_KEY_E = 69, GLFW_KEY_F = 70, GLFW_KEY_G = 71, GLFW_KEY_H = 72, - GLFW_KEY_I = 73, GLFW_KEY_J = 74, GLFW_KEY_K = 75, GLFW_KEY_L = 76, GLFW_KEY_M = 77, GLFW_KEY_N = 78, - GLFW_KEY_O = 79, GLFW_KEY_P = 80, GLFW_KEY_Q = 81, GLFW_KEY_R = 82, GLFW_KEY_S = 83, GLFW_KEY_T = 84, - GLFW_KEY_U = 85, GLFW_KEY_V = 86, GLFW_KEY_W = 87, GLFW_KEY_X = 88, GLFW_KEY_Y = 89, GLFW_KEY_Z = 90, - GLFW_KEY_LEFT_BRACKET = 91, GLFW_KEY_BACKSLASH = 92, GLFW_KEY_RIGHT_BRACKET = 93, - GLFW_KEY_GRAVE_ACCENT = 96, GLFW_KEY_WORLD_1 = 161, GLFW_KEY_WORLD_2 = 162; - - private static final int GLFW_KEY_ESCAPE = 256, GLFW_KEY_ENTER = 257, GLFW_KEY_TAB = 258, GLFW_KEY_BACKSPACE = 259, - GLFW_KEY_INSERT = 260, GLFW_KEY_DELETE = 261, GLFW_KEY_RIGHT = 262, GLFW_KEY_LEFT = 263, - GLFW_KEY_DOWN = 264, GLFW_KEY_UP = 265, GLFW_KEY_PAGE_UP = 266, GLFW_KEY_PAGE_DOWN = 267, - GLFW_KEY_HOME = 268, GLFW_KEY_END = 269, GLFW_KEY_CAPS_LOCK = 280, GLFW_KEY_SCROLL_LOCK = 281, - GLFW_KEY_NUM_LOCK = 282, GLFW_KEY_PRINT_SCREEN = 283, GLFW_KEY_PAUSE = 284, GLFW_KEY_F1 = 290, - GLFW_KEY_F2 = 291, GLFW_KEY_F3 = 292, GLFW_KEY_F4 = 293, GLFW_KEY_F5 = 294, GLFW_KEY_F6 = 295, - GLFW_KEY_F7 = 296, GLFW_KEY_F8 = 297, GLFW_KEY_F9 = 298, GLFW_KEY_F10 = 299, GLFW_KEY_F11 = 300, - GLFW_KEY_F12 = 301, GLFW_KEY_F13 = 302, GLFW_KEY_F14 = 303, GLFW_KEY_F15 = 304, GLFW_KEY_F16 = 305, - GLFW_KEY_F17 = 306, GLFW_KEY_F18 = 307, GLFW_KEY_F19 = 308, GLFW_KEY_F20 = 309, GLFW_KEY_F21 = 310, - GLFW_KEY_F22 = 311, GLFW_KEY_F23 = 312, GLFW_KEY_F24 = 313, GLFW_KEY_F25 = 314, GLFW_KEY_KP_0 = 320, - GLFW_KEY_KP_1 = 321, GLFW_KEY_KP_2 = 322, GLFW_KEY_KP_3 = 323, GLFW_KEY_KP_4 = 324, GLFW_KEY_KP_5 = 325, - GLFW_KEY_KP_6 = 326, GLFW_KEY_KP_7 = 327, GLFW_KEY_KP_8 = 328, GLFW_KEY_KP_9 = 329, - GLFW_KEY_KP_DECIMAL = 330, GLFW_KEY_KP_DIVIDE = 331, GLFW_KEY_KP_MULTIPLY = 332, GLFW_KEY_KP_SUBTRACT = 333, - GLFW_KEY_KP_ADD = 334, GLFW_KEY_KP_ENTER = 335, GLFW_KEY_KP_EQUAL = 336, GLFW_KEY_LEFT_SHIFT = 340, - GLFW_KEY_LEFT_CONTROL = 341, GLFW_KEY_LEFT_ALT = 342, GLFW_KEY_LEFT_SUPER = 343, GLFW_KEY_RIGHT_SHIFT = 344, - GLFW_KEY_RIGHT_CONTROL = 345, GLFW_KEY_RIGHT_ALT = 346, GLFW_KEY_RIGHT_SUPER = 347, GLFW_KEY_MENU = 348, - GLFW_KEY_LAST = GLFW_KEY_MENU; - - private static final int DOM_KEY_LOCATION_STANDARD = 0, DOM_KEY_LOCATION_LEFT = 1, DOM_KEY_LOCATION_RIGHT = 2, - DOM_KEY_LOCATION_NUMPAD = 3; - - private static void register(int minecraftId, int glfwId, int browserId, int browserLocation, String name, char character) { - if(keyboardMinecraftToGLFW[minecraftId] != 0) throw new IllegalArgumentException("Duplicate keyboardMinecraftToGLFW entry: " + minecraftId + " -> " + glfwId); - keyboardMinecraftToGLFW[minecraftId] = glfwId; - if(keyboardGLFWToMinecraft[glfwId] != 0) throw new IllegalArgumentException("Duplicate keyboardGLFWToMinecraft entry: " + glfwId + " -> " + minecraftId); - keyboardGLFWToMinecraft[glfwId] = minecraftId; - if(browserLocation == 0) { - if(keyboardMinecraftToBrowser[minecraftId] != 0) throw new IllegalArgumentException("Duplicate keyboardMinecraftToBrowser entry: " + minecraftId + " -> " + browserId + "(0)"); - keyboardMinecraftToBrowser[minecraftId] = browserId; - if(keyboardBrowserToMinecraft[browserId] != 0) throw new IllegalArgumentException("Duplicate keyboardBrowserToMinecraft entry: " + browserId + "(0) -> " + minecraftId); - keyboardBrowserToMinecraft[browserId] = minecraftId; - }else { - browserLocation *= 384; - if(keyboardMinecraftToBrowser[minecraftId] != 0) throw new IllegalArgumentException("Duplicate keyboardMinecraftToBrowser entry: " + minecraftId + " -> " + browserId + "(" + browserLocation + ")"); - keyboardMinecraftToBrowser[minecraftId] = browserId + browserLocation; - if(keyboardBrowserToMinecraft[browserId + browserLocation] != 0) throw new IllegalArgumentException("Duplicate keyboardBrowserToMinecraft entry: " + browserId + "(" + browserLocation + ") -> " + minecraftId); - keyboardBrowserToMinecraft[browserId + browserLocation] = minecraftId; - } - if(keyboardNames[minecraftId] != null) throw new IllegalArgumentException("Duplicate keyboardNames entry: " + minecraftId + " -> " + name); - keyboardNames[minecraftId] = name; - if(keyboardChars[minecraftId] != '\0') throw new IllegalArgumentException("Duplicate keyboardChars entry: " + minecraftId + " -> " + character); - keyboardChars[minecraftId] = character; - } - - private static void registerAlt(int minecraftId, int browserId, int browserLocation) { - if(browserLocation == 0) { - if(keyboardBrowserToMinecraft[browserId] != 0) throw new IllegalArgumentException("Duplicate (alt) keyboardBrowserToMinecraft entry: " + browserId + " -> " + minecraftId); - keyboardBrowserToMinecraft[browserId] = minecraftId; - }else { - browserLocation *= 384; - if(keyboardBrowserToMinecraft[browserId + browserLocation] != 0) throw new IllegalArgumentException("Duplicate (alt) keyboardBrowserToMinecraft entry: " + browserId + "(" + browserLocation + ") -> " + minecraftId); - keyboardBrowserToMinecraft[browserId + browserLocation] = minecraftId; - } - } - - static { - register(Keyboard.KEY_SPACE, GLFW_KEY_SPACE, 32, DOM_KEY_LOCATION_STANDARD, "Space", ' '); - register(Keyboard.KEY_APOSTROPHE, GLFW_KEY_APOSTROPHE, 222, DOM_KEY_LOCATION_STANDARD, "Quote", '\''); - register(Keyboard.KEY_COMMA, GLFW_KEY_COMMA, 188, DOM_KEY_LOCATION_STANDARD, "Comma", ','); - register(Keyboard.KEY_MINUS, GLFW_KEY_MINUS, 189, DOM_KEY_LOCATION_STANDARD, "Minus", '-'); - register(Keyboard.KEY_PERIOD, GLFW_KEY_PERIOD, 190, DOM_KEY_LOCATION_STANDARD, "Period", '.'); - register(Keyboard.KEY_SLASH, GLFW_KEY_SLASH, 191, DOM_KEY_LOCATION_STANDARD, "Slash", '/'); - register(Keyboard.KEY_0, GLFW_KEY_0, 48, DOM_KEY_LOCATION_STANDARD, "0", '0'); - register(Keyboard.KEY_1, GLFW_KEY_1, 49, DOM_KEY_LOCATION_STANDARD, "1", '1'); - register(Keyboard.KEY_2, GLFW_KEY_2, 50, DOM_KEY_LOCATION_STANDARD, "2", '2'); - register(Keyboard.KEY_3, GLFW_KEY_3, 51, DOM_KEY_LOCATION_STANDARD, "3", '3'); - register(Keyboard.KEY_4, GLFW_KEY_4, 52, DOM_KEY_LOCATION_STANDARD, "4", '4'); - register(Keyboard.KEY_5, GLFW_KEY_5, 53, DOM_KEY_LOCATION_STANDARD, "5", '5'); - register(Keyboard.KEY_6, GLFW_KEY_6, 54, DOM_KEY_LOCATION_STANDARD, "6", '6'); - register(Keyboard.KEY_7, GLFW_KEY_7, 55, DOM_KEY_LOCATION_STANDARD, "7", '7'); - register(Keyboard.KEY_8, GLFW_KEY_8, 56, DOM_KEY_LOCATION_STANDARD, "8", '8'); - register(Keyboard.KEY_9, GLFW_KEY_9, 57, DOM_KEY_LOCATION_STANDARD, "9", '9'); - register(Keyboard.KEY_SEMICOLON, GLFW_KEY_SEMICOLON, 186, DOM_KEY_LOCATION_STANDARD, "Semicolon", ';'); - register(Keyboard.KEY_EQUALS, GLFW_KEY_EQUAL, 187, DOM_KEY_LOCATION_STANDARD, "Equals", '='); - register(Keyboard.KEY_A, GLFW_KEY_A, 65, DOM_KEY_LOCATION_STANDARD, "A", 'a'); - register(Keyboard.KEY_B, GLFW_KEY_B, 66, DOM_KEY_LOCATION_STANDARD, "B", 'b'); - register(Keyboard.KEY_C, GLFW_KEY_C, 67, DOM_KEY_LOCATION_STANDARD, "C", 'c'); - register(Keyboard.KEY_D, GLFW_KEY_D, 68, DOM_KEY_LOCATION_STANDARD, "D", 'd'); - register(Keyboard.KEY_E, GLFW_KEY_E, 69, DOM_KEY_LOCATION_STANDARD, "E", 'e'); - register(Keyboard.KEY_F, GLFW_KEY_F, 70, DOM_KEY_LOCATION_STANDARD, "F", 'f'); - register(Keyboard.KEY_G, GLFW_KEY_G, 71, DOM_KEY_LOCATION_STANDARD, "G", 'g'); - register(Keyboard.KEY_H, GLFW_KEY_H, 72, DOM_KEY_LOCATION_STANDARD, "H", 'h'); - register(Keyboard.KEY_I, GLFW_KEY_I, 73, DOM_KEY_LOCATION_STANDARD, "I", 'i'); - register(Keyboard.KEY_J, GLFW_KEY_J, 74, DOM_KEY_LOCATION_STANDARD, "J", 'j'); - register(Keyboard.KEY_K, GLFW_KEY_K, 75, DOM_KEY_LOCATION_STANDARD, "K", 'k'); - register(Keyboard.KEY_L, GLFW_KEY_L, 76, DOM_KEY_LOCATION_STANDARD, "L", 'l'); - register(Keyboard.KEY_M, GLFW_KEY_M, 77, DOM_KEY_LOCATION_STANDARD, "M", 'm'); - register(Keyboard.KEY_N, GLFW_KEY_N, 78, DOM_KEY_LOCATION_STANDARD, "N", 'n'); - register(Keyboard.KEY_O, GLFW_KEY_O, 79, DOM_KEY_LOCATION_STANDARD, "O", 'o'); - register(Keyboard.KEY_P, GLFW_KEY_P, 80, DOM_KEY_LOCATION_STANDARD, "P", 'p'); - register(Keyboard.KEY_Q, GLFW_KEY_Q, 81, DOM_KEY_LOCATION_STANDARD, "Q", 'q'); - register(Keyboard.KEY_R, GLFW_KEY_R, 82, DOM_KEY_LOCATION_STANDARD, "R", 'r'); - register(Keyboard.KEY_S, GLFW_KEY_S, 83, DOM_KEY_LOCATION_STANDARD, "S", 's'); - register(Keyboard.KEY_T, GLFW_KEY_T, 84, DOM_KEY_LOCATION_STANDARD, "T", 't'); - register(Keyboard.KEY_U, GLFW_KEY_U, 85, DOM_KEY_LOCATION_STANDARD, "U", 'u'); - register(Keyboard.KEY_V, GLFW_KEY_V, 86, DOM_KEY_LOCATION_STANDARD, "V", 'v'); - register(Keyboard.KEY_W, GLFW_KEY_W, 87, DOM_KEY_LOCATION_STANDARD, "W", 'w'); - register(Keyboard.KEY_X, GLFW_KEY_X, 88, DOM_KEY_LOCATION_STANDARD, "X", 'x'); - register(Keyboard.KEY_Y, GLFW_KEY_Y, 89, DOM_KEY_LOCATION_STANDARD, "Y", 'y'); - register(Keyboard.KEY_Z, GLFW_KEY_Z, 90, DOM_KEY_LOCATION_STANDARD, "Z", 'z'); - register(Keyboard.KEY_LBRACKET, GLFW_KEY_LEFT_BRACKET, 219, DOM_KEY_LOCATION_STANDARD, "L. Bracket", '['); - register(Keyboard.KEY_BACKSLASH, GLFW_KEY_BACKSLASH, 220, DOM_KEY_LOCATION_STANDARD, "Backslash", '\\'); - register(Keyboard.KEY_RBRACKET, GLFW_KEY_RIGHT_BRACKET, 221, DOM_KEY_LOCATION_STANDARD, "R. Bracket", ']'); - register(Keyboard.KEY_GRAVE, GLFW_KEY_GRAVE_ACCENT, 192, DOM_KEY_LOCATION_STANDARD, "Backtick", '`'); - register(Keyboard.KEY_ESCAPE, GLFW_KEY_ESCAPE, 27, DOM_KEY_LOCATION_STANDARD, "Escape", '\0'); - register(Keyboard.KEY_RETURN, GLFW_KEY_ENTER, 13, DOM_KEY_LOCATION_STANDARD, "Enter", '\n'); - register(Keyboard.KEY_TAB, GLFW_KEY_TAB, 9, DOM_KEY_LOCATION_STANDARD, "Tab", '\t'); - register(Keyboard.KEY_BACK, GLFW_KEY_BACKSPACE, 8, DOM_KEY_LOCATION_STANDARD, "Backspace", '\0'); - register(Keyboard.KEY_INSERT, GLFW_KEY_INSERT, 45, DOM_KEY_LOCATION_STANDARD, "Insert", '\0'); - register(Keyboard.KEY_DELETE, GLFW_KEY_DELETE, 46, DOM_KEY_LOCATION_STANDARD, "Delete", '\0'); - register(Keyboard.KEY_RIGHT, GLFW_KEY_RIGHT, 39, DOM_KEY_LOCATION_STANDARD, "Right", '\0'); - register(Keyboard.KEY_LEFT, GLFW_KEY_LEFT, 37, DOM_KEY_LOCATION_STANDARD, "Left", '\0'); - register(Keyboard.KEY_DOWN, GLFW_KEY_DOWN, 40, DOM_KEY_LOCATION_STANDARD, "Down", '\0'); - register(Keyboard.KEY_UP, GLFW_KEY_UP, 38, DOM_KEY_LOCATION_STANDARD, "Up", '\0'); - register(Keyboard.KEY_PRIOR, GLFW_KEY_PAGE_UP, 33, DOM_KEY_LOCATION_STANDARD, "Page Up", '\0'); - register(Keyboard.KEY_NEXT, GLFW_KEY_PAGE_DOWN, 34, DOM_KEY_LOCATION_STANDARD, "Page Down", '\0'); - register(Keyboard.KEY_HOME, GLFW_KEY_HOME, 36, DOM_KEY_LOCATION_STANDARD, "Home", '\0'); - register(Keyboard.KEY_END, GLFW_KEY_END, 35, DOM_KEY_LOCATION_STANDARD, "End", '\0'); - register(Keyboard.KEY_CAPITAL, GLFW_KEY_CAPS_LOCK, 20, DOM_KEY_LOCATION_STANDARD, "Caps Lock", '\0'); - register(Keyboard.KEY_SCROLL, GLFW_KEY_SCROLL_LOCK, 145, DOM_KEY_LOCATION_STANDARD, "Scroll Lock", '\0'); - register(Keyboard.KEY_NUMLOCK, GLFW_KEY_NUM_LOCK, 144, DOM_KEY_LOCATION_STANDARD, "Num Lock", '\0'); - register(Keyboard.KEY_PAUSE, GLFW_KEY_PAUSE, 19, DOM_KEY_LOCATION_STANDARD, "Pause", '\0'); - register(Keyboard.KEY_F1, GLFW_KEY_F1, 112, DOM_KEY_LOCATION_STANDARD, "F1", '\0'); - register(Keyboard.KEY_F2, GLFW_KEY_F2, 113, DOM_KEY_LOCATION_STANDARD, "F2", '\0'); - register(Keyboard.KEY_F3, GLFW_KEY_F3, 114, DOM_KEY_LOCATION_STANDARD, "F3", '\0'); - register(Keyboard.KEY_F4, GLFW_KEY_F4, 115, DOM_KEY_LOCATION_STANDARD, "F4", '\0'); - register(Keyboard.KEY_F5, GLFW_KEY_F5, 116, DOM_KEY_LOCATION_STANDARD, "F5", '\0'); - register(Keyboard.KEY_F6, GLFW_KEY_F6, 117, DOM_KEY_LOCATION_STANDARD, "F6", '\0'); - register(Keyboard.KEY_F7, GLFW_KEY_F7, 118, DOM_KEY_LOCATION_STANDARD, "F7", '\0'); - register(Keyboard.KEY_F8, GLFW_KEY_F8, 119, DOM_KEY_LOCATION_STANDARD, "F8", '\0'); - register(Keyboard.KEY_F9, GLFW_KEY_F9, 120, DOM_KEY_LOCATION_STANDARD, "F9", '\0'); - register(Keyboard.KEY_F10, GLFW_KEY_F10, 121, DOM_KEY_LOCATION_STANDARD, "F10", '\0'); - register(Keyboard.KEY_F11, GLFW_KEY_F11, 122, DOM_KEY_LOCATION_STANDARD, "F11", '\0'); - register(Keyboard.KEY_F12, GLFW_KEY_F12, 123, DOM_KEY_LOCATION_STANDARD, "F12", '\0'); - register(Keyboard.KEY_NUMPAD0, GLFW_KEY_KP_0, 96, DOM_KEY_LOCATION_NUMPAD, "Keypad 0", '0'); - register(Keyboard.KEY_NUMPAD1, GLFW_KEY_KP_1, 97, DOM_KEY_LOCATION_NUMPAD, "Keypad 1", '1'); - register(Keyboard.KEY_NUMPAD2, GLFW_KEY_KP_2, 98, DOM_KEY_LOCATION_NUMPAD, "Keypad 2", '2'); - register(Keyboard.KEY_NUMPAD3, GLFW_KEY_KP_3, 99, DOM_KEY_LOCATION_NUMPAD, "Keypad 3", '3'); - register(Keyboard.KEY_NUMPAD4, GLFW_KEY_KP_4, 100, DOM_KEY_LOCATION_NUMPAD, "Keypad 4", '4'); - register(Keyboard.KEY_NUMPAD5, GLFW_KEY_KP_5, 101, DOM_KEY_LOCATION_NUMPAD, "Keypad 5", '5'); - register(Keyboard.KEY_NUMPAD6, GLFW_KEY_KP_6, 102, DOM_KEY_LOCATION_NUMPAD, "Keypad 6", '6'); - register(Keyboard.KEY_NUMPAD7, GLFW_KEY_KP_7, 103, DOM_KEY_LOCATION_NUMPAD, "Keypad 7", '7'); - register(Keyboard.KEY_NUMPAD8, GLFW_KEY_KP_8, 104, DOM_KEY_LOCATION_NUMPAD, "Keypad 8", '8'); - register(Keyboard.KEY_NUMPAD9, GLFW_KEY_KP_9, 105, DOM_KEY_LOCATION_NUMPAD, "Keypad 9", '9'); - register(Keyboard.KEY_DECIMAL, GLFW_KEY_KP_DECIMAL, 110, DOM_KEY_LOCATION_NUMPAD, "Decimal", '.'); - register(Keyboard.KEY_DIVIDE, GLFW_KEY_KP_DIVIDE, 111, DOM_KEY_LOCATION_NUMPAD, "Divide", '/'); - register(Keyboard.KEY_MULTIPLY, GLFW_KEY_KP_MULTIPLY, 106, DOM_KEY_LOCATION_NUMPAD, "Multiply", '*'); - register(Keyboard.KEY_SUBTRACT, GLFW_KEY_KP_SUBTRACT, 109, DOM_KEY_LOCATION_NUMPAD, "Subtract", '-'); - register(Keyboard.KEY_ADD, GLFW_KEY_KP_ADD, 107, DOM_KEY_LOCATION_NUMPAD, "Add", '+'); - register(Keyboard.KEY_NUMPADENTER, GLFW_KEY_KP_ENTER, 13, DOM_KEY_LOCATION_NUMPAD, "Enter", '\n'); - register(Keyboard.KEY_NUMPADEQUALS, GLFW_KEY_KP_EQUAL, 187, DOM_KEY_LOCATION_NUMPAD, "Equals", '='); - register(Keyboard.KEY_LSHIFT, GLFW_KEY_LEFT_SHIFT, 16, DOM_KEY_LOCATION_LEFT, "L. Shift", '\0'); - register(Keyboard.KEY_LCONTROL, GLFW_KEY_LEFT_CONTROL, 17, DOM_KEY_LOCATION_LEFT, "L. Control", '\0'); - register(Keyboard.KEY_LMENU, GLFW_KEY_LEFT_ALT, 18, DOM_KEY_LOCATION_LEFT, "L. Alt", '\0'); - registerAlt(Keyboard.KEY_LSHIFT, 16, DOM_KEY_LOCATION_STANDARD); - registerAlt(Keyboard.KEY_LCONTROL, 17, DOM_KEY_LOCATION_STANDARD); - registerAlt(Keyboard.KEY_LMENU, 18, DOM_KEY_LOCATION_STANDARD); - register(Keyboard.KEY_RSHIFT, GLFW_KEY_RIGHT_SHIFT, 16, DOM_KEY_LOCATION_RIGHT, "R. Shift", '\0'); - register(Keyboard.KEY_RCONTROL, GLFW_KEY_RIGHT_CONTROL, 17, DOM_KEY_LOCATION_RIGHT, "R. Control", '\0'); - register(Keyboard.KEY_RMENU, GLFW_KEY_RIGHT_ALT, 18, DOM_KEY_LOCATION_RIGHT, "R. Alt", '\0'); - } - - public static String getKeyName(int key) { - if (key < 0 || key >= 256 || keyboardNames[key] == null) { - return "Unknown"; - } else { - return keyboardNames[key]; - } - } - - public static int getMinecraftKeyFromGLFW(int key) { - if (key < 0 || key >= 384) { - return 0; - } else { - return keyboardGLFWToMinecraft[key]; - } - } - - public static int getGLFWKeyFromMinecraft(int key) { - if (key < 0 || key >= 256) { - return 0; - } else { - return keyboardMinecraftToGLFW[key]; - } - } - - public static int getMinecraftKeyFromBrowser(int key) { - return getMinecraftKeyFromBrowser(key, 0); - } - - public static int getMinecraftKeyFromBrowser(int key, int location) { - if (key < 0 || key >= 384) { - return 0; - } else { - if(location <= 0 || location >= 4) { - return keyboardBrowserToMinecraft[key]; - }else { - int i = keyboardBrowserToMinecraft[key + location * 384]; - if(i == 0) { - i = keyboardBrowserToMinecraft[key]; - } - return i; - } - } - } - - public static int getBrowserKeyFromMinecraft(int key) { - if (key < 0 || key >= 256) { - return 0; - } else { - return keyboardMinecraftToBrowser[key] % 384; - } - } - - public static int getBrowserLocationFromMinecraft(int key) { - if (key < 0 || key >= 384) { - return 0; - } else { - return keyboardMinecraftToBrowser[key] / 384; - } - } - - public static char getKeyCharFromMinecraft(int key) { - if (key < 0 || key >= 256) { - return '\0'; - } else { - return keyboardChars[key]; - } - } - -} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/lwjgl/LWJGL.java b/src/main/java/net/PeytonPlayz585/lwjgl/LWJGL.java deleted file mode 100644 index bed46a6..0000000 --- a/src/main/java/net/PeytonPlayz585/lwjgl/LWJGL.java +++ /dev/null @@ -1,586 +0,0 @@ -package net.PeytonPlayz585.lwjgl; - -import static net.PeytonPlayz585.teavm.WebGL2RenderingContext.*; - -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.nio.charset.Charset; - -import org.teavm.jso.JSBody; -import org.teavm.jso.JSObject; -import org.teavm.jso.typedarrays.ArrayBuffer; -import org.teavm.jso.typedarrays.Float32Array; -import org.teavm.jso.typedarrays.Int32Array; -import org.teavm.jso.typedarrays.Uint8Array; -import org.teavm.jso.webgl.WebGLBuffer; -import org.teavm.jso.webgl.WebGLFramebuffer; -import org.teavm.jso.webgl.WebGLProgram; -import org.teavm.jso.webgl.WebGLRenderbuffer; -import org.teavm.jso.webgl.WebGLShader; -import org.teavm.jso.webgl.WebGLTexture; -import org.teavm.jso.webgl.WebGLUniformLocation; - -import net.PeytonPlayz585.main.MinecraftMain; -import net.PeytonPlayz585.minecraft.GlStateManager; -import net.PeytonPlayz585.minecraft.MinecraftClient; -import net.PeytonPlayz585.teavm.WebGL2RenderingContext; -import net.PeytonPlayz585.teavm.WebGLQuery; -import net.PeytonPlayz585.teavm.WebGLVertexArray; - -public class LWJGL { -static WebGL2RenderingContext webgl = null; - - public static final void initWebGL(WebGL2RenderingContext wgl2rc) { - webgl = wgl2rc; - } - - public static final String _wgetShaderHeader() { - return "#version 300 es"; - } - - public static final class TextureGL { - protected final WebGLTexture obj; - public int w = -1; - public int h = -1; - public boolean nearest = true; - public boolean anisotropic = false; - protected TextureGL(WebGLTexture obj) { - this.obj = obj; - } - } - public static final class BufferGL { - protected final WebGLBuffer obj; - protected BufferGL(WebGLBuffer obj) { - this.obj = obj; - } - } - public static final class ShaderGL { - protected final WebGLShader obj; - protected ShaderGL(WebGLShader obj) { - this.obj = obj; - } - } - private static int progId = 0; - public static final class ProgramGL { - protected final WebGLProgram obj; - protected final int hashcode; - protected ProgramGL(WebGLProgram obj) { - this.obj = obj; - this.hashcode = ++progId; - } - } - public static final class UniformGL { - protected final WebGLUniformLocation obj; - protected UniformGL(WebGLUniformLocation obj) { - this.obj = obj; - } - } - public static final class BufferArrayGL { - protected final WebGLVertexArray obj; - public boolean isQuadBufferBound; - protected BufferArrayGL(WebGLVertexArray obj) { - this.obj = obj; - this.isQuadBufferBound = false; - } - } - public static final class FramebufferGL { - protected final WebGLFramebuffer obj; - protected FramebufferGL(WebGLFramebuffer obj) { - this.obj = obj; - } - } - public static final class RenderbufferGL { - protected final WebGLRenderbuffer obj; - protected RenderbufferGL(WebGLRenderbuffer obj) { - this.obj = obj; - } - } - public static final class QueryGL { - protected final WebGLQuery obj; - protected QueryGL(WebGLQuery obj) { - this.obj = obj; - } - } - - public static final void _wglEnable(int p1) { - webgl.enable(p1); - } - public static final void _wglClearDepth(float p1) { - webgl.clearDepth(p1); - } - public static final void _wglDepthFunc(int p1) { - webgl.depthFunc(p1); - } - public static final void _wglCullFace(int p1) { - webgl.cullFace(p1); - } - private static int[] viewportCache = new int[4]; - public static final void _wglViewport(int p1, int p2, int p3, int p4) { - viewportCache[0] = p1; viewportCache[1] = p2; - viewportCache[2] = p3; viewportCache[3] = p4; - webgl.viewport(p1, p2, p3, p4); - } - public static final void _wglClear(int p1) { - webgl.clear(p1); - } - public static final void _wglClearColor(float p1, float p2, float p3, float p4) { - webgl.clearColor(p1, p2, p3, p4); - } - public static final void _wglDisable(int p1) { - webgl.disable(p1); - } - public static final int _wglGetError() { - return webgl.getError(); - } - public static final void _wglFlush() { - //webgl.flush(); - } - private static Uint8Array uploadBuffer = Uint8Array.create(ArrayBuffer.create(4 * 1024 * 1024)); - public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { - if(p9 == null) { - webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, null); - }else { - int len = p9.remaining(); - Uint8Array uploadBuffer1 = uploadBuffer; - for(int i = 0; i < len; ++i) { - uploadBuffer1.set(i, (short) ((int)p9.get() & 0xff)); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); - webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - } - public static final void _wglBlendFunc(int p1, int p2) { - webgl.blendFunc(p1, p2); - } - public static final void _wglDepthMask(boolean p1) { - webgl.depthMask(p1); - } - public static final void _wglColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { - webgl.colorMask(p1, p2, p3, p4); - } - public static final void _wglBindTexture(int p1, TextureGL p2) { - webgl.bindTexture(p1, p2 == null ? null : p2.obj); - } - public static final void _wglCopyTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { - webgl.copyTexSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8); - } - public static final void _wglTexParameteri(int p1, int p2, int p3) { - webgl.texParameteri(p1, p2, p3); - } - public static final void _wglTexParameterf(int p1, int p2, float p3) { - webgl.texParameterf(p1, p2, p3); - } - public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { - int len = p9.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p9.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { - int len = p9.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p9.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - public static final void _wglDeleteTextures(TextureGL p1) { - webgl.deleteTexture(p1.obj); - } - public static final void _wglDrawArrays(int p1, int p2, int p3) { - webgl.drawArrays(p1, p2, p3); - } - public static final void _wglDrawElements(int p1, int p2, int p3, int p4) { - webgl.drawElements(p1, p2, p3, p4); - } - public static final TextureGL _wglGenTextures() { - return new TextureGL(webgl.createTexture()); - } - public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { - int len = p9.remaining(); - for(int i = 0; i < len; ++i) { - uploadBuffer.set(i, (short) ((int)p9.get() & 0xff)); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); - webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - public static final void _wglActiveTexture(int p1) { - webgl.activeTexture(p1); - } - public static final ProgramGL _wglCreateProgram() { - return new ProgramGL(webgl.createProgram()); - } - public static final ShaderGL _wglCreateShader(int p1) { - return new ShaderGL(webgl.createShader(p1)); - } - public static final void _wglAttachShader(ProgramGL p1, ShaderGL p2) { - webgl.attachShader(p1.obj, p2.obj); - } - public static final void _wglDetachShader(ProgramGL p1, ShaderGL p2) { - webgl.detachShader(p1.obj, p2.obj); - } - public static final void _wglCompileShader(ShaderGL p1) { - webgl.compileShader(p1.obj); - } - public static final void _wglLinkProgram(ProgramGL p1) { - webgl.linkProgram(p1.obj); - } - public static final void _wglShaderSource(ShaderGL p1, String p2) { - webgl.shaderSource(p1.obj, p2); - } - public static final String _wglGetShaderInfoLog(ShaderGL p1) { - return webgl.getShaderInfoLog(p1.obj); - } - public static final String _wglGetProgramInfoLog(ProgramGL p1) { - return webgl.getProgramInfoLog(p1.obj); - } - public static final boolean _wglGetShaderCompiled(ShaderGL p1) { - return webgl.getShaderParameteri(p1.obj, COMPILE_STATUS) == 1; - } - public static final boolean _wglGetProgramLinked(ProgramGL p1) { - return webgl.getProgramParameteri(p1.obj, LINK_STATUS) == 1; - } - public static final void _wglDeleteShader(ShaderGL p1) { - webgl.deleteShader(p1.obj); - } - public static final void _wglDeleteProgram(ProgramGL p1) { - webgl.deleteProgram(p1.obj); - } - public static final BufferGL _wglCreateBuffer() { - return new BufferGL(webgl.createBuffer()); - } - public static final void _wglDeleteBuffer(BufferGL p1) { - webgl.deleteBuffer(p1.obj); - } - public static final void _wglBindBuffer(int p1, BufferGL p2) { - webgl.bindBuffer(p1, p2 == null ? null : p2.obj); - } - public static final void _wglBufferData0(int p1, IntBuffer p2, int p3) { - int len = p2.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p2.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.bufferData(p1, data, p3); - } - public static final void _wglBufferSubData0(int p1, int p2, IntBuffer p3) { - int len = p3.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p3.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.bufferSubData(p1, p2, data); - } - public static final void _wglBufferData(int p1, Object p2, int p3) { - webgl.bufferData(p1, (Int32Array)p2, p3); - } - public static final void _wglBufferSubData(int p1, int p2, Object p3) { - webgl.bufferSubData(p1, p2, (Int32Array)p3); - } - public static final void _wglBindAttribLocation(ProgramGL p1, int p2, String p3) { - webgl.bindAttribLocation(p1.obj, p2, p3); - } - public static final void _wglEnableVertexAttribArray(int p1) { - webgl.enableVertexAttribArray(p1); - } - public static final void _wglDisableVertexAttribArray(int p1) { - webgl.disableVertexAttribArray(p1); - } - public static final UniformGL _wglGetUniformLocation(ProgramGL p1, String p2) { - WebGLUniformLocation u = webgl.getUniformLocation(p1.obj, p2); - return u == null ? null : new UniformGL(u); - } - public static final void _wglBindAttributeLocation(ProgramGL p1, int p2, String p3) { - webgl.bindAttribLocation(p1.obj, p2, p3); - } - public static final void _wglUniform1f(UniformGL p1, float p2) { - if(p1 != null) webgl.uniform1f(p1.obj, p2); - } - public static final void _wglUniform2f(UniformGL p1, float p2, float p3) { - if(p1 != null) webgl.uniform2f(p1.obj, p2, p3); - } - public static final void _wglUniform3f(UniformGL p1, float p2, float p3, float p4) { - if(p1 != null) webgl.uniform3f(p1.obj, p2, p3, p4); - } - public static final void _wglUniform4f(UniformGL p1, float p2, float p3, float p4, float p5) { - if(p1 != null) webgl.uniform4f(p1.obj, p2, p3, p4, p5); - } - public static final void _wglUniform1i(UniformGL p1, int p2) { - if(p1 != null) webgl.uniform1i(p1.obj, p2); - } - public static final void _wglUniform2i(UniformGL p1, int p2, int p3) { - if(p1 != null) webgl.uniform2i(p1.obj, p2, p3); - } - public static final void _wglUniform3i(UniformGL p1, int p2, int p3, int p4) { - if(p1 != null) webgl.uniform3i(p1.obj, p2, p3, p4); - } - public static final void _wglUniform4i(UniformGL p1, int p2, int p3, int p4, int p5) { - if(p1 != null) webgl.uniform4i(p1.obj, p2, p3, p4, p5); - } - private static Float32Array mat2 = Float32Array.create(4); - private static Float32Array mat3 = Float32Array.create(9); - private static Float32Array mat4 = Float32Array.create(16); - public static final void _wglUniformMat2fv(UniformGL p1, float[] mat) { - mat2.set(mat); - if(p1 != null) webgl.uniformMatrix2fv(p1.obj, false, mat2); - } - public static final void _wglUniformMat3fv(UniformGL p1, float[] mat) { - mat3.set(mat); - if(p1 != null) webgl.uniformMatrix3fv(p1.obj, false, mat3); - } - public static final void _wglUniformMat4fv(UniformGL p1, float[] mat) { - mat4.set(mat); - if(p1 != null) webgl.uniformMatrix4fv(p1.obj, false, mat4); - } - private static int currentProgram = -1; - public static final void _wglUseProgram(ProgramGL p1) { - if(p1 != null && currentProgram != p1.hashcode) { - currentProgram = p1.hashcode; - webgl.useProgram(p1.obj); - } - } - public static final void _wglGetParameter(int p1, int size, int[] ret) { - if(p1 == _wGL_VIEWPORT) { - ret[0] = viewportCache[0]; - ret[1] = viewportCache[1]; - ret[2] = viewportCache[2]; - ret[3] = viewportCache[3]; - } - } - public static final void _wglPolygonOffset(float p1, float p2) { - webgl.polygonOffset(p1, p2); - } - public static final void _wglVertexAttribPointer(int p1, int p2, int p3, boolean p4, int p5, int p6) { - webgl.vertexAttribPointer(p1, p2, p3, p4, p5, p6); - } - public static final void _wglBindFramebuffer(int p1, FramebufferGL p2) { - webgl.bindFramebuffer(p1, p2 == null ? null : p2.obj); - } - public static final FramebufferGL _wglCreateFramebuffer() { - return new FramebufferGL(webgl.createFramebuffer()); - } - public static final void _wglDeleteFramebuffer(FramebufferGL p1) { - webgl.deleteFramebuffer(p1.obj); - } - public static final void _wglFramebufferTexture2D(int p1, TextureGL p2) { - webgl.framebufferTexture2D(FRAMEBUFFER, p1, TEXTURE_2D, p2 == null ? null : p2.obj, 0); - } - public static final QueryGL _wglCreateQuery() { - return new QueryGL(webgl.createQuery()); - } - public static final void _wglBeginQuery(int p1, QueryGL p2) { - webgl.beginQuery(p1, p2.obj); - } - public static final void _wglEndQuery(int p1) { - webgl.endQuery(p1); - } - public static final void _wglDeleteQuery(QueryGL p1) { - webgl.deleteQuery(p1.obj); - } - public static final int _wglGetQueryObjecti(QueryGL p1, int p2) { - return webgl.getQueryParameter(p1.obj, p2); - } - public static final BufferArrayGL _wglCreateVertexArray() { - return new BufferArrayGL(webgl.createVertexArray()); - } - public static final void _wglDeleteVertexArray(BufferArrayGL p1) { - webgl.deleteVertexArray(p1.obj); - } - public static final void _wglBindVertexArray(BufferArrayGL p1) { - webgl.bindVertexArray(p1 == null ? null : p1.obj); - } - public static final void _wglDrawBuffer(int p1) { - webgl.drawBuffers(new int[] { p1 }); - } - public static final RenderbufferGL _wglCreateRenderBuffer() { - return new RenderbufferGL(webgl.createRenderbuffer()); - } - public static final void _wglBindRenderbuffer(RenderbufferGL p1) { - webgl.bindRenderbuffer(RENDERBUFFER, p1 == null ? null : p1.obj); - } - public static final void _wglRenderbufferStorage(int p1, int p2, int p3) { - webgl.renderbufferStorage(RENDERBUFFER, p1, p2, p3); - } - public static final void _wglFramebufferRenderbuffer(int p1, RenderbufferGL p2) { - webgl.framebufferRenderbuffer(FRAMEBUFFER, p1, RENDERBUFFER, p2 == null ? null : p2.obj); - } - public static final void _wglDeleteRenderbuffer(RenderbufferGL p1) { - webgl.deleteRenderbuffer(p1.obj); - } - public static final void _wglRenderbufferStorageMultisample(int p1, int p2, int p3, int p4) { - webgl.renderbufferStorageMultisample(RENDERBUFFER, p1, p2, p3, p4); - } - public static final void _wglBlitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) { - webgl.blitFramebuffer(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); - } - public static final int _wglGetAttribLocation(ProgramGL p1, String p2) { - return webgl.getAttribLocation(p1.obj, p2); - } - - @JSBody(params = { "ctx", "p" }, script = "return ctx.getTexParameter(0x0DE1, p) | 0;") - private static final native int __wglGetTexParameteri(WebGL2RenderingContext ctx, int p); - public static final int _wglGetTexParameteri(int p1) { - return __wglGetTexParameteri(webgl, p1); - } - @JSBody(params = { "ctx", "p" }, script = "return (0.0 + ctx.getTexParameter(0x0DE1, p));") - private static final native float __wglGetTexParameterf(WebGL2RenderingContext ctx, int p); - public static final float _wglGetTexParameterf(int p1) { - return __wglGetTexParameterf(webgl, p1); - } - - public static final int _wArrayByteLength(Object obj) { - return ((Int32Array)obj).getByteLength(); - } - - public static final Object _wCreateLowLevelIntBuffer(int len) { - return Int32Array.create(len); - } - - private static int appendbufferindex = 0; - private static Int32Array appendbuffer = Int32Array.create(ArrayBuffer.create(525000*4)); - - public static final void _wAppendLowLevelBuffer(Object arr) { - Int32Array a = ((Int32Array)arr); - if(appendbufferindex + a.getLength() < appendbuffer.getLength()) { - appendbuffer.set(a, appendbufferindex); - appendbufferindex += a.getLength(); - } - } - - public static final Object _wGetLowLevelBuffersAppended() { - Int32Array ret = Int32Array.create(appendbuffer.getBuffer(), 0, appendbufferindex); - appendbufferindex = 0; - return ret; - } - - @JSBody(params = { "obj" }, script = "if(obj.commit) obj.commit();") - private static native int commitContext(JSObject obj); - - public static final void updateDisplay() { - commitContext(webgl); - MinecraftMain.canvasContext.drawImage(MinecraftMain.canvasBack, 0d, 0d, MinecraftMain.canvas.getWidth(), MinecraftMain.canvas.getHeight()); - - int ww = MinecraftMain.canvas.getClientWidth(); - int hh = MinecraftMain.canvas.getClientHeight(); - if(ww != MinecraftMain.width || hh != MinecraftMain.height) { - MinecraftMain.width = ww; - MinecraftMain.height = hh; - MinecraftMain.canvasBack.setWidth(ww); - MinecraftMain.canvasBack.setHeight(hh); - } - - try { - Thread.sleep(1l); - } catch (InterruptedException e) { - ; - } - } - - public static final byte[] loadResourceBytes(String path) { - return MinecraftClient.getResource(path); - } - - public static final String fileContents(String path) { - byte[] contents = loadResourceBytes(path); - if(contents == null) { - return null; - }else { - return new String(contents, Charset.forName("UTF-8")); - } - } - - public static final int _wGL_TEXTURE_2D = TEXTURE_2D; - public static final int _wGL_DEPTH_TEST = DEPTH_TEST; - public static final int _wGL_LEQUAL = LEQUAL; - public static final int _wGL_GEQUAL = GEQUAL; - public static final int _wGL_GREATER = GREATER; - public static final int _wGL_LESS = LESS; - public static final int _wGL_BACK = BACK; - public static final int _wGL_FRONT = FRONT; - public static final int _wGL_FRONT_AND_BACK = FRONT_AND_BACK; - public static final int _wGL_COLOR_BUFFER_BIT = COLOR_BUFFER_BIT; - public static final int _wGL_DEPTH_BUFFER_BIT = DEPTH_BUFFER_BIT; - public static final int _wGL_BLEND = BLEND; - public static final int _wGL_RGBA = RGBA; - public static final int _wGL_RGB = RGB; - public static final int _wGL_RGB8 = RGB8; - public static final int _wGL_RGBA8 = RGBA8; - public static final int _wGL_UNSIGNED_BYTE = UNSIGNED_BYTE; - public static final int _wGL_UNSIGNED_SHORT = UNSIGNED_SHORT; - public static final int _wGL_SRC_ALPHA = SRC_ALPHA; - public static final int _wGL_ONE_MINUS_SRC_ALPHA = ONE_MINUS_SRC_ALPHA; - public static final int _wGL_ONE_MINUS_DST_COLOR = ONE_MINUS_DST_COLOR; - public static final int _wGL_ONE_MINUS_SRC_COLOR = ONE_MINUS_SRC_COLOR; - public static final int _wGL_ZERO = ZERO; - public static final int _wGL_CULL_FACE = CULL_FACE; - public static final int _wGL_TEXTURE_MIN_FILTER = TEXTURE_MIN_FILTER; - public static final int _wGL_TEXTURE_MAG_FILTER = TEXTURE_MAG_FILTER; - public static final int _wGL_LINEAR = LINEAR; - public static final int _wGL_EQUAL = EQUAL; - public static final int _wGL_SRC_COLOR = SRC_COLOR; - public static final int _wGL_ONE = ONE; - public static final int _wGL_NEAREST = NEAREST; - public static final int _wGL_CLAMP = CLAMP_TO_EDGE; - public static final int _wGL_TEXTURE_WRAP_S = TEXTURE_WRAP_S; - public static final int _wGL_TEXTURE_WRAP_T = TEXTURE_WRAP_T; - public static final int _wGL_REPEAT = REPEAT; - public static final int _wGL_DST_COLOR = DST_COLOR; - public static final int _wGL_DST_ALPHA = DST_ALPHA; - public static final int _wGL_FLOAT = FLOAT; - public static final int _wGL_SHORT = SHORT; - public static final int _wGL_TRIANGLES = TRIANGLES; - public static final int _wGL_TRIANGLE_STRIP = TRIANGLE_STRIP; - public static final int _wGL_TRIANGLE_FAN = TRIANGLE_FAN; - public static final int _wGL_LINE_STRIP = LINE_STRIP; - public static final int _wGL_LINES = LINES; - public static final int _wGL_PACK_ALIGNMENT = PACK_ALIGNMENT; - public static final int _wGL_UNPACK_ALIGNMENT = UNPACK_ALIGNMENT; - public static final int _wGL_TEXTURE0 = TEXTURE0; - public static final int _wGL_TEXTURE1 = TEXTURE1; - public static final int _wGL_TEXTURE2 = TEXTURE2; - public static final int _wGL_TEXTURE3 = TEXTURE3; - public static final int _wGL_VIEWPORT = VIEWPORT; - public static final int _wGL_VERTEX_SHADER = VERTEX_SHADER; - public static final int _wGL_FRAGMENT_SHADER = FRAGMENT_SHADER; - public static final int _wGL_ARRAY_BUFFER = ARRAY_BUFFER; - public static final int _wGL_ELEMENT_ARRAY_BUFFER = ELEMENT_ARRAY_BUFFER; - public static final int _wGL_STATIC_DRAW = STATIC_DRAW; - public static final int _wGL_DYNAMIC_DRAW = DYNAMIC_DRAW; - public static final int _wGL_INVALID_ENUM = INVALID_ENUM; - public static final int _wGL_INVALID_VALUE= INVALID_VALUE; - public static final int _wGL_INVALID_OPERATION = INVALID_OPERATION; - public static final int _wGL_OUT_OF_MEMORY = OUT_OF_MEMORY; - public static final int _wGL_CONTEXT_LOST_WEBGL = CONTEXT_LOST_WEBGL; - public static final int _wGL_FRAMEBUFFER_COMPLETE = FRAMEBUFFER_COMPLETE; - public static final int _wGL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - public static final int _wGL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; - public static final int _wGL_COLOR_ATTACHMENT0 = COLOR_ATTACHMENT0; - public static final int _wGL_DEPTH_STENCIL_ATTACHMENT = DEPTH_STENCIL_ATTACHMENT; - public static final int _wGL_DEPTH_STENCIL = DEPTH_STENCIL; - public static final int _wGL_NEAREST_MIPMAP_LINEAR = NEAREST_MIPMAP_LINEAR; - public static final int _wGL_LINEAR_MIPMAP_LINEAR = LINEAR_MIPMAP_LINEAR; - public static final int _wGL_LINEAR_MIPMAP_NEAREST = LINEAR_MIPMAP_NEAREST; - public static final int _wGL_NEAREST_MIPMAP_NEAREST = NEAREST_MIPMAP_NEAREST; - public static final int _wGL_TEXTURE_MAX_LEVEL = TEXTURE_MAX_LEVEL; - public static final int _wGL_UNSIGNED_INT_24_8 = UNSIGNED_INT_24_8; - public static final int _wGL_UNSIGNED_INT = UNSIGNED_INT; - public static final int _wGL_ANY_SAMPLES_PASSED = ANY_SAMPLES_PASSED; - public static final int _wGL_QUERY_RESULT = QUERY_RESULT; - public static final int _wGL_QUERY_RESULT_AVAILABLE = QUERY_RESULT_AVAILABLE; - public static final int _wGL_TEXTURE_MAX_ANISOTROPY = TEXTURE_MAX_ANISOTROPY_EXT; - public static final int _wGL_DEPTH24_STENCIL8 = DEPTH24_STENCIL8; - public static final int _wGL_DEPTH_COMPONENT32F = DEPTH_COMPONENT32F; - public static final int _wGL_DEPTH_ATTACHMENT = DEPTH_ATTACHMENT; - public static final int _wGL_MULTISAMPLE = -1; - public static final int _wGL_LINE_SMOOTH = -1; - public static final int _wGL_READ_FRAMEBUFFER = READ_FRAMEBUFFER; - public static final int _wGL_DRAW_FRAMEBUFFER = DRAW_FRAMEBUFFER; - public static final int _wGL_FRAMEBUFFER = FRAMEBUFFER; - public static final int _wGL_POLYGON_OFFSET_FILL = POLYGON_OFFSET_FILL; -} diff --git a/src/main/java/net/PeytonPlayz585/lwjgl/LWJGLUtils.java b/src/main/java/net/PeytonPlayz585/lwjgl/LWJGLUtils.java deleted file mode 100644 index 11e8ba0..0000000 --- a/src/main/java/net/PeytonPlayz585/lwjgl/LWJGLUtils.java +++ /dev/null @@ -1,82 +0,0 @@ -package net.PeytonPlayz585.lwjgl; - -import org.lwjgl.opengl.GL11; -import org.teavm.interop.Async; -import org.teavm.interop.AsyncCallback; -import org.teavm.jso.canvas.CanvasRenderingContext2D; -import org.teavm.jso.canvas.ImageData; -import org.teavm.jso.dom.events.Event; -import org.teavm.jso.dom.events.EventListener; -import org.teavm.jso.dom.html.HTMLCanvasElement; -import org.teavm.jso.dom.html.HTMLImageElement; -import org.teavm.jso.typedarrays.ArrayBuffer; -import org.teavm.jso.typedarrays.Uint8Array; -import org.teavm.jso.typedarrays.Uint8ClampedArray; - -import net.PeytonPlayz585.main.MinecraftMain; -import net.PeytonPlayz585.minecraft.MinecraftImage; - -public class LWJGLUtils extends GL11 { - - public LWJGLUtils() { - - } - - public static final MinecraftImage loadPNG(byte[] data) { - ArrayBuffer arr = ArrayBuffer.create(data.length); - Uint8Array.create(arr).set(data); - return loadPNG0(arr); - } - - @Async - private static native MinecraftImage loadPNG0(ArrayBuffer data); - - private static void loadPNG0(ArrayBuffer data, final AsyncCallback ret) { - final HTMLImageElement toLoad = (HTMLImageElement) MinecraftMain.doc.createElement("img"); - toLoad.addEventListener("load", new EventListener() { - @Override - public void handleEvent(Event evt) { - if(MinecraftMain.imageLoadCanvas == null) { - MinecraftMain.imageLoadCanvas = (HTMLCanvasElement) MinecraftMain.doc.createElement("canvas"); - } - if(MinecraftMain.imageLoadCanvas.getWidth() < toLoad.getWidth()) { - MinecraftMain.imageLoadCanvas.setWidth(toLoad.getWidth()); - } - if(MinecraftMain.imageLoadCanvas.getHeight() < toLoad.getHeight()) { - MinecraftMain.imageLoadCanvas.setHeight(toLoad.getHeight()); - } - if(MinecraftMain.imageLoadContext == null) { - MinecraftMain.imageLoadContext = (CanvasRenderingContext2D) MinecraftMain.imageLoadCanvas.getContext("2d"); - } - MinecraftMain.imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight()); - MinecraftMain.imageLoadContext.drawImage(toLoad, 0, 0, toLoad.getWidth(), toLoad.getHeight()); - ImageData pxlsDat = MinecraftMain.imageLoadContext.getImageData(0, 0, toLoad.getWidth(), toLoad.getHeight()); - Uint8ClampedArray pxls = pxlsDat.getData(); - int totalPixels = pxlsDat.getWidth() * pxlsDat.getHeight(); - MinecraftMain.freeDataURL(toLoad.getSrc()); - if(pxls.getByteLength() < totalPixels * 4) { - ret.complete(null); - return; - } - int[] pixels = new int[totalPixels]; - for(int i = 0; i < pixels.length; ++i) { - pixels[i] = (pxls.get(i * 4) << 16) | (pxls.get(i * 4 + 1) << 8) | pxls.get(i * 4 + 2) | (pxls.get(i * 4 + 3) << 24); - } - ret.complete(new MinecraftImage(pixels, pxlsDat.getWidth(), pxlsDat.getHeight(), true)); - } - }); - toLoad.addEventListener("error", new EventListener() { - @Override - public void handleEvent(Event evt) { - MinecraftMain.freeDataURL(toLoad.getSrc()); - ret.complete(null); - } - }); - String src = MinecraftMain.getDataURL(data, "image/png"); - if(src == null) { - ret.complete(null); - }else { - toLoad.setSrc(src); - } - } -} diff --git a/src/main/java/net/PeytonPlayz585/lwjgl/ModeBuffer.java b/src/main/java/net/PeytonPlayz585/lwjgl/ModeBuffer.java deleted file mode 100644 index 5493a31..0000000 --- a/src/main/java/net/PeytonPlayz585/lwjgl/ModeBuffer.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.PeytonPlayz585.lwjgl; - -import org.lwjgl.BufferUtils; - -import java.nio.FloatBuffer; - -/** - * Utility class that emulates immediate mode vertex data submission. - * Can be used to create VBO data. - */ -public final class ModeBuffer { - - private FloatBuffer buffer; - - public ModeBuffer(final int startSize) { - this.buffer = BufferUtils.createFloatBuffer(startSize); - } - - private void checkSize(final int count) { - while ( buffer.remaining() < count ) { - final FloatBuffer newBuffer = BufferUtils.createFloatBuffer(buffer.capacity() << 1); - buffer.flip(); - newBuffer.put(buffer); - buffer = newBuffer; - } - } - - public FloatBuffer getBuffer() { - buffer.flip(); - return buffer; - } - - public void glVertex2f(final float x, final float y) { - checkSize(2); - buffer.put(x).put(y); - } - - public void glVertex3f(final float x, final float y, final float z) { - checkSize(3); - buffer.put(x).put(y).put(z); - } - - public void glVertex4f(final float x, final float y, final float z, final float w) { - checkSize(4); - buffer.put(x).put(y).put(z).put(w); - } - - public void glNormal3f(final float x, final float y, final float z) { - checkSize(3); - buffer.put(x).put(y).put(z); - } - - public void glTexCoord2f(final float s, final float t) { - checkSize(2); - buffer.put(s).put(t); - } - -} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/lwjgl/PlatformInput.java b/src/main/java/net/PeytonPlayz585/lwjgl/PlatformInput.java deleted file mode 100644 index 2f3267b..0000000 --- a/src/main/java/net/PeytonPlayz585/lwjgl/PlatformInput.java +++ /dev/null @@ -1,507 +0,0 @@ -package net.PeytonPlayz585.lwjgl; - -import java.util.LinkedList; -import java.util.List; - -import org.lwjgl.input.Keyboard; -import org.teavm.jso.JSBody; -import org.teavm.jso.browser.TimerHandler; -import org.teavm.jso.browser.Window; -import org.teavm.jso.dom.events.EventListener; -import org.teavm.jso.dom.events.KeyboardEvent; -import org.teavm.jso.dom.events.MouseEvent; -import org.teavm.jso.dom.events.WheelEvent; -import org.teavm.jso.dom.html.HTMLCanvasElement; -import org.teavm.jso.webgl.WebGLFramebuffer; -import org.teavm.jso.webgl.WebGLRenderbuffer; - -import net.PeytonPlayz585.main.MinecraftMain; -import net.PeytonPlayz585.teavm.WebGL2RenderingContext; - -import static net.PeytonPlayz585.teavm.WebGL2RenderingContext.*; - -/** - * Copyright (c) 2022 LAX1DUDE. All Rights Reserved. - * - * WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES - * NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED - * TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE - * SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR. - * - * NOT FOR COMMERCIAL OR MALICIOUS USE - * - * (please read the 'LICENSE' file this repo's root directory for more info) - * - */ -public class PlatformInput { - static WebGLFramebuffer mainFramebuffer = null; - static WebGLRenderbuffer mainColorRenderbuffer = null; - static WebGLRenderbuffer mainDepthRenderbuffer = null; - private static int framebufferWidth = -1; - private static int framebufferHeight = -1; - - private static EventListener contextmenu = null; - private static EventListener mousedown = null; - private static EventListener mouseup = null; - private static EventListener mousemove = null; - private static EventListener mouseenter = null; - private static EventListener mouseleave = null; - private static EventListener keydown = null; - private static EventListener keyup = null; - private static EventListener keypress = null; - private static EventListener wheel = null; - private static EventListener pointerlock = null; - - private static List mouseEvents = new LinkedList(); - private static List keyEvents = new LinkedList(); - - private static int mouseX = 0; - private static int mouseY = 0; - private static double mouseDX = 0.0D; - private static double mouseDY = 0.0D; - private static double mouseDWheel = 0.0D; - private static int width = 0; - private static int height = 0; - private static boolean enableRepeatEvents = true; - private static boolean isWindowFocused = true; - private static boolean isMouseOverWindow = true; - static boolean unpressCTRL = false; - - private static int windowWidth = -1; - private static int windowHeight = -1; - private static int lastWasResizedWindowWidth = -2; - private static int lastWasResizedWindowHeight = -2; - - private static MouseEvent currentEvent = null; - private static KeyboardEvent currentEventK = null; - private static boolean[] buttonStates = new boolean[8]; - private static boolean[] keyStates = new boolean[256]; - - private static int functionKeyModifier = Keyboard.KEY_F; - - private static long mouseUngrabTimer = 0l; - private static long mouseGrabTimer = 0l; - private static int mouseUngrabTimeout = -1; - private static boolean pointerLockFlag = false; - - @JSBody(params = { }, script = "window.onbeforeunload = () => {return false;};") - private static native void onBeforeCloseRegister(); - - public static void initHooks() { - MinecraftMain.win.addEventListener("contextmenu", contextmenu = new EventListener() { - @Override - public void handleEvent(MouseEvent evt) { - evt.preventDefault(); - evt.stopPropagation(); - } - }); - MinecraftMain.canvas.addEventListener("mousedown", mousedown = new EventListener() { - @Override - public void handleEvent(MouseEvent evt) { - evt.preventDefault(); - evt.stopPropagation(); - int b = evt.getButton(); - buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = true; - mouseEvents.add(evt); - } - }); - MinecraftMain.canvas.addEventListener("mouseup", mouseup = new EventListener() { - @Override - public void handleEvent(MouseEvent evt) { - evt.preventDefault(); - evt.stopPropagation(); - int b = evt.getButton(); - buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = false; - mouseEvents.add(evt); - } - }); - MinecraftMain.canvas.addEventListener("mousemove", mousemove = new EventListener() { - @Override - public void handleEvent(MouseEvent evt) { - evt.preventDefault(); - evt.stopPropagation(); - mouseX = (int)(getOffsetX(evt) * MinecraftMain.win.getDevicePixelRatio()); - mouseY = (int)((MinecraftMain.canvas.getClientHeight() - getOffsetY(evt)) * MinecraftMain.win.getDevicePixelRatio()); - mouseDX += evt.getMovementX(); - mouseDY += -evt.getMovementY(); - if(hasBeenActive()) { - mouseEvents.add(evt); - } - } - }); - MinecraftMain.canvas.addEventListener("mouseenter", mouseenter = new EventListener() { - @Override - public void handleEvent(MouseEvent evt) { - isMouseOverWindow = true; - } - }); - MinecraftMain.canvas.addEventListener("mouseleave", mouseleave = new EventListener() { - @Override - public void handleEvent(MouseEvent evt) { - isMouseOverWindow = false; - } - }); - MinecraftMain.win.addEventListener("keydown", keydown = new EventListener() { - @Override - public void handleEvent(KeyboardEvent evt) { - int w = getWhich(evt); - if (w == 122) return; // F11 - evt.preventDefault(); - evt.stopPropagation(); - if(!enableRepeatEvents && evt.isRepeat()) return; - w = processFunctionKeys(w); - keyStates[KeyboardConstants.getMinecraftKeyFromBrowser(w, evt.getLocation())] = true; - keyEvents.add(evt); - } - }); - MinecraftMain.win.addEventListener("keyup", keyup = new EventListener() { - @Override - public void handleEvent(KeyboardEvent evt) { - int w = getWhich(evt); - if (w == 122) return; // F11 - evt.preventDefault(); - evt.stopPropagation(); - if(!enableRepeatEvents && evt.isRepeat()) return; - w = processFunctionKeys(w); - keyStates[KeyboardConstants.getMinecraftKeyFromBrowser(w, evt.getLocation())] = false; - keyEvents.add(evt); - } - }); - MinecraftMain.win.addEventListener("keypress", keypress = new EventListener() { - @Override - public void handleEvent(KeyboardEvent evt) { - evt.preventDefault(); - evt.stopPropagation(); - if(enableRepeatEvents && evt.isRepeat()) keyEvents.add(evt); - } - }); - MinecraftMain.canvas.addEventListener("wheel", wheel = new EventListener() { - @Override - public void handleEvent(WheelEvent evt) { - evt.preventDefault(); - evt.stopPropagation(); - mouseEvents.add(evt); - mouseDWheel += evt.getDeltaY(); - } - }); - MinecraftMain.win.addEventListener("blur", new EventListener() { - @Override - public void handleEvent(WheelEvent evt) { - isWindowFocused = false; - for(int i = 0; i < buttonStates.length; ++i) { - buttonStates[i] = false; - } - for(int i = 0; i < keyStates.length; ++i) { - keyStates[i] = false; - } - } - }); - MinecraftMain.win.addEventListener("focus", new EventListener() { - @Override - public void handleEvent(WheelEvent evt) { - isWindowFocused = true; - } - }); - MinecraftMain.win.getDocument().addEventListener("pointerlockchange", pointerlock = new EventListener() { - @Override - public void handleEvent(WheelEvent evt) { - Window.setTimeout(new TimerHandler() { - @Override - public void onTimer() { - boolean grab = isPointerLocked(); - if(!grab) { - if(pointerLockFlag) { - mouseUngrabTimer = System.currentTimeMillis(); - } - } - pointerLockFlag = grab; - } - }, 60); - mouseDX = 0.0D; - mouseDY = 0.0D; - } - }); - onBeforeCloseRegister(); - } - - @JSBody(params = { }, script = "if(window.navigator.userActivation){return window.navigator.userActivation.hasBeenActive;}else{return false;}") - public static native boolean hasBeenActive(); - - @JSBody(params = { "m" }, script = "return m.offsetX;") - private static native int getOffsetX(MouseEvent m); - - @JSBody(params = { "m" }, script = "return m.offsetY;") - private static native int getOffsetY(MouseEvent m); - - @JSBody(params = { "e" }, script = "return e.which;") - private static native int getWhich(KeyboardEvent e); - - public static int getWindowWidth() { - return windowWidth; - } - - public static int getWindowHeight() { - return windowHeight; - } - - public static boolean getWindowFocused() { - return isWindowFocused || isPointerLocked(); - } - - public static boolean isCloseRequested() { - return false; - } - - public static void update() { - double r = MinecraftMain.win.getDevicePixelRatio(); - int w = MinecraftMain.parent.getClientWidth(); - int h = MinecraftMain.parent.getClientHeight(); - int w2 = windowWidth = (int)(w * r); - int h2 = windowHeight = (int)(h * r); - if(MinecraftMain.canvas.getWidth() != w2) { - MinecraftMain.canvas.setWidth(w2); - } - if(MinecraftMain.canvas.getHeight() != h2) { - MinecraftMain.canvas.setHeight(h2); - } - flipBuffer(); - MinecraftMain.sleep(1l); - } - - public static void initFramebuffer(WebGLFramebuffer fbo, int sw, int sh) { - mainFramebuffer = fbo; - - framebufferWidth = windowWidth = sw; - framebufferHeight = windowHeight = sh; - - MinecraftMain.webgl.bindFramebuffer(FRAMEBUFFER, fbo); - - mainColorRenderbuffer = MinecraftMain.webgl.createRenderbuffer(); - mainDepthRenderbuffer = MinecraftMain.webgl.createRenderbuffer(); - - MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainColorRenderbuffer); - MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, RGBA8, sw, sh); - MinecraftMain.webgl.framebufferRenderbuffer(FRAMEBUFFER, COLOR_ATTACHMENT0, RENDERBUFFER, mainColorRenderbuffer); - - MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainDepthRenderbuffer); - MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, DEPTH_COMPONENT32F, sw, sh); - MinecraftMain.webgl.framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, RENDERBUFFER, mainDepthRenderbuffer); - - MinecraftMain.webgl.drawBuffers(new int[] { COLOR_ATTACHMENT0 }); - } - - private static void flipBuffer() { - - MinecraftMain.webgl.bindFramebuffer(READ_FRAMEBUFFER, mainFramebuffer); - MinecraftMain.webgl.bindFramebuffer(DRAW_FRAMEBUFFER, null); - MinecraftMain.webgl.blitFramebuffer(0, 0, framebufferWidth, framebufferHeight, 0, 0, windowWidth, windowHeight, COLOR_BUFFER_BIT, NEAREST); - - MinecraftMain.webgl.bindFramebuffer(FRAMEBUFFER, mainFramebuffer); - - if(windowWidth != framebufferWidth || windowHeight != framebufferHeight) { - framebufferWidth = windowWidth; - framebufferHeight = windowHeight; - - MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainColorRenderbuffer); - MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, RGBA8, framebufferWidth, framebufferHeight); - - MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainDepthRenderbuffer); - MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, DEPTH_COMPONENT32F, framebufferWidth, framebufferHeight); - } - - } - - public static boolean wasResized() { - if(windowWidth != lastWasResizedWindowWidth || windowHeight != lastWasResizedWindowHeight) { - lastWasResizedWindowWidth = windowWidth; - lastWasResizedWindowHeight = windowHeight; - return true; - }else { - return false; - } - } - - public static boolean keyboardNext() { - if(unpressCTRL) { //un-press ctrl after copy/paste permission - keyEvents.clear(); - currentEventK = null; - keyStates[29] = false; - keyStates[157] = false; - keyStates[28] = false; - keyStates[219] = false; - keyStates[220] = false; - unpressCTRL = false; - return false; - } - currentEventK = null; - return !keyEvents.isEmpty() && (currentEventK = keyEvents.remove(0)) != null; - } - - public static boolean keyboardGetEventKeyState() { - return currentEventK == null? false : !currentEventK.getType().equals("keyup"); - } - - public static int keyboardGetEventKey() { - int w = processFunctionKeys(getWhich(currentEventK)); - return currentEventK == null ? -1 : KeyboardConstants.getMinecraftKeyFromBrowser(w, currentEventK.getLocation()); - } - - public static char keyboardGetEventCharacter() { - if(currentEventK == null) return '\0'; - String s = currentEventK.getKey(); - return currentEventK == null ? ' ' : (char) (s.length() > 1 ? '\0' : s.charAt(0)); - } - - public static boolean keyboardIsKeyDown(int key) { - if(unpressCTRL) { //un-press ctrl after copy/paste permission - keyStates[28] = false; - keyStates[29] = false; - keyStates[157] = false; - keyStates[219] = false; - keyStates[220] = false; - } - return key < 0 || key >= keyStates.length ? false : keyStates[key]; - } - - public static boolean keyboardIsRepeatEvent() { - return currentEventK == null ? false : currentEventK.isRepeat(); - } - - public static void keyboardEnableRepeatEvents(boolean b) { - enableRepeatEvents = b; - } - - public static boolean mouseNext() { - currentEvent = null; - return !mouseEvents.isEmpty() && (currentEvent = mouseEvents.remove(0)) != null; - } - - public static boolean mouseGetEventButtonState() { - return currentEvent == null ? false : currentEvent.getType().equals(MouseEvent.MOUSEDOWN); - } - - public static int mouseGetEventButton() { - if(currentEvent == null || currentEvent.getType().equals(MouseEvent.MOUSEMOVE)) return -1; - int b = currentEvent.getButton(); - return b == 1 ? 2 : (b == 2 ? 1 : b); - } - - public static int mouseGetEventX() { - return currentEvent == null ? -1 : (int)(currentEvent.getClientX() * MinecraftMain.win.getDevicePixelRatio()); - } - - public static int mouseGetEventY() { - return currentEvent == null ? -1 : (int)((MinecraftMain.canvas.getClientHeight() - currentEvent.getClientY()) * MinecraftMain.win.getDevicePixelRatio()); - } - - public static int mouseGetEventDWheel() { - return ("wheel".equals(currentEvent.getType())) ? (((WheelEvent)currentEvent).getDeltaY() == 0.0D ? 0 : (((WheelEvent)currentEvent).getDeltaY() > 0.0D ? -1 : 1)) : 0; - } - - public static int mouseGetX() { - return mouseX; - } - - public static int mouseGetY() { - return mouseY; - } - - public static boolean mouseIsButtonDown(int i) { - return buttonStates[i]; - } - - public static int mouseGetDWheel() { - int ret = (int)mouseDWheel; - mouseDWheel = 0.0D; - return ret; - } - - public static void mouseSetGrabbed(boolean grab) { - long t = System.currentTimeMillis(); - pointerLockFlag = grab; - mouseGrabTimer = t; - if(grab) { - MinecraftMain.canvas.requestPointerLock(); - if(mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout); - mouseUngrabTimeout = -1; - if(t - mouseUngrabTimer < 3000l) { - mouseUngrabTimeout = Window.setTimeout(new TimerHandler() { - @Override - public void onTimer() { - MinecraftMain.canvas.requestPointerLock(); - } - }, 3100 - (int)(t - mouseUngrabTimer)); - } - }else { - if(mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout); - mouseUngrabTimeout = -1; - Window.current().getDocument().exitPointerLock(); - } - mouseDX = 0.0D; - mouseDY = 0.0D; - } - - public static boolean isMouseGrabbed() { - return pointerLockFlag; - } - - @JSBody(params = { }, script = "return document.pointerLockElement != null;") - public static native boolean isPointerLocked(); - - public static int mouseGetDX() { - int ret = (int)mouseDX; - mouseDX = 0.0D; - return ret; - } - - public static int mouseGetDY() { - int ret = (int)mouseDY; - mouseDY = 0.0D; - return ret; - } - - public static void mouseSetCursorPosition(int x, int y) { - // obsolete - } - - public static boolean mouseIsInsideWindow() { - return isMouseOverWindow; - } - - private static int processFunctionKeys(int key) { - if(keyboardIsKeyDown(functionKeyModifier)) { - if(key >= 49 && key <= 57) { - key = key - 49 + 112; - } - } - return key; - } - - public static void setFunctionKeyModifier(int key) { - functionKeyModifier = key; - } - - public static void removeEventHandlers() { - MinecraftMain.win.removeEventListener("contextmenu", contextmenu); - MinecraftMain.canvas.removeEventListener("mousedown", mousedown); - MinecraftMain.canvas.removeEventListener("mouseup", mouseup); - MinecraftMain.canvas.removeEventListener("mousemove", mousemove); - MinecraftMain.canvas.removeEventListener("mouseenter", mouseenter); - MinecraftMain.canvas.removeEventListener("mouseleave", mouseleave); - MinecraftMain.win.removeEventListener("keydown", keydown); - MinecraftMain.win.removeEventListener("keyup", keyup); - MinecraftMain.win.removeEventListener("keypress", keypress); - MinecraftMain.canvas.removeEventListener("wheel", wheel); - MinecraftMain.win.getDocument().removeEventListener("pointerlockchange", pointerlock); - if(mouseUngrabTimeout != -1) { - Window.clearTimeout(mouseUngrabTimeout); - mouseUngrabTimeout = -1; - } - } - - public static void clearEvenBuffers() { - mouseEvents.clear(); - keyEvents.clear(); - } - -} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/main/MinecraftMain.java b/src/main/java/net/PeytonPlayz585/main/MinecraftMain.java deleted file mode 100644 index 745a0ff..0000000 --- a/src/main/java/net/PeytonPlayz585/main/MinecraftMain.java +++ /dev/null @@ -1,192 +0,0 @@ -package net.PeytonPlayz585.main; - -import java.io.IOException; - -import org.lwjgl.opengl.GL11; -import org.teavm.interop.Async; -import org.teavm.interop.AsyncCallback; -import org.teavm.jso.JSBody; -import org.teavm.jso.JSObject; -import org.teavm.jso.ajax.ReadyStateChangeHandler; -import org.teavm.jso.ajax.XMLHttpRequest; -import org.teavm.jso.browser.Window; -import org.teavm.jso.canvas.CanvasRenderingContext2D; -import org.teavm.jso.dom.html.HTMLCanvasElement; -import org.teavm.jso.dom.html.HTMLDocument; -import org.teavm.jso.dom.html.HTMLElement; -import org.teavm.jso.typedarrays.ArrayBuffer; -import org.teavm.jso.typedarrays.Uint8Array; -import org.teavm.jso.webgl.WebGLFramebuffer; -import org.teavm.jso.webgl.WebGLRenderingContext; - -import com.mojang.minecraft.Minecraft; -import com.mojang.minecraft.SessionData; - -import net.PeytonPlayz585.lwjgl.PlatformInput; -import net.PeytonPlayz585.minecraft.MinecraftClient; -import net.PeytonPlayz585.teavm.WebGL2RenderingContext; - -public class MinecraftMain { - - public static Window win = null; - public static HTMLCanvasElement canvas = null; - public static HTMLElement rootElement = null; - public static WebGL2RenderingContext webgl = null; - public static HTMLElement parent = null; - public static HTMLDocument doc = null; - public static CanvasRenderingContext2D canvasContext = null; - public static HTMLCanvasElement canvasBack = null; - public static HTMLCanvasElement imageLoadCanvas = null; - public static CanvasRenderingContext2D imageLoadContext = null; - private static byte[] loadedPackage = null; - static WebGLFramebuffer mainFramebuffer = null; - - public static int width = 0; - public static int height = 0; - - public static void main(String args[]) { - String[] element = getClassicConfig(); - try { - initContext(rootElement = Window.current().getDocument().getElementById(element[0]), element[1]); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public final static void initContext(HTMLElement rootElement, String assetsURI) throws Exception { - parent = rootElement; - String s = parent.getAttribute("style"); - parent.setAttribute("style", (s == null ? "" : s)+"overflow-x:hidden;overflow-y:hidden;"); - win = Window.current(); - doc = win.getDocument(); - canvas = (HTMLCanvasElement)doc.createElement("canvas"); - width = rootElement.getClientWidth(); - height = rootElement.getClientHeight(); - canvas.setWidth(width); - canvas.setHeight(height); - canvasContext = (CanvasRenderingContext2D) canvas.getContext("2d"); - canvas.setAttribute("id", "minecraftClassicBrowser"); - rootElement.appendChild(canvas); - canvasBack = (HTMLCanvasElement)doc.createElement("canvas"); - imageLoadCanvas = (HTMLCanvasElement) doc.createElement("canvas"); - imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d"); - - double r = win.getDevicePixelRatio(); - int iw = parent.getClientWidth(); - int ih = parent.getClientHeight(); - int sw = (int)(r * iw); - int sh = (int)(r * ih); - - canvasBack.setWidth(width); - canvasBack.setHeight(height); - - try { - PlatformInput.initHooks(); - }catch(Throwable t) { - throw new Exception("Exception while registering window event handlers"); - } - - try { - doc.exitPointerLock(); - }catch(Throwable t) { - throw new Exception("Mouse cursor lock is not available on this device!"); - } - - webgl = (WebGL2RenderingContext) canvasBack.getContext("webgl2"); - if(webgl == null) { - throw new RuntimeException("WebGL 2.0 is not supported in your browser, please get a new one!"); - } - setCurrentContext(webgl); - GL11.initWebGL(webgl); - - mainFramebuffer = webgl.createFramebuffer(); - PlatformInput.initFramebuffer(mainFramebuffer, sw, sh); - - webgl.getExtension("EXT_texture_filter_anisotropic"); - - downloadAssetPack(assetsURI); - - try { - MinecraftClient.install(loadedPackage); - } catch (IOException e) { - e.printStackTrace(); - } - - //Start Game - Minecraft minecraft = new Minecraft(canvas.getWidth(), canvas.getHeight(), true); - //minecraft.host = "127.0.0.1:25565"; - minecraft.session = new SessionData("PeytonPlayz585", "TeaVM-WebGL"); - minecraft.levelLoaded = true; - canvas.focus(); - - Thread thread = null; - thread = new Thread(minecraft); - thread.start(); - minecraft.waiting = false; - - } - - @Async - public static native String downloadAssetPack(String assetPackageURI); - - private static void downloadAssetPack(String assetPackageURI, final AsyncCallback cb) { - final XMLHttpRequest request = XMLHttpRequest.create(); - request.setResponseType("arraybuffer"); - request.open("GET", assetPackageURI, true); - request.setOnReadyStateChange(new ReadyStateChangeHandler() { - @Override - public void stateChanged() { - if(request.getReadyState() == XMLHttpRequest.DONE) { - Uint8Array bl = Uint8Array.create((ArrayBuffer)request.getResponse()); - loadedPackage = new byte[bl.getByteLength()]; - for(int i = 0; i < loadedPackage.length; ++i) { - loadedPackage[i] = (byte) bl.get(i); - } - cb.complete("yee"); - } - } - }); - request.send(); - } - - public static final int getCanvasWidth() { - int w = parent.getClientWidth(); - if(w != width) { - canvas.setWidth(w); - canvasBack.setWidth(w); - width = w; - } - return w; - } - public static final int getCanvasHeight() { - int h = parent.getClientHeight(); - if(h != height) { - canvas.setHeight(h); - canvasBack.setHeight(h); - height = h; - } - return h; - } - - public static void sleep(long millis) { - try { - Thread.sleep(millis); - }catch(InterruptedException ex) { - } - } - - @JSBody(params = { "obj" }, script = "window.currentContext = obj;") - private static native int setCurrentContext(JSObject obj); - - @JSBody(params = { }, script = "return window.classicConfig;") - public static native String[] getClassicConfig(); - - @JSBody(params = { "obj" }, script = "if(obj.commit) obj.commit();") - public static native int commitContext(JSObject obj); - - @JSBody(params = { "url" }, script = "URL.revokeObjectURL(url);") - public static native void freeDataURL(String url); - - @JSBody(params = { "buf", "mime" }, script = "return URL.createObjectURL(new Blob([buf], {type: mime}));") - public static native String getDataURL(ArrayBuffer buf, String mime); -} diff --git a/src/main/java/org/lwjgl/BufferUtils.java b/src/main/java/org/lwjgl/BufferUtils.java deleted file mode 100644 index bdba91c..0000000 --- a/src/main/java/org/lwjgl/BufferUtils.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.lwjgl; - -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; - -import net.PeytonPlayz585.minecraft.GLAllocation; - -public class BufferUtils { - - public static ByteBuffer createByteBuffer(int parInt) { - return GLAllocation.createDirectByteBuffer(parInt); - } - - public static IntBuffer createIntBuffer(int parInt) { - return GLAllocation.createDirectIntBuffer(parInt); - } - - public static FloatBuffer createFloatBuffer(int parInt) { - return GLAllocation.createDirectFloatBuffer(parInt); - } - -} diff --git a/src/main/java/org/lwjgl/input/Keyboard.java b/src/main/java/org/lwjgl/input/Keyboard.java deleted file mode 100644 index 9e24766..0000000 --- a/src/main/java/org/lwjgl/input/Keyboard.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.lwjgl.input; - -import net.PeytonPlayz585.lwjgl.KeyboardConstants; -import net.PeytonPlayz585.lwjgl.PlatformInput; - -/** - * Copyright (c) 2022 LAX1DUDE. All Rights Reserved. - * - * WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES - * NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED - * TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE - * SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR. - * - * NOT FOR COMMERCIAL OR MALICIOUS USE - * - * (please read the 'LICENSE' file this repo's root directory for more info) - * - */ -public class Keyboard { - - public static final int KEY_NONE = 0x00; - public static final int KEY_ESCAPE = 0x01; - public static final int KEY_1 = 0x02; - public static final int KEY_2 = 0x03; - public static final int KEY_3 = 0x04; - public static final int KEY_4 = 0x05; - public static final int KEY_5 = 0x06; - public static final int KEY_6 = 0x07; - public static final int KEY_7 = 0x08; - public static final int KEY_8 = 0x09; - public static final int KEY_9 = 0x0A; - public static final int KEY_0 = 0x0B; - public static final int KEY_MINUS = 0x0C; /* - on main keyboard */ - public static final int KEY_EQUALS = 0x0D; - public static final int KEY_BACK = 0x0E; /* backspace */ - public static final int KEY_TAB = 0x0F; - public static final int KEY_Q = 0x10; - public static final int KEY_W = 0x11; - public static final int KEY_E = 0x12; - public static final int KEY_R = 0x13; - public static final int KEY_T = 0x14; - public static final int KEY_Y = 0x15; - public static final int KEY_U = 0x16; - public static final int KEY_I = 0x17; - public static final int KEY_O = 0x18; - public static final int KEY_P = 0x19; - public static final int KEY_LBRACKET = 0x1A; - public static final int KEY_RBRACKET = 0x1B; - public static final int KEY_RETURN = 0x1C; /* Enter on main keyboard */ - public static final int KEY_LCONTROL = 0x1D; - public static final int KEY_A = 0x1E; - public static final int KEY_S = 0x1F; - public static final int KEY_D = 0x20; - public static final int KEY_F = 0x21; - public static final int KEY_G = 0x22; - public static final int KEY_H = 0x23; - public static final int KEY_J = 0x24; - public static final int KEY_K = 0x25; - public static final int KEY_L = 0x26; - public static final int KEY_SEMICOLON = 0x27; - public static final int KEY_APOSTROPHE = 0x28; - public static final int KEY_GRAVE = 0x29; /* accent grave */ - public static final int KEY_LSHIFT = 0x2A; - public static final int KEY_BACKSLASH = 0x2B; - public static final int KEY_Z = 0x2C; - public static final int KEY_X = 0x2D; - public static final int KEY_C = 0x2E; - public static final int KEY_V = 0x2F; - public static final int KEY_B = 0x30; - public static final int KEY_N = 0x31; - public static final int KEY_M = 0x32; - public static final int KEY_COMMA = 0x33; - public static final int KEY_PERIOD = 0x34; /* . on main keyboard */ - public static final int KEY_SLASH = 0x35; /* / on main keyboard */ - public static final int KEY_RSHIFT = 0x36; - public static final int KEY_MULTIPLY = 0x37; /* * on numeric keypad */ - public static final int KEY_LMENU = 0x38; /* left Alt */ - public static final int KEY_SPACE = 0x39; - public static final int KEY_CAPITAL = 0x3A; - public static final int KEY_F1 = 0x3B; - public static final int KEY_F2 = 0x3C; - public static final int KEY_F3 = 0x3D; - public static final int KEY_F4 = 0x3E; - public static final int KEY_F5 = 0x3F; - public static final int KEY_F6 = 0x40; - public static final int KEY_F7 = 0x41; - public static final int KEY_F8 = 0x42; - public static final int KEY_F9 = 0x43; - public static final int KEY_F10 = 0x44; - public static final int KEY_NUMLOCK = 0x45; - public static final int KEY_SCROLL = 0x46; /* Scroll Lock */ - public static final int KEY_NUMPAD7 = 0x47; - public static final int KEY_NUMPAD8 = 0x48; - public static final int KEY_NUMPAD9 = 0x49; - public static final int KEY_SUBTRACT = 0x4A; /* - on numeric keypad */ - public static final int KEY_NUMPAD4 = 0x4B; - public static final int KEY_NUMPAD5 = 0x4C; - public static final int KEY_NUMPAD6 = 0x4D; - public static final int KEY_ADD = 0x4E; /* + on numeric keypad */ - public static final int KEY_NUMPAD1 = 0x4F; - public static final int KEY_NUMPAD2 = 0x50; - public static final int KEY_NUMPAD3 = 0x51; - public static final int KEY_NUMPAD0 = 0x52; - public static final int KEY_DECIMAL = 0x53; /* . on numeric keypad */ - public static final int KEY_F11 = 0x57; - public static final int KEY_F12 = 0x58; - public static final int KEY_F13 = 0x64; /* (NEC PC98) */ - public static final int KEY_F14 = 0x65; /* (NEC PC98) */ - public static final int KEY_F15 = 0x66; /* (NEC PC98) */ - public static final int KEY_F16 = 0x67; /* Extended Function keys - (Mac) */ - public static final int KEY_F17 = 0x68; - public static final int KEY_F18 = 0x69; - public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */ - public static final int KEY_F19 = 0x71; /* Extended Function keys - (Mac) */ - public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */ - public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */ - public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */ - public static final int KEY_NUMPADEQUALS = 0x8D; /* = on numeric keypad (NEC PC98) */ - public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */ - public static final int KEY_AT = 0x91; /* (NEC PC98) */ - public static final int KEY_COLON = 0x92; /* (NEC PC98) */ - public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */ - public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */ - public static final int KEY_STOP = 0x95; /* (NEC PC98) */ - public static final int KEY_AX = 0x96; /* (Japan AX) */ - public static final int KEY_UNLABELED = 0x97; /* (J3100) */ - public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */ - public static final int KEY_RCONTROL = 0x9D; - public static final int KEY_SECTION = 0xA7; /* Section symbol (Mac) */ - public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */ - public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */ - public static final int KEY_SYSRQ = 0xB7; - public static final int KEY_RMENU = 0xB8; /* right Alt */ - public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */ - public static final int KEY_PAUSE = 0xC5; /* Pause */ - public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */ - public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */ - public static final int KEY_PRIOR = 0xC9; /* PgUp on arrow keypad */ - public static final int KEY_LEFT = 0xCB; /* LeftArrow on arrow keypad */ - public static final int KEY_RIGHT = 0xCD; /* RightArrow on arrow keypad */ - public static final int KEY_END = 0xCF; /* End on arrow keypad */ - public static final int KEY_DOWN = 0xD0; /* DownArrow on arrow keypad */ - public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */ - public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */ - public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */ - public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */ - public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */ - public static final int KEY_RMETA = 0xDC; /* Right Windows/Option key */ - public static final int KEY_APPS = 0xDD; /* AppMenu key */ - public static final int KEY_POWER = 0xDE; - public static final int KEY_SLEEP = 0xDF; - - public static void enableRepeatEvents(boolean b) { - PlatformInput.keyboardEnableRepeatEvents(b); - } - - public static boolean isCreated() { - return true; - } - - public static boolean next() { - return PlatformInput.keyboardNext(); - } - - public static boolean getEventKeyState() { - return PlatformInput.keyboardGetEventKeyState(); - } - - public static char getEventCharacter() { - return PlatformInput.keyboardGetEventCharacter(); - } - - public static int getEventKey() { - return PlatformInput.keyboardGetEventKey(); - } - - public static void setFunctionKeyModifier(int key) { - PlatformInput.setFunctionKeyModifier(key); - } - - public static boolean isKeyDown(int key) { - return PlatformInput.keyboardIsKeyDown(key); - } - - public static String getKeyName(int key) { - return KeyboardConstants.getKeyName(key); - } - - public static boolean isRepeatEvent() { - return PlatformInput.keyboardIsRepeatEvent(); - } - -} \ No newline at end of file diff --git a/src/main/java/org/lwjgl/input/Mouse.java b/src/main/java/org/lwjgl/input/Mouse.java deleted file mode 100644 index 12ef918..0000000 --- a/src/main/java/org/lwjgl/input/Mouse.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.lwjgl.input; - -import org.lwjgl.opengl.Display; - -import net.PeytonPlayz585.lwjgl.PlatformInput; - -/** - * Copyright (c) 2022 LAX1DUDE. All Rights Reserved. - * - * WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES - * NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED - * TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE - * SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR. - * - * NOT FOR COMMERCIAL OR MALICIOUS USE - * - * (please read the 'LICENSE' file this repo's root directory for more info) - * - */ -public class Mouse { - - public static int getEventDWheel() { - return PlatformInput.mouseGetEventDWheel(); - } - - public static int getX() { - return PlatformInput.mouseGetX(); - } - - public static int getY() { - return PlatformInput.mouseGetY(); - } - - public static boolean getEventButtonState() { - return PlatformInput.mouseGetEventButtonState(); - } - - public static boolean isCreated() { - return true; - } - - public static boolean next() { - return PlatformInput.mouseNext(); - } - - public static int getEventX() { - return PlatformInput.mouseGetEventX(); - } - - public static int getEventY() { - return PlatformInput.mouseGetEventY(); - } - - public static int getEventButton() { - return PlatformInput.mouseGetEventButton(); - } - - public static boolean isButtonDown(int i) { - return PlatformInput.mouseIsButtonDown(i); - } - - public static int getDWheel() { - return PlatformInput.mouseGetDWheel(); - } - - public static void setGrabbed(boolean grab) { - PlatformInput.mouseSetGrabbed(grab); - } - - public static int getDX() { - return PlatformInput.mouseGetDX(); - } - - public static int getDY() { - return PlatformInput.mouseGetDY(); - } - - public static void setCursorPosition(int x, int y) { - PlatformInput.mouseSetCursorPosition(x, y); - } - - public static boolean isInsideWindow() { - return PlatformInput.mouseIsInsideWindow(); - } - - public static boolean isActuallyGrabbed() { - return PlatformInput.isPointerLocked(); - } - - public static boolean isMouseGrabbed() { - return PlatformInput.isMouseGrabbed(); - } - - public static boolean isFocused() { - return Display.isActive() && isActuallyGrabbed(); - } - -} \ No newline at end of file diff --git a/src/main/java/org/lwjgl/opengl/Display.java b/src/main/java/org/lwjgl/opengl/Display.java deleted file mode 100644 index e696fab..0000000 --- a/src/main/java/org/lwjgl/opengl/Display.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.lwjgl.opengl; - -import net.PeytonPlayz585.lwjgl.PlatformInput; -import net.PeytonPlayz585.main.MinecraftMain; - -public class Display { - - private static long lastSwap = 0l; - - public static int getWidth() { - return PlatformInput.getWindowWidth(); - } - - public static int getHeight() { - return PlatformInput.getWindowHeight(); - } - - public static boolean isActive() { - return PlatformInput.getWindowFocused(); - } - - public static void create() { - - } - - public static void setTitle(String string) { - - } - - public static boolean isCloseRequested() { - return PlatformInput.isCloseRequested(); - } - - public static void update() { - PlatformInput.update(); - } - - public static void sync(int limitFramerate) { - boolean limitFPS = limitFramerate > 0 && limitFramerate < 1000; - - if(limitFPS) { - long millis = System.currentTimeMillis(); - long frameMillis = (1000l / limitFramerate) - (millis - lastSwap); - if(frameMillis > 0l) { - MinecraftMain.sleep(frameMillis); - } - } - - lastSwap = System.currentTimeMillis(); - } - - public static boolean wasResized() { - return PlatformInput.wasResized(); - } - -} \ No newline at end of file diff --git a/src/main/java/org/lwjgl/opengl/GL11.java b/src/main/java/org/lwjgl/opengl/GL11.java deleted file mode 100644 index 507ea3a..0000000 --- a/src/main/java/org/lwjgl/opengl/GL11.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.lwjgl.opengl; - -import net.PeytonPlayz585.minecraft.GlStateManager; - -public class GL11 extends GlStateManager { - -} \ No newline at end of file diff --git a/src/main/java/com/mojang/minecraft/ChatLine.java b/src/teavm/java/com/mojang/minecraft/ChatLine.java similarity index 100% rename from src/main/java/com/mojang/minecraft/ChatLine.java rename to src/teavm/java/com/mojang/minecraft/ChatLine.java diff --git a/src/main/java/com/mojang/minecraft/Entity.java b/src/teavm/java/com/mojang/minecraft/Entity.java similarity index 94% rename from src/main/java/com/mojang/minecraft/Entity.java rename to src/teavm/java/com/mojang/minecraft/Entity.java index cb1c307..0d47cf7 100644 --- a/src/main/java/com/mojang/minecraft/Entity.java +++ b/src/teavm/java/com/mojang/minecraft/Entity.java @@ -4,9 +4,11 @@ import com.mojang.minecraft.level.BlockMap; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.liquid.LiquidType; import com.mojang.minecraft.level.tile.Block; +import com.mojang.minecraft.level.tile.Tile$SoundType; import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.net.PositionUpdate; import com.mojang.minecraft.phys.AABB; +import com.mojang.minecraft.render.TextureManager; import com.mojang.util.MathHelper; import java.io.Serializable; import java.util.ArrayList; @@ -176,7 +178,7 @@ public abstract class Entity implements Serializable { float var7 = var2; float var8 = var3; AABB var9 = this.bb.copy(); - ArrayList var10 = this.level.getCubes(this.bb.expand(var1, var2, var3)); + ArrayList var10 = this.level.getCubes(this.bb.expand(var1, var2, var3)); for(int var11 = 0; var11 < var10.size(); ++var11) { var2 = ((AABB)var10.get(var11)).clipYCollide(this.bb, var2); @@ -358,7 +360,7 @@ public abstract class Entity implements Serializable { return this.level.getBrightness(var4, var2, var3); } - public void render(float var2) {} + public void render(TextureManager var1, float var2) {} public void setLevel(Level var1) { this.level = var1; @@ -463,5 +465,5 @@ public abstract class Entity implements Serializable { return false; } - public void renderHover(float var2) {} + public void renderHover(TextureManager var1, float var2) {} } diff --git a/src/main/java/com/mojang/minecraft/GameSettings.java b/src/teavm/java/com/mojang/minecraft/GameSettings.java similarity index 69% rename from src/main/java/com/mojang/minecraft/GameSettings.java rename to src/teavm/java/com/mojang/minecraft/GameSettings.java index cb4d5d7..69def43 100644 --- a/src/main/java/com/mojang/minecraft/GameSettings.java +++ b/src/teavm/java/com/mojang/minecraft/GameSettings.java @@ -1,8 +1,6 @@ package com.mojang.minecraft; -import org.lwjgl.input.Keyboard; - -import com.mojang.minecraft.gamemode.*; +import org.lwjgl.opengl.GL11; public final class GameSettings { @@ -10,12 +8,10 @@ public final class GameSettings { bindings = new KeyBinding[] {forwardKey, leftKey, backKey, rightKey, jumpKey, buildKey, chatKey, toggleFogKey, saveLocationKey, loadLocationKey}; - settingCount = 8; + settingCount = 9; this.minecraft = minecraft; -// settingsFile = new File(minecraftFolder, "options.txt"); - load(); } @@ -28,11 +24,6 @@ public final class GameSettings public boolean viewBobbing = true; public boolean anaglyph = false; public boolean limitFramerate = false; - public boolean ofBetterGrass = false; - public boolean ofFastMath = true; - public boolean ofSmoothFPS = false; - public boolean gamemode = false; - public boolean randomDrops = false; public KeyBinding forwardKey = new KeyBinding("Forward", 17); public KeyBinding leftKey = new KeyBinding("Left", 30); public KeyBinding backKey = new KeyBinding("Back", 31); @@ -45,12 +36,11 @@ public final class GameSettings public KeyBinding loadLocationKey = new KeyBinding("Load location", 19); public KeyBinding[] bindings; private Minecraft minecraft; -// private File settingsFile; public int settingCount; public String getBinding(int key) { - return bindings[key].name + ": " + Keyboard.getKeyName(bindings[key].key); + return bindings[key].name + ": " + GL11.getKeyName(bindings[key].key); } public void setBinding(int key, int keyID) @@ -104,35 +94,6 @@ public final class GameSettings limitFramerate = !limitFramerate; } - if(setting == 8) { - ofBetterGrass = !ofBetterGrass; - minecraft.levelRenderer.refresh(); - } - - if(setting == 9) { - ofFastMath = !ofFastMath; - minecraft.levelRenderer.refresh(); - } - - if(setting == 11) { - if(gamemode) { - GameMode game = new SurvivalGameMode(minecraft); - game.apply(minecraft.level); - game.apply(minecraft.player); - minecraft.gamemode = game; - } else { - GameMode game = new CreativeGameMode(minecraft); - game.apply(minecraft.level); - game.apply(minecraft.player); - minecraft.gamemode = game; - } - gamemode = !gamemode; - } - - if(setting == 12) { - randomDrops = !randomDrops; - } - save(); } @@ -146,12 +107,7 @@ public final class GameSettings : (id == 5 ? "View bobbing: " + (viewBobbing ? "ON" : "OFF") : (id == 6 ? "3d anaglyph: " + (anaglyph ? "ON" : "OFF") : (id == 7 ? "Limit framerate: " + (limitFramerate ? "ON" : "OFF") - : (id == 8 ? "Better Grass: " + (ofBetterGrass ? "ON" : "OFF") - : (id == 9 ? "Fast Math: " + (ofFastMath ? "ON" : "OFF") - : (id == 10 ? "Smooth FPS: " + (ofSmoothFPS ? "ON" : "OFF") - : (id == 11 ? "GameMode: " + (gamemode ? "Creative" : "Survival") - : (id == 12 ? "Random Drops: " + (randomDrops ? "ON": "OFF") - : "")))))))))))); + : ""))))))); } private void load() @@ -209,21 +165,6 @@ public final class GameSettings // limitFramerate = setting[1].equals("true"); // } // -// if(setting[0].equals("ofBetterGrass")) -// { -// ofBetterGrass = setting[1].equals("true"); -// } -// -// if(setting[0].equals("ofFastMath")) -// { -// ofFastMath = setting[1].equals("true"); -// } -// -// if(setting[0].equals("ofSmoothFPS")) -// { -// ofSmoothFPS = setting[1].equals("true"); -// } -// // for(int index = 0; index < this.bindings.length; index++) // { // if(setting[0].equals("key_" + bindings[index].name)) @@ -256,9 +197,6 @@ public final class GameSettings // writer.println("bobView:" + viewBobbing); // writer.println("anaglyph3d:" + anaglyph); // writer.println("limitFramerate:" + limitFramerate); -// writer.println("ofBetterGrass:" + ofBetterGrass); -// writer.println("ofFastMath:" + ofFastMath); -// writer.println("ofSmoothFPS:" + ofSmoothFPS); // // for(int binding = 0; binding < bindings.length; binding++) // { diff --git a/src/main/java/com/mojang/minecraft/KeyBinding.java b/src/teavm/java/com/mojang/minecraft/KeyBinding.java similarity index 100% rename from src/main/java/com/mojang/minecraft/KeyBinding.java rename to src/teavm/java/com/mojang/minecraft/KeyBinding.java diff --git a/src/main/java/com/mojang/minecraft/Minecraft.java b/src/teavm/java/com/mojang/minecraft/Minecraft.java similarity index 85% rename from src/main/java/com/mojang/minecraft/Minecraft.java rename to src/teavm/java/com/mojang/minecraft/Minecraft.java index 62008d6..95e1e2b 100644 --- a/src/main/java/com/mojang/minecraft/Minecraft.java +++ b/src/teavm/java/com/mojang/minecraft/Minecraft.java @@ -17,7 +17,6 @@ import com.mojang.minecraft.model.ModelManager; import com.mojang.minecraft.model.ModelPart; import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.net.NetworkPlayer; -import com.mojang.minecraft.net.PacketType; import com.mojang.minecraft.particle.Particle; import com.mojang.minecraft.particle.ParticleManager; import com.mojang.minecraft.particle.WaterDropParticle; @@ -25,19 +24,18 @@ import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.player.InputHandlerImpl; import com.mojang.minecraft.player.Player; import com.mojang.minecraft.render.*; +import com.mojang.minecraft.render.Renderer; import com.mojang.minecraft.render.texture.TextureFX; import com.mojang.minecraft.render.texture.TextureLavaFX; import com.mojang.minecraft.render.texture.TextureWaterFX; import com.mojang.util.MathHelper; -import net.PeytonPlayz585.main.MinecraftMain; +import net.lax1dude.eaglercraft.GLAllocation; -import org.lwjgl.BufferUtils; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; +import java.awt.*; +import java.io.*; import java.nio.IntBuffer; import java.util.Collections; import java.util.List; @@ -56,6 +54,7 @@ public final class Minecraft implements Runnable { public String host; public boolean levelLoaded = false; public volatile boolean waiting = false; + public TextureManager textureManager; public FontRenderer fontRenderer; public GuiScreen currentScreen = null; public ProgressBarDisplay progressBar = new ProgressBarDisplay(this); @@ -68,7 +67,7 @@ public final class Minecraft implements Runnable { public HUDScreen hud; public boolean online; public MovingObjectPosition selected; - public static GameSettings settings; + public GameSettings settings; String server; int port; volatile boolean running; @@ -78,7 +77,7 @@ public final class Minecraft implements Runnable { public boolean raining; - public Minecraft(int var3, int var4, boolean var5) { + public Minecraft() { this.levelIo = new LevelIO(this.progressBar); this.ticks = 0; this.blockHitTime = 0; @@ -95,8 +94,8 @@ public final class Minecraft implements Runnable { this.lastClick = 0; this.raining = false; new SleepForeverThread(this); - this.width = var3; - this.height = var4; + this.width = GL11.getCanvasWidth(); + this.height = GL11.getCanvasHeight(); } public final void setCurrentScreen(GuiScreen var1) { @@ -114,11 +113,7 @@ public final class Minecraft implements Runnable { if(this.hasMouse) { this.player.releaseAllKeys(); this.hasMouse = false; - if(this.levelLoaded) { - Mouse.setGrabbed(false); - } else { - Mouse.setGrabbed(false); - } + GL11.mouseSetGrabbed(false); } int var2 = this.width * 240 / this.height; @@ -138,13 +133,13 @@ public final class Minecraft implements Runnable { System.out.println("########## GL ERROR ##########"); System.out.println("@ " + var0); System.out.println(var1 + ": " + var2); + System.exit(0); } } public final void shutdown() { - this.running = false; - MinecraftMain.canvas.delete(); + GL11.destroyContext(); } public final void run() { @@ -152,9 +147,6 @@ public final class Minecraft implements Runnable { //try { Minecraft var1 = this; - this.width = MinecraftMain.canvas.getWidth(); - this.height = MinecraftMain.canvas.getHeight(); - checkGLError("Pre startup"); GL11.glEnable(3553); GL11.glShadeModel(7425); @@ -169,10 +161,13 @@ public final class Minecraft implements Runnable { GL11.glMatrixMode(5888); checkGLError("Startup"); this.settings = new GameSettings(this); - this.fontRenderer = new FontRenderer(this.settings, "/default.png"); + this.textureManager = new TextureManager(this.settings); + this.textureManager.registerAnimation(new TextureLavaFX()); + this.textureManager.registerAnimation(new TextureWaterFX()); + this.fontRenderer = new FontRenderer(this.settings, "/default.png", this.textureManager); IntBuffer var9; - (var9 = BufferUtils.createIntBuffer(256)).clear().limit(256); - this.levelRenderer = new LevelRenderer(this); + (var9 = GLAllocation.createDirectIntBuffer(256)).clear().limit(256); + this.levelRenderer = new LevelRenderer(this, this.textureManager); Item.initModels(); Mob.modelCache = new ModelManager(); GL11.glViewport(0, 0, this.width, this.height); @@ -181,14 +176,16 @@ public final class Minecraft implements Runnable { (var85 = new Level()).setData(8, 8, 8, new byte[512]); this.setLevel(var85); } else { + boolean var10 = false; this.generateLevel(1); } - this.particleManager = new ParticleManager(this.level); + this.particleManager = new ParticleManager(this.level, this.textureManager); checkGLError("Post startup"); this.hud = new HUDScreen(this, this.width, this.height); //} catch (Exception var62) { //var62.printStackTrace(); + //JOptionPane.showMessageDialog((Component)null, var62.toString(), "Failed to start Minecraft", 0); //throw new RuntimeException("Failed to start Minecraft! :("); //} @@ -200,10 +197,6 @@ public final class Minecraft implements Runnable { if(this.waiting) { Thread.sleep(100L); } else { - if(Display.isCloseRequested()) { - this.running = false; - } - try { Timer var63 = this.timer; long var16; @@ -254,11 +247,11 @@ public final class Minecraft implements Runnable { this.gamemode.applyCracks(this.timer.delta); float var65 = this.timer.delta; Renderer var66 = this.renderer; - if(this.renderer.displayActive && !Display.isActive()) { + if(this.renderer.displayActive && !GL11.isFocused()) { var66.minecraft.pause(); } - var66.displayActive = Display.isActive(); + var66.displayActive = GL11.isFocused(); int var68; int var70; int var86; @@ -267,20 +260,10 @@ public final class Minecraft implements Runnable { var81 = 0; var86 = 0; if(var66.minecraft.levelLoaded) { -// if(var66.minecraft.canvas != null) { -// Point var90; -// var70 = (var90 = MinecraftMain.canvas.mouse).x + var66.minecraft.width / 2; -// var68 = var90.y + var66.minecraft.height / 2; -// Point var75; -// var81 = (var75 = MouseInfo.getPointerInfo().getLocation()).x - var70; -// var86 = -(var75.y - var68); -// Mouse.setCursorPosition(var70, var68); -// } else { - Mouse.setCursorPosition(var66.minecraft.width / 2, var66.minecraft.height / 2); -// } + GL11.mouseSetCursorPosition(var66.minecraft.width / 2, var66.minecraft.height / 2); } else { - var81 = Mouse.getDX(); - var86 = Mouse.getDY(); + var81 = GL11.mouseGetDX(); + var86 = GL11.mouseGetDY(); } byte var91 = 1; @@ -294,8 +277,8 @@ public final class Minecraft implements Runnable { if(!var66.minecraft.online) { var81 = var66.minecraft.width * 240 / var66.minecraft.height; var86 = var66.minecraft.height * 240 / var66.minecraft.height; - int var94 = Mouse.getX() * var81 / var66.minecraft.width; - var70 = var86 - Mouse.getY() * var86 / var66.minecraft.height - 1; + int var94 = GL11.mouseGetX() * var81 / var66.minecraft.width; + var70 = var86 - GL11.mouseGetY() * var86 / var66.minecraft.height - 1; if(var66.minecraft.level != null) { float var80 = var65; Renderer var82 = var66; @@ -519,7 +502,7 @@ public final class Minecraft implements Runnable { var82.setLighting(true); Vec3D var103 = var82.getPlayerVector(var80); - var89.level.blockMap.render(var103, var76, var80); + var89.level.blockMap.render(var103, var76, var89.textureManager, var80); var82.setLighting(false); var82.updateFog(); float var107 = var80; @@ -531,18 +514,16 @@ public final class Minecraft implements Runnable { for(var83 = 0; var83 < 2; ++var83) { if(var96.particles[var83].size() != 0) { - RenderEngine r = new RenderEngine(); - var110 = 0; + var110 = 0; if(var83 == 0) { - var110 = r.getTexture("/particles.png"); - new TextureLocation("/particles.png").bindTexture(); + var110 = var96.textureManager.load("/particles.png"); } if(var83 == 1) { - var110 = r.getTexture("/terrain.png"); - new TextureLocation("/terrain.png").bindTexture(); + var110 = var96.textureManager.load("/terrain.png"); } + GL11.glBindTexture(3553, var110); ShapeRenderer var121 = ShapeRenderer.instance; ShapeRenderer.instance.begin(); @@ -554,12 +535,12 @@ public final class Minecraft implements Runnable { } } - new TextureLocation("/rock.png").bindTexture(); + GL11.glBindTexture(3553, var89.textureManager.load("/rock.png")); GL11.glEnable(3553); GL11.glCallList(var89.listId); var82.updateFog(); var101 = var89; - new TextureLocation("/clouds.png").bindTexture(); + GL11.glBindTexture(3553, var89.textureManager.load("/clouds.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); var107 = (float)(var89.level.cloudColor >> 16 & 255) / 255.0F; var29 = (float)(var89.level.cloudColor >> 8 & 255) / 255.0F; @@ -640,9 +621,8 @@ public final class Minecraft implements Runnable { GL11.glColor4f(1.0F, 1.0F, 1.0F, (MathHelper.sin((float)System.currentTimeMillis() / 100.0F) * 0.2F + 0.4F) * 0.5F); if(var89.cracks > 0.0F) { GL11.glBlendFunc(774, 768); - RenderEngine r = new RenderEngine(); - var108 = r.getTexture("/terrain.png"); - new TextureLocation("/terrain.png").bindTexture(); + var108 = var89.textureManager.load("/terrain.png"); + GL11.glBindTexture(3553, var108); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); GL11.glPushMatrix(); Block var10000 = (var114 = var89.level.getTile(var102.x, var102.y, var102.z)) > 0?Block.blocks[var114]:null; @@ -683,34 +663,6 @@ public final class Minecraft implements Runnable { GL11.glDisable(3553); GL11.glDepthMask(false); var29 = 0.002F; -// if((var104 = var89.level.getTile(var102.x, var102.y, var102.z)) > 0) { -// AABB var111 = Block.blocks[var104].getSelectionBox(var102.x, var102.y, var102.z).grow(var29, var29, var29); -// GL11.glBegin(3); -// GL11.glVertex3f(var111.x0, var111.y0, var111.z0); -// GL11.glVertex3f(var111.x1, var111.y0, var111.z0); -// GL11.glVertex3f(var111.x1, var111.y0, var111.z1); -// GL11.glVertex3f(var111.x0, var111.y0, var111.z1); -// GL11.glVertex3f(var111.x0, var111.y0, var111.z0); -// GL11.glEnd(); -// GL11.glBegin(3); -// GL11.glVertex3f(var111.x0, var111.y1, var111.z0); -// GL11.glVertex3f(var111.x1, var111.y1, var111.z0); -// GL11.glVertex3f(var111.x1, var111.y1, var111.z1); -// GL11.glVertex3f(var111.x0, var111.y1, var111.z1); -// GL11.glVertex3f(var111.x0, var111.y1, var111.z0); -// GL11.glEnd(); -// GL11.glBegin(1); -// GL11.glVertex3f(var111.x0, var111.y0, var111.z0); -// GL11.glVertex3f(var111.x0, var111.y1, var111.z0); -// GL11.glVertex3f(var111.x1, var111.y0, var111.z0); -// GL11.glVertex3f(var111.x1, var111.y1, var111.z0); -// GL11.glVertex3f(var111.x1, var111.y0, var111.z1); -// GL11.glVertex3f(var111.x1, var111.y1, var111.z1); -// GL11.glVertex3f(var111.x0, var111.y0, var111.z1); -// GL11.glVertex3f(var111.x0, var111.y1, var111.z1); -// GL11.glEnd(); -// } - GL11.glDepthMask(true); GL11.glEnable(3553); GL11.glDisable(3042); @@ -721,7 +673,7 @@ public final class Minecraft implements Runnable { var82.updateFog(); GL11.glEnable(3553); GL11.glEnable(3042); - new TextureLocation("/water.png").bindTexture(); + GL11.glBindTexture(3553, var89.textureManager.load("/water.png")); GL11.glCallList(var89.listId + 1); GL11.glDisable(3042); GL11.glEnable(3042); @@ -737,12 +689,8 @@ public final class Minecraft implements Runnable { } if(var120 > 0) { - new TextureLocation("/terrain.png").bindTexture(); - if(settings.ofFastMath) { - GL11.glCallLists(var89.buffer_fast); - } else { - GL11.glCallLists(var89.buffer); - } + GL11.glBindTexture(3553, var89.textureManager.load("/terrain.png")); + GL11.glCallLists(var89.buffer); } GL11.glDepthMask(true); @@ -761,7 +709,7 @@ public final class Minecraft implements Runnable { GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); - new TextureLocation("/rain.png").bindTexture(); + GL11.glBindTexture(3553, var82.minecraft.textureManager.load("/rain.png")); for(var110 = var104 - 5; var110 <= var104 + 5; ++var110) { for(var122 = var114 - 5; var122 <= var114 + 5; ++var122) { @@ -801,7 +749,7 @@ public final class Minecraft implements Runnable { } if(var82.entity != null) { - var82.entity.renderHover(var80); + var82.entity.renderHover(var82.minecraft.textureManager, var80); } GL11.glClear(256); @@ -845,10 +793,10 @@ public final class Minecraft implements Runnable { var34 = 0.4F; GL11.glScalef(0.4F, var34, var34); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - new TextureLocation("/terrain.png").bindTexture(); + GL11.glBindTexture(3553, var112.minecraft.textureManager.load("/terrain.png")); var112.block.renderPreview(var123); } else { - var116.bindTexture(); + var116.bindTexture(var112.minecraft.textureManager); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.0F, 0.2F, 0.0F); GL11.glRotatef(-120.0F, 0.0F, 0.0F, 1.0F); @@ -889,7 +837,7 @@ public final class Minecraft implements Runnable { } Thread.yield(); - Display.update(); + GL11.updateDisplay(); } } @@ -926,17 +874,17 @@ public final class Minecraft implements Runnable { } public final void grabMouse() { - if(!this.hasMouse) { - if(!Mouse.isFocused()) { - return; - } else if(Mouse.isActuallyGrabbed()) { - return; - } else { - Mouse.setGrabbed(true); - this.setCurrentScreen((GuiScreen)null); - this.lastClick = this.ticks + 10000; - } - } + if(GL11.isFocused()) { + return; + } + if (GL11.isPointerLocked2()) { + return; + } else { + GL11.mouseSetGrabbed(true); + this.setCurrentScreen((GuiScreen)null); + this.lastClick = this.ticks + 10000; + return; + } } public final void pause() { @@ -1017,7 +965,7 @@ public final class Minecraft implements Runnable { if(!this.gamemode.canPlace(var10)) { return; } - + this.level.netSetTile(var3, var4, var5, var10); var2 = this.renderer.heldBlock; this.renderer.heldBlock.pos = 0.0F; @@ -1040,49 +988,51 @@ public final class Minecraft implements Runnable { ++((ChatLine)var17.chat.get(var16)).time; } - new TextureLocation("/terrain.png").bindTexture(); + GL11.glBindTexture(3553, this.textureManager.load("/terrain.png")); + TextureManager var19 = this.textureManager; -// for(var16 = 0; var16 < var19.animations.size(); ++var16) { -// TextureFX var3; -// (var3 = (TextureFX)var19.animations.get(var16)).anaglyph = var19.settings.anaglyph; -// var3.animate(); -// var19.textureBuffer.clear(); -// var19.textureBuffer.put(var3.textureData); -// var19.textureBuffer.position(0).limit(var3.textureData.length); -// GL11.glTexSubImage2D(3553, 0, var3.textureId % 16 << 4, var3.textureId / 16 << 4, 16, 16, 6408, 5121, var19.textureBuffer); -// } + for(var16 = 0; var16 < var19.animations.size(); ++var16) { + TextureFX var3; + (var3 = (TextureFX)var19.animations.get(var16)).anaglyph = var19.settings.anaglyph; + var3.animate(); + var19.textureBuffer.clear(); + var19.textureBuffer.put(var3.textureData); + var19.textureBuffer.position(0).limit(var3.textureData.length); + GL11.glTexSubImage2D(3553, 0, var3.textureId % 16 << 4, var3.textureId / 16 << 4, 16, 16, 6408, 5121, var19.textureBuffer); + } int var4; int var8; int var40; int var46; int var45; + if(this.currentScreen == null && this.player != null && this.player.health <= 0) { this.setCurrentScreen((GuiScreen)null); } if(this.currentScreen == null || this.currentScreen.grabsMouse) { int var25; - while(Mouse.next()) { - if((var25 = Mouse.getEventDWheel()) != 0) { + while(GL11.mouseNext()) { + if((var25 = GL11.mouseGetEventDWheel()) != 0) { this.player.inventory.swapPaint(var25); } if(this.currentScreen == null) { - if(!this.hasMouse && Mouse.getEventButtonState()) { + if(!this.hasMouse && GL11.mouseGetEventButtonState()) { this.grabMouse(); } else { - if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) { + if(GL11.mouseGetEventButton() == 0 && GL11.mouseGetEventButtonState()) { this.onMouseClick(0); this.lastClick = this.ticks; } - if(Mouse.getEventButton() == 1 && Mouse.getEventButtonState()) { + if(GL11.mouseGetEventButton() == 1 && GL11.mouseGetEventButtonState()) { this.onMouseClick(1); this.lastClick = this.ticks; } - if(Mouse.getEventButton() == 2 && Mouse.getEventButtonState() && this.selected != null) { + if(GL11.mouseGetEventButton() == 2 && GL11.mouseGetEventButtonState() && this.selected != null) { if((var16 = this.level.getTile(this.selected.x, this.selected.y, this.selected.z)) == Block.GRASS.id) { var16 = Block.DIRT.id; } @@ -1109,69 +1059,69 @@ public final class Minecraft implements Runnable { --this.blockHitTime; } - while(Keyboard.next()) { - this.player.setKey(Keyboard.getEventKey(), Keyboard.getEventKeyState()); - if(Keyboard.getEventKeyState()) { + while(GL11.keysNext()) { + this.player.setKey(GL11.getEventKey(), GL11.getEventKeyState()); + if(GL11.getEventKeyState()) { if(this.currentScreen != null) { this.currentScreen.keyboardEvent(); } if(this.currentScreen == null) { - if(Keyboard.getEventKey() == 1) { + if(GL11.getEventKey() == 1) { this.pause(); } if(this.gamemode instanceof CreativeGameMode) { - if(Keyboard.getEventKey() == this.settings.loadLocationKey.key) { + if(GL11.getEventKey() == this.settings.loadLocationKey.key) { this.player.resetPos(); } - if(Keyboard.getEventKey() == this.settings.saveLocationKey.key) { + if(GL11.getEventKey() == this.settings.saveLocationKey.key) { this.level.setSpawnPos((int)this.player.x, (int)this.player.y, (int)this.player.z, this.player.yRot); this.player.resetPos(); } } - Keyboard.getEventKey(); - if(Keyboard.getEventKey() == 63) { + GL11.getEventKey(); + if(GL11.getEventKey() == 63) { this.raining = !this.raining; } - if(Keyboard.getEventKey() == 15 && this.gamemode instanceof SurvivalGameMode && this.player.arrows > 0) { + if(GL11.getEventKey() == 15 && this.gamemode instanceof SurvivalGameMode && this.player.arrows > 0) { this.level.addEntity(new Arrow(this.level, this.player, this.player.x, this.player.y, this.player.z, this.player.yRot, this.player.xRot, 1.2F)); --this.player.arrows; } - if(Keyboard.getEventKey() == this.settings.buildKey.key) { + if(GL11.getEventKey() == this.settings.buildKey.key) { this.gamemode.openInventory(); } } for(var25 = 0; var25 < 9; ++var25) { - if(Keyboard.getEventKey() == var25 + 2) { + if(GL11.getEventKey() == var25 + 2) { this.player.inventory.selected = var25; } } - if(Keyboard.getEventKey() == this.settings.toggleFogKey.key) { - this.settings.toggleSetting(4, !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54)?1:-1); + if(GL11.getEventKey() == this.settings.toggleFogKey.key) { + this.settings.toggleSetting(4, !GL11.isKeyDown(42) && !GL11.isKeyDown(54)?1:-1); } } } if(this.currentScreen == null) { - if(Mouse.isButtonDown(0) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) { + if(GL11.mouseIsButtonDown(0) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) { this.onMouseClick(0); this.lastClick = this.ticks; } - if(Mouse.isButtonDown(1) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) { + if(GL11.mouseIsButtonDown(1) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) { this.onMouseClick(1); this.lastClick = this.ticks; } } - boolean var26 = this.currentScreen == null && Mouse.isButtonDown(0) && this.hasMouse; + boolean var26 = this.currentScreen == null && GL11.mouseIsButtonDown(0) && this.hasMouse; boolean var35 = false; if(!this.gamemode.instantBreak && this.blockHitTime <= 0) { if(var26 && this.selected != null && this.selected.entityPos == 0) { diff --git a/src/main/java/com/mojang/minecraft/MovingObjectPosition.java b/src/teavm/java/com/mojang/minecraft/MovingObjectPosition.java similarity index 100% rename from src/main/java/com/mojang/minecraft/MovingObjectPosition.java rename to src/teavm/java/com/mojang/minecraft/MovingObjectPosition.java diff --git a/src/main/java/com/mojang/minecraft/ProgressBarDisplay.java b/src/teavm/java/com/mojang/minecraft/ProgressBarDisplay.java similarity index 89% rename from src/main/java/com/mojang/minecraft/ProgressBarDisplay.java rename to src/teavm/java/com/mojang/minecraft/ProgressBarDisplay.java index 6dedf7c..2aaf9f5 100644 --- a/src/main/java/com/mojang/minecraft/ProgressBarDisplay.java +++ b/src/teavm/java/com/mojang/minecraft/ProgressBarDisplay.java @@ -2,11 +2,7 @@ package com.mojang.minecraft; import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.StopGameException; -import com.mojang.minecraft.render.RenderEngine; import com.mojang.minecraft.render.ShapeRenderer; -import com.mojang.minecraft.render.TextureLocation; - -import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; public final class ProgressBarDisplay { @@ -58,9 +54,8 @@ public final class ProgressBarDisplay { int var5 = this.minecraft.height * 240 / this.minecraft.height; GL11.glClear(16640); ShapeRenderer var6 = ShapeRenderer.instance; - RenderEngine r = new RenderEngine(); - int var7 = r.getTexture("/dirt.png"); - new TextureLocation("/dirt.png").bindTexture(); + int var7 = this.minecraft.textureManager.load("/dirt.png"); + GL11.glBindTexture(3553, var7); float var10 = 32.0F; var6.begin(); var6.color(4210752); @@ -90,7 +85,7 @@ public final class ProgressBarDisplay { this.minecraft.fontRenderer.render(this.title, (var4 - this.minecraft.fontRenderer.getWidth(this.title)) / 2, var5 / 2 - 4 - 16, 16777215); this.minecraft.fontRenderer.render(this.text, (var4 - this.minecraft.fontRenderer.getWidth(this.text)) / 2, var5 / 2 - 4 + 8, 16777215); - Display.update(); + GL11.updateDisplay(); try { Thread.yield(); diff --git a/src/main/java/com/mojang/minecraft/SessionData.java b/src/teavm/java/com/mojang/minecraft/SessionData.java similarity index 97% rename from src/main/java/com/mojang/minecraft/SessionData.java rename to src/teavm/java/com/mojang/minecraft/SessionData.java index fa354c2..64452a3 100644 --- a/src/main/java/com/mojang/minecraft/SessionData.java +++ b/src/teavm/java/com/mojang/minecraft/SessionData.java @@ -1,66 +1,65 @@ -package com.mojang.minecraft; - -import com.mojang.minecraft.level.tile.Block; -import java.util.ArrayList; -import java.util.List; - -public final class SessionData { - - public static List allowedBlocks; - public String username; - public String sessionId; - public String mppass; - public boolean haspaid; - - - public SessionData(String var1, String var2) { - this.username = var1; - this.sessionId = var2; - } - - static { - (allowedBlocks = new ArrayList()).add(Block.STONE); - allowedBlocks.add(Block.COBBLESTONE); - allowedBlocks.add(Block.BRICK); - allowedBlocks.add(Block.DIRT); - allowedBlocks.add(Block.WOOD); - allowedBlocks.add(Block.LOG); - allowedBlocks.add(Block.LEAVES); - allowedBlocks.add(Block.GLASS); - allowedBlocks.add(Block.SLAB); - allowedBlocks.add(Block.MOSSY_COBBLESTONE); - allowedBlocks.add(Block.SAPLING); - allowedBlocks.add(Block.DANDELION); - allowedBlocks.add(Block.ROSE); - allowedBlocks.add(Block.BROWN_MUSHROOM); - allowedBlocks.add(Block.RED_MUSHROOM); - allowedBlocks.add(Block.SAND); - allowedBlocks.add(Block.GRAVEL); - allowedBlocks.add(Block.SPONGE); - allowedBlocks.add(Block.RED_WOOL); - allowedBlocks.add(Block.ORANGE_WOOL); - allowedBlocks.add(Block.YELLOW_WOOL); - allowedBlocks.add(Block.LIME_WOOL); - allowedBlocks.add(Block.GREEN_WOOL); - allowedBlocks.add(Block.AQUA_GREEN_WOOL); - allowedBlocks.add(Block.CYAN_WOOL); - allowedBlocks.add(Block.BLUE_WOOL); - allowedBlocks.add(Block.PURPLE_WOOL); - allowedBlocks.add(Block.INDIGO_WOOL); - allowedBlocks.add(Block.VIOLET_WOOL); - allowedBlocks.add(Block.MAGENTA_WOOL); - allowedBlocks.add(Block.PINK_WOOL); - allowedBlocks.add(Block.BLACK_WOOL); - allowedBlocks.add(Block.GRAY_WOOL); - allowedBlocks.add(Block.WHITE_WOOL); - allowedBlocks.add(Block.COAL_ORE); - allowedBlocks.add(Block.IRON_ORE); - allowedBlocks.add(Block.GOLD_ORE); - allowedBlocks.add(Block.IRON_BLOCK); - allowedBlocks.add(Block.GOLD_BLOCK); - allowedBlocks.add(Block.BOOKSHELF); - allowedBlocks.add(Block.TNT); - allowedBlocks.add(Block.OBSIDIAN); - allowedBlocks.add(Block.BEDROCK); - } -} +package com.mojang.minecraft; + +import com.mojang.minecraft.level.tile.Block; +import java.util.ArrayList; +import java.util.List; + +public final class SessionData { + + public static List allowedBlocks; + public String username; + public String sessionId; + public String mppass; + public boolean haspaid; + + + public SessionData(String var1, String var2) { + this.username = var1; + this.sessionId = var2; + } + + static { + (allowedBlocks = new ArrayList()).add(Block.STONE); + allowedBlocks.add(Block.COBBLESTONE); + allowedBlocks.add(Block.BRICK); + allowedBlocks.add(Block.DIRT); + allowedBlocks.add(Block.WOOD); + allowedBlocks.add(Block.LOG); + allowedBlocks.add(Block.LEAVES); + allowedBlocks.add(Block.GLASS); + allowedBlocks.add(Block.SLAB); + allowedBlocks.add(Block.MOSSY_COBBLESTONE); + allowedBlocks.add(Block.SAPLING); + allowedBlocks.add(Block.DANDELION); + allowedBlocks.add(Block.ROSE); + allowedBlocks.add(Block.BROWN_MUSHROOM); + allowedBlocks.add(Block.RED_MUSHROOM); + allowedBlocks.add(Block.SAND); + allowedBlocks.add(Block.GRAVEL); + allowedBlocks.add(Block.SPONGE); + allowedBlocks.add(Block.RED_WOOL); + allowedBlocks.add(Block.ORANGE_WOOL); + allowedBlocks.add(Block.YELLOW_WOOL); + allowedBlocks.add(Block.LIME_WOOL); + allowedBlocks.add(Block.GREEN_WOOL); + allowedBlocks.add(Block.AQUA_GREEN_WOOL); + allowedBlocks.add(Block.CYAN_WOOL); + allowedBlocks.add(Block.BLUE_WOOL); + allowedBlocks.add(Block.PURPLE_WOOL); + allowedBlocks.add(Block.INDIGO_WOOL); + allowedBlocks.add(Block.VIOLET_WOOL); + allowedBlocks.add(Block.MAGENTA_WOOL); + allowedBlocks.add(Block.PINK_WOOL); + allowedBlocks.add(Block.BLACK_WOOL); + allowedBlocks.add(Block.GRAY_WOOL); + allowedBlocks.add(Block.WHITE_WOOL); + allowedBlocks.add(Block.COAL_ORE); + allowedBlocks.add(Block.IRON_ORE); + allowedBlocks.add(Block.GOLD_ORE); + allowedBlocks.add(Block.IRON_BLOCK); + allowedBlocks.add(Block.GOLD_BLOCK); + allowedBlocks.add(Block.BOOKSHELF); + allowedBlocks.add(Block.TNT); + allowedBlocks.add(Block.OBSIDIAN); + } +} diff --git a/src/teavm/java/com/mojang/minecraft/SkinDownloadThread.java b/src/teavm/java/com/mojang/minecraft/SkinDownloadThread.java new file mode 100644 index 0000000..5e85d64 --- /dev/null +++ b/src/teavm/java/com/mojang/minecraft/SkinDownloadThread.java @@ -0,0 +1,51 @@ +package com.mojang.minecraft; + +import com.mojang.minecraft.player.Player; +import java.net.HttpURLConnection; +import java.net.URL; +import javax.imageio.ImageIO; + +public class SkinDownloadThread extends Thread +{ + public SkinDownloadThread(Minecraft minecraft) + { + super(); + + this.minecraft = minecraft; + } + + @Override + public void run() + { + if(minecraft.session != null) + { + HttpURLConnection connection = null; + + try { + connection = (HttpURLConnection)new URL("http://www.minecraft.net/skin/" + minecraft.session.username + ".png").openConnection(); + + connection.setDoInput(true); + connection.setDoOutput(false); + + connection.connect(); + + if(connection.getResponseCode() != 404) + { + Player.newTexture = ImageIO.read(connection.getInputStream()); + + return; + } + } catch (Exception var4) { + var4.printStackTrace(); + } finally { + if(connection != null) + { + connection.disconnect(); + } + } + + } + } + + private Minecraft minecraft; +} diff --git a/src/main/java/com/mojang/minecraft/SleepForeverThread.java b/src/teavm/java/com/mojang/minecraft/SleepForeverThread.java similarity index 100% rename from src/main/java/com/mojang/minecraft/SleepForeverThread.java rename to src/teavm/java/com/mojang/minecraft/SleepForeverThread.java diff --git a/src/main/java/com/mojang/minecraft/StopGameException.java b/src/teavm/java/com/mojang/minecraft/StopGameException.java similarity index 100% rename from src/main/java/com/mojang/minecraft/StopGameException.java rename to src/teavm/java/com/mojang/minecraft/StopGameException.java diff --git a/src/main/java/com/mojang/minecraft/Timer.java b/src/teavm/java/com/mojang/minecraft/Timer.java similarity index 100% rename from src/main/java/com/mojang/minecraft/Timer.java rename to src/teavm/java/com/mojang/minecraft/Timer.java diff --git a/src/main/java/com/mojang/minecraft/gamemode/CreativeGameMode.java b/src/teavm/java/com/mojang/minecraft/gamemode/CreativeGameMode.java similarity index 100% rename from src/main/java/com/mojang/minecraft/gamemode/CreativeGameMode.java rename to src/teavm/java/com/mojang/minecraft/gamemode/CreativeGameMode.java diff --git a/src/main/java/com/mojang/minecraft/gamemode/GameMode.java b/src/teavm/java/com/mojang/minecraft/gamemode/GameMode.java similarity index 100% rename from src/main/java/com/mojang/minecraft/gamemode/GameMode.java rename to src/teavm/java/com/mojang/minecraft/gamemode/GameMode.java diff --git a/src/main/java/com/mojang/minecraft/gamemode/SurvivalGameMode.java b/src/teavm/java/com/mojang/minecraft/gamemode/SurvivalGameMode.java similarity index 92% rename from src/main/java/com/mojang/minecraft/gamemode/SurvivalGameMode.java rename to src/teavm/java/com/mojang/minecraft/gamemode/SurvivalGameMode.java index 6c055f0..fc2db8f 100644 --- a/src/main/java/com/mojang/minecraft/gamemode/SurvivalGameMode.java +++ b/src/teavm/java/com/mojang/minecraft/gamemode/SurvivalGameMode.java @@ -140,7 +140,7 @@ public final class SurvivalGameMode extends GameMode public void preparePlayer(Player player) { player.inventory.slots[8] = Block.TNT.id; - player.inventory.count[8] = (int) 1e+5; + player.inventory.count[8] = 10; } @Override @@ -166,9 +166,4 @@ public final class SurvivalGameMode extends GameMode spawner.spawn(area, null, minecraft.progressBar); } - - @Override - public void apply(Player player) { - - } } diff --git a/src/main/java/com/mojang/minecraft/gui/BlockSelectScreen.java b/src/teavm/java/com/mojang/minecraft/gui/BlockSelectScreen.java similarity index 90% rename from src/main/java/com/mojang/minecraft/gui/BlockSelectScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/BlockSelectScreen.java index f9fd8a9..34fa93d 100644 --- a/src/main/java/com/mojang/minecraft/gui/BlockSelectScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/BlockSelectScreen.java @@ -4,8 +4,7 @@ import com.mojang.minecraft.SessionData; import com.mojang.minecraft.gui.GuiScreen; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.render.ShapeRenderer; -import com.mojang.minecraft.render.TextureLocation; - +import com.mojang.minecraft.render.TextureManager; import org.lwjgl.opengl.GL11; public final class BlockSelectScreen extends GuiScreen { @@ -36,8 +35,10 @@ public final class BlockSelectScreen extends GuiScreen { } drawCenteredString(this.fontRenderer, "Select block", this.width / 2, 40, 16777215); + TextureManager var7 = this.minecraft.textureManager; ShapeRenderer var8 = ShapeRenderer.instance; - new TextureLocation("/terrain.png").bindTexture(); + var2 = var7.load("/terrain.png"); + GL11.glBindTexture(3553, var2); for(var2 = 0; var2 < SessionData.allowedBlocks.size(); ++var2) { Block var4 = (Block)SessionData.allowedBlocks.get(var2); diff --git a/src/main/java/com/mojang/minecraft/gui/Button.java b/src/teavm/java/com/mojang/minecraft/gui/Button.java similarity index 100% rename from src/main/java/com/mojang/minecraft/gui/Button.java rename to src/teavm/java/com/mojang/minecraft/gui/Button.java diff --git a/src/main/java/com/mojang/minecraft/gui/ChatInputScreen.java b/src/teavm/java/com/mojang/minecraft/gui/ChatInputScreen.java similarity index 89% rename from src/main/java/com/mojang/minecraft/gui/ChatInputScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/ChatInputScreen.java index 8e36f90..d9a4f84 100644 --- a/src/main/java/com/mojang/minecraft/gui/ChatInputScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/ChatInputScreen.java @@ -1,8 +1,7 @@ package com.mojang.minecraft.gui; import com.mojang.minecraft.gui.GuiScreen; -import com.mojang.minecraft.net.PacketType; -import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; public final class ChatInputScreen extends GuiScreen { @@ -11,11 +10,11 @@ public final class ChatInputScreen extends GuiScreen { public final void onOpen() { - Keyboard.enableRepeatEvents(true); + GL11.enableRepeatEvents(true); } public final void onClose() { - Keyboard.enableRepeatEvents(false); + GL11.enableRepeatEvents(false); } public final void tick() { diff --git a/src/main/java/com/mojang/minecraft/gui/ControlsScreen.java b/src/teavm/java/com/mojang/minecraft/gui/ControlsScreen.java similarity index 100% rename from src/main/java/com/mojang/minecraft/gui/ControlsScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/ControlsScreen.java diff --git a/src/main/java/com/mojang/minecraft/gui/ErrorScreen.java b/src/teavm/java/com/mojang/minecraft/gui/ErrorScreen.java similarity index 100% rename from src/main/java/com/mojang/minecraft/gui/ErrorScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/ErrorScreen.java diff --git a/src/main/java/com/mojang/minecraft/gui/FontRenderer.java b/src/teavm/java/com/mojang/minecraft/gui/FontRenderer.java similarity index 84% rename from src/main/java/com/mojang/minecraft/gui/FontRenderer.java rename to src/teavm/java/com/mojang/minecraft/gui/FontRenderer.java index fdf93fa..d14cc79 100644 --- a/src/main/java/com/mojang/minecraft/gui/FontRenderer.java +++ b/src/teavm/java/com/mojang/minecraft/gui/FontRenderer.java @@ -2,14 +2,12 @@ package com.mojang.minecraft.gui; import com.mojang.minecraft.GameSettings; import com.mojang.minecraft.render.ShapeRenderer; - -import net.PeytonPlayz585.lwjgl.LWJGLUtils; -import net.PeytonPlayz585.minecraft.MinecraftImage; - +import com.mojang.minecraft.render.TextureManager; +import java.awt.image.BufferedImage; +import java.io.IOException; +import javax.imageio.ImageIO; import org.lwjgl.opengl.GL11; -import com.mojang.minecraft.render.RenderEngine; - public final class FontRenderer { private int[] widthmap = new int[256]; @@ -17,12 +15,21 @@ public final class FontRenderer { private GameSettings settings; - public FontRenderer(GameSettings var1, String var2) { + public FontRenderer(GameSettings var1, String var2, TextureManager var3) { this.settings = var1; - MinecraftImage var14 = LWJGLUtils.loadPNG(GL11.loadResourceBytes(var2)); - int var4 = var14.w; - int var5 = var14.h; + + BufferedImage var14; + try { + var14 = ImageIO.read(TextureManager.class.getResourceAsStream(var2)); + } catch (IOException var13) { + throw new RuntimeException(var13); + } + + int var4 = var14.getWidth(); + int var5 = var14.getHeight(); int[] var6 = new int[var4 * var5]; + var14.getRGB(0, 0, var4, var5, var6, 0, var4); + for(int var15 = 0; var15 < 128; ++var15) { var5 = var15 % 16; int var7 = var15 / 16; @@ -46,10 +53,8 @@ public final class FontRenderer { this.widthmap[var15] = var8; } - - RenderEngine r = new RenderEngine(); - this.fontTexture = r.getTexture(var2); + this.fontTexture = var3.load(var2); } public final void render(String var1, int var2, int var3, int var4) { diff --git a/src/main/java/com/mojang/minecraft/gui/GameOverScreen.java b/src/teavm/java/com/mojang/minecraft/gui/GameOverScreen.java similarity index 82% rename from src/main/java/com/mojang/minecraft/gui/GameOverScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/GameOverScreen.java index 0a82253..dd65df7 100644 --- a/src/main/java/com/mojang/minecraft/gui/GameOverScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/GameOverScreen.java @@ -1,5 +1,9 @@ package com.mojang.minecraft.gui; +import com.mojang.minecraft.gui.Button; +import com.mojang.minecraft.gui.GenerateLevelScreen; +import com.mojang.minecraft.gui.GuiScreen; +import com.mojang.minecraft.gui.OptionsScreen; import org.lwjgl.opengl.GL11; public final class GameOverScreen extends GuiScreen { @@ -9,7 +13,7 @@ public final class GameOverScreen extends GuiScreen { this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 72, "Generate new level...")); this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 96, "Load level..")); if(this.minecraft.session == null) { - ((Button)this.buttons.get(1)).active = false; + ((Button)this.buttons.get(2)).active = false; } } diff --git a/src/main/java/com/mojang/minecraft/gui/GenerateLevelScreen.java b/src/teavm/java/com/mojang/minecraft/gui/GenerateLevelScreen.java similarity index 100% rename from src/main/java/com/mojang/minecraft/gui/GenerateLevelScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/GenerateLevelScreen.java diff --git a/src/main/java/com/mojang/minecraft/gui/GuiScreen.java b/src/teavm/java/com/mojang/minecraft/gui/GuiScreen.java similarity index 80% rename from src/main/java/com/mojang/minecraft/gui/GuiScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/GuiScreen.java index 939fd31..d2f4b44 100644 --- a/src/main/java/com/mojang/minecraft/gui/GuiScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/GuiScreen.java @@ -4,12 +4,8 @@ import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.gui.Button; import com.mojang.minecraft.gui.FontRenderer; import com.mojang.minecraft.gui.Screen; -import com.mojang.minecraft.render.TextureLocation; - import java.util.ArrayList; import java.util.List; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; public class GuiScreen extends Screen { @@ -29,7 +25,7 @@ public class GuiScreen extends Screen { Button var4 = var10000; if(var10000.visible) { FontRenderer var8 = var7.fontRenderer; - new TextureLocation("/gui/gui.png").bindTexture(); + GL11.glBindTexture(3553, var7.textureManager.load("/gui/gui.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); byte var9 = 1; boolean var6 = var1 >= var4.x && var2 >= var4.y && var1 < var4.x + var4.width && var2 < var4.y + var4.height; @@ -87,28 +83,28 @@ public class GuiScreen extends Screen { public void onOpen() {} public final void doInput() { - while(Mouse.next()) { + while(GL11.mouseNext()) { this.mouseEvent(); } - while(Keyboard.next()) { + while(GL11.keysNext()) { this.keyboardEvent(); } } public final void mouseEvent() { - if(Mouse.getEventButtonState()) { - int var1 = Mouse.getEventX() * this.width / this.minecraft.width; - int var2 = this.height - Mouse.getEventY() * this.height / this.minecraft.height - 1; - this.onMouseClick(var1, var2, Mouse.getEventButton()); + if(GL11.mouseGetEventButtonState()) { + int var1 = GL11.mouseGetEventX() * this.width / this.minecraft.width; + int var2 = this.height - GL11.mouseGetEventY() * this.height / this.minecraft.height - 1; + this.onMouseClick(var1, var2, GL11.mouseGetEventButton()); } } public final void keyboardEvent() { - if(Keyboard.getEventKeyState()) { - this.onKeyPress(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + if(GL11.getEventKeyState()) { + this.onKeyPress(GL11.getEventChar(), GL11.getEventKey()); } } diff --git a/src/main/java/com/mojang/minecraft/gui/HUDScreen.java b/src/teavm/java/com/mojang/minecraft/gui/HUDScreen.java similarity index 92% rename from src/main/java/com/mojang/minecraft/gui/HUDScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/HUDScreen.java index 9a5c92e..b72d8c1 100644 --- a/src/main/java/com/mojang/minecraft/gui/HUDScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/HUDScreen.java @@ -9,12 +9,11 @@ import com.mojang.minecraft.gui.Screen; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.player.Inventory; import com.mojang.minecraft.render.ShapeRenderer; -import com.mojang.minecraft.render.TextureLocation; +import com.mojang.minecraft.render.TextureManager; import com.mojang.util.MathHelper; import java.util.ArrayList; import java.util.List; import java.util.Random; -import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; public final class HUDScreen extends Screen { @@ -37,7 +36,8 @@ public final class HUDScreen extends Screen { public final void render(float var1, boolean var2, int var3, int var4) { FontRenderer var5 = this.mc.fontRenderer; this.mc.renderer.enableGuiMode(); - new TextureLocation("/gui/gui.png").bindTexture(); + TextureManager var6 = this.mc.textureManager; + GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/gui.png")); ShapeRenderer var7 = ShapeRenderer.instance; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(3042); @@ -45,7 +45,7 @@ public final class HUDScreen extends Screen { this.imgZ = -90.0F; this.drawImage(this.width / 2 - 91, this.height - 22, 0, 0, 182, 22); this.drawImage(this.width / 2 - 91 - 1 + var8.selected * 20, this.height - 22 - 1, 0, 22, 24, 22); - new TextureLocation("/gui/icons.png").bindTexture(); + GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/icons.png")); this.drawImage(this.width / 2 - 7, this.height / 2 - 7, 0, 0, 16, 16); boolean var9 = this.mc.player.invulnerableTime / 3 % 2 == 1; if(this.mc.player.invulnerableTime < 10) { @@ -131,7 +131,8 @@ public final class HUDScreen extends Screen { GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-1.5F, 0.5F, 0.5F); GL11.glScalef(-1.0F, -1.0F, -1.0F); - new TextureLocation("/terrain.png").bindTexture(); + int var20 = var6.load("/terrain.png"); + GL11.glBindTexture(3553, var20); var7.begin(); Block.blocks[var15].renderFullbright(var7); var7.end(); diff --git a/src/main/java/com/mojang/minecraft/gui/OptionButton.java b/src/teavm/java/com/mojang/minecraft/gui/OptionButton.java similarity index 100% rename from src/main/java/com/mojang/minecraft/gui/OptionButton.java rename to src/teavm/java/com/mojang/minecraft/gui/OptionButton.java diff --git a/src/main/java/com/mojang/minecraft/gui/OptionsScreen.java b/src/teavm/java/com/mojang/minecraft/gui/OptionsScreen.java similarity index 86% rename from src/main/java/com/mojang/minecraft/gui/OptionsScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/OptionsScreen.java index 391eda6..99cd877 100644 --- a/src/main/java/com/mojang/minecraft/gui/OptionsScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/OptionsScreen.java @@ -23,7 +23,6 @@ public final class OptionsScreen extends GuiScreen { this.buttons.add(new OptionButton(var1, this.width / 2 - 155 + var1 % 2 * 160, this.height / 6 + 24 * (var1 >> 1), this.settings.getSetting(var1))); } - this.buttons.add(new Button(50, this.width / 2 - 100, this.height / 6 + 95 + 12, "More...")); this.buttons.add(new Button(100, this.width / 2 - 100, this.height / 6 + 120 + 12, "Controls...")); this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168, "Done")); } @@ -34,10 +33,6 @@ public final class OptionsScreen extends GuiScreen { this.settings.toggleSetting(var1.id, 1); var1.text = this.settings.getSetting(var1.id); } - - if(var1.id == 50) { - this.minecraft.setCurrentScreen(new GuiMore(this)); - } if(var1.id == 100) { this.minecraft.setCurrentScreen(new ControlsScreen(this, this.settings)); diff --git a/src/main/java/com/mojang/minecraft/gui/PauseScreen.java b/src/teavm/java/com/mojang/minecraft/gui/PauseScreen.java similarity index 73% rename from src/main/java/com/mojang/minecraft/gui/PauseScreen.java rename to src/teavm/java/com/mojang/minecraft/gui/PauseScreen.java index 294b48f..849878a 100644 --- a/src/main/java/com/mojang/minecraft/gui/PauseScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/PauseScreen.java @@ -1,5 +1,10 @@ package com.mojang.minecraft.gui; +import com.mojang.minecraft.gui.Button; +import com.mojang.minecraft.gui.GenerateLevelScreen; +import com.mojang.minecraft.gui.GuiScreen; +import com.mojang.minecraft.gui.OptionsScreen; + public final class PauseScreen extends GuiScreen { public final void onOpen() { @@ -24,6 +29,16 @@ public final class PauseScreen extends GuiScreen { this.minecraft.setCurrentScreen(new GenerateLevelScreen(this)); } + if(this.minecraft.session != null) { + //if(var1.id == 2) { + //this.minecraft.setCurrentScreen(new SaveLevelScreen(this)); + //} + + //if(var1.id == 3) { + //this.minecraft.setCurrentScreen(new LoadLevelScreen(this)); + //} + } + if(var1.id == 4) { this.minecraft.setCurrentScreen((GuiScreen)null); this.minecraft.grabMouse(); diff --git a/src/main/java/com/mojang/minecraft/gui/Screen.java b/src/teavm/java/com/mojang/minecraft/gui/Screen.java similarity index 96% rename from src/main/java/com/mojang/minecraft/gui/Screen.java rename to src/teavm/java/com/mojang/minecraft/gui/Screen.java index a17a86b..220fb12 100644 --- a/src/main/java/com/mojang/minecraft/gui/Screen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/Screen.java @@ -41,6 +41,8 @@ public class Screen { GL11.glDisable(3553); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); + //TODO: Rewrite later... + //GL11.glBegin(7); GL11.glColor4f(var7, var8, var12, var6); //GL11.glVertex2f((float)var2, (float)var1); diff --git a/src/main/java/com/mojang/minecraft/item/Arrow.java b/src/teavm/java/com/mojang/minecraft/item/Arrow.java similarity index 92% rename from src/main/java/com/mojang/minecraft/item/Arrow.java rename to src/teavm/java/com/mojang/minecraft/item/Arrow.java index bc010da..641ab27 100644 --- a/src/main/java/com/mojang/minecraft/item/Arrow.java +++ b/src/teavm/java/com/mojang/minecraft/item/Arrow.java @@ -5,7 +5,7 @@ import com.mojang.minecraft.level.Level; import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.player.Player; import com.mojang.minecraft.render.ShapeRenderer; -import com.mojang.minecraft.render.TextureLocation; +import com.mojang.minecraft.render.TextureManager; import com.mojang.util.MathHelper; import java.util.List; import org.lwjgl.opengl.GL11; @@ -176,9 +176,11 @@ public class Arrow extends Entity } @Override - public void render(float unknown0) + public void render(TextureManager textureManager, float unknown0) { - new TextureLocation("/item/arrows.png").bindTexture(); + textureId = textureManager.load("/item/arrows.png"); + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); float brightness = level.getBrightness((int)x, (int)y, (int)z); diff --git a/src/main/java/com/mojang/minecraft/item/Item.java b/src/teavm/java/com/mojang/minecraft/item/Item.java similarity index 88% rename from src/main/java/com/mojang/minecraft/item/Item.java rename to src/teavm/java/com/mojang/minecraft/item/Item.java index aec4474..650cb9f 100644 --- a/src/main/java/com/mojang/minecraft/item/Item.java +++ b/src/teavm/java/com/mojang/minecraft/item/Item.java @@ -4,7 +4,7 @@ import com.mojang.minecraft.Entity; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.player.Player; -import com.mojang.minecraft.render.TextureLocation; +import com.mojang.minecraft.render.TextureManager; import com.mojang.util.MathHelper; import org.lwjgl.opengl.GL11; @@ -64,9 +64,11 @@ public class Item extends Entity } @Override - public void render(float unknown0) + public void render(TextureManager textureManager, float unknown0) { - new TextureLocation("/terrain.png").bindTexture(); + textureId = textureManager.load("/terrain.png"); + + GL11.glBindTexture(3553, this.textureId); float brightness = level.getBrightness((int)x, (int)y, (int)z); float unknown1 = rot + ((float)tickCount + unknown0) * 3.0F; diff --git a/src/main/java/com/mojang/minecraft/item/ItemModel.java b/src/teavm/java/com/mojang/minecraft/item/ItemModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/item/ItemModel.java rename to src/teavm/java/com/mojang/minecraft/item/ItemModel.java diff --git a/src/main/java/com/mojang/minecraft/item/PrimedTnt.java b/src/teavm/java/com/mojang/minecraft/item/PrimedTnt.java similarity index 90% rename from src/main/java/com/mojang/minecraft/item/PrimedTnt.java rename to src/teavm/java/com/mojang/minecraft/item/PrimedTnt.java index b5efb23..814d511 100644 --- a/src/main/java/com/mojang/minecraft/item/PrimedTnt.java +++ b/src/teavm/java/com/mojang/minecraft/item/PrimedTnt.java @@ -7,7 +7,7 @@ import com.mojang.minecraft.particle.SmokeParticle; import com.mojang.minecraft.particle.TerrainParticle; import com.mojang.minecraft.player.Player; import com.mojang.minecraft.render.ShapeRenderer; -import com.mojang.minecraft.render.TextureLocation; +import com.mojang.minecraft.render.TextureManager; import com.mojang.util.MathHelper; import java.util.Random; import org.lwjgl.opengl.GL11; @@ -97,9 +97,11 @@ public class PrimedTnt extends Entity } @Override - public void render(float unknown0) + public void render(TextureManager textureManager, float unknown0) { - new TextureLocation("/terrain.png").bindTexture(); + int textureID = textureManager.load("/terrain.png"); + + GL11.glBindTexture(3553, textureID); float brightness = level.getBrightness((int)x, (int)y, (int)z); diff --git a/src/main/java/com/mojang/minecraft/item/TakeEntityAnim.java b/src/teavm/java/com/mojang/minecraft/item/TakeEntityAnim.java similarity index 81% rename from src/main/java/com/mojang/minecraft/item/TakeEntityAnim.java rename to src/teavm/java/com/mojang/minecraft/item/TakeEntityAnim.java index a2b899e..335cb13 100644 --- a/src/main/java/com/mojang/minecraft/item/TakeEntityAnim.java +++ b/src/teavm/java/com/mojang/minecraft/item/TakeEntityAnim.java @@ -2,6 +2,7 @@ package com.mojang.minecraft.item; import com.mojang.minecraft.Entity; import com.mojang.minecraft.level.Level; +import com.mojang.minecraft.render.TextureManager; public class TakeEntityAnim extends Entity { @@ -44,9 +45,9 @@ public class TakeEntityAnim extends Entity } @Override - public void render(float unknown0) + public void render(TextureManager textureManager, float unknown0) { - item.render(unknown0); + item.render(textureManager, unknown0); } private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/mojang/minecraft/level/BlockMap$Slot.java b/src/teavm/java/com/mojang/minecraft/level/BlockMap$Slot.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/BlockMap$Slot.java rename to src/teavm/java/com/mojang/minecraft/level/BlockMap$Slot.java diff --git a/src/main/java/com/mojang/minecraft/level/BlockMap.java b/src/teavm/java/com/mojang/minecraft/level/BlockMap.java similarity index 95% rename from src/main/java/com/mojang/minecraft/level/BlockMap.java rename to src/teavm/java/com/mojang/minecraft/level/BlockMap.java index d3035fc..9d9f2ca 100644 --- a/src/main/java/com/mojang/minecraft/level/BlockMap.java +++ b/src/teavm/java/com/mojang/minecraft/level/BlockMap.java @@ -6,6 +6,7 @@ import com.mojang.minecraft.level.SyntheticClass; import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.render.Frustrum; +import com.mojang.minecraft.render.TextureManager; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -165,7 +166,7 @@ public class BlockMap implements Serializable { } - public void render(Vec3D var1, Frustrum var2, float var4) { + public void render(Vec3D var1, Frustrum var2, TextureManager var3, float var4) { for(int var5 = 0; var5 < this.width; ++var5) { float var6 = (float)((var5 << 4) - 2); float var7 = (float)((var5 + 1 << 4) + 2); @@ -251,7 +252,7 @@ public class BlockMap implements Serializable { } } - var22.render(var4); + var22.render(var3, var4); } } } diff --git a/src/main/java/com/mojang/minecraft/level/Level.java b/src/teavm/java/com/mojang/minecraft/level/Level.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/Level.java rename to src/teavm/java/com/mojang/minecraft/level/Level.java diff --git a/src/main/java/com/mojang/minecraft/level/LevelIO.java b/src/teavm/java/com/mojang/minecraft/level/LevelIO.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/LevelIO.java rename to src/teavm/java/com/mojang/minecraft/level/LevelIO.java diff --git a/src/main/java/com/mojang/minecraft/level/LevelObjectInputStream.java b/src/teavm/java/com/mojang/minecraft/level/LevelObjectInputStream.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/LevelObjectInputStream.java rename to src/teavm/java/com/mojang/minecraft/level/LevelObjectInputStream.java diff --git a/src/main/java/com/mojang/minecraft/level/MobSpawner.java b/src/teavm/java/com/mojang/minecraft/level/MobSpawner.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/MobSpawner.java rename to src/teavm/java/com/mojang/minecraft/level/MobSpawner.java diff --git a/src/main/java/com/mojang/minecraft/level/NextTickListEntry.java b/src/teavm/java/com/mojang/minecraft/level/NextTickListEntry.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/NextTickListEntry.java rename to src/teavm/java/com/mojang/minecraft/level/NextTickListEntry.java diff --git a/src/main/java/com/mojang/minecraft/level/SyntheticClass.java b/src/teavm/java/com/mojang/minecraft/level/SyntheticClass.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/SyntheticClass.java rename to src/teavm/java/com/mojang/minecraft/level/SyntheticClass.java diff --git a/src/main/java/com/mojang/minecraft/level/generator/LevelGenerator.java b/src/teavm/java/com/mojang/minecraft/level/generator/LevelGenerator.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/generator/LevelGenerator.java rename to src/teavm/java/com/mojang/minecraft/level/generator/LevelGenerator.java diff --git a/src/main/java/com/mojang/minecraft/level/generator/noise/CombinedNoise.java b/src/teavm/java/com/mojang/minecraft/level/generator/noise/CombinedNoise.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/generator/noise/CombinedNoise.java rename to src/teavm/java/com/mojang/minecraft/level/generator/noise/CombinedNoise.java diff --git a/src/main/java/com/mojang/minecraft/level/generator/noise/Noise.java b/src/teavm/java/com/mojang/minecraft/level/generator/noise/Noise.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/generator/noise/Noise.java rename to src/teavm/java/com/mojang/minecraft/level/generator/noise/Noise.java diff --git a/src/main/java/com/mojang/minecraft/level/generator/noise/OctaveNoise.java b/src/teavm/java/com/mojang/minecraft/level/generator/noise/OctaveNoise.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/generator/noise/OctaveNoise.java rename to src/teavm/java/com/mojang/minecraft/level/generator/noise/OctaveNoise.java diff --git a/src/main/java/com/mojang/minecraft/level/generator/noise/PerlinNoise.java b/src/teavm/java/com/mojang/minecraft/level/generator/noise/PerlinNoise.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/generator/noise/PerlinNoise.java rename to src/teavm/java/com/mojang/minecraft/level/generator/noise/PerlinNoise.java diff --git a/src/main/java/com/mojang/minecraft/level/liquid/LiquidType.java b/src/teavm/java/com/mojang/minecraft/level/liquid/LiquidType.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/liquid/LiquidType.java rename to src/teavm/java/com/mojang/minecraft/level/liquid/LiquidType.java diff --git a/src/main/java/com/mojang/minecraft/level/tile/Block.java b/src/teavm/java/com/mojang/minecraft/level/tile/Block.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/tile/Block.java rename to src/teavm/java/com/mojang/minecraft/level/tile/Block.java diff --git a/src/main/java/com/mojang/minecraft/level/tile/BookshelfBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/BookshelfBlock.java similarity index 58% rename from src/main/java/com/mojang/minecraft/level/tile/BookshelfBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/BookshelfBlock.java index e9a90ee..82835ba 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/BookshelfBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/BookshelfBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.tile.Block; public final class BookshelfBlock extends Block { @@ -14,13 +11,6 @@ public final class BookshelfBlock extends Block { protected final int getTextureId(int texture) { return texture <= 1?4:this.textureId; } - - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.BOOKSHELF.id; - } public final int getDropCount() { return 0; diff --git a/src/teavm/java/com/mojang/minecraft/level/tile/DirtBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/DirtBlock.java new file mode 100644 index 0000000..2ebd3ec --- /dev/null +++ b/src/teavm/java/com/mojang/minecraft/level/tile/DirtBlock.java @@ -0,0 +1,10 @@ +package com.mojang.minecraft.level.tile; + +import com.mojang.minecraft.level.tile.Block; + +public final class DirtBlock extends Block { + + protected DirtBlock(int var1, int var2) { + super(3, 2); + } +} diff --git a/src/main/java/com/mojang/minecraft/level/tile/FlowerBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/FlowerBlock.java similarity index 90% rename from src/main/java/com/mojang/minecraft/level/tile/FlowerBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/FlowerBlock.java index f09d98b..40a49c7 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/FlowerBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/FlowerBlock.java @@ -1,6 +1,5 @@ package com.mojang.minecraft.level.tile; -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.render.ShapeRenderer; @@ -93,11 +92,4 @@ public class FlowerBlock extends Block { { return null; } - - public int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return this == Block.ROSE ? Block.ROSE.id : Block.DANDELION.id; - } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/GlassBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/GlassBlock.java similarity index 86% rename from src/main/java/com/mojang/minecraft/level/tile/GlassBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/GlassBlock.java index 8ebbc25..fdc0d64 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/GlassBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/GlassBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; public final class GlassBlock extends Block { diff --git a/src/main/java/com/mojang/minecraft/level/tile/GrassBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/GrassBlock.java similarity index 79% rename from src/main/java/com/mojang/minecraft/level/tile/GrassBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/GrassBlock.java index 8599528..72ce2a2 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/GrassBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/GrassBlock.java @@ -1,6 +1,5 @@ package com.mojang.minecraft.level.tile; -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; import java.util.Random; @@ -14,7 +13,7 @@ public final class GrassBlock extends Block { } protected final int getTextureId(int texture) { - return texture == 1 ? 0 : (texture == 0 ? 2 : Minecraft.settings.ofBetterGrass ? 0 : 3); + return texture == 1?0:(texture == 0?2:3); } public final void update(Level level, int x, int y, int z, Random rand) { @@ -36,9 +35,6 @@ public final class GrassBlock extends Block { } public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } return Block.DIRT.getDrop(); } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/LeavesBaseBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/LeavesBaseBlock.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/tile/LeavesBaseBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/LeavesBaseBlock.java diff --git a/src/main/java/com/mojang/minecraft/level/tile/LeavesBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/LeavesBlock.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/tile/LeavesBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/LeavesBlock.java diff --git a/src/main/java/com/mojang/minecraft/level/tile/LiquidBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/LiquidBlock.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/tile/LiquidBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/LiquidBlock.java diff --git a/src/main/java/com/mojang/minecraft/level/tile/MetalBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/MetalBlock.java similarity index 55% rename from src/main/java/com/mojang/minecraft/level/tile/MetalBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/MetalBlock.java index e439f89..f0702ea 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/MetalBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/MetalBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.tile.Block; public final class MetalBlock extends Block { @@ -15,11 +12,4 @@ public final class MetalBlock extends Block { protected final int getTextureId(int texture) { return texture == 1?this.textureId - 16:(texture == 0?this.textureId + 16:this.textureId); } - - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return this == Block.GOLD_BLOCK ? Block.GOLD_BLOCK.id : Block.IRON_BLOCK.id; - } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/MushroomBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/MushroomBlock.java similarity index 70% rename from src/main/java/com/mojang/minecraft/level/tile/MushroomBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/MushroomBlock.java index f63b611..eb0ce70 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/MushroomBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/MushroomBlock.java @@ -1,6 +1,5 @@ package com.mojang.minecraft.level.tile; -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.level.tile.FlowerBlock; @@ -21,12 +20,4 @@ public final class MushroomBlock extends FlowerBlock { } } - - @Override - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return this == Block.RED_MUSHROOM ? Block.RED_MUSHROOM.id : Block.BROWN_MUSHROOM.id; - } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/OreBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/OreBlock.java similarity index 71% rename from src/main/java/com/mojang/minecraft/level/tile/OreBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/OreBlock.java index d1e5c02..a1acc2e 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/OreBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/OreBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.tile.Block; public final class OreBlock extends Block { @@ -12,9 +9,6 @@ public final class OreBlock extends Block { } public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } return this == Block.COAL_ORE?Block.SLAB.id:(this == Block.GOLD_ORE?Block.GOLD_BLOCK.id:(this == Block.IRON_ORE?Block.IRON_BLOCK.id:this.id)); } diff --git a/src/main/java/com/mojang/minecraft/level/tile/SandBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/SandBlock.java similarity index 82% rename from src/main/java/com/mojang/minecraft/level/tile/SandBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/SandBlock.java index 793db28..9019d03 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/SandBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/SandBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.liquid.LiquidType; import com.mojang.minecraft.level.tile.Block; @@ -45,11 +42,4 @@ public final class SandBlock extends Block { --var5; } } - - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.SAND.id; - } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/SaplingBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/SaplingBlock.java similarity index 79% rename from src/main/java/com/mojang/minecraft/level/tile/SaplingBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/SaplingBlock.java index 48cc55a..74797a4 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/SaplingBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/SaplingBlock.java @@ -1,6 +1,5 @@ package com.mojang.minecraft.level.tile; -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.level.tile.FlowerBlock; @@ -28,11 +27,4 @@ public final class SaplingBlock extends FlowerBlock { level.setTile(x, y, z, 0); } } - - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.SAPLING.id; - } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/SlabBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/SlabBlock.java similarity index 84% rename from src/main/java/com/mojang/minecraft/level/tile/SlabBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/SlabBlock.java index 1a155e0..9e3ddca 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/SlabBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/SlabBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; @@ -47,10 +44,7 @@ public final class SlabBlock extends Block { } public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.SLAB.id; + return Block.SLAB.id; } public final boolean isCube() { diff --git a/src/main/java/com/mojang/minecraft/level/tile/SpongeBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/SpongeBlock.java similarity index 79% rename from src/main/java/com/mojang/minecraft/level/tile/SpongeBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/SpongeBlock.java index 6e13069..0637d9b 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/SpongeBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/SpongeBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; @@ -36,11 +33,4 @@ public final class SpongeBlock extends Block { } } - - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.SPONGE.id; - } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/StillLiquidBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/StillLiquidBlock.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/tile/StillLiquidBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/StillLiquidBlock.java diff --git a/src/main/java/com/mojang/minecraft/level/tile/StoneBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/StoneBlock.java similarity index 53% rename from src/main/java/com/mojang/minecraft/level/tile/StoneBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/StoneBlock.java index 9518e37..70bf0c2 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/StoneBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/StoneBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.tile.Block; public final class StoneBlock extends Block { @@ -12,9 +9,6 @@ public final class StoneBlock extends Block { } public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.COBBLESTONE.id; + return Block.COBBLESTONE.id; } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/TNTBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/TNTBlock.java similarity index 81% rename from src/main/java/com/mojang/minecraft/level/tile/TNTBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/TNTBlock.java index 7db3915..407e20e 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/TNTBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/TNTBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.item.PrimedTnt; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; @@ -38,11 +35,4 @@ public final class TNTBlock extends Block { super.spawnBreakParticles(level, x, y, z, particleManager); } } - - public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.TNT.id; - } } diff --git a/src/main/java/com/mojang/minecraft/level/tile/Tile$SoundType.java b/src/teavm/java/com/mojang/minecraft/level/tile/Tile$SoundType.java similarity index 100% rename from src/main/java/com/mojang/minecraft/level/tile/Tile$SoundType.java rename to src/teavm/java/com/mojang/minecraft/level/tile/Tile$SoundType.java diff --git a/src/main/java/com/mojang/minecraft/level/tile/WoodBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/WoodBlock.java similarity index 67% rename from src/main/java/com/mojang/minecraft/level/tile/WoodBlock.java rename to src/teavm/java/com/mojang/minecraft/level/tile/WoodBlock.java index 1805f72..e3ec0fd 100644 --- a/src/main/java/com/mojang/minecraft/level/tile/WoodBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/WoodBlock.java @@ -1,8 +1,5 @@ package com.mojang.minecraft.level.tile; -import java.util.Random; - -import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.tile.Block; public final class WoodBlock extends Block { @@ -17,10 +14,7 @@ public final class WoodBlock extends Block { } public final int getDrop() { - if(Minecraft.settings.randomDrops) { - return new Random().nextInt(49 - 1 + 1) + 1; - } - return Block.WOOD.id; + return Block.WOOD.id; } protected final int getTextureId(int texture) { diff --git a/src/main/java/com/mojang/minecraft/mob/Creeper$1.java b/src/teavm/java/com/mojang/minecraft/mob/Creeper$1.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Creeper$1.java rename to src/teavm/java/com/mojang/minecraft/mob/Creeper$1.java diff --git a/src/main/java/com/mojang/minecraft/mob/Creeper.java b/src/teavm/java/com/mojang/minecraft/mob/Creeper.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Creeper.java rename to src/teavm/java/com/mojang/minecraft/mob/Creeper.java diff --git a/src/main/java/com/mojang/minecraft/mob/HumanoidMob.java b/src/teavm/java/com/mojang/minecraft/mob/HumanoidMob.java similarity index 85% rename from src/main/java/com/mojang/minecraft/mob/HumanoidMob.java rename to src/teavm/java/com/mojang/minecraft/mob/HumanoidMob.java index 4ea34a4..bf4175a 100644 --- a/src/main/java/com/mojang/minecraft/mob/HumanoidMob.java +++ b/src/teavm/java/com/mojang/minecraft/mob/HumanoidMob.java @@ -4,7 +4,7 @@ import com.mojang.minecraft.level.Level; import com.mojang.minecraft.mob.Mob; import com.mojang.minecraft.model.HumanoidModel; import com.mojang.minecraft.model.Model; -import com.mojang.minecraft.render.TextureLocation; +import com.mojang.minecraft.render.TextureManager; import org.lwjgl.opengl.GL11; public class HumanoidMob extends Mob { @@ -20,8 +20,8 @@ public class HumanoidMob extends Mob { this.setPos(var2, var3, var4); } - public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) { - super.renderModel(var2, var3, var4, var5, var6, var7); + public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) { + super.renderModel(var1, var2, var3, var4, var5, var6, var7); Model var9 = modelCache.getModel(this.modelName); GL11.glEnable(3008); if(this.allowAlpha) { @@ -38,7 +38,7 @@ public class HumanoidMob extends Mob { } if(this.armor || this.helmet) { - new TextureLocation("/armor/plate.png").bindTexture(); + GL11.glBindTexture(3553, var1.load("/armor/plate.png")); GL11.glDisable(2884); HumanoidModel var8; (var8 = (HumanoidModel)modelCache.getModel("humanoid.armor")).head.render = this.helmet; diff --git a/src/main/java/com/mojang/minecraft/mob/Mob.java b/src/teavm/java/com/mojang/minecraft/mob/Mob.java similarity index 92% rename from src/main/java/com/mojang/minecraft/mob/Mob.java rename to src/teavm/java/com/mojang/minecraft/mob/Mob.java index 4d89d08..36a3e29 100644 --- a/src/main/java/com/mojang/minecraft/mob/Mob.java +++ b/src/teavm/java/com/mojang/minecraft/mob/Mob.java @@ -5,7 +5,7 @@ import com.mojang.minecraft.level.Level; import com.mojang.minecraft.mob.ai.AI; import com.mojang.minecraft.mob.ai.BasicAI; import com.mojang.minecraft.model.ModelManager; -import com.mojang.minecraft.render.TextureLocation; +import com.mojang.minecraft.render.TextureManager; import com.mojang.util.MathHelper; import org.lwjgl.opengl.GL11; @@ -204,11 +204,12 @@ public class Mob extends Entity { } - protected void bindTexture() { - new TextureLocation(textureName).bindTexture(); + protected void bindTexture(TextureManager var1) { + this.textureId = var1.load(this.textureName); + GL11.glBindTexture(3553, this.textureId); } - public void render(float var2) { + public void render(TextureManager var1, float var2) { if(this.modelName != null) { float var3; if((var3 = (float)this.attackTime - var2) < 0.0F) { @@ -287,14 +288,14 @@ public class Mob extends Entity { GL11.glScalef(-1.0F, 1.0F, 1.0F); modelCache.getModel(this.modelName).attackOffset = var3 / 5.0F; - this.bindTexture(); - this.renderModel(var8, var2, var5, var6, var7, var9); + this.bindTexture(var1); + this.renderModel(var1, var8, var2, var5, var6, var7, var9); if(this.invulnerableTime > this.invulnerableDuration - 10) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); GL11.glEnable(3042); GL11.glBlendFunc(770, 1); - this.bindTexture(); - this.renderModel(var8, var2, var5, var6, var7, var9); + this.bindTexture(var1); + this.renderModel(var1, var8, var2, var5, var6, var7, var9); GL11.glDisable(3042); GL11.glBlendFunc(770, 771); } @@ -309,7 +310,7 @@ public class Mob extends Entity { } } - public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) { + public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) { modelCache.getModel(this.modelName).render(var2, var4, (float)this.tickCount + var3, var5, var6, var7); } diff --git a/src/main/java/com/mojang/minecraft/mob/Pig.java b/src/teavm/java/com/mojang/minecraft/mob/Pig.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Pig.java rename to src/teavm/java/com/mojang/minecraft/mob/Pig.java diff --git a/src/main/java/com/mojang/minecraft/mob/QuadrupedMob.java b/src/teavm/java/com/mojang/minecraft/mob/QuadrupedMob.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/QuadrupedMob.java rename to src/teavm/java/com/mojang/minecraft/mob/QuadrupedMob.java diff --git a/src/main/java/com/mojang/minecraft/mob/Sheep$1.java b/src/teavm/java/com/mojang/minecraft/mob/Sheep$1.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Sheep$1.java rename to src/teavm/java/com/mojang/minecraft/mob/Sheep$1.java diff --git a/src/main/java/com/mojang/minecraft/mob/Sheep.java b/src/teavm/java/com/mojang/minecraft/mob/Sheep.java similarity index 88% rename from src/main/java/com/mojang/minecraft/mob/Sheep.java rename to src/teavm/java/com/mojang/minecraft/mob/Sheep.java index 33a958a..9eb126b 100644 --- a/src/main/java/com/mojang/minecraft/mob/Sheep.java +++ b/src/teavm/java/com/mojang/minecraft/mob/Sheep.java @@ -8,8 +8,7 @@ import com.mojang.minecraft.mob.QuadrupedMob; import com.mojang.minecraft.mob.Sheep$1; import com.mojang.minecraft.model.AnimalModel; import com.mojang.minecraft.player.Player; -import com.mojang.minecraft.render.TextureLocation; - +import com.mojang.minecraft.render.TextureManager; import org.lwjgl.opengl.GL11; public class Sheep extends QuadrupedMob { @@ -79,15 +78,15 @@ public class Sheep extends QuadrupedMob { } } - public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) { + public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) { AnimalModel var8; float var9 = (var8 = (AnimalModel)modelCache.getModel(this.modelName)).head.y; float var10 = var8.head.z; var8.head.y += (this.grazeO + (this.graze - this.grazeO) * var3) * 8.0F; var8.head.z -= this.grazeO + (this.graze - this.grazeO) * var3; - super.renderModel(var2, var3, var4, var5, var6, var7); + super.renderModel(var1, var2, var3, var4, var5, var6, var7); if(this.hasFur) { - new TextureLocation("/mob/sheep_fur.png").bindTexture(); + GL11.glBindTexture(3553, var1.load("/mob/sheep_fur.png")); GL11.glDisable(2884); AnimalModel var11; (var11 = (AnimalModel)modelCache.getModel("sheep.fur")).head.yaw = var8.head.yaw; diff --git a/src/main/java/com/mojang/minecraft/mob/Skeleton$1.java b/src/teavm/java/com/mojang/minecraft/mob/Skeleton$1.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Skeleton$1.java rename to src/teavm/java/com/mojang/minecraft/mob/Skeleton$1.java diff --git a/src/main/java/com/mojang/minecraft/mob/Skeleton.java b/src/teavm/java/com/mojang/minecraft/mob/Skeleton.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Skeleton.java rename to src/teavm/java/com/mojang/minecraft/mob/Skeleton.java diff --git a/src/main/java/com/mojang/minecraft/mob/Spider.java b/src/teavm/java/com/mojang/minecraft/mob/Spider.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Spider.java rename to src/teavm/java/com/mojang/minecraft/mob/Spider.java diff --git a/src/main/java/com/mojang/minecraft/mob/Zombie.java b/src/teavm/java/com/mojang/minecraft/mob/Zombie.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/Zombie.java rename to src/teavm/java/com/mojang/minecraft/mob/Zombie.java diff --git a/src/main/java/com/mojang/minecraft/mob/ai/AI.java b/src/teavm/java/com/mojang/minecraft/mob/ai/AI.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/ai/AI.java rename to src/teavm/java/com/mojang/minecraft/mob/ai/AI.java diff --git a/src/main/java/com/mojang/minecraft/mob/ai/BasicAI.java b/src/teavm/java/com/mojang/minecraft/mob/ai/BasicAI.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/ai/BasicAI.java rename to src/teavm/java/com/mojang/minecraft/mob/ai/BasicAI.java diff --git a/src/main/java/com/mojang/minecraft/mob/ai/BasicAttackAI.java b/src/teavm/java/com/mojang/minecraft/mob/ai/BasicAttackAI.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/ai/BasicAttackAI.java rename to src/teavm/java/com/mojang/minecraft/mob/ai/BasicAttackAI.java diff --git a/src/main/java/com/mojang/minecraft/mob/ai/JumpAttackAI.java b/src/teavm/java/com/mojang/minecraft/mob/ai/JumpAttackAI.java similarity index 100% rename from src/main/java/com/mojang/minecraft/mob/ai/JumpAttackAI.java rename to src/teavm/java/com/mojang/minecraft/mob/ai/JumpAttackAI.java diff --git a/src/main/java/com/mojang/minecraft/model/AnimalModel.java b/src/teavm/java/com/mojang/minecraft/model/AnimalModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/AnimalModel.java rename to src/teavm/java/com/mojang/minecraft/model/AnimalModel.java diff --git a/src/main/java/com/mojang/minecraft/model/CreeperModel.java b/src/teavm/java/com/mojang/minecraft/model/CreeperModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/CreeperModel.java rename to src/teavm/java/com/mojang/minecraft/model/CreeperModel.java diff --git a/src/main/java/com/mojang/minecraft/model/HumanoidModel.java b/src/teavm/java/com/mojang/minecraft/model/HumanoidModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/HumanoidModel.java rename to src/teavm/java/com/mojang/minecraft/model/HumanoidModel.java diff --git a/src/main/java/com/mojang/minecraft/model/Model.java b/src/teavm/java/com/mojang/minecraft/model/Model.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/Model.java rename to src/teavm/java/com/mojang/minecraft/model/Model.java diff --git a/src/main/java/com/mojang/minecraft/model/ModelManager.java b/src/teavm/java/com/mojang/minecraft/model/ModelManager.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/ModelManager.java rename to src/teavm/java/com/mojang/minecraft/model/ModelManager.java diff --git a/src/main/java/com/mojang/minecraft/model/ModelPart.java b/src/teavm/java/com/mojang/minecraft/model/ModelPart.java similarity index 92% rename from src/main/java/com/mojang/minecraft/model/ModelPart.java rename to src/teavm/java/com/mojang/minecraft/model/ModelPart.java index 699ee66..2f61d76 100644 --- a/src/main/java/com/mojang/minecraft/model/ModelPart.java +++ b/src/teavm/java/com/mojang/minecraft/model/ModelPart.java @@ -3,9 +3,6 @@ package com.mojang.minecraft.model; import com.mojang.minecraft.model.TexturedQuad; import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.model.Vertex; - -import net.PeytonPlayz585.lwjgl.ModeBuffer; - import org.lwjgl.opengl.GL11; public final class ModelPart { @@ -131,7 +128,7 @@ public final class ModelPart { public void generateList(float var1) { this.list = GL11.glGenLists(1); GL11.glNewList(this.list, 4864); - GL11.glBeginQuery(7); + GL11.glBegin(7); for(int var2 = 0; var2 < this.quads.length; ++var2) { TexturedQuad var10000 = this.quads[var2]; @@ -143,13 +140,12 @@ public final class ModelPart { for(int var7 = 0; var7 < 4; ++var7) { Vertex var8; - final ModeBuffer imb = new ModeBuffer(1024); - imb.glTexCoord2f((var8 = var4.vertices[var7]).u, var8.v); - imb.glVertex3f(var8.vector.x * var3, var8.vector.y * var3, var8.vector.z * var3); + GL11.glTexCoord2f((var8 = var4.vertices[var7]).u, var8.v); + GL11.glVertex3f(var8.vector.x * var3, var8.vector.y * var3, var8.vector.z * var3); } } - GL11.glEndQuery(); + GL11.glEnd(); GL11.glEndList(); this.hasList = true; } diff --git a/src/main/java/com/mojang/minecraft/model/PigModel.java b/src/teavm/java/com/mojang/minecraft/model/PigModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/PigModel.java rename to src/teavm/java/com/mojang/minecraft/model/PigModel.java diff --git a/src/main/java/com/mojang/minecraft/model/SheepFurModel.java b/src/teavm/java/com/mojang/minecraft/model/SheepFurModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/SheepFurModel.java rename to src/teavm/java/com/mojang/minecraft/model/SheepFurModel.java diff --git a/src/main/java/com/mojang/minecraft/model/SheepModel.java b/src/teavm/java/com/mojang/minecraft/model/SheepModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/SheepModel.java rename to src/teavm/java/com/mojang/minecraft/model/SheepModel.java diff --git a/src/main/java/com/mojang/minecraft/model/SkeletonModel.java b/src/teavm/java/com/mojang/minecraft/model/SkeletonModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/SkeletonModel.java rename to src/teavm/java/com/mojang/minecraft/model/SkeletonModel.java diff --git a/src/main/java/com/mojang/minecraft/model/SpiderModel.java b/src/teavm/java/com/mojang/minecraft/model/SpiderModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/SpiderModel.java rename to src/teavm/java/com/mojang/minecraft/model/SpiderModel.java diff --git a/src/main/java/com/mojang/minecraft/model/TexturedQuad.java b/src/teavm/java/com/mojang/minecraft/model/TexturedQuad.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/TexturedQuad.java rename to src/teavm/java/com/mojang/minecraft/model/TexturedQuad.java diff --git a/src/main/java/com/mojang/minecraft/model/Vec3D.java b/src/teavm/java/com/mojang/minecraft/model/Vec3D.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/Vec3D.java rename to src/teavm/java/com/mojang/minecraft/model/Vec3D.java diff --git a/src/main/java/com/mojang/minecraft/model/Vertex.java b/src/teavm/java/com/mojang/minecraft/model/Vertex.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/Vertex.java rename to src/teavm/java/com/mojang/minecraft/model/Vertex.java diff --git a/src/main/java/com/mojang/minecraft/model/ZombieModel.java b/src/teavm/java/com/mojang/minecraft/model/ZombieModel.java similarity index 100% rename from src/main/java/com/mojang/minecraft/model/ZombieModel.java rename to src/teavm/java/com/mojang/minecraft/model/ZombieModel.java diff --git a/src/main/java/com/mojang/minecraft/net/NetworkPlayer.java b/src/teavm/java/com/mojang/minecraft/net/NetworkPlayer.java similarity index 74% rename from src/main/java/com/mojang/minecraft/net/NetworkPlayer.java rename to src/teavm/java/com/mojang/minecraft/net/NetworkPlayer.java index c29138a..b8c0045 100644 --- a/src/main/java/com/mojang/minecraft/net/NetworkPlayer.java +++ b/src/teavm/java/com/mojang/minecraft/net/NetworkPlayer.java @@ -3,8 +3,9 @@ package com.mojang.minecraft.net; import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.gui.FontRenderer; import com.mojang.minecraft.mob.HumanoidMob; -import com.mojang.minecraft.render.TextureLocation; - +import com.mojang.minecraft.net.PositionUpdate; +import com.mojang.minecraft.net.SkinDownloadThread; +import com.mojang.minecraft.render.TextureManager; import java.awt.image.BufferedImage; import java.util.LinkedList; import java.util.List; @@ -13,15 +14,18 @@ import org.lwjgl.opengl.GL11; public class NetworkPlayer extends HumanoidMob { public static final long serialVersionUID = 77479605454997290L; - private List moveQueue = new LinkedList(); + private List moveQueue = new LinkedList(); private Minecraft minecraft; private int xp; private int yp; private int zp; + private transient int a = -1; public transient BufferedImage newTexture = null; public String name; public String displayName; int tickCount = 0; + private TextureManager textures; + public NetworkPlayer(Minecraft var1, int var2, String var3, int var4, int var5, int var6, float var7, float var8) { super(var1.level, (float)var4, (float)var5, (float)var6); @@ -39,6 +43,7 @@ public class NetworkPlayer extends HumanoidMob { this.yRot = var7; this.armor = this.helmet = false; this.renderOffset = 0.6875F; + (new SkinDownloadThread(this)).start(); this.allowAlpha = false; } @@ -54,11 +59,42 @@ public class NetworkPlayer extends HumanoidMob { this.onGround = true; } - public void bindTexture() { - new TextureLocation("/char.png").bindTexture(); + public void bindTexture(TextureManager var1) { + this.textures = var1; + if(this.newTexture != null) { + BufferedImage var2 = this.newTexture; + int[] var3 = new int[512]; + var2.getRGB(32, 0, 32, 16, var3, 0, 32); + int var5 = 0; + + boolean var10001; + while(true) { + if(var5 >= var3.length) { + var10001 = false; + break; + } + + if(var3[var5] >>> 24 < 128) { + var10001 = true; + break; + } + + ++var5; + } + + this.hasHair = var10001; + this.a = var1.load(this.newTexture); + this.newTexture = null; + } + + if(this.a < 0) { + GL11.glBindTexture(3553, var1.load("/char.png")); + } else { + GL11.glBindTexture(3553, this.a); + } } - public void renderHover(float var2) { + public void renderHover(TextureManager var1, float var2) { FontRenderer var3 = this.minecraft.fontRenderer; GL11.glPushMatrix(); GL11.glTranslatef(this.xo + (this.x - this.xo) * var2, this.yo + (this.y - this.yo) * var2 + 0.8F + this.renderOffset, this.zo + (this.z - this.zo) * var2); @@ -182,4 +218,18 @@ public class NetworkPlayer extends HumanoidMob { this.moveQueue.add(new PositionUpdate(var3, var4)); this.moveQueue.add(new PositionUpdate(var1, var2)); } + + public void clear() { + if(this.a >= 0 && this.textures != null) { + TextureManager var10000 = this.textures; + int var1 = this.a; + TextureManager var2 = this.textures; + var10000.textureImages.remove(Integer.valueOf(var1)); + var2.idBuffer.clear(); + var2.idBuffer.put(var1); + var2.idBuffer.flip(); + GL11.glDeleteTextures(var2.idBuffer.get()); + } + + } } diff --git a/src/main/java/com/mojang/minecraft/net/PositionUpdate.java b/src/teavm/java/com/mojang/minecraft/net/PositionUpdate.java similarity index 100% rename from src/main/java/com/mojang/minecraft/net/PositionUpdate.java rename to src/teavm/java/com/mojang/minecraft/net/PositionUpdate.java diff --git a/src/teavm/java/com/mojang/minecraft/net/SkinDownloadThread.java b/src/teavm/java/com/mojang/minecraft/net/SkinDownloadThread.java new file mode 100644 index 0000000..e8a4098 --- /dev/null +++ b/src/teavm/java/com/mojang/minecraft/net/SkinDownloadThread.java @@ -0,0 +1,46 @@ +package com.mojang.minecraft.net; + +import java.net.HttpURLConnection; +import java.net.URL; +import javax.imageio.ImageIO; + +public class SkinDownloadThread extends Thread +{ + public SkinDownloadThread(NetworkPlayer networkPlayer) + { + super(); + + this.player = networkPlayer; + } + + @Override + public void run() + { + HttpURLConnection connection = null; + + try { + connection = (HttpURLConnection)new URL("http://www.minecraft.net/skin/" + player.name + ".png").openConnection(); + + connection.setDoInput(true); + connection.setDoOutput(false); + + connection.connect(); + + if(connection.getResponseCode() == 404) + { + return; + } + + player.newTexture = ImageIO.read(connection.getInputStream()); + } catch(Exception e) { + e.printStackTrace(); + } finally { + if(connection != null) + { + connection.disconnect(); + } + } + } + + private NetworkPlayer player; +} diff --git a/src/main/java/com/mojang/minecraft/particle/Particle.java b/src/teavm/java/com/mojang/minecraft/particle/Particle.java similarity index 100% rename from src/main/java/com/mojang/minecraft/particle/Particle.java rename to src/teavm/java/com/mojang/minecraft/particle/Particle.java diff --git a/src/main/java/com/mojang/minecraft/particle/ParticleManager.java b/src/teavm/java/com/mojang/minecraft/particle/ParticleManager.java similarity index 77% rename from src/main/java/com/mojang/minecraft/particle/ParticleManager.java rename to src/teavm/java/com/mojang/minecraft/particle/ParticleManager.java index 79d1106..8dbeef6 100644 --- a/src/main/java/com/mojang/minecraft/particle/ParticleManager.java +++ b/src/teavm/java/com/mojang/minecraft/particle/ParticleManager.java @@ -2,18 +2,24 @@ package com.mojang.minecraft.particle; import com.mojang.minecraft.Entity; import com.mojang.minecraft.level.Level; +import com.mojang.minecraft.particle.Particle; +import com.mojang.minecraft.render.TextureManager; import java.util.ArrayList; import java.util.List; public final class ParticleManager { public List[] particles = new List[2]; + public TextureManager textureManager; - public ParticleManager(Level var1) { + + public ParticleManager(Level var1, TextureManager var2) { if(var1 != null) { var1.particleEngine = this; } + this.textureManager = var2; + for(int var3 = 0; var3 < 2; ++var3) { this.particles[var3] = new ArrayList(); } diff --git a/src/main/java/com/mojang/minecraft/particle/SmokeParticle.java b/src/teavm/java/com/mojang/minecraft/particle/SmokeParticle.java similarity index 100% rename from src/main/java/com/mojang/minecraft/particle/SmokeParticle.java rename to src/teavm/java/com/mojang/minecraft/particle/SmokeParticle.java diff --git a/src/main/java/com/mojang/minecraft/particle/TerrainParticle.java b/src/teavm/java/com/mojang/minecraft/particle/TerrainParticle.java similarity index 100% rename from src/main/java/com/mojang/minecraft/particle/TerrainParticle.java rename to src/teavm/java/com/mojang/minecraft/particle/TerrainParticle.java diff --git a/src/main/java/com/mojang/minecraft/particle/WaterDropParticle.java b/src/teavm/java/com/mojang/minecraft/particle/WaterDropParticle.java similarity index 100% rename from src/main/java/com/mojang/minecraft/particle/WaterDropParticle.java rename to src/teavm/java/com/mojang/minecraft/particle/WaterDropParticle.java diff --git a/src/main/java/com/mojang/minecraft/phys/AABB.java b/src/teavm/java/com/mojang/minecraft/phys/AABB.java similarity index 100% rename from src/main/java/com/mojang/minecraft/phys/AABB.java rename to src/teavm/java/com/mojang/minecraft/phys/AABB.java diff --git a/src/main/java/com/mojang/minecraft/player/InputHandler.java b/src/teavm/java/com/mojang/minecraft/player/InputHandler.java similarity index 100% rename from src/main/java/com/mojang/minecraft/player/InputHandler.java rename to src/teavm/java/com/mojang/minecraft/player/InputHandler.java diff --git a/src/main/java/com/mojang/minecraft/player/InputHandlerImpl.java b/src/teavm/java/com/mojang/minecraft/player/InputHandlerImpl.java similarity index 100% rename from src/main/java/com/mojang/minecraft/player/InputHandlerImpl.java rename to src/teavm/java/com/mojang/minecraft/player/InputHandlerImpl.java diff --git a/src/main/java/com/mojang/minecraft/player/Inventory.java b/src/teavm/java/com/mojang/minecraft/player/Inventory.java similarity index 100% rename from src/main/java/com/mojang/minecraft/player/Inventory.java rename to src/teavm/java/com/mojang/minecraft/player/Inventory.java diff --git a/src/main/java/com/mojang/minecraft/player/Player$1.java b/src/teavm/java/com/mojang/minecraft/player/Player$1.java similarity index 100% rename from src/main/java/com/mojang/minecraft/player/Player$1.java rename to src/teavm/java/com/mojang/minecraft/player/Player$1.java diff --git a/src/main/java/com/mojang/minecraft/player/Player.java b/src/teavm/java/com/mojang/minecraft/player/Player.java similarity index 78% rename from src/main/java/com/mojang/minecraft/player/Player.java rename to src/teavm/java/com/mojang/minecraft/player/Player.java index 54627eb..8009833 100644 --- a/src/main/java/com/mojang/minecraft/player/Player.java +++ b/src/teavm/java/com/mojang/minecraft/player/Player.java @@ -4,12 +4,14 @@ import com.mojang.minecraft.Entity; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.mob.Mob; import com.mojang.minecraft.model.HumanoidModel; -import com.mojang.minecraft.render.TextureLocation; +import com.mojang.minecraft.player.InputHandler; +import com.mojang.minecraft.player.Inventory; +import com.mojang.minecraft.player.Player$1; +import com.mojang.minecraft.render.TextureManager; import com.mojang.util.MathHelper; - -import net.PeytonPlayz585.minecraft.MinecraftImage; - +import java.awt.image.BufferedImage; import java.util.List; +import org.lwjgl.opengl.GL11; public class Player extends Mob { @@ -24,7 +26,7 @@ public class Player extends Mob { public int score = 0; public int arrows = 20; private static int newTextureId = -1; - public static MinecraftImage newTexture; + public static BufferedImage newTexture; public Player(Level var1) { @@ -84,7 +86,7 @@ public class Player extends Mob { } - public void render(float var2) {} + public void render(TextureManager var1, float var2) {} public void releaseAllKeys() { this.input.resetKeys(); @@ -130,8 +132,20 @@ public class Player extends Mob { return true; } - public void bindTexture() { - new TextureLocation("/char.png").bindTexture(); + public void bindTexture(TextureManager var1) { + if(newTexture != null) { + newTextureId = var1.load(newTexture); + newTexture = null; + } + + int var2; + if(newTextureId < 0) { + var2 = var1.load("/char.png"); + GL11.glBindTexture(3553, var2); + } else { + var2 = newTextureId; + GL11.glBindTexture(3553, var2); + } } public void hurt(Entity var1, int var2) { diff --git a/src/main/java/com/mojang/minecraft/render/Chunk.java b/src/teavm/java/com/mojang/minecraft/render/Chunk.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/Chunk.java rename to src/teavm/java/com/mojang/minecraft/render/Chunk.java diff --git a/src/main/java/com/mojang/minecraft/render/ChunkDirtyDistanceComparator.java b/src/teavm/java/com/mojang/minecraft/render/ChunkDirtyDistanceComparator.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/ChunkDirtyDistanceComparator.java rename to src/teavm/java/com/mojang/minecraft/render/ChunkDirtyDistanceComparator.java diff --git a/src/main/java/com/mojang/minecraft/render/ChunkDistanceComparator.java b/src/teavm/java/com/mojang/minecraft/render/ChunkDistanceComparator.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/ChunkDistanceComparator.java rename to src/teavm/java/com/mojang/minecraft/render/ChunkDistanceComparator.java diff --git a/src/main/java/com/mojang/minecraft/render/Frustrum.java b/src/teavm/java/com/mojang/minecraft/render/Frustrum.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/Frustrum.java rename to src/teavm/java/com/mojang/minecraft/render/Frustrum.java diff --git a/src/main/java/com/mojang/minecraft/render/FrustrumImpl.java b/src/teavm/java/com/mojang/minecraft/render/FrustrumImpl.java similarity index 94% rename from src/main/java/com/mojang/minecraft/render/FrustrumImpl.java rename to src/teavm/java/com/mojang/minecraft/render/FrustrumImpl.java index 05d18e9..fce492d 100644 --- a/src/main/java/com/mojang/minecraft/render/FrustrumImpl.java +++ b/src/teavm/java/com/mojang/minecraft/render/FrustrumImpl.java @@ -2,16 +2,18 @@ package com.mojang.minecraft.render; import com.mojang.minecraft.render.Frustrum; import com.mojang.util.MathHelper; + +import net.lax1dude.eaglercraft.GLAllocation; + import java.nio.FloatBuffer; -import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; public final class FrustrumImpl extends Frustrum { private static FrustrumImpl instance = new FrustrumImpl(); - private FloatBuffer projectionBuff = BufferUtils.createFloatBuffer(16); - private FloatBuffer modelviewBuff = BufferUtils.createFloatBuffer(16); - private FloatBuffer unused = BufferUtils.createFloatBuffer(16); + private FloatBuffer projectionBuff = GLAllocation.createDirectFloatBuffer(16); + private FloatBuffer modelviewBuff = GLAllocation.createDirectFloatBuffer(16); + private FloatBuffer unused = GLAllocation.createDirectFloatBuffer(16); public static Frustrum update() { diff --git a/src/main/java/com/mojang/minecraft/render/HeldBlock.java b/src/teavm/java/com/mojang/minecraft/render/HeldBlock.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/HeldBlock.java rename to src/teavm/java/com/mojang/minecraft/render/HeldBlock.java diff --git a/src/main/java/com/mojang/minecraft/render/LevelRenderer.java b/src/teavm/java/com/mojang/minecraft/render/LevelRenderer.java similarity index 87% rename from src/main/java/com/mojang/minecraft/render/LevelRenderer.java rename to src/teavm/java/com/mojang/minecraft/render/LevelRenderer.java index 17b8936..f66b0d5 100644 --- a/src/main/java/com/mojang/minecraft/render/LevelRenderer.java +++ b/src/teavm/java/com/mojang/minecraft/render/LevelRenderer.java @@ -3,20 +3,26 @@ package com.mojang.minecraft.render; import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.player.Player; +import com.mojang.minecraft.render.Chunk; +import com.mojang.minecraft.render.ChunkDistanceComparator; +import com.mojang.minecraft.render.ShapeRenderer; +import com.mojang.minecraft.render.TextureManager; + +import net.lax1dude.eaglercraft.GLAllocation; + import java.nio.IntBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; public final class LevelRenderer { public Level level; + public TextureManager textureManager; public int listId; - public IntBuffer buffer = BufferUtils.createIntBuffer(65536); - public IntBuffer buffer_fast = BufferUtils.createIntBuffer(4096); - public List chunks = new ArrayList(); + public IntBuffer buffer = GLAllocation.createDirectIntBuffer(4096); + public List chunks = new ArrayList(); private Chunk[] loadQueue; public Chunk[] chunkCache; private int xChunks; @@ -32,8 +38,9 @@ public final class LevelRenderer { public float cracks; - public LevelRenderer(Minecraft var1) { + public LevelRenderer(Minecraft var1, TextureManager var2) { this.minecraft = var1; + this.textureManager = var2; this.listId = GL11.glGenLists(2); this.baseListId = GL11.glGenLists(4096 << 6 << 1); } @@ -190,27 +197,15 @@ public final class LevelRenderer { var6 = this.loadQueue[var7].appendLists(this.chunkDataCache, var6, var2); } - if(!Minecraft.settings.ofFastMath) { - this.buffer.clear(); - this.buffer.put(this.chunkDataCache, 0, var6); - this.buffer.flip(); - if(this.buffer.remaining() > 0) { - new TextureLocation("/terrain.png").bindTexture(); - GL11.glCallLists(this.buffer); - } - - return this.buffer.remaining(); - } else { - this.buffer_fast.clear(); - this.buffer_fast.put(this.chunkDataCache, 0, var6); - this.buffer_fast.flip(); - if(this.buffer_fast.remaining() > 0) { - new TextureLocation("/terrain.png").bindTexture(); - GL11.glCallLists(this.buffer_fast); - } - - return this.buffer_fast.remaining(); + this.buffer.clear(); + this.buffer.put(this.chunkDataCache, 0, var6); + this.buffer.flip(); + if(this.buffer.remaining() > 0) { + GL11.glBindTexture(3553, this.textureManager.load("/terrain.png")); + GL11.glCallLists(this.buffer); } + + return this.buffer.remaining(); } public final void queueChunks(int var1, int var2, int var3, int var4, int var5, int var6) { diff --git a/src/main/java/com/mojang/minecraft/render/Renderer.java b/src/teavm/java/com/mojang/minecraft/render/Renderer.java similarity index 95% rename from src/main/java/com/mojang/minecraft/render/Renderer.java rename to src/teavm/java/com/mojang/minecraft/render/Renderer.java index 023070a..bab588f 100644 --- a/src/main/java/com/mojang/minecraft/render/Renderer.java +++ b/src/teavm/java/com/mojang/minecraft/render/Renderer.java @@ -9,9 +9,11 @@ import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.player.Player; import com.mojang.minecraft.render.HeldBlock; import com.mojang.util.MathHelper; + +import net.lax1dude.eaglercraft.GLAllocation; + import java.nio.FloatBuffer; import java.util.Random; -import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; public final class Renderer { @@ -26,7 +28,7 @@ public final class Renderer { public Random random = new Random(); private volatile int unused1 = 0; private volatile int unused2 = 0; - private FloatBuffer buffer = BufferUtils.createFloatBuffer(16); + private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); public float fogRed; public float fogBlue; public float fogGreen; diff --git a/src/main/java/com/mojang/minecraft/render/ShapeRenderer.java b/src/teavm/java/com/mojang/minecraft/render/ShapeRenderer.java similarity index 69% rename from src/main/java/com/mojang/minecraft/render/ShapeRenderer.java rename to src/teavm/java/com/mojang/minecraft/render/ShapeRenderer.java index d507199..1a484dc 100644 --- a/src/main/java/com/mojang/minecraft/render/ShapeRenderer.java +++ b/src/teavm/java/com/mojang/minecraft/render/ShapeRenderer.java @@ -16,8 +16,6 @@ public final class ShapeRenderer { private float b; private boolean color = false; private boolean texture = false; - private boolean normals = false; - private int normal; private int vertexLength = 3; private int length = 0; private boolean noColor = false; @@ -25,37 +23,41 @@ public final class ShapeRenderer { public final void end() { + if(this.vertices > 0) { this.buffer.clear(); this.buffer.put(this.data, 0, this.length); this.buffer.flip(); - - if (this.texture) { - GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); - } - - if (this.color) { - GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY); - } - - if (this.normals) { - GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY); - } - - GL11._wglDrawArrays(7, 0, this.vertices); - - if (this.texture) { - GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); + if(this.texture && this.color) { + GL11.glInterleavedArrays(10794, 0, this.buffer); + } else if(this.texture) { + GL11.glInterleavedArrays(10791, 0, this.buffer); + } else if(this.color) { + GL11.glInterleavedArrays(10788, 0, this.buffer); + } else { + GL11.glInterleavedArrays(10785, 0, this.buffer); } - if (this.color) { - GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY); + GL11.glEnableClientState('\u8074'); + if(this.texture) { + GL11.glEnableClientState('\u8078'); } - if (this.normals) { - GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY); + if(this.color) { + GL11.glEnableClientState('\u8076'); } - - this.clear(); + + GL11.glDrawArrays(7, 0, this.vertices); + GL11.glDisableClientState('\u8074'); + if(this.texture) { + GL11.glDisableClientState('\u8078'); + } + + if(this.color) { + GL11.glDisableClientState('\u8076'); + } + } + + this.clear(); } private void clear() { @@ -66,7 +68,6 @@ public final class ShapeRenderer { public final void begin() { this.clear(); - this.normals = false; this.color = false; this.texture = false; this.noColor = false; @@ -107,10 +108,6 @@ public final class ShapeRenderer { this.data[this.length++] = this.g; this.data[this.length++] = this.b; } - - if(this.normals) { - this.data[this.length++] = this.normal; - } this.data[this.length++] = var1; this.data[this.length++] = var2; @@ -154,13 +151,7 @@ public final class ShapeRenderer { } public final void normal(float var1, float var2, float var3) { - this.normals = true; - float len = (float) Math.sqrt(var1 * var1 + var2 * var2 + var3 * var3); - int var4 = (int) ((var1 / len) * 127.0F) + 127; - int var5 = (int) ((var2 / len) * 127.0F) + 127; - int var6 = (int) ((var3 / len) * 127.0F) + 127; - this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16; - GL11.glNormal3f(var1, var2, var3); + GL11.glNormal3f(var1, var2, var3); } } diff --git a/src/teavm/java/com/mojang/minecraft/render/TextureManager.java b/src/teavm/java/com/mojang/minecraft/render/TextureManager.java new file mode 100644 index 0000000..2edab86 --- /dev/null +++ b/src/teavm/java/com/mojang/minecraft/render/TextureManager.java @@ -0,0 +1,117 @@ +package com.mojang.minecraft.render; + +import com.mojang.minecraft.GameSettings; +import com.mojang.minecraft.render.texture.TextureFX; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.awt.image.ImageObserver; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import javax.imageio.ImageIO; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +public class TextureManager { + + public HashMap textures = new HashMap(); + public HashMap textureImages = new HashMap(); + public IntBuffer idBuffer = BufferUtils.createIntBuffer(1); + public ByteBuffer textureBuffer = BufferUtils.createByteBuffer(262144); + public List animations = new ArrayList(); + public GameSettings settings; + + + public TextureManager(GameSettings var1) { + this.settings = var1; + } + + public final int load(String var1) { + Integer var2; + if((var2 = (Integer)this.textures.get(var1)) != null) { + return var2.intValue(); + } else { + try { + this.idBuffer.clear(); + GL11.glGenTextures(this.idBuffer); + int var4 = this.idBuffer.get(0); + if(var1.startsWith("##")) { + this.load(load1(ImageIO.read(TextureManager.class.getResourceAsStream(var1.substring(2)))), var4); + } else { + this.load(ImageIO.read(TextureManager.class.getResourceAsStream(var1)), var4); + } + + this.textures.put(var1, Integer.valueOf(var4)); + return var4; + } catch (IOException var3) { + throw new RuntimeException("!!"); + } + } + } + + public static BufferedImage load1(BufferedImage var0) { + int var1 = var0.getWidth() / 16; + BufferedImage var2; + Graphics var3 = (var2 = new BufferedImage(16, var0.getHeight() * var1, 2)).getGraphics(); + + for(int var4 = 0; var4 < var1; ++var4) { + var3.drawImage(var0, -var4 << 4, var4 * var0.getHeight(), (ImageObserver)null); + } + + var3.dispose(); + return var2; + } + + public final int load(BufferedImage var1) { + this.idBuffer.clear(); + GL11.glGenTextures(this.idBuffer); + int var2 = this.idBuffer.get(0); + this.load(var1, var2); + this.textureImages.put(Integer.valueOf(var2), var1); + return var2; + } + + public void load(BufferedImage var1, int var2) { + GL11.glBindTexture(3553, var2); + GL11.glTexParameteri(3553, 10241, 9728); + GL11.glTexParameteri(3553, 10240, 9728); + var2 = var1.getWidth(); + int var3 = var1.getHeight(); + int[] var4 = new int[var2 * var3]; + byte[] var5 = new byte[var2 * var3 << 2]; + var1.getRGB(0, 0, var2, var3, var4, 0, var2); + + for(int var11 = 0; var11 < var4.length; ++var11) { + int var6 = var4[var11] >>> 24; + int var7 = var4[var11] >> 16 & 255; + int var8 = var4[var11] >> 8 & 255; + int var9 = var4[var11] & 255; + if(this.settings.anaglyph) { + int var10 = (var7 * 30 + var8 * 59 + var9 * 11) / 100; + var8 = (var7 * 30 + var8 * 70) / 100; + var9 = (var7 * 30 + var9 * 70) / 100; + var7 = var10; + var8 = var8; + var9 = var9; + } + + var5[var11 << 2] = (byte)var7; + var5[(var11 << 2) + 1] = (byte)var8; + var5[(var11 << 2) + 2] = (byte)var9; + var5[(var11 << 2) + 3] = (byte)var6; + } + + this.textureBuffer.clear(); + this.textureBuffer.put(var5); + this.textureBuffer.position(0).limit(var5.length); + GL11.glTexImage2D(3553, 0, 6408, var2, var3, 0, 6408, 5121, this.textureBuffer); + } + + public final void registerAnimation(TextureFX var1) { + this.animations.add(var1); + var1.animate(); + } +} diff --git a/src/main/java/com/mojang/minecraft/render/texture/TextureFX.java b/src/teavm/java/com/mojang/minecraft/render/texture/TextureFX.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/texture/TextureFX.java rename to src/teavm/java/com/mojang/minecraft/render/texture/TextureFX.java diff --git a/src/main/java/com/mojang/minecraft/render/texture/TextureLavaFX.java b/src/teavm/java/com/mojang/minecraft/render/texture/TextureLavaFX.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/texture/TextureLavaFX.java rename to src/teavm/java/com/mojang/minecraft/render/texture/TextureLavaFX.java diff --git a/src/main/java/com/mojang/minecraft/render/texture/TextureWaterFX.java b/src/teavm/java/com/mojang/minecraft/render/texture/TextureWaterFX.java similarity index 100% rename from src/main/java/com/mojang/minecraft/render/texture/TextureWaterFX.java rename to src/teavm/java/com/mojang/minecraft/render/texture/TextureWaterFX.java diff --git a/src/teavm/java/com/mojang/util/MathHelper.java b/src/teavm/java/com/mojang/util/MathHelper.java new file mode 100644 index 0000000..daa8ff3 --- /dev/null +++ b/src/teavm/java/com/mojang/util/MathHelper.java @@ -0,0 +1,30 @@ +package com.mojang.util; + + +public final class MathHelper { + + private static float[] SIN_TABLE = new float[4096]; + + + public static final float sin(float var0) { + return SIN_TABLE[(int)(var0 * 651.8986F) & 4095]; + } + + public static final float cos(float var0) { + return SIN_TABLE[(int)((var0 + ((float)Math.PI / 2F)) * 651.8986F) & 4095]; + } + + public static final float sqrt(float var0) { + return (float)Math.sqrt((double)var0); + } + + static { + for (int j = 0; j < 4096; ++j) { + SIN_TABLE[j] = (float)Math.sin((double)(((float)j + 0.5F) / 4096.0F * ((float)Math.PI * 2F))); + } + + for (int l = 0; l < 360; l += 90) { + SIN_TABLE[(int)((float)l * 11.377778F) & 4095] = (float)Math.sin((double)((float)l * 0.017453292F)); + } + } +} diff --git a/src/main/java/de/jarnbjo/ogg/BasicStream.java b/src/teavm/java/de/jarnbjo/ogg/BasicStream.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/BasicStream.java rename to src/teavm/java/de/jarnbjo/ogg/BasicStream.java diff --git a/src/main/java/de/jarnbjo/ogg/CachedUrlStream.java b/src/teavm/java/de/jarnbjo/ogg/CachedUrlStream.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/CachedUrlStream.java rename to src/teavm/java/de/jarnbjo/ogg/CachedUrlStream.java diff --git a/src/main/java/de/jarnbjo/ogg/EndOfOggStreamException.java b/src/teavm/java/de/jarnbjo/ogg/EndOfOggStreamException.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/EndOfOggStreamException.java rename to src/teavm/java/de/jarnbjo/ogg/EndOfOggStreamException.java diff --git a/src/main/java/de/jarnbjo/ogg/FileStream.java b/src/teavm/java/de/jarnbjo/ogg/FileStream.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/FileStream.java rename to src/teavm/java/de/jarnbjo/ogg/FileStream.java diff --git a/src/main/java/de/jarnbjo/ogg/LogicalOggStream.java b/src/teavm/java/de/jarnbjo/ogg/LogicalOggStream.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/LogicalOggStream.java rename to src/teavm/java/de/jarnbjo/ogg/LogicalOggStream.java diff --git a/src/main/java/de/jarnbjo/ogg/LogicalOggStreamImpl.java b/src/teavm/java/de/jarnbjo/ogg/LogicalOggStreamImpl.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/LogicalOggStreamImpl.java rename to src/teavm/java/de/jarnbjo/ogg/LogicalOggStreamImpl.java diff --git a/src/main/java/de/jarnbjo/ogg/OggFormatException.java b/src/teavm/java/de/jarnbjo/ogg/OggFormatException.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/OggFormatException.java rename to src/teavm/java/de/jarnbjo/ogg/OggFormatException.java diff --git a/src/main/java/de/jarnbjo/ogg/OggPage.java b/src/teavm/java/de/jarnbjo/ogg/OggPage.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/OggPage.java rename to src/teavm/java/de/jarnbjo/ogg/OggPage.java diff --git a/src/main/java/de/jarnbjo/ogg/OnDemandUrlStream.java b/src/teavm/java/de/jarnbjo/ogg/OnDemandUrlStream.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/OnDemandUrlStream.java rename to src/teavm/java/de/jarnbjo/ogg/OnDemandUrlStream.java diff --git a/src/main/java/de/jarnbjo/ogg/PhysicalOggStream.java b/src/teavm/java/de/jarnbjo/ogg/PhysicalOggStream.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/PhysicalOggStream.java rename to src/teavm/java/de/jarnbjo/ogg/PhysicalOggStream.java diff --git a/src/main/java/de/jarnbjo/ogg/UncachedUrlStream.java b/src/teavm/java/de/jarnbjo/ogg/UncachedUrlStream.java similarity index 100% rename from src/main/java/de/jarnbjo/ogg/UncachedUrlStream.java rename to src/teavm/java/de/jarnbjo/ogg/UncachedUrlStream.java diff --git a/src/main/java/de/jarnbjo/util/audio/FadeableAudioInputStream.java b/src/teavm/java/de/jarnbjo/util/audio/FadeableAudioInputStream.java similarity index 100% rename from src/main/java/de/jarnbjo/util/audio/FadeableAudioInputStream.java rename to src/teavm/java/de/jarnbjo/util/audio/FadeableAudioInputStream.java diff --git a/src/main/java/de/jarnbjo/util/io/BitInputStream.java b/src/teavm/java/de/jarnbjo/util/io/BitInputStream.java similarity index 100% rename from src/main/java/de/jarnbjo/util/io/BitInputStream.java rename to src/teavm/java/de/jarnbjo/util/io/BitInputStream.java diff --git a/src/main/java/de/jarnbjo/util/io/ByteArrayBitInputStream.java b/src/teavm/java/de/jarnbjo/util/io/ByteArrayBitInputStream.java similarity index 100% rename from src/main/java/de/jarnbjo/util/io/ByteArrayBitInputStream.java rename to src/teavm/java/de/jarnbjo/util/io/ByteArrayBitInputStream.java diff --git a/src/main/java/de/jarnbjo/util/io/HuffmanNode.java b/src/teavm/java/de/jarnbjo/util/io/HuffmanNode.java similarity index 100% rename from src/main/java/de/jarnbjo/util/io/HuffmanNode.java rename to src/teavm/java/de/jarnbjo/util/io/HuffmanNode.java diff --git a/src/main/java/de/jarnbjo/vorbis/AudioPacket.java b/src/teavm/java/de/jarnbjo/vorbis/AudioPacket.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/AudioPacket.java rename to src/teavm/java/de/jarnbjo/vorbis/AudioPacket.java diff --git a/src/main/java/de/jarnbjo/vorbis/CodeBook.java b/src/teavm/java/de/jarnbjo/vorbis/CodeBook.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/CodeBook.java rename to src/teavm/java/de/jarnbjo/vorbis/CodeBook.java diff --git a/src/main/java/de/jarnbjo/vorbis/CommentHeader.java b/src/teavm/java/de/jarnbjo/vorbis/CommentHeader.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/CommentHeader.java rename to src/teavm/java/de/jarnbjo/vorbis/CommentHeader.java diff --git a/src/main/java/de/jarnbjo/vorbis/Floor.java b/src/teavm/java/de/jarnbjo/vorbis/Floor.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Floor.java rename to src/teavm/java/de/jarnbjo/vorbis/Floor.java diff --git a/src/main/java/de/jarnbjo/vorbis/Floor0.java b/src/teavm/java/de/jarnbjo/vorbis/Floor0.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Floor0.java rename to src/teavm/java/de/jarnbjo/vorbis/Floor0.java diff --git a/src/main/java/de/jarnbjo/vorbis/Floor1.java b/src/teavm/java/de/jarnbjo/vorbis/Floor1.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Floor1.java rename to src/teavm/java/de/jarnbjo/vorbis/Floor1.java diff --git a/src/main/java/de/jarnbjo/vorbis/Floor1.java~1~ b/src/teavm/java/de/jarnbjo/vorbis/Floor1.java~1~ similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Floor1.java~1~ rename to src/teavm/java/de/jarnbjo/vorbis/Floor1.java~1~ diff --git a/src/main/java/de/jarnbjo/vorbis/IdentificationHeader.java b/src/teavm/java/de/jarnbjo/vorbis/IdentificationHeader.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/IdentificationHeader.java rename to src/teavm/java/de/jarnbjo/vorbis/IdentificationHeader.java diff --git a/src/main/java/de/jarnbjo/vorbis/Mapping.java b/src/teavm/java/de/jarnbjo/vorbis/Mapping.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Mapping.java rename to src/teavm/java/de/jarnbjo/vorbis/Mapping.java diff --git a/src/main/java/de/jarnbjo/vorbis/Mapping0.java b/src/teavm/java/de/jarnbjo/vorbis/Mapping0.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Mapping0.java rename to src/teavm/java/de/jarnbjo/vorbis/Mapping0.java diff --git a/src/main/java/de/jarnbjo/vorbis/MdctFloat.java b/src/teavm/java/de/jarnbjo/vorbis/MdctFloat.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/MdctFloat.java rename to src/teavm/java/de/jarnbjo/vorbis/MdctFloat.java diff --git a/src/main/java/de/jarnbjo/vorbis/Mode.java b/src/teavm/java/de/jarnbjo/vorbis/Mode.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Mode.java rename to src/teavm/java/de/jarnbjo/vorbis/Mode.java diff --git a/src/main/java/de/jarnbjo/vorbis/Residue.java b/src/teavm/java/de/jarnbjo/vorbis/Residue.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Residue.java rename to src/teavm/java/de/jarnbjo/vorbis/Residue.java diff --git a/src/main/java/de/jarnbjo/vorbis/Residue0.java b/src/teavm/java/de/jarnbjo/vorbis/Residue0.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Residue0.java rename to src/teavm/java/de/jarnbjo/vorbis/Residue0.java diff --git a/src/main/java/de/jarnbjo/vorbis/Residue1.java b/src/teavm/java/de/jarnbjo/vorbis/Residue1.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Residue1.java rename to src/teavm/java/de/jarnbjo/vorbis/Residue1.java diff --git a/src/main/java/de/jarnbjo/vorbis/Residue2.java b/src/teavm/java/de/jarnbjo/vorbis/Residue2.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Residue2.java rename to src/teavm/java/de/jarnbjo/vorbis/Residue2.java diff --git a/src/main/java/de/jarnbjo/vorbis/SetupHeader.java b/src/teavm/java/de/jarnbjo/vorbis/SetupHeader.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/SetupHeader.java rename to src/teavm/java/de/jarnbjo/vorbis/SetupHeader.java diff --git a/src/main/java/de/jarnbjo/vorbis/Util.java b/src/teavm/java/de/jarnbjo/vorbis/Util.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/Util.java rename to src/teavm/java/de/jarnbjo/vorbis/Util.java diff --git a/src/main/java/de/jarnbjo/vorbis/VorbisAudioFileReader.java b/src/teavm/java/de/jarnbjo/vorbis/VorbisAudioFileReader.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/VorbisAudioFileReader.java rename to src/teavm/java/de/jarnbjo/vorbis/VorbisAudioFileReader.java diff --git a/src/main/java/de/jarnbjo/vorbis/VorbisFormatException.java b/src/teavm/java/de/jarnbjo/vorbis/VorbisFormatException.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/VorbisFormatException.java rename to src/teavm/java/de/jarnbjo/vorbis/VorbisFormatException.java diff --git a/src/main/java/de/jarnbjo/vorbis/VorbisStream.java b/src/teavm/java/de/jarnbjo/vorbis/VorbisStream.java similarity index 100% rename from src/main/java/de/jarnbjo/vorbis/VorbisStream.java rename to src/teavm/java/de/jarnbjo/vorbis/VorbisStream.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java b/src/teavm/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java similarity index 99% rename from src/main/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java rename to src/teavm/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java index ad8563d..5056a5e 100644 --- a/src/main/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java +++ b/src/teavm/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java @@ -1,6 +1,6 @@ package net.PeytonPlayz585.glemu; -import static net.PeytonPlayz585.minecraft.GlStateManager.*; +import static org.lwjgl.opengl.GL11.*; import net.PeytonPlayz585.glemu.vector.*; diff --git a/src/main/java/net/PeytonPlayz585/glemu/GLObjectMap.java b/src/teavm/java/net/PeytonPlayz585/glemu/GLObjectMap.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/GLObjectMap.java rename to src/teavm/java/net/PeytonPlayz585/glemu/GLObjectMap.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Matrix.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Matrix.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Quaternion.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Quaternion.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Quaternion.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Quaternion.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Vector.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Vector.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Vector2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector2f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Vector2f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector2f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Vector3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector3f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Vector3f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector3f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/Vector4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector4f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/Vector4f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector4f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java diff --git a/src/main/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java similarity index 100% rename from src/main/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java rename to src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java diff --git a/src/teavm/java/net/PeytonPlayz585/math/MathHelper.java b/src/teavm/java/net/PeytonPlayz585/math/MathHelper.java new file mode 100644 index 0000000..b5954f7 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/math/MathHelper.java @@ -0,0 +1,29 @@ +package net.PeytonPlayz585.math; + +public final class MathHelper { + + private static float[] SIN_TABLE = new float[4096]; + + public static final float sin(float var0) { + return SIN_TABLE[(int)(var0 * 651.8986F) & 4095]; + } + + public static final float cos(float var0) { + return SIN_TABLE[(int)((var0 + ((float)Math.PI / 2F)) * 651.8986F) & 4095]; + } + + public static final float sqrt(float var0) { + return (float)Math.sqrt((double)var0); + } + + static { + + for (int j = 0; j < 4096; ++j) { + SIN_TABLE[j] = (float)Math.sin((double)(((float)j + 0.5F) / 4096.0F * ((float)Math.PI * 2F))); + } + + for (int l = 0; l < 360; l += 90) { + SIN_TABLE[(int)((float)l * 11.377778F) & 4095] = (float)Math.sin((double)((float)l * 0.017453292F)); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/minecraft/MinecraftClient.java b/src/teavm/java/net/lax1dude/eaglercraft/AssetRepository.java similarity index 95% rename from src/main/java/net/PeytonPlayz585/minecraft/MinecraftClient.java rename to src/teavm/java/net/lax1dude/eaglercraft/AssetRepository.java index 00337fe..f952b08 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/MinecraftClient.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/AssetRepository.java @@ -1,4 +1,4 @@ -package net.PeytonPlayz585.minecraft; +package net.lax1dude.eaglercraft; import java.io.ByteArrayInputStream; import java.io.DataInputStream; @@ -9,7 +9,8 @@ import java.util.HashMap; import com.jcraft.jzlib.InflaterInputStream; -public class MinecraftClient { +public class AssetRepository { + private static final HashMap filePool = new HashMap(); public static final void install(byte[] pkg) throws IOException { @@ -44,11 +45,11 @@ public class MinecraftClient { if (in.available() > 0 || !" end".equals(s)) throw new IOException("invalid epk file"); } - + public static final byte[] getResource(String path) { if (path.startsWith("/")) path = path.substring(1); return filePool.get(path); } -} +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/minecraft/Base64.java b/src/teavm/java/net/lax1dude/eaglercraft/Base64.java similarity index 99% rename from src/main/java/net/PeytonPlayz585/minecraft/Base64.java rename to src/teavm/java/net/lax1dude/eaglercraft/Base64.java index ab0b0ec..c8b3f69 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/Base64.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/Base64.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package net.PeytonPlayz585.minecraft; +package net.lax1dude.eaglercraft; import java.math.BigInteger; import java.nio.charset.Charset; diff --git a/src/main/java/net/PeytonPlayz585/minecraft/BaseNCodec.java b/src/teavm/java/net/lax1dude/eaglercraft/BaseNCodec.java similarity index 99% rename from src/main/java/net/PeytonPlayz585/minecraft/BaseNCodec.java rename to src/teavm/java/net/lax1dude/eaglercraft/BaseNCodec.java index 8fbeceb..9ab019c 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/BaseNCodec.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/BaseNCodec.java @@ -1,8 +1,10 @@ -package net.PeytonPlayz585.minecraft; +package net.lax1dude.eaglercraft; import java.nio.charset.Charset; import java.util.Arrays; +import net.lax1dude.eaglercraft.BaseNCodec.CodecPolicy; + public abstract class BaseNCodec { static enum CodecPolicy { diff --git a/src/teavm/java/net/lax1dude/eaglercraft/Client.java b/src/teavm/java/net/lax1dude/eaglercraft/Client.java new file mode 100644 index 0000000..493f80e --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/Client.java @@ -0,0 +1,138 @@ +package net.lax1dude.eaglercraft; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.lwjgl.opengl.GL11; +import org.teavm.jso.JSBody; +import org.teavm.jso.browser.Window; +import org.teavm.jso.core.JSError; +import org.teavm.jso.dom.html.HTMLDocument; +import org.teavm.jso.dom.html.HTMLElement; + +import com.mojang.minecraft.Minecraft; +import com.mojang.minecraft.SessionData; + +import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; + +public class Client { + private static final String crashImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATEAAABxCAYAAAC9SpSwAAAQtnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZlrkly7jYT/cxVeAt8gl0OAZMTsYJY/H1jdsqQrh+2Y2yXV4/QpPoBEZoIdzv/+zw3/4KemFkNtMvrsPfJTZ5158WbEz896zynW9/x+Svp6l369HuTrTcxcKn7n5+Pon9f0ff37vq/XtHjXfhpo2Ncv9NdfzPo1/vhtoPLTyjJv9tdA82ugkj+/SF8DrM+2Yp9Dft6Cns/r1/c/YeB/8Kcib+wfg/z+uQrR242LJedTUok851I/Cyj+P4eyeJN45hfZ39V35fM8v1ZCQP4Up/jTqsLvWfnx7restPPnpJT+uSNw4ddg9h+vf7wOZP4Y/PBC/DNO7Otd/vX6rfH8vp3v//fuEe49n92t2glp/9rU9xbfO25UQl7e1zoP4X/jvbzH5DEC6DWys6NF5WFppkxabqppp5VuOu/VkrHEmk8WXnO2XN61USTPbCWGlyce6WYps+wyyJ+R3sLV/GMt6c0733SWBhPvxJ05MVj6pD//PY9/OdC9DvmUPJikPr38pOxAZRmeOX/mLhKS7jeO2gvw9+P3H89rIYPthXmwwRX1M4S29IUtx1F5iS7c2Hj9lEWS/TUAIWLuxmJSIQOxp9JST1FylpSI4yA/i4GG14aSgtRa3qwy11I6yRnZ5+Y7kt69ueXPZTiLRLTSi5CaWRa5qhAb+JE6wNBqpdXWWm/SRptt9dJrb7136U5+S4pUadJFZMiUNcqoo40+ZIww5lgzzwI5ttmnzDHnXItJFyMvvr24YS3NWrRq066iQ6cuAz5WrVk3sRFs2tp5lw1P7L5ljz33OukApVNPO/3IGWeedYH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gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz61xwk6AAAABmJLR0QAnQCdAJ2roJyEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5gEYFgQKOBb3JwAAIABJ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Go3Fc5UIgEIDVakV3dzfq6upYsa5arWYF5S6XC4mJiXj22WexZs2aKQloOTg4iXGERVdXF/bs2YNNmzahpaUFCoUiIrEIW8uE6/MUTqdDWUmVSoU1a9ZgzZo1mDt3LhISErisgoOTGMf0YHBwEE1NTTh+/Di+/fZb1NTUAAgtuZgM4QibzpHyurCwEPfccw8qKiqQl5eHhISEsIe6cnBwEuO4JVCt48jICLq7u9HW1oabN29iYGAAFosFPT09zK0cK8mQyWRQqVSse0RcXBzrypqamsoOI53pk9Y5ODiJcYQ09aN+ZG63m50BQL2XhK+nDhl0QpGwa4awMy4HBycxju+N2ML9HPLAvoOimYODkxgHBwfHHQqed+fg4OAkxsHBwcFJjIODg4OTGAcHBycxDg4ODk5iHBwcHJzEODg4ODiJcXBwcBLj4ODg4CTGwcHBwUmMg4ODg5MYBwcHJzEODg4OTmIcHBwcnMQ4ODg4iXFwcHBwEuPg4ODgJMbBwcHBSYyDg+MvCv8foPuErXNuO3cAAAAASUVORK5CYII="; + + public static class AbortedLaunchException extends RuntimeException { + // yee + } + + public static HTMLElement rootElement = null; + public static Minecraft instance = null; + public static void main(String[] args) { + registerErrorHandler(); + String[] e = getOpts(); + try { + try { + EaglerAdapterImpl2.initializeContext(rootElement = Window.current().getDocument().getElementById(e[0]), e[1]); + }catch(AbortedLaunchException ex) { + return; + } + }catch(Throwable ex2) { + StringWriter s = new StringWriter(); + ex2.printStackTrace(new PrintWriter(s)); + return; + } + run0(); + } + + private static void run0() { + System.out.println(" -------- starting minecraft -------- "); + instance = new Minecraft(); + run1(); + } + + private static void run1() { + instance.host = "0.0.0.0:25565"; + instance.session = new SessionData("PeytonPlayz585", "TeaVM-WebGL"); + instance.levelLoaded = true; + GL11.canvas.focus(); + GL11.canvasBack.focus(); + instance.waiting = false; + instance.run(); + } + + @JSBody(params = { }, script = "return window.minecraftOpts;") + public static native String[] getOpts(); + + @JSBody(params = { }, script = "window.minecraftError = null; window.onerror = function(message, file, line, column, errorObj) { if(errorObj) { window.minecraftError = errorObj; window.minecraftErrorL = \"\"+line+\":\"+column; javaMethods.get(\"net.lax1dude.eaglercraft.Client.handleNativeError()V\").invoke(); } else { alert(\"a native browser exception was thrown but your browser does not support fith argument in onerror\"); } };") + public static native void registerErrorHandler(); + + @JSBody(params = { }, script = "return window.minecraftError;") + public static native JSError getWindowError(); + + @JSBody(params = { }, script = "return window.minecraftErrorL;") + public static native String getWindowErrorL(); + + public static void handleNativeError() { + JSError e = getWindowError(); + StringBuilder str = new StringBuilder(); + str.append("Native Browser Exception\n"); + str.append("----------------------------------\n"); + str.append(" Line: ").append(getWindowErrorL()).append('\n'); + str.append(" Type: ").append(e.getName()).append('\n'); + str.append(" Message: ").append(e.getMessage()).append('\n'); + str.append("----------------------------------\n\n"); + str.append(e.getStack()).append('\n'); + } + + private static boolean isCrashed = false; + + public static void showDatabaseLockedScreen(String msg) { + String s = rootElement.getAttribute("style"); + rootElement.setAttribute("style", (s == null ? "" : s) + "position:relative;"); + HTMLDocument doc = Window.current().getDocument(); + HTMLElement img = doc.createElement("img"); + HTMLElement div = doc.createElement("div"); + img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);"); + img.setAttribute("src", crashImage); + div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 24px sans-serif;padding:10px;"); + rootElement.appendChild(img); + rootElement.appendChild(div); + div.appendChild(doc.createTextNode(msg)); + } + + @JSBody(params = { "v" }, script = "try { return \"\"+window[v]; } catch(e) { return \"\"; }") + private static native String getString(String var); + + @JSBody(params = { "v" }, script = "try { return \"\"+window.navigator[v]; } catch(e) { return \"\"; }") + private static native String getStringNav(String var); + + @JSBody(params = { "v" }, script = "try { return \"\"+window.screen[v]; } catch(e) { return \"\"; }") + private static native String getStringScreen(String var); + + @JSBody(params = { "v" }, script = "try { return \"\"+window.location[v]; } catch(e) { return \"\"; }") + private static native String getStringLocation(String var); + + @JSBody(params = { }, script = "for(var i = 0; i < window.minecraftOpts.length; ++i) { if(window.minecraftOpts[i].length > 2048) window.minecraftOpts[i] = \"[\" + Math.floor(window.minecraftOpts[i].length * 0.001) + \"k characters]\"; }") + private static native void shortenMinecraftOpts(); + + private static void addDebug(StringBuilder str, String var) { + str.append("window.").append(var).append(" = ").append(getString(var)).append('\n'); + } + + private static void addDebugNav(StringBuilder str, String var) { + str.append("window.navigator.").append(var).append(" = ").append(getStringNav(var)).append('\n'); + } + + private static void addDebugScreen(StringBuilder str, String var) { + str.append("window.screen.").append(var).append(" = ").append(getStringScreen(var)).append('\n'); + } + + private static void addDebugLocation(StringBuilder str, String var) { + str.append("window.location.").append(var).append(" = ").append(getStringLocation(var)).append('\n'); + } + + private static void addArray(StringBuilder str, String var) { + str.append("window.").append(var).append(" = ").append(getArray(var)).append('\n'); + } + + @JSBody(params = { "v" }, script = "try { return (typeof window[v] !== \"undefined\") ? JSON.stringify(window[v]) : \"[\\\"\\\"]\"; } catch(e) { return \"[\\\"\\\"]\"; }") + private static native String getArray(String var); + +} diff --git a/src/main/java/net/PeytonPlayz585/minecraft/MinecraftImage.java b/src/teavm/java/net/lax1dude/eaglercraft/EaglerImage.java similarity index 64% rename from src/main/java/net/PeytonPlayz585/minecraft/MinecraftImage.java rename to src/teavm/java/net/lax1dude/eaglercraft/EaglerImage.java index 88532c1..a96c393 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/MinecraftImage.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/EaglerImage.java @@ -1,20 +1,23 @@ -package net.PeytonPlayz585.minecraft; +package net.lax1dude.eaglercraft; -public class MinecraftImage { +import java.io.ByteArrayInputStream; +import java.io.IOException; + +public class EaglerImage { public final int[] data; public final int w; public final int h; public final boolean alpha; - public MinecraftImage(int pw, int ph, boolean palpha) { + public EaglerImage(int pw, int ph, boolean palpha) { this.w = pw; this.h = ph; this.alpha = palpha; this.data = new int[pw * ph]; } - public MinecraftImage(int[] pdata, int pw, int ph, boolean palpha) { + public EaglerImage(int[] pdata, int pw, int ph, boolean palpha) { if (pdata.length != pw * ph) { throw new IllegalArgumentException("array size does not equal image size"); } @@ -29,12 +32,12 @@ public class MinecraftImage { this.data = pdata; } - public MinecraftImage getSubImage(int x, int y, int pw, int ph) { + public EaglerImage getSubImage(int x, int y, int pw, int ph) { int[] img = new int[pw * ph]; for (int i = 0; i < ph; ++i) { System.arraycopy(data, (i + y) * this.w + x, img, i * pw, pw); } - return new MinecraftImage(img, pw, ph, alpha); + return new EaglerImage(img, pw, ph, alpha); } } \ No newline at end of file diff --git a/src/teavm/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java b/src/teavm/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java new file mode 100644 index 0000000..131056b --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java @@ -0,0 +1,180 @@ +package net.lax1dude.eaglercraft; + +import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.*; + +import java.nio.IntBuffer; + +import org.lwjgl.opengl.GL11; + +import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.BufferArrayGL; + +public class EarlyLoadScreen { + + public static final String loadScreen = "iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAWonpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZpZjmO3lkX/OYoaAnseDoctUDOo4dfaVGRUOm0Dfnh+QH04w5YUiite8jS7IeXO//z3df/Fv9KruVya1V6r51/uucfBC/Off+M9Bp/f4/u3vv7E7795333/IfJW4jl9frX6df2P98P3AJ+nwavy00D2NVKYv/1Dz1/j2y8Dfd0oaUaRF/troP41UIqfP4SvAcZnWb52az8vYZ7P8/6xEvv87/SQ2hv7e5Bff8+N6O3CmynGk0LyPMaUPxNI+j+4NPhDfI+NC3nkdUz1Pf6ICQH5ozj5n2blfs3K96vwJ+//kpRUP+873vhtMOv38x++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AgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz4gG/WSAAAABmJLR0QAnQCdAJ2roJyEAAAACXBIWXMAAAsTAAAL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OvZYmAU4OhOMKk5MjlqJUQeJ00hOV7rM2iN3b354EaaTNRfvWrkxuH7lta2nl3p3WIlpPmgQY0H+OI2Vv01qK4ld4EXXcIvS+eyD32PZQOUN5xemGcqt91iJC7fzU0iTAgHFA+P1s4cbdqNx44NGt3pknT7e0Nrfb7Z9yq312NC+1NPda1qOffcQYII0oIdKUmu/Wk5eLoGkfPdd6lPZXer1pb3em5/u5gfvejFB6XC1C7R37XppagAMChMFXejLTQWyuAu5Fi7jJLg0+cwPs2v5yszAtFTrtArV0IWpdlHignxtj1D7LzWa1HHstzVfA49Gf3L3LTUO+w5qIFgDNEuzNIEEL8JbkuhxWdAkAPAyXQ4MAAAEAAgAEAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIAAAAEAAgAEAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIAAAAGAZVn+ANVuB8euXCQKAAAAAElFTkSuQmCC"; + public static final String enableScreen = "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAC4jAAAuIwF4pT92AAAEAklEQVR42u2dvXbjIBBG7T0+xw+gTp06v//LmE6dO/VR5a3wGZNh+BGSFeveJgkIBrDy8TGKds8/Pz/PExyW8/P55AY4MP9YgmNzmeeZVUABAA8AKADgAQAFADwAoACABwAUAPAAgAIAHgBQAMADAAoAeABAAY7LOI7fpQDX65VPtZCt18w5d7rdbigAbOgBxnE8DcPwJnnDMCTrNJlsUVcizTnj9HWxeVvINfN9y361OdTEk30551ZZt3PsvYDYxOSChoPQ6sJ21mRLBm61jY0lpy61gDKWNdfcNcv5wErWLbfPF88I9/s9WtayzopXS85YtPqcMeT23SqedV1pucal1V4iTUooV/IaWSfbWHU5JmkvpmzrsayaB9DqfJnVTpMff72sc869/WzVlcjjOI7mOOVYfBzfT05exLfT5pqae008a71Ly6tPASV79CfPylvFjpm+teLH+tXiF5nA2LOAUMpCibckWpPBUOJT20btFuDjyK8p+S45Z4fX+ti+LDb3pef62PosWbfkDbBW8mFPhB/gt8Vr7gG+kZK9+C/GM2+ArffnnKRHbT5gSdJoK0+ydrziGyCW115LolLxnHOr59q3lt89b6U8Czg4pgdI5bUtKY3VzfOclGBtTLVSmmqn1cdyC7Iud+5791KX1MLJDz3Mg2s59pK6sM/asdTmLrRx5pzjS+e+awWw9lstVeuv1/a10rqwT8sn5LQr8RzaMVfmKrR2qfnFjs57/puLS0nyoTZp0fL8XGq+ap8v4AES+3Msx74kN2/tmblewWoXPl9o+RykZH5/5hTQYv+y+vj084XcPHpJbHmt1s7yGbV1q+UBnHO/gnoZje2RmuzK/Vr2F3sWEF6TGkvutqH5CG08qTmk5u77tLyK5Qtq62rgxRA8AO8FHBkygQeHLQAFADwAoACABwAUAPAAgAIAHgBQAMADAAoAeABAAQAPACgA4AEABQA8AKAAgAcAFAC+3gNM03Tqum7VQSyN4dtvMdZDKcBWC9oqhr8JoIEHeDwep77vf5VJfL0vl9fLa/u+f+vPfx9eszSGNXZo5AH6vlcXW36gsqykrzViwAIPYL3r3nXd63v5m6i9J2+VaT8viWGNHZQbYE97+KdjHPIGKH0XPSyL7eXSjPk2YZlsN03Tq21OjLAs598ZggIT2MpMbW3IMICFN0Dsv4xpfUbfAvIAK9wAcOAtAMgDwJHzAIACAB4AUADAAwAKAHgAQAEADwAoAOABAAUAPACgAIAHABQA8ACAAgAeAFAAwAMACgB4AEABAA8AKADgAQAFADwAoACABwAUAPAAgAIAHgBQAMADAAoAeABAAQAPACgA4AEABQA8AKAAgAcAFADwANCe/0of1jQ8XY5YAAAAAElFTkSuQmCC"; + + private static BufferGL vbo = null; + private static ProgramGL program = null; + + public static void paintScreen() { + + TextureGL tex = _wglGenTextures(); + _wglActiveTexture(_wGL_TEXTURE0); + _wglBindTexture(_wGL_TEXTURE_2D, tex); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MAG_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP); + EaglerImage img = GL11.loadPNG(Base64.decodeBase64(loadScreen)); + IntBuffer upload = GLAllocation.createDirectIntBuffer(192 * 192); + upload.put(img.data); + upload.flip(); + _wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA, 192, 192, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, upload); + + upload.clear(); + upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(1.0f)); + upload.put(Float.floatToIntBits(1.0f)); + upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(1.0f)); + upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(1.0f)); + upload.put(Float.floatToIntBits(1.0f)); + upload.put(Float.floatToIntBits(1.0f)); + upload.flip(); + + vbo = _wglCreateBuffer(); + _wglBindBuffer(_wGL_ARRAY_BUFFER, vbo); + _wglBufferData0(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); + + ShaderGL vert = _wglCreateShader(_wGL_VERTEX_SHADER); + _wglShaderSource(vert, _wgetShaderHeader() + + "\nprecision lowp float; in vec2 a_pos; out vec2 v_pos; void main() { gl_Position = vec4(((v_pos = a_pos) - 0.5) * vec2(2.0, -2.0), 0.0, 1.0); }"); + _wglCompileShader(vert); + + ShaderGL frag = _wglCreateShader(_wGL_FRAGMENT_SHADER); + _wglShaderSource(frag, _wgetShaderHeader() + + "\nprecision lowp float; in vec2 v_pos; out vec4 fragColor; uniform sampler2D tex; uniform vec2 aspect; void main() { fragColor = vec4(texture(tex, clamp(v_pos * aspect - ((aspect - 1.0) * 0.5), 0.02, 0.98)).rgb, 1.0); }"); + _wglCompileShader(frag); + + program = _wglCreateProgram(); + + _wglAttachShader(program, vert); + _wglAttachShader(program, frag); + _wglBindAttributeLocation(program, 0, "a_pos"); + _wglLinkProgram(program); + _wglDetachShader(program, vert); + _wglDetachShader(program, frag); + _wglDeleteShader(vert); + _wglDeleteShader(frag); + + try { + Thread.sleep(50l); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + _wglUseProgram(program); + _wglUniform1i(_wglGetUniformLocation(program, "tex"), 0); + + int width = getCanvasWidth(); + int height = getCanvasHeight(); + float x, y; + if (width > height) { + x = (float) width / (float) height; + y = 1.0f; + } else { + x = 1.0f; + y = (float) height / (float) width; + } + + _wglActiveTexture(_wGL_TEXTURE0); + _wglBindTexture(_wGL_TEXTURE_2D, tex); + + _wglViewport(0, 0, width, height); + _wglClearColor(1.0f, 1.0f, 1.0f, 1.0f); + _wglClear(_wGL_COLOR_BUFFER_BIT | _wGL_DEPTH_BUFFER_BIT); + + _wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y); + + BufferArrayGL vao = _wglCreateVertexArray(); + _wglBindVertexArray(vao); + _wglEnableVertexAttribArray(0); + _wglVertexAttribPointer(0, 2, _wGL_FLOAT, false, 8, 0); + _wglDrawArrays(_wGL_TRIANGLES, 0, 6); + _wglDisableVertexAttribArray(0); + _wglFlush(); + updateDisplay(); + + _wglUseProgram(null); + _wglBindBuffer(_wGL_ARRAY_BUFFER, null); + _wglBindTexture(_wGL_TEXTURE_2D, null); + _wglDeleteTextures(tex); + _wglDeleteVertexArray(vao); + } + + public static void paintEnable() { + + TextureGL tex = _wglGenTextures(); + _wglActiveTexture(_wGL_TEXTURE0); + _wglBindTexture(_wGL_TEXTURE_2D, tex); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MAG_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP); + EaglerImage img = GL11.loadPNG(Base64.decodeBase64(enableScreen)); + IntBuffer upload = GLAllocation.createDirectIntBuffer(128 * 128); + upload.put(img.data); + upload.flip(); + _wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA, 128, 128, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, upload); + + try { + Thread.sleep(50l); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + _wglUseProgram(program); + + int width = getCanvasWidth(); + int height = getCanvasHeight(); + float x, y; + if (width > height) { + x = (float) width / (float) height; + y = 1.0f; + } else { + x = 1.0f; + y = (float) height / (float) width; + } + + _wglActiveTexture(_wGL_TEXTURE0); + _wglBindTexture(_wGL_TEXTURE_2D, tex); + + _wglViewport(0, 0, width, height); + _wglClearColor(1.0f, 1.0f, 1.0f, 1.0f); + _wglClear(_wGL_COLOR_BUFFER_BIT | _wGL_DEPTH_BUFFER_BIT); + + _wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y); + + BufferArrayGL vao = _wglCreateVertexArray(); + _wglBindVertexArray(vao); + _wglBindBuffer(_wGL_ARRAY_BUFFER, vbo); + _wglEnableVertexAttribArray(0); + _wglVertexAttribPointer(0, 2, _wGL_FLOAT, false, 8, 0); + _wglDrawArrays(_wGL_TRIANGLES, 0, 6); + _wglDisableVertexAttribArray(0); + _wglFlush(); + updateDisplay(); + + _wglUseProgram(null); + _wglBindBuffer(_wGL_ARRAY_BUFFER, null); + _wglBindTexture(_wGL_TEXTURE_2D, null); + _wglDeleteTextures(tex); + _wglDeleteVertexArray(vao); + + } + +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/minecraft/GLAllocation.java b/src/teavm/java/net/lax1dude/eaglercraft/GLAllocation.java similarity index 63% rename from src/main/java/net/PeytonPlayz585/minecraft/GLAllocation.java rename to src/teavm/java/net/lax1dude/eaglercraft/GLAllocation.java index a8975da..0352944 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/GLAllocation.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/GLAllocation.java @@ -1,16 +1,18 @@ -package net.PeytonPlayz585.minecraft; +package net.lax1dude.eaglercraft; import java.nio.*; import java.util.ArrayList; import java.util.List; +import org.lwjgl.opengl.GL11; + public class GLAllocation { public GLAllocation() { } public static synchronized int generateDisplayLists(int i) { - int j = GlStateManager.glGenLists(i); + int j = GL11.glGenLists(i); displayLists.add(Integer.valueOf(j)); displayLists.add(Integer.valueOf(i)); return j; @@ -19,7 +21,7 @@ public class GLAllocation { public static synchronized void generateTextureNames(IntBuffer intbuffer) { for (int i = intbuffer.position(); i < intbuffer.limit(); i++) { - int tx = GlStateManager.glGenTextures(); + int tx = GL11.glGenTextures(); intbuffer.put(i, tx); textureNames.add(Integer.valueOf(tx)); } @@ -28,12 +30,12 @@ public class GLAllocation { public static synchronized void deleteTexturesAndDisplayLists() { for (int i = 0; i < displayLists.size(); i += 2) { - GlStateManager.glDeleteLists(((Integer) displayLists.get(i)).intValue(), + GL11.glDeleteLists(((Integer) displayLists.get(i)).intValue(), ((Integer) displayLists.get(i + 1)).intValue()); } for (int j = 0; j < textureNames.size(); j++) { - GlStateManager.glDeleteTextures(((Integer) textureNames.get(j)).intValue()); + GL11.glDeleteTextures(((Integer) textureNames.get(j)).intValue()); } displayLists.clear(); @@ -41,15 +43,15 @@ public class GLAllocation { } public static ByteBuffer createDirectByteBuffer(int par0) { - return ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()); + return GL11.isWebGL ? ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()) : ByteBuffer.allocateDirect(par0).order(ByteOrder.nativeOrder()); } public static IntBuffer createDirectIntBuffer(int par0) { - return IntBuffer.wrap(new int[par0]); + return GL11.isWebGL ? IntBuffer.wrap(new int[par0]) : createDirectByteBuffer(par0 << 2).asIntBuffer(); } public static FloatBuffer createDirectFloatBuffer(int par0) { - return FloatBuffer.wrap(new float[par0]); + return GL11.isWebGL ? FloatBuffer.wrap(new float[par0]) : createDirectByteBuffer(par0 << 2).asFloatBuffer(); } private static List displayLists = new ArrayList(); diff --git a/src/main/java/net/PeytonPlayz585/minecraft/GeneralDigest.java b/src/teavm/java/net/lax1dude/eaglercraft/GeneralDigest.java similarity index 97% rename from src/main/java/net/PeytonPlayz585/minecraft/GeneralDigest.java rename to src/teavm/java/net/lax1dude/eaglercraft/GeneralDigest.java index c7054e1..079352d 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/GeneralDigest.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/GeneralDigest.java @@ -1,4 +1,4 @@ -package net.PeytonPlayz585.minecraft; +package net.lax1dude.eaglercraft; /** * base implementation of MD4 family style digest as outlined in "Handbook of diff --git a/src/main/java/net/PeytonPlayz585/minecraft/SHA1Digest.java b/src/teavm/java/net/lax1dude/eaglercraft/SHA1Digest.java similarity index 99% rename from src/main/java/net/PeytonPlayz585/minecraft/SHA1Digest.java rename to src/teavm/java/net/lax1dude/eaglercraft/SHA1Digest.java index c93990a..9ba1d4d 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/SHA1Digest.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/SHA1Digest.java @@ -1,4 +1,4 @@ -package net.PeytonPlayz585.minecraft; +package net.lax1dude.eaglercraft; /** * implementation of SHA-1 as outlined in "Handbook of Applied Cryptography", diff --git a/src/teavm/java/net/lax1dude/eaglercraft/TestFilesystem.java b/src/teavm/java/net/lax1dude/eaglercraft/TestFilesystem.java new file mode 100644 index 0000000..d87bb41 --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/TestFilesystem.java @@ -0,0 +1,121 @@ +package net.lax1dude.eaglercraft; + +import java.util.Collection; + +import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry; +import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem; +import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem.OpenState; + +public class TestFilesystem { + + public static void main(String[] args) { + OpenState os = IndexedDBFilesystem.initialize(); + + if(os != OpenState.OPENED) { + System.out.println("Error: " + os); + System.out.println("Detail: " + IndexedDBFilesystem.errorDetail()); + return; + } + + IndexedDBFilesystem.writeFile("text.txt", "fuck fuck shit".getBytes()); + IndexedDBFilesystem.writeFile("folder/text.txt", "fuck shit fuck".getBytes()); + IndexedDBFilesystem.writeFile("folder/eee/text.txt", "shit shit fuck".getBytes()); + + System.out.println("exists text.txt:" + IndexedDBFilesystem.fileExists("text.txt")); + System.out.println("exists folder/text.txt:" + IndexedDBFilesystem.fileExists("folder/text.txt")); + System.out.println("exists folder/eee/text.txt:" + IndexedDBFilesystem.fileExists("folder/eee/text.txt")); + + System.out.println("type file text.txt:" + IndexedDBFilesystem.fileExists("text.txt")); + System.out.println("type file folder:" + IndexedDBFilesystem.fileExists("folder")); + System.out.println("type file folder/text.txt:" + IndexedDBFilesystem.fileExists("folder/text.txt")); + System.out.println("type file folder/eee:" + IndexedDBFilesystem.fileExists("folder/eee")); + System.out.println("type file folder/eee/text.txt:" + IndexedDBFilesystem.fileExists("folder/eee/text.txt")); + + System.out.println("type folder text.txt:" + IndexedDBFilesystem.directoryExists("text.txt")); + System.out.println("type folder folder:" + IndexedDBFilesystem.directoryExists("folder")); + System.out.println("type folder folder/text.txt:" + IndexedDBFilesystem.directoryExists("folder/text.txt")); + System.out.println("type folder folder/eee:" + IndexedDBFilesystem.directoryExists("folder/eee")); + System.out.println("type folder folder/eee/text.txt:" + IndexedDBFilesystem.directoryExists("folder/eee/text.txt")); + + System.out.println("data file text.txt:" + new String(IndexedDBFilesystem.readFile("text.txt"))); + System.out.println("data file folder/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/text.txt"))); + System.out.println("data file folder/eee/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/eee/text.txt"))); + + System.out.println("copy file text.txt to text2.txt"); IndexedDBFilesystem.copyFile("text.txt", "text2.txt"); + System.out.println("copy file text.txt to folder2/text2.txt"); IndexedDBFilesystem.copyFile("text.txt", "folder2/text2.txt"); + System.out.println("copy file folder/text.txt to folder3/eee2/text2.txt:"); IndexedDBFilesystem.copyFile("folder/text.txt", "folder3/eee2/text2.txt"); + System.out.println("copy file folder3/eee2/text2.txt to text2.txt:"); IndexedDBFilesystem.copyFile("folder3/eee2/text2.txt", "text2.txt"); + + System.out.println("type folder folder2:" + IndexedDBFilesystem.directoryExists("folder2")); + System.out.println("type folder folder3:" + IndexedDBFilesystem.directoryExists("folder3")); + System.out.println("type folder folder3/eee2:" + IndexedDBFilesystem.directoryExists("folder3/eee2")); + + System.out.println("data file text.txt:" + new String(IndexedDBFilesystem.readFile("text.txt"))); + System.out.println("data file folder/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/text.txt"))); + System.out.println("data file folder/eee/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/eee/text.txt"))); + System.out.println("data file text2.txt:" + new String(IndexedDBFilesystem.readFile("text2.txt"))); + System.out.println("data file folder2/text2.txt:" + new String(IndexedDBFilesystem.readFile("folder2/text2.txt"))); + System.out.println("data file folder3/eee2/text2.txt:" + new String(IndexedDBFilesystem.readFile("folder3/eee2/text2.txt"))); + + System.out.println("data file folder2/tefjfgj.txt:" + IndexedDBFilesystem.readFile("folder2/tefjfgj.txt")); + System.out.println("data file folder3/gjjg/text2.txt:" + IndexedDBFilesystem.readFile("folder3/eegjjge2/text2.txt")); + + System.out.println("move file text.txt to text3.txt"); IndexedDBFilesystem.renameFile("text.txt", "text3.txt"); + System.out.println("move file text.txt to folder4/text2.txt"); IndexedDBFilesystem.renameFile("text.txt", "folder4/text2.txt"); + System.out.println("move file text3.txt to folder4/text2.txt"); IndexedDBFilesystem.renameFile("text.txt", "folder4/text3.txt"); + System.out.println("move file folder22/text.txt to folder3/eee2/text3.txt:"); IndexedDBFilesystem.renameFile("folder22/text.txt", "folder3/eee2/text3.txt"); + + System.out.println("last modified text.txt:" + IndexedDBFilesystem.getLastModified("text.txt")); + System.out.println("last modified folder/text.txt:" + IndexedDBFilesystem.getLastModified("folder/text.txt")); + System.out.println("last modified folder/eee/text.txt:" + IndexedDBFilesystem.getLastModified("folder/eee/text.txt")); + System.out.println("last modified text2.txt:" + IndexedDBFilesystem.getLastModified("text2.txt")); + System.out.println("last modified folder2/text2.txt:" + IndexedDBFilesystem.getLastModified("folder2/text2.txt")); + System.out.println("last modified folder3/eee2/text2.txt:" + IndexedDBFilesystem.getLastModified("folder3/eee2/text2.txt")); + + System.out.println("last modified folder2/tefjfgj.txt:" + IndexedDBFilesystem.getLastModified("folder2/tefjfgj.txt")); + System.out.println("last modified folder3/gjjg/text2.txt:" + IndexedDBFilesystem.getLastModified("folder3/eegjjge2/text2.txt")); + + System.out.println("last modified text3.txt: " + IndexedDBFilesystem.getLastModified("text3.txt")); + System.out.println("last modified folder4/text2.txt: " + IndexedDBFilesystem.getLastModified("folder4/text2.txt")); + System.out.println("last modified folder4/text3.txt: " + IndexedDBFilesystem.getLastModified("folder4/text3.txt")); + System.out.println("last modified folder3/eee2/text3.txt:" + IndexedDBFilesystem.getLastModified("folder3/eee2/text3.txt")); + + System.out.println("delete file text3.txt"); IndexedDBFilesystem.deleteFile("text3.txt"); + System.out.println("delete file folder4/text2.txt"); IndexedDBFilesystem.deleteFile("folder4/text2.txt"); + System.out.println("delete file folder4/text2.txt"); IndexedDBFilesystem.deleteFile("folder4/text3.txt"); + System.out.println("delete file folder4"); IndexedDBFilesystem.deleteFile("folder4"); + System.out.println("delete file folder3/eee2/text3.txt:"); IndexedDBFilesystem.deleteFile("folder3/eee2/text3.txt"); + + Collection files = IndexedDBFilesystem.listFiles("", true, true); + System.out.println(); + System.out.println("List all:"); + listFileList(files); + + files = IndexedDBFilesystem.listFiles("", false, true); + System.out.println(); + System.out.println("List all files:"); + listFileList(files); + + files = IndexedDBFilesystem.listFiles("", false, false); + System.out.println(); + System.out.println("List all files not recursive:"); + listFileList(files); + + files = IndexedDBFilesystem.listFiles("folder", true, true); + System.out.println(); + System.out.println("List all files in 'folder':"); + listFileList(files); + + files = IndexedDBFilesystem.listFiles("folder", true, false); + System.out.println(); + System.out.println("List all files in 'folder' no recursive:"); + listFileList(files); + } + + private static void listFileList(Collection files) { + for(FileEntry f : files) { + System.out.println(" - " + f.path + " " + f.isDirectory + " " + f.lastModified + " " + f.getName()); + } + } + +} diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java new file mode 100644 index 0000000..0435410 --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -0,0 +1,1976 @@ +package net.lax1dude.eaglercraft.adapter; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.charset.Charset; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Set; + +import org.teavm.interop.Async; +import org.teavm.interop.AsyncCallback; +import org.teavm.jso.JSBody; +import org.teavm.jso.JSFunctor; +import org.teavm.jso.JSObject; +import org.teavm.jso.ajax.ReadyStateChangeHandler; +import org.teavm.jso.ajax.XMLHttpRequest; +import org.teavm.jso.browser.TimerHandler; +import org.teavm.jso.browser.Window; +import org.teavm.jso.canvas.CanvasRenderingContext2D; +import org.teavm.jso.canvas.ImageData; +import org.teavm.jso.dom.events.Event; +import org.teavm.jso.dom.events.EventListener; +import org.teavm.jso.dom.events.KeyboardEvent; +import org.teavm.jso.dom.events.MessageEvent; +import org.teavm.jso.dom.events.MouseEvent; +import org.teavm.jso.dom.events.WheelEvent; +import org.teavm.jso.dom.html.HTMLCanvasElement; +import org.teavm.jso.dom.html.HTMLDocument; +import org.teavm.jso.dom.html.HTMLElement; +import org.teavm.jso.dom.html.HTMLImageElement; +import org.teavm.jso.typedarrays.ArrayBuffer; +import org.teavm.jso.typedarrays.Float32Array; +import org.teavm.jso.typedarrays.Int32Array; +import org.teavm.jso.typedarrays.Uint8Array; +import org.teavm.jso.typedarrays.Uint8ClampedArray; +import org.teavm.jso.webaudio.AudioBuffer; +import org.teavm.jso.webaudio.AudioBufferSourceNode; +import org.teavm.jso.webaudio.AudioContext; +import org.teavm.jso.webaudio.AudioListener; +import org.teavm.jso.webaudio.DecodeErrorCallback; +import org.teavm.jso.webaudio.DecodeSuccessCallback; +import org.teavm.jso.webaudio.GainNode; +import org.teavm.jso.webaudio.MediaEvent; +import org.teavm.jso.webaudio.PannerNode; +import org.teavm.jso.webgl.WebGLBuffer; +import org.teavm.jso.webgl.WebGLFramebuffer; +import org.teavm.jso.webgl.WebGLProgram; +import org.teavm.jso.webgl.WebGLRenderbuffer; +import org.teavm.jso.webgl.WebGLShader; +import org.teavm.jso.webgl.WebGLTexture; +import org.teavm.jso.webgl.WebGLUniformLocation; +import org.teavm.jso.websocket.CloseEvent; +import org.teavm.jso.websocket.WebSocket; + +import net.lax1dude.eaglercraft.adapter.teavm.WebGLQuery; +import net.lax1dude.eaglercraft.adapter.teavm.WebGLVertexArray; +import net.PeytonPlayz585.math.MathHelper; +import net.lax1dude.eaglercraft.AssetRepository; +import net.lax1dude.eaglercraft.Base64; +import net.lax1dude.eaglercraft.Client; +import net.lax1dude.eaglercraft.EaglerImage; +import net.lax1dude.eaglercraft.EarlyLoadScreen; +import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem; +import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem.OpenState; +import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext; +import static net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext.*; + +public class EaglerAdapterImpl2 { + + public static final boolean _wisWebGL() { + return true; + } + private static boolean isAnisotropicPatched = false; + public static final boolean _wisAnisotropicPatched() { + return isAnisotropicPatched; + } + public static final String _wgetShaderHeader() { + return "#version 300 es"; + } + + @JSBody(params = { }, script = "return window.location.href;") + private static native String getLocationString(); + + public static final boolean isSSLPage() { + return getLocationString().startsWith("https"); + } + + public static final InputStream loadResource(String path) { + byte[] file = loadResourceBytes(path); + if (file != null) { + return new ByteArrayInputStream(file); + } else { + return null; + } + } + + public static final byte[] loadResourceBytes(String path) { + return AssetRepository.getResource(path); + } + + public static final String fileContents(String path) { + byte[] contents = loadResourceBytes(path); + if(contents == null) { + return null; + }else { + return new String(contents, Charset.forName("UTF-8")); + } + } + + public static final String[] fileContentsLines(String path) { + String contents = fileContents(path); + if(contents == null) { + return null; + }else { + return contents.replace("\r\n", "\n").split("[\r\n]"); + } + } + + @Async + public static native String downloadAssetPack(String assetPackageURI); + + private static void downloadAssetPack(String assetPackageURI, final AsyncCallback cb) { + final XMLHttpRequest request = XMLHttpRequest.create(); + request.setResponseType("arraybuffer"); + request.open("GET", assetPackageURI, true); + request.setOnReadyStateChange(new ReadyStateChangeHandler() { + @Override + public void stateChanged() { + if(request.getReadyState() == XMLHttpRequest.DONE) { + Uint8Array bl = Uint8Array.create((ArrayBuffer)request.getResponse()); + loadedPackage = new byte[bl.getByteLength()]; + for(int i = 0; i < loadedPackage.length; ++i) { + loadedPackage[i] = (byte) bl.get(i); + } + cb.complete("yee"); + } + } + }); + request.send(); + } + + @JSBody(params = { "obj" }, script = "window.currentContext = obj;") + private static native int setContextVar(JSObject obj); + + @JSBody(params = { "v", "s" }, script = "window[v] = s;") + public static native void setDebugVar(String v, String s); + + @JSBody(params = { }, script = "if(window.navigator.userActivation){return window.navigator.userActivation.hasBeenActive;}else{return false;}") + public static native boolean hasBeenActive(); + + public static HTMLDocument doc = null; + public static HTMLElement parent = null; + public static HTMLCanvasElement canvas = null; + public static CanvasRenderingContext2D canvasContext = null; + public static HTMLCanvasElement canvasBack = null; + public static WebGL2RenderingContext webgl = null; + public static Window win = null; + private static byte[] loadedPackage = null; + private static EventListener contextmenu = null; + private static EventListener mousedown = null; + private static EventListener mouseup = null; + private static EventListener mousemove = null; + private static EventListener keydown = null; + private static EventListener keyup = null; + private static EventListener keypress = null; + private static EventListener wheel = null; + private static String[] identifier = new String[0]; + + public static final String[] getIdentifier() { + return identifier; + } + + @JSBody(params = { }, script = "return window.navigator.userAgent;") + private static native String getUA(); + + @JSBody(params = { }, script = "return window.navigator.platform;") + private static native String getPlaf(); + + @JSBody(params = { "m" }, script = "return m.offsetX;") + private static native int getOffsetX(MouseEvent m); + + @JSBody(params = { "m" }, script = "return m.offsetY;") + private static native int getOffsetY(MouseEvent m); + + @JSBody(params = { "e" }, script = "return e.which;") + private static native int getWhich(KeyboardEvent e); + + public static final void initializeContext(HTMLElement rootElement, String assetPackageURI) { + parent = rootElement; + String s = parent.getAttribute("style"); + parent.setAttribute("style", (s == null ? "" : s)+"overflow-x:hidden;overflow-y:hidden;"); + win = Window.current(); + doc = win.getDocument(); + canvas = (HTMLCanvasElement)doc.createElement("canvas"); + width = rootElement.getClientWidth(); + height = rootElement.getClientHeight(); + canvas.setWidth(width); + canvas.setHeight(height); + canvasContext = (CanvasRenderingContext2D) canvas.getContext("2d"); + canvas.setAttribute("id", "deevis589723589"); + rootElement.appendChild(canvas); + canvasBack = (HTMLCanvasElement)doc.createElement("canvas"); + canvasBack.setWidth(width); + canvasBack.setHeight(height); + webgl = (WebGL2RenderingContext) canvasBack.getContext("webgl2", youEagler()); + if(webgl == null) { + throw new RuntimeException("WebGL 2.0 is not supported in your browser ("+getUA()+")"); + } + setContextVar(webgl); + + webgl.getExtension("EXT_texture_filter_anisotropic"); + + win.addEventListener("contextmenu", contextmenu = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + evt.preventDefault(); + evt.stopPropagation(); + } + }); + canvas.addEventListener("mousedown", mousedown = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + int b = evt.getButton(); + buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = true; + mouseEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + forceMouseGrabbed(); + } + }); + canvas.addEventListener("mouseup", mouseup = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + int b = evt.getButton(); + buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = false; + mouseEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + canvas.addEventListener("mousemove", mousemove = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + mouseX = getOffsetX(evt); + mouseY = canvas.getClientHeight() - getOffsetY(evt); + mouseDX += evt.getMovementX(); + mouseDY += -evt.getMovementY(); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + win.addEventListener("keydown", keydown = new EventListener() { + @Override + public void handleEvent(KeyboardEvent evt) { + //keyStates[remapKey(evt.getKeyCode())] = true; + keyStates[remapKey(getWhich(evt))] = true; + keyEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + forceMouseGrabbed(); + } + }); + win.addEventListener("keyup", keyup = new EventListener() { + @Override + public void handleEvent(KeyboardEvent evt) { + //keyStates[remapKey(evt.getKeyCode())] = false; + keyStates[remapKey(getWhich(evt))] = false; + keyEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + win.addEventListener("keypress", keypress = new EventListener() { + @Override + public void handleEvent(KeyboardEvent evt) { + if(enableRepeatEvents && evt.isRepeat()) keyEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + canvas.addEventListener("wheel", wheel = new EventListener() { + @Override + public void handleEvent(WheelEvent evt) { + mouseEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + win.addEventListener("blur", new EventListener() { + @Override + public void handleEvent(WheelEvent evt) { + isWindowFocused = false; + } + }); + win.addEventListener("focus", new EventListener() { + @Override + public void handleEvent(WheelEvent evt) { + isWindowFocused = true; + forceMouseGrabbed(); + } + }); + initFileChooser(); + + EarlyLoadScreen.paintScreen(); + + OpenState st = IndexedDBFilesystem.initialize(); + if(st != OpenState.OPENED) { + if(st == OpenState.LOCKED) { + Client.showDatabaseLockedScreen("\nError: World folder is locked!\n\nYou are already playing Eaglercraft in a different tab.\nClose all other Eaglercraft tabs and reload"); + }else { + Client.showDatabaseLockedScreen("\nError: World folder could not be loaded!\n\n" + IndexedDBFilesystem.errorDetail()); + } + throw new Client.AbortedLaunchException(); + } + + downloadAssetPack(assetPackageURI); + + try { + AssetRepository.install(loadedPackage); + } catch (IOException e) { + e.printStackTrace(); + } + + if(mouseEvents.isEmpty() && keyEvents.isEmpty() && !hasBeenActive()) { + EarlyLoadScreen.paintEnable(); + + while(mouseEvents.isEmpty() && keyEvents.isEmpty()) { + try { + Thread.sleep(100l); + } catch (InterruptedException e) { + ; + } + } + } + + audioctx = AudioContext.create(); + + mouseEvents.clear(); + keyEvents.clear(); + } + + @JSBody(params = { }, script = + "window.eagsFileChooser = {\r\n" + + "inputElement: null,\r\n" + + "openFileChooser: function(ext, mime){\r\n" + + "var el = window.eagsFileChooser.inputElement = document.createElement(\"input\");\r\n" + + "el.type = \"file\";\r\n" + + "el.multiple = false;\r\n" + + "el.addEventListener(\"change\", function(evt){\r\n" + + "var f = window.eagsFileChooser.inputElement.files;\r\n" + + "if(f.length == 0){\r\n" + + "window.eagsFileChooser.getFileChooserResult = null;\r\n" + + "}else{\r\n" + + "(async function(){\r\n" + + "window.eagsFileChooser.getFileChooserResult = await f[0].arrayBuffer();\r\n" + + "window.eagsFileChooser.getFileChooserResultName = f[0].name;\r\n" + + "})();\r\n" + + "}\r\n" + + "});\r\n" + + "window.eagsFileChooser.getFileChooserResult = null;\r\n" + + "window.eagsFileChooser.getFileChooserResultName = null;\r\n" + + "el.accept = mime;\r\n" + + "el.click();\r\n" + + "},\r\n" + + "getFileChooserResult: null,\r\n" + + "getFileChooserResultName: null\r\n" + + "};") + private static native void initFileChooser(); + + public static final void destroyContext() { + + } + + public static final void removeEventHandlers() { + win.removeEventListener("contextmenu", contextmenu); + win.removeEventListener("mousedown", mousedown); + win.removeEventListener("mouseup", mouseup); + win.removeEventListener("mousemove", mousemove); + win.removeEventListener("keydown", keydown); + win.removeEventListener("keyup", keyup); + win.removeEventListener("keypress", keypress); + win.removeEventListener("wheel", wheel); + } + + private static LinkedList mouseEvents = new LinkedList(); + private static LinkedList keyEvents = new LinkedList(); + + private static int mouseX = 0; + private static int mouseY = 0; + private static double mouseDX = 0.0D; + private static double mouseDY = 0.0D; + private static int width = 0; + private static int height = 0; + private static boolean enableRepeatEvents = false; + private static boolean isWindowFocused = true; + + @JSBody(params = { }, script = "return {antialias: false, depth: true, powerPreference: \"high-performance\", desynchronized: false, preserveDrawingBuffer: false, premultipliedAlpha: false, alpha: false};") + public static native JSObject youEagler(); + + public static final int _wGL_TEXTURE_2D = TEXTURE_2D; + public static final int _wGL_DEPTH_TEST = DEPTH_TEST; + public static final int _wGL_LEQUAL = LEQUAL; + public static final int _wGL_GEQUAL = GEQUAL; + public static final int _wGL_GREATER = GREATER; + public static final int _wGL_LESS = LESS; + public static final int _wGL_BACK = BACK; + public static final int _wGL_FRONT = FRONT; + public static final int _wGL_FRONT_AND_BACK = FRONT_AND_BACK; + public static final int _wGL_COLOR_BUFFER_BIT = COLOR_BUFFER_BIT; + public static final int _wGL_DEPTH_BUFFER_BIT = DEPTH_BUFFER_BIT; + public static final int _wGL_BLEND = BLEND; + public static final int _wGL_RGBA = RGBA; + public static final int _wGL_RGB = RGB; + public static final int _wGL_RGB8 = RGB8; + public static final int _wGL_RGBA8 = RGBA8; + public static final int _wGL_UNSIGNED_BYTE = UNSIGNED_BYTE; + public static final int _wGL_UNSIGNED_SHORT = UNSIGNED_SHORT; + public static final int _wGL_SRC_ALPHA = SRC_ALPHA; + public static final int _wGL_ONE_MINUS_SRC_ALPHA = ONE_MINUS_SRC_ALPHA; + public static final int _wGL_ONE_MINUS_DST_COLOR = ONE_MINUS_DST_COLOR; + public static final int _wGL_ONE_MINUS_SRC_COLOR = ONE_MINUS_SRC_COLOR; + public static final int _wGL_ZERO = ZERO; + public static final int _wGL_CULL_FACE = CULL_FACE; + public static final int _wGL_TEXTURE_MIN_FILTER = TEXTURE_MIN_FILTER; + public static final int _wGL_TEXTURE_MAG_FILTER = TEXTURE_MAG_FILTER; + public static final int _wGL_LINEAR = LINEAR; + public static final int _wGL_EQUAL = EQUAL; + public static final int _wGL_SRC_COLOR = SRC_COLOR; + public static final int _wGL_ONE = ONE; + public static final int _wGL_NEAREST = NEAREST; + public static final int _wGL_CLAMP = CLAMP_TO_EDGE; + public static final int _wGL_TEXTURE_WRAP_S = TEXTURE_WRAP_S; + public static final int _wGL_TEXTURE_WRAP_T = TEXTURE_WRAP_T; + public static final int _wGL_REPEAT = REPEAT; + public static final int _wGL_DST_COLOR = DST_COLOR; + public static final int _wGL_DST_ALPHA = DST_ALPHA; + public static final int _wGL_FLOAT = FLOAT; + public static final int _wGL_SHORT = SHORT; + public static final int _wGL_TRIANGLES = TRIANGLES; + public static final int _wGL_TRIANGLE_STRIP = TRIANGLE_STRIP; + public static final int _wGL_TRIANGLE_FAN = TRIANGLE_FAN; + public static final int _wGL_LINE_STRIP = LINE_STRIP; + public static final int _wGL_LINES = LINES; + public static final int _wGL_PACK_ALIGNMENT = PACK_ALIGNMENT; + public static final int _wGL_UNPACK_ALIGNMENT = UNPACK_ALIGNMENT; + public static final int _wGL_TEXTURE0 = TEXTURE0; + public static final int _wGL_TEXTURE1 = TEXTURE1; + public static final int _wGL_TEXTURE2 = TEXTURE2; + public static final int _wGL_TEXTURE3 = TEXTURE3; + public static final int _wGL_VIEWPORT = VIEWPORT; + public static final int _wGL_VERTEX_SHADER = VERTEX_SHADER; + public static final int _wGL_FRAGMENT_SHADER = FRAGMENT_SHADER; + public static final int _wGL_ARRAY_BUFFER = ARRAY_BUFFER; + public static final int _wGL_ELEMENT_ARRAY_BUFFER = ELEMENT_ARRAY_BUFFER; + public static final int _wGL_STATIC_DRAW = STATIC_DRAW; + public static final int _wGL_DYNAMIC_DRAW = DYNAMIC_DRAW; + public static final int _wGL_INVALID_ENUM = INVALID_ENUM; + public static final int _wGL_INVALID_VALUE= INVALID_VALUE; + public static final int _wGL_INVALID_OPERATION = INVALID_OPERATION; + public static final int _wGL_OUT_OF_MEMORY = OUT_OF_MEMORY; + public static final int _wGL_CONTEXT_LOST_WEBGL = CONTEXT_LOST_WEBGL; + public static final int _wGL_FRAMEBUFFER_COMPLETE = FRAMEBUFFER_COMPLETE; + public static final int _wGL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + public static final int _wGL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + public static final int _wGL_COLOR_ATTACHMENT0 = COLOR_ATTACHMENT0; + public static final int _wGL_DEPTH_STENCIL_ATTACHMENT = DEPTH_STENCIL_ATTACHMENT; + public static final int _wGL_DEPTH_STENCIL = DEPTH_STENCIL; + public static final int _wGL_NEAREST_MIPMAP_LINEAR = NEAREST_MIPMAP_LINEAR; + public static final int _wGL_LINEAR_MIPMAP_LINEAR = LINEAR_MIPMAP_LINEAR; + public static final int _wGL_LINEAR_MIPMAP_NEAREST = LINEAR_MIPMAP_NEAREST; + public static final int _wGL_NEAREST_MIPMAP_NEAREST = NEAREST_MIPMAP_NEAREST; + public static final int _wGL_TEXTURE_MAX_LEVEL = TEXTURE_MAX_LEVEL; + public static final int _wGL_UNSIGNED_INT_24_8 = UNSIGNED_INT_24_8; + public static final int _wGL_UNSIGNED_INT = UNSIGNED_INT; + public static final int _wGL_ANY_SAMPLES_PASSED = ANY_SAMPLES_PASSED; + public static final int _wGL_QUERY_RESULT = QUERY_RESULT; + public static final int _wGL_QUERY_RESULT_AVAILABLE = QUERY_RESULT_AVAILABLE; + public static final int _wGL_TEXTURE_MAX_ANISOTROPY = TEXTURE_MAX_ANISOTROPY_EXT; + public static final int _wGL_DEPTH24_STENCIL8 = DEPTH24_STENCIL8; + public static final int _wGL_DEPTH_COMPONENT32F = DEPTH_COMPONENT32F; + public static final int _wGL_DEPTH_ATTACHMENT = DEPTH_ATTACHMENT; + public static final int _wGL_MULTISAMPLE = -1; + public static final int _wGL_LINE_SMOOTH = -1; + public static final int _wGL_READ_FRAMEBUFFER = READ_FRAMEBUFFER; + public static final int _wGL_DRAW_FRAMEBUFFER = DRAW_FRAMEBUFFER; + public static final int _wGL_FRAMEBUFFER = FRAMEBUFFER; + public static final int _wGL_POLYGON_OFFSET_FILL = POLYGON_OFFSET_FILL; + + public static final class TextureGL { + protected final WebGLTexture obj; + public int w = -1; + public int h = -1; + public boolean nearest = true; + public boolean anisotropic = false; + protected TextureGL(WebGLTexture obj) { + this.obj = obj; + } + } + public static final class BufferGL { + protected final WebGLBuffer obj; + protected BufferGL(WebGLBuffer obj) { + this.obj = obj; + } + } + public static final class ShaderGL { + protected final WebGLShader obj; + protected ShaderGL(WebGLShader obj) { + this.obj = obj; + } + } + private static int progId = 0; + public static final class ProgramGL { + protected final WebGLProgram obj; + protected final int hashcode; + protected ProgramGL(WebGLProgram obj) { + this.obj = obj; + this.hashcode = ++progId; + } + } + public static final class UniformGL { + protected final WebGLUniformLocation obj; + protected UniformGL(WebGLUniformLocation obj) { + this.obj = obj; + } + } + public static final class BufferArrayGL { + protected final WebGLVertexArray obj; + public boolean isQuadBufferBound; + protected BufferArrayGL(WebGLVertexArray obj) { + this.obj = obj; + this.isQuadBufferBound = false; + } + } + public static final class FramebufferGL { + protected final WebGLFramebuffer obj; + protected FramebufferGL(WebGLFramebuffer obj) { + this.obj = obj; + } + } + public static final class RenderbufferGL { + protected final WebGLRenderbuffer obj; + protected RenderbufferGL(WebGLRenderbuffer obj) { + this.obj = obj; + } + } + public static final class QueryGL { + protected final WebGLQuery obj; + protected QueryGL(WebGLQuery obj) { + this.obj = obj; + } + } + + public static final void _wglEnable(int p1) { + webgl.enable(p1); + } + public static final void _wglClearDepth(float p1) { + webgl.clearDepth(p1); + } + public static final void _wglDepthFunc(int p1) { + webgl.depthFunc(p1); + } + public static final void _wglCullFace(int p1) { + webgl.cullFace(p1); + } + private static int[] viewportCache = new int[4]; + public static final void _wglViewport(int p1, int p2, int p3, int p4) { + viewportCache[0] = p1; viewportCache[1] = p2; + viewportCache[2] = p3; viewportCache[3] = p4; + webgl.viewport(p1, p2, p3, p4); + } + public static final void _wglClear(int p1) { + webgl.clear(p1); + } + public static final void _wglClearColor(float p1, float p2, float p3, float p4) { + webgl.clearColor(p1, p2, p3, p4); + } + public static final void _wglDisable(int p1) { + webgl.disable(p1); + } + public static final int _wglGetError() { + return webgl.getError(); + } + public static final void _wglFlush() { + //webgl.flush(); + } + private static Uint8Array uploadBuffer = Uint8Array.create(ArrayBuffer.create(4 * 1024 * 1024)); + public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { + if(p9 == null) { + webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, null); + }else { + int len = p9.remaining(); + Uint8Array uploadBuffer1 = uploadBuffer; + for(int i = 0; i < len; ++i) { + uploadBuffer1.set(i, (short) ((int)p9.get() & 0xff)); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); + webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + } + public static final void _wglBlendFunc(int p1, int p2) { + webgl.blendFunc(p1, p2); + } + public static final void _wglDepthMask(boolean p1) { + webgl.depthMask(p1); + } + public static final void _wglColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { + webgl.colorMask(p1, p2, p3, p4); + } + public static final void _wglBindTexture(int p1, TextureGL p2) { + webgl.bindTexture(p1, p2 == null ? null : p2.obj); + } + public static final void _wglCopyTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { + webgl.copyTexSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8); + } + public static final void _wglTexParameteri(int p1, int p2, int p3) { + webgl.texParameteri(p1, p2, p3); + } + public static final void _wglTexParameterf(int p1, int p2, float p3) { + webgl.texParameterf(p1, p2, p3); + } + public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { + int len = p9.remaining(); + Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.set(i, p9.get()); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { + int len = p9.remaining(); + Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.set(i, p9.get()); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + public static final void _wglDeleteTextures(TextureGL p1) { + webgl.deleteTexture(p1.obj); + } + public static final void _wglDrawArrays(int p1, int p2, int p3) { + webgl.drawArrays(p1, p2, p3); + } + public static final void _wglDrawElements(int p1, int p2, int p3, int p4) { + webgl.drawElements(p1, p2, p3, p4); + } + public static final TextureGL _wglGenTextures() { + return new TextureGL(webgl.createTexture()); + } + public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { + int len = p9.remaining(); + for(int i = 0; i < len; ++i) { + uploadBuffer.set(i, (short) ((int)p9.get() & 0xff)); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); + webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + public static final void _wglActiveTexture(int p1) { + webgl.activeTexture(p1); + } + public static final ProgramGL _wglCreateProgram() { + return new ProgramGL(webgl.createProgram()); + } + public static final ShaderGL _wglCreateShader(int p1) { + return new ShaderGL(webgl.createShader(p1)); + } + public static final void _wglAttachShader(ProgramGL p1, ShaderGL p2) { + webgl.attachShader(p1.obj, p2.obj); + } + public static final void _wglDetachShader(ProgramGL p1, ShaderGL p2) { + webgl.detachShader(p1.obj, p2.obj); + } + public static final void _wglCompileShader(ShaderGL p1) { + webgl.compileShader(p1.obj); + } + public static final void _wglLinkProgram(ProgramGL p1) { + webgl.linkProgram(p1.obj); + } + public static final void _wglShaderSource(ShaderGL p1, String p2) { + webgl.shaderSource(p1.obj, p2); + } + public static final String _wglGetShaderInfoLog(ShaderGL p1) { + return webgl.getShaderInfoLog(p1.obj); + } + public static final String _wglGetProgramInfoLog(ProgramGL p1) { + return webgl.getProgramInfoLog(p1.obj); + } + public static final boolean _wglGetShaderCompiled(ShaderGL p1) { + return webgl.getShaderParameteri(p1.obj, COMPILE_STATUS) == 1; + } + public static final boolean _wglGetProgramLinked(ProgramGL p1) { + return webgl.getProgramParameteri(p1.obj, LINK_STATUS) == 1; + } + public static final void _wglDeleteShader(ShaderGL p1) { + webgl.deleteShader(p1.obj); + } + public static final void _wglDeleteProgram(ProgramGL p1) { + webgl.deleteProgram(p1.obj); + } + public static final BufferGL _wglCreateBuffer() { + return new BufferGL(webgl.createBuffer()); + } + public static final void _wglDeleteBuffer(BufferGL p1) { + webgl.deleteBuffer(p1.obj); + } + public static final void _wglBindBuffer(int p1, BufferGL p2) { + webgl.bindBuffer(p1, p2 == null ? null : p2.obj); + } + public static final void _wglBufferData0(int p1, IntBuffer p2, int p3) { + int len = p2.remaining(); + Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.set(i, p2.get()); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.bufferData(p1, data, p3); + } + public static final void _wglBufferSubData0(int p1, int p2, IntBuffer p3) { + int len = p3.remaining(); + Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.set(i, p3.get()); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.bufferSubData(p1, p2, data); + } + public static final void _wglBufferData(int p1, Object p2, int p3) { + webgl.bufferData(p1, (Int32Array)p2, p3); + } + public static final void _wglBufferSubData(int p1, int p2, Object p3) { + webgl.bufferSubData(p1, p2, (Int32Array)p3); + } + public static final void _wglBindAttribLocation(ProgramGL p1, int p2, String p3) { + webgl.bindAttribLocation(p1.obj, p2, p3); + } + public static final void _wglEnableVertexAttribArray(int p1) { + webgl.enableVertexAttribArray(p1); + } + public static final void _wglDisableVertexAttribArray(int p1) { + webgl.disableVertexAttribArray(p1); + } + public static final UniformGL _wglGetUniformLocation(ProgramGL p1, String p2) { + WebGLUniformLocation u = webgl.getUniformLocation(p1.obj, p2); + return u == null ? null : new UniformGL(u); + } + public static final void _wglBindAttributeLocation(ProgramGL p1, int p2, String p3) { + webgl.bindAttribLocation(p1.obj, p2, p3); + } + public static final void _wglUniform1f(UniformGL p1, float p2) { + if(p1 != null) webgl.uniform1f(p1.obj, p2); + } + public static final void _wglUniform2f(UniformGL p1, float p2, float p3) { + if(p1 != null) webgl.uniform2f(p1.obj, p2, p3); + } + public static final void _wglUniform3f(UniformGL p1, float p2, float p3, float p4) { + if(p1 != null) webgl.uniform3f(p1.obj, p2, p3, p4); + } + public static final void _wglUniform4f(UniformGL p1, float p2, float p3, float p4, float p5) { + if(p1 != null) webgl.uniform4f(p1.obj, p2, p3, p4, p5); + } + public static final void _wglUniform1i(UniformGL p1, int p2) { + if(p1 != null) webgl.uniform1i(p1.obj, p2); + } + public static final void _wglUniform2i(UniformGL p1, int p2, int p3) { + if(p1 != null) webgl.uniform2i(p1.obj, p2, p3); + } + public static final void _wglUniform3i(UniformGL p1, int p2, int p3, int p4) { + if(p1 != null) webgl.uniform3i(p1.obj, p2, p3, p4); + } + public static final void _wglUniform4i(UniformGL p1, int p2, int p3, int p4, int p5) { + if(p1 != null) webgl.uniform4i(p1.obj, p2, p3, p4, p5); + } + private static Float32Array mat2 = Float32Array.create(4); + private static Float32Array mat3 = Float32Array.create(9); + private static Float32Array mat4 = Float32Array.create(16); + public static final void _wglUniformMat2fv(UniformGL p1, float[] mat) { + mat2.set(mat); + if(p1 != null) webgl.uniformMatrix2fv(p1.obj, false, mat2); + } + public static final void _wglUniformMat3fv(UniformGL p1, float[] mat) { + mat3.set(mat); + if(p1 != null) webgl.uniformMatrix3fv(p1.obj, false, mat3); + } + public static final void _wglUniformMat4fv(UniformGL p1, float[] mat) { + mat4.set(mat); + if(p1 != null) webgl.uniformMatrix4fv(p1.obj, false, mat4); + } + private static int currentProgram = -1; + public static final void _wglUseProgram(ProgramGL p1) { + if(p1 != null && currentProgram != p1.hashcode) { + currentProgram = p1.hashcode; + webgl.useProgram(p1.obj); + } + } + public static final void _wglGetParameter(int p1, int size, int[] ret) { + if(p1 == _wGL_VIEWPORT) { + ret[0] = viewportCache[0]; + ret[1] = viewportCache[1]; + ret[2] = viewportCache[2]; + ret[3] = viewportCache[3]; + } + } + public static final void _wglPolygonOffset(float p1, float p2) { + webgl.polygonOffset(p1, p2); + } + public static final void _wglVertexAttribPointer(int p1, int p2, int p3, boolean p4, int p5, int p6) { + webgl.vertexAttribPointer(p1, p2, p3, p4, p5, p6); + } + public static final void _wglBindFramebuffer(int p1, FramebufferGL p2) { + webgl.bindFramebuffer(p1, p2 == null ? null : p2.obj); + } + public static final FramebufferGL _wglCreateFramebuffer() { + return new FramebufferGL(webgl.createFramebuffer()); + } + public static final void _wglDeleteFramebuffer(FramebufferGL p1) { + webgl.deleteFramebuffer(p1.obj); + } + public static final void _wglFramebufferTexture2D(int p1, TextureGL p2) { + webgl.framebufferTexture2D(FRAMEBUFFER, p1, TEXTURE_2D, p2 == null ? null : p2.obj, 0); + } + public static final QueryGL _wglCreateQuery() { + return new QueryGL(webgl.createQuery()); + } + public static final void _wglBeginQuery(int p1, QueryGL p2) { + webgl.beginQuery(p1, p2.obj); + } + public static final void _wglEndQuery(int p1) { + webgl.endQuery(p1); + } + public static final void _wglDeleteQuery(QueryGL p1) { + webgl.deleteQuery(p1.obj); + } + public static final int _wglGetQueryObjecti(QueryGL p1, int p2) { + return webgl.getQueryParameter(p1.obj, p2); + } + public static final BufferArrayGL _wglCreateVertexArray() { + return new BufferArrayGL(webgl.createVertexArray()); + } + public static final void _wglDeleteVertexArray(BufferArrayGL p1) { + webgl.deleteVertexArray(p1.obj); + } + public static final void _wglBindVertexArray(BufferArrayGL p1) { + webgl.bindVertexArray(p1 == null ? null : p1.obj); + } + public static final void _wglDrawBuffer(int p1) { + webgl.drawBuffers(new int[] { p1 }); + } + public static final RenderbufferGL _wglCreateRenderBuffer() { + return new RenderbufferGL(webgl.createRenderbuffer()); + } + public static final void _wglBindRenderbuffer(RenderbufferGL p1) { + webgl.bindRenderbuffer(RENDERBUFFER, p1 == null ? null : p1.obj); + } + public static final void _wglRenderbufferStorage(int p1, int p2, int p3) { + webgl.renderbufferStorage(RENDERBUFFER, p1, p2, p3); + } + public static final void _wglFramebufferRenderbuffer(int p1, RenderbufferGL p2) { + webgl.framebufferRenderbuffer(FRAMEBUFFER, p1, RENDERBUFFER, p2 == null ? null : p2.obj); + } + public static final void _wglDeleteRenderbuffer(RenderbufferGL p1) { + webgl.deleteRenderbuffer(p1.obj); + } + public static final void _wglRenderbufferStorageMultisample(int p1, int p2, int p3, int p4) { + webgl.renderbufferStorageMultisample(RENDERBUFFER, p1, p2, p3, p4); + } + public static final void _wglBlitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) { + webgl.blitFramebuffer(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); + } + public static final int _wglGetAttribLocation(ProgramGL p1, String p2) { + return webgl.getAttribLocation(p1.obj, p2); + } + + @JSBody(params = { "ctx", "p" }, script = "return ctx.getTexParameter(0x0DE1, p) | 0;") + private static final native int __wglGetTexParameteri(WebGL2RenderingContext ctx, int p); + public static final int _wglGetTexParameteri(int p1) { + return __wglGetTexParameteri(webgl, p1); + } + @JSBody(params = { "ctx", "p" }, script = "return (0.0 + ctx.getTexParameter(0x0DE1, p));") + private static final native float __wglGetTexParameterf(WebGL2RenderingContext ctx, int p); + public static final float _wglGetTexParameterf(int p1) { + return __wglGetTexParameterf(webgl, p1); + } + public static final boolean isWindows() { + return getPlaf().toLowerCase().contains("win"); + } + private static HTMLCanvasElement imageLoadCanvas = null; + private static CanvasRenderingContext2D imageLoadContext = null; + + @JSBody(params = { "buf", "mime" }, script = "return URL.createObjectURL(new Blob([buf], {type: mime}));") + private static native String getDataURL(ArrayBuffer buf, String mime); + + @JSBody(params = { "url" }, script = "URL.revokeObjectURL(url);") + private static native void freeDataURL(String url); + + public static final EaglerImage loadPNG(byte[] data) { + ArrayBuffer arr = ArrayBuffer.create(data.length); + Uint8Array.create(arr).set(data); + return loadPNG0(arr); + } + + @Async + private static native EaglerImage loadPNG0(ArrayBuffer data); + + private static void loadPNG0(ArrayBuffer data, final AsyncCallback ret) { + final HTMLImageElement toLoad = (HTMLImageElement) doc.createElement("img"); + toLoad.addEventListener("load", new EventListener() { + @Override + public void handleEvent(Event evt) { + if(imageLoadCanvas == null) { + imageLoadCanvas = (HTMLCanvasElement) doc.createElement("canvas"); + } + if(imageLoadCanvas.getWidth() < toLoad.getWidth()) { + imageLoadCanvas.setWidth(toLoad.getWidth()); + } + if(imageLoadCanvas.getHeight() < toLoad.getHeight()) { + imageLoadCanvas.setHeight(toLoad.getHeight()); + } + if(imageLoadContext == null) { + imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d"); + } + imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight()); + imageLoadContext.drawImage(toLoad, 0, 0, toLoad.getWidth(), toLoad.getHeight()); + ImageData pxlsDat = imageLoadContext.getImageData(0, 0, toLoad.getWidth(), toLoad.getHeight()); + Uint8ClampedArray pxls = pxlsDat.getData(); + int totalPixels = pxlsDat.getWidth() * pxlsDat.getHeight(); + freeDataURL(toLoad.getSrc()); + if(pxls.getByteLength() < totalPixels * 4) { + ret.complete(null); + return; + } + int[] pixels = new int[totalPixels]; + for(int i = 0; i < pixels.length; ++i) { + pixels[i] = (pxls.get(i * 4) << 16) | (pxls.get(i * 4 + 1) << 8) | pxls.get(i * 4 + 2) | (pxls.get(i * 4 + 3) << 24); + } + ret.complete(new EaglerImage(pixels, pxlsDat.getWidth(), pxlsDat.getHeight(), true)); + } + }); + toLoad.addEventListener("error", new EventListener() { + @Override + public void handleEvent(Event evt) { + freeDataURL(toLoad.getSrc()); + ret.complete(null); + } + }); + String src = getDataURL(data, "image/png"); + if(src == null) { + ret.complete(null); + }else { + toLoad.setSrc(src); + } + } + + private static MouseEvent currentEvent = null; + private static KeyboardEvent currentEventK = null; + private static boolean[] buttonStates = new boolean[8]; + private static boolean[] keyStates = new boolean[256]; + public static final boolean mouseNext() { + currentEvent = null; + return !mouseEvents.isEmpty() && (currentEvent = mouseEvents.remove(0)) != null; + } + public static final int mouseGetEventButton() { + if(currentEvent == null) return -1; + int b = currentEvent.getButton(); + return b == 1 ? 2 : (b == 2 ? 1 : b); + } + public static final boolean mouseGetEventButtonState() { + return currentEvent == null ? false : currentEvent.getType().equals(MouseEvent.MOUSEDOWN); + } + public static final boolean mouseIsButtonDown(int p1) { + return buttonStates[p1]; + } + public static final int mouseGetEventDWheel() { + return ("wheel".equals(currentEvent.getType())) ? (((WheelEvent)currentEvent).getDeltaY() == 0.0D ? 0 : (((WheelEvent)currentEvent).getDeltaY() > 0.0D ? -1 : 1)) : 0; + } + public static final void mouseSetCursorPosition(int x, int y) { + + } + private static long mouseUngrabTimer = 0l; + private static int mouseUngrabTimeout = 0; + private static boolean needsPointerLock = false; + public static final void mouseSetGrabbed(boolean grabbed) { + needsPointerLock = grabbed; + if(grabbed) { + mouseDX = 0.0D; + mouseDY = 0.0D; + Window.setTimeout(new TimerHandler() { + @Override + public void onTimer() { + canvas.requestPointerLock(); + long t = System.currentTimeMillis(); + if(mouseUngrabTimeout != 0) Window.clearTimeout(mouseUngrabTimeout); + mouseUngrabTimeout = 0; + if(t - mouseUngrabTimer < 3000l) { + mouseUngrabTimeout = Window.setTimeout(new TimerHandler() { + @Override + public void onTimer() { + canvas.requestPointerLock(); + mouseUngrabTimeout = 0; + } + }, 3000 - (int)(t - mouseUngrabTimer)); + } + } + }, 200); + }else { + mouseUngrabTimer = System.currentTimeMillis(); + if(mouseUngrabTimeout != 0) Window.clearTimeout(mouseUngrabTimeout); + mouseUngrabTimeout = 0; + doc.exitPointerLock(); + } + } + private static void forceMouseGrabbed() { + long t = System.currentTimeMillis(); + if(t - mouseUngrabTimer > 3000l) { + if(needsPointerLock && !isPointerLocked()) { + canvas.requestPointerLock(); + if(isPointerLocked()) { + needsPointerLock = false; + } + } + } + } + public static final int mouseGetDX() { + double dx = mouseDX; + mouseDX = 0.0D; + return (int)dx; + } + public static final int mouseGetDY() { + double dy = mouseDY; + mouseDY = 0.0D; + return (int)dy; + } + public static final int mouseGetX() { + return mouseX; + } + public static final int mouseGetY() { + return mouseY; + } + public static final int mouseGetEventX() { + return currentEvent == null ? -1 : currentEvent.getClientX(); + } + public static final int mouseGetEventY() { + return currentEvent == null ? -1 : canvas.getClientHeight() - currentEvent.getClientY(); + } + public static final boolean keysNext() { + if(unpressCTRL) { //un-press ctrl after copy/paste permission + keyEvents.clear(); + currentEventK = null; + keyStates[29] = false; + keyStates[157] = false; + keyStates[28] = false; + keyStates[219] = false; + keyStates[220] = false; + unpressCTRL = false; + return false; + } + currentEventK = null; + return !keyEvents.isEmpty() && (currentEventK = keyEvents.remove(0)) != null; + } + public static final int getEventKey() { + return currentEventK == null ? -1 : remapKey(getWhich(currentEventK)); + } + public static final char getEventChar() { + if(currentEventK == null) return '\0'; + String s = currentEventK.getKey(); + return currentEventK == null ? ' ' : (char) (s.length() > 1 ? '\0' : s.charAt(0)); + } + public static final boolean getEventKeyState() { + return currentEventK == null? false : !currentEventK.getType().equals("keyup"); + } + public static final boolean isKeyDown(int p1) { + if(unpressCTRL) { //un-press ctrl after copy/paste permission + keyStates[28] = false; + keyStates[29] = false; + keyStates[157] = false; + keyStates[219] = false; + keyStates[220] = false; + } + return keyStates[p1]; + } + public static final String getKeyName(int p1) { + return (p1 >= 0 && p1 < 256) ? LWJGLKeyNames[p1] : "null"; + } + public static final void setFullscreen(boolean p1) { + win.alert("use F11 to enter fullscreen"); + } + public static final boolean shouldShutdown() { + return false; + } + public static final boolean isFunctionKeyDown(boolean mod, int p1) { + return mod && p1 >= 59 && p1 <= 67 && getEventKey() == (2 + (p1 - 59)); + } + public static final boolean isFunctionKeyDown(int mod, int p1) { + return isKeyDown(mod) && p1 >= 59 && p1 <= 67 & getEventKey() == (2 + (p1 - 59)); + } + public static final boolean isFunctionKeyHeldDown(int mod, int p1) { + return isKeyDown(mod) && p1 >= 59 && p1 <= 67 & isKeyDown(2 + (p1 - 59)); + } + + @JSBody(params = { "obj" }, script = "if(obj.commit) obj.commit();") + private static native int commitContext(JSObject obj); + + public static final void updateDisplay() { + commitContext(webgl); + canvasContext.drawImage(canvasBack, 0d, 0d, canvas.getWidth(), canvas.getHeight()); + + int ww = canvas.getClientWidth(); + int hh = canvas.getClientHeight(); + if(ww != width || hh != height) { + width = ww; + height = hh; + canvasBack.setWidth(ww); + canvasBack.setHeight(hh); + } + + try { + Thread.sleep(1l); + } catch (InterruptedException e) { + ; + } + } + public static final void setVSyncEnabled(boolean p1) { + + } + public static final void enableRepeatEvents(boolean b) { + enableRepeatEvents = b; + } + + public static boolean isPointerLocked2() { + return mouseUngrabTimeout != 0 || isPointerLocked(); + } + + @JSBody(params = { }, script = "return document.pointerLockElement != null;") + public static native boolean isPointerLocked(); + + private static boolean pointerLockFlag = false; + + public static final boolean isFocused() { + boolean yee = isPointerLocked(); + boolean dee = pointerLockFlag; + pointerLockFlag = yee; + if(!dee && yee) { + mouseDX = 0.0D; + mouseDY = 0.0D; + } + return isWindowFocused && !(dee && !yee); + } + public static final int getScreenWidth() { + return win.getScreen().getAvailWidth(); + } + public static final int getScreenHeight() { + return win.getScreen().getAvailHeight(); + } + public static final int getCanvasWidth() { + int w = parent.getClientWidth(); + if(w != width) { + canvas.setWidth(w); + canvasBack.setWidth(w); + width = w; + } + return w; + } + public static final int getCanvasHeight() { + int h = parent.getClientHeight(); + if(h != height) { + canvas.setHeight(h); + canvasBack.setHeight(h); + height = h; + } + return h; + } + public static final void setDisplaySize(int x, int y) { + + } + public static final void syncDisplay(int performanceToFps) { + + } + + private static final DateFormat dateFormatSS = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); + public static final void saveScreenshot() { + saveScreenshot("screenshot_" + dateFormatSS.format(new Date()).toString() + ".png", canvas); + } + + @JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=cvs.toDataURL(\"image/png\");a.download=name;a.click();") + private static native void saveScreenshot(String name, HTMLCanvasElement cvs); + + public static enum RateLimit { + NONE, FAILED, BLOCKED, FAILED_POSSIBLY_LOCKED, LOCKED, NOW_LOCKED; + } + + private static final Set rateLimitedAddresses = new HashSet(); + private static final Set blockedAddresses = new HashSet(); + + private static WebSocket sock = null; + private static boolean sockIsConnecting = false; + private static boolean sockIsConnected = false; + private static boolean sockIsAlive = false; + private static LinkedList readPackets = new LinkedList(); + private static RateLimit rateLimitStatus = null; + private static String currentSockURI = null; + + public static final RateLimit getRateLimitStatus() { + RateLimit l = rateLimitStatus; + rateLimitStatus = null; + return l; + } + public static final void logRateLimit(String addr, RateLimit l) { + if(l == RateLimit.BLOCKED) { + blockedAddresses.add(addr); + }else { + rateLimitedAddresses.add(addr); + } + } + public static final RateLimit checkRateLimitHistory(String addr) { + if(blockedAddresses.contains(addr)) { + return RateLimit.LOCKED; + }else if(rateLimitedAddresses.contains(addr)) { + return RateLimit.BLOCKED; + }else { + return RateLimit.NONE; + } + } + + @Async + public static native String connectWebSocket(String sockURI); + + private static void connectWebSocket(String sockURI, final AsyncCallback cb) { + sockIsConnecting = true; + sockIsConnected = false; + sockIsAlive = false; + rateLimitStatus = null; + currentSockURI = sockURI; + try { + sock = WebSocket.create(sockURI); + } catch(Throwable t) { + sockIsConnecting = false; + sockIsAlive = false; + return; + } + sock.setBinaryType("arraybuffer"); + sock.onOpen(new EventListener() { + @Override + public void handleEvent(MessageEvent evt) { + sockIsConnecting = false; + sockIsAlive = false; + sockIsConnected = true; + readPackets.clear(); + cb.complete("okay"); + } + }); + sock.onClose(new EventListener() { + @Override + public void handleEvent(CloseEvent evt) { + sock = null; + if(sockIsConnecting) { + if(rateLimitStatus == null) { + if(blockedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.LOCKED; + }else if(rateLimitedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.FAILED_POSSIBLY_LOCKED; + }else { + rateLimitStatus = RateLimit.FAILED; + } + } + }else if(!sockIsAlive) { + if(rateLimitStatus == null) { + if(blockedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.LOCKED; + }else if(rateLimitedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.BLOCKED; + } + } + } + boolean b = sockIsConnecting; + sockIsConnecting = false; + sockIsConnected = false; + sockIsAlive = false; + if(b) cb.complete("fail"); + } + }); + sock.onMessage(new EventListener() { + @Override + public void handleEvent(MessageEvent evt) { + sockIsAlive = true; + if(isString(evt.getData())) { + String stat = evt.getDataAsString(); + if(stat.equalsIgnoreCase("BLOCKED")) { + if(rateLimitStatus == null) { + rateLimitStatus = RateLimit.BLOCKED; + } + rateLimitedAddresses.add(currentSockURI); + }else if(stat.equalsIgnoreCase("LOCKED")) { + if(rateLimitStatus == null) { + rateLimitStatus = RateLimit.NOW_LOCKED; + } + rateLimitedAddresses.add(currentSockURI); + blockedAddresses.add(currentSockURI); + } + sockIsConnecting = false; + sockIsConnected = false; + sock.close(); + return; + } + Uint8Array a = Uint8Array.create(evt.getDataAsArray()); + byte[] b = new byte[a.getByteLength()]; + for(int i = 0; i < b.length; ++i) { + b[i] = (byte) (a.get(i) & 0xFF); + } + readPackets.add(b); + } + }); + } + + public static final boolean startConnection(String uri) { + String res = connectWebSocket(uri); + return "fail".equals(res) ? false : true; + } + public static final void endConnection() { + if(sock == null || sock.getReadyState() == 3) { + sockIsConnecting = false; + } + if(sock != null && !sockIsConnecting) sock.close(); + } + public static final boolean connectionOpen() { + if(sock == null || sock.getReadyState() == 3) { + sockIsConnecting = false; + } + return sock != null && !sockIsConnecting && sock.getReadyState() != 3; + } + @JSBody(params = { "sock", "buffer" }, script = "sock.send(buffer);") + private static native void nativeBinarySend(WebSocket sock, ArrayBuffer buffer); + public static final void writePacket(byte[] packet) { + if(sock != null && !sockIsConnecting) { + Uint8Array arr = Uint8Array.create(packet.length); + arr.set(packet); + nativeBinarySend(sock, arr.getBuffer()); + } + } + public static final byte[] readPacket() { + if(!readPackets.isEmpty()) { + return readPackets.remove(0); + }else { + return null; + } + } + public static final byte[] loadLocalStorage(String key) { + String s = win.getLocalStorage().getItem("_eaglercraft_beta."+key); + if(s != null) { + return Base64.decodeBase64(s); + }else { + return null; + } + } + public static final void saveLocalStorage(String key, byte[] data) { + win.getLocalStorage().setItem("_eaglercraft_beta."+key, Base64.encodeBase64String(data)); + } + public static final void openLink(String url) { + win.open(url, "_blank"); + } + public static final void redirectTo(String url) { + Window.current().getLocation().setFullURL(url); + } + + @JSBody(params = { "ext", "mime" }, script = "window.eagsFileChooser.openFileChooser(ext, mime);") + public static native void openFileChooser(String ext, String mime); + + public static final byte[] getFileChooserResult() { + ArrayBuffer b = getFileChooserResult0(); + if(b == null) return null; + Uint8Array array = Uint8Array.create(b); + byte[] ret = new byte[array.getByteLength()]; + for(int i = 0; i < ret.length; ++i) { + ret[i] = (byte) array.get(i); + } + return ret; + } + + @JSBody(params = { }, script = "var ret = window.eagsFileChooser.getFileChooserResult; window.eagsFileChooser.getFileChooserResult = null; return ret;") + private static native ArrayBuffer getFileChooserResult0(); + + @JSBody(params = { }, script = "var ret = window.eagsFileChooser.getFileChooserResultName; window.eagsFileChooser.getFileChooserResultName = null; return ret;") + public static native String getFileChooserResultName(); + + public static final void setListenerPos(float x, float y, float z, float vx, float vy, float vz, float pitch, float yaw) { + float var2 = MathHelper.cos(-yaw * 0.017453292F); + float var3 = MathHelper.sin(-yaw * 0.017453292F); + float var4 = -MathHelper.cos(pitch * 0.017453292F); + float var5 = MathHelper.sin(pitch * 0.017453292F); + AudioListener l = audioctx.getListener(); + l.setPosition(x, y, z); + l.setOrientation(-var3 * var4, -var5, -var2 * var4, 0.0f, 1.0f, 0.0f); + } + + private static int playbackId = 0; + private static final HashMap loadedSoundFiles = new HashMap(); + private static AudioContext audioctx = null; + private static float playbackOffsetDelay = 0.03f; + + public static final void setPlaybackOffsetDelay(float f) { + playbackOffsetDelay = f; + } + + @Async + public static native AudioBuffer decodeAudioAsync(ArrayBuffer buffer); + + private static void decodeAudioAsync(ArrayBuffer buffer, final AsyncCallback cb) { + audioctx.decodeAudioData(buffer, new DecodeSuccessCallback() { + @Override + public void onSuccess(AudioBuffer decodedData) { + cb.complete(decodedData); + } + }, new DecodeErrorCallback() { + @Override + public void onError(JSObject error) { + cb.complete(null); + } + }); + } + + private static final HashMap activeSoundEffects = new HashMap(); + + private static class AudioBufferX { + private final AudioBuffer buffer; + private AudioBufferX(AudioBuffer buffer) { + this.buffer = buffer; + } + } + + private static class AudioBufferSourceNodeX { + private final AudioBufferSourceNode source; + private final PannerNode panner; + private final GainNode gain; + private AudioBufferSourceNodeX(AudioBufferSourceNode source, PannerNode panner, GainNode gain) { + this.source = source; + this.panner = panner; + this.gain = gain; + } + } + + private static final AudioBuffer getBufferFor(String fileName) { + AudioBufferX ret = loadedSoundFiles.get(fileName); + if(ret == null) { + byte[] file = loadResourceBytes(fileName); + if(file == null) return null; + Uint8Array buf = Uint8Array.create(file.length); + buf.set(file); + ret = new AudioBufferX(decodeAudioAsync(buf.getBuffer())); + loadedSoundFiles.put(fileName, ret); + } + return ret.buffer; + } + public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) { + AudioBuffer b = getBufferFor(fileName); + if(b == null) return -1; + AudioBufferSourceNode s = audioctx.createBufferSource(); + s.setBuffer(b); + s.getPlaybackRate().setValue(pitch); + PannerNode p = audioctx.createPanner(); + p.setPosition(x, y, z); + p.setMaxDistance(volume * 16f + 0.1f); + p.setRolloffFactor(1f); + //p.setVelocity(0f, 0f, 0f); + p.setDistanceModel("linear"); + p.setPanningModel("HRTF"); + p.setConeInnerAngle(360f); + p.setConeOuterAngle(0f); + p.setConeOuterGain(0f); + p.setOrientation(0f, 1f, 0f); + GainNode g = audioctx.createGain(); + g.getGain().setValue(volume > 1.0f ? 1.0f : volume); + s.connect(g); + g.connect(p); + p.connect(audioctx.getDestination()); + s.start(0.0d, playbackOffsetDelay); + final int theId = ++playbackId; + activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g)); + s.setOnEnded(new EventListener() { + + @Override + public void handleEvent(MediaEvent evt) { + activeSoundEffects.remove(theId); + } + + }); + return theId; + } + public static final int beginPlaybackStatic(String fileName, float volume, float pitch) { + AudioBuffer b = getBufferFor(fileName); + if(b == null) return -1; + AudioBufferSourceNode s = audioctx.createBufferSource(); + s.setBuffer(b); + s.getPlaybackRate().setValue(pitch); + GainNode g = audioctx.createGain(); + g.getGain().setValue(volume > 1.0f ? 1.0f : volume); + s.connect(g); + g.connect(audioctx.getDestination()); + s.start(0.0d, playbackOffsetDelay); + final int theId = ++playbackId; + activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g)); + s.setOnEnded(new EventListener() { + @Override + public void handleEvent(MediaEvent evt) { + activeSoundEffects.remove(theId); + } + + }); + return playbackId; + } + public static final void setPitch(int id, float pitch) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null) { + b.source.getPlaybackRate().setValue(pitch); + } + } + public static final void setVolume(int id, float volume) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null) { + b.gain.getGain().setValue(volume > 1.0f ? 1.0f : volume); + if(b.panner != null) b.panner.setMaxDistance(volume * 16f + 0.1f); + } + } + public static final void moveSound(int id, float x, float y, float z, float vx, float vy, float vz) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null && b.panner != null) { + b.panner.setPosition(x, y, z); + //b.panner.setVelocity(vx, vy, vz); + } + } + public static final void endSound(int id) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null) { + b.source.stop(); + activeSoundEffects.remove(id); + } + } + public static final boolean isPlaying(int id) { + return activeSoundEffects.containsKey(id); + } + public static final void openConsole() { + + } + private static boolean connected = false; + public static final void voiceConnect(String channel) { + win.alert("voice channels are not implemented yet"); + connected = true; + } + public static final void voiceVolume(float volume) { + + } + public static final boolean voiceActive() { + return connected; + } + public static final boolean voiceRelayed() { + return connected; + } + public static final String[] voiceUsers() { + return new String[0]; + } + public static final String[] voiceUsersTalking() { + return new String[0]; + } + public static final void voiceEnd() { + connected = false; + } + public static final void doJavascriptCoroutines() { + + } + public static final long maxMemory() { + return 1024*1024*1024; + } + public static final long totalMemory() { + return 1024*1024*1024; + } + public static final long freeMemory() { + return 0l; + } + public static final void exit() { + + } + + @JSBody(params = { }, script = "return window.navigator.userAgent;") + public static native String getUserAgent(); + + private static String[] LWJGLKeyNames = new String[] {"NONE", "ESCAPE", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "MINUS", "EQUALS", "BACK", "TAB", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LBRACKET", "RBRACKET", "RETURN", "LCONTROL", "A", "S", "D", "F", "G", "H", "J", "K", "L", "SEMICOLON", "APOSTROPHE", "GRAVE", "LSHIFT", "BACKSLASH", "Z", "X", "C", "V", "B", "N", "M", "COMMA", "PERIOD", "SLASH", "RSHIFT", "MULTIPLY", "LMENU", "SPACE", "CAPITAL", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NUMLOCK", "SCROLL", "NUMPAD7", "NUMPAD8", "NUMPAD9", "SUBTRACT", "NUMPAD4", "NUMPAD5", "NUMPAD6", "ADD", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0", "DECIMAL", "null", "null", "null", "F11", "F12", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "F13", "F14", "F15", "F16", "F17", "F18", "null", "null", "null", "null", "null", "null", "KANA", "F19", "null", "null", "null", "null", "null", "null", "null", "CONVERT", "null", "NOCONVERT", "null", "YEN", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADEQUALS", "null", "null", "CIRCUMFLEX", "AT", "COLON", "UNDERLINE", "KANJI", "STOP", "AX", "UNLABELED", "null", "null", "null", "null", "NUMPADENTER", "RCONTROL", "null", "null", "null", "null", "null", "null", "null", "null", "null", "SECTION", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADCOMMA", "null", "DIVIDE", "null", "SYSRQ", "RMENU", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "FUNCTION", "PAUSE", "null", "HOME", "UP", "PRIOR", "null", "LEFT", "null", "RIGHT", "null", "END", "DOWN", "NEXT", "INSERT", "DELETE", "null", "null", "null", "null", "null", "null", "CLEAR", "LMETA", "RMETA", "APPS", "POWER", "SLEEP", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null"}; + + private static int[] LWJGLKeyCodes = new int[] { + /* 0 */ -1, + /* 1 */ -1, + /* 2 */ -1, + /* 3 */ -1, + /* 4 */ -1, + /* 5 */ -1, + /* 6 */ -1, + /* 7 */ -1, + /* 8 */ 14, + /* 9 */ 15, + /* 10 */ -1, + /* 11 */ -1, + /* 12 */ -1, + /* 13 */ 28, + /* 14 */ -1, + /* 15 */ -1, + /* 16 */ 42, + /* 17 */ 29, + /* 18 */ 56, + /* 19 */ -1, + /* 20 */ -1, + /* 21 */ -1, + /* 22 */ -1, + /* 23 */ -1, + /* 24 */ -1, + /* 25 */ -1, + /* 26 */ -1, + /* 27 */ 1, + /* 28 */ -1, + /* 29 */ -1, + /* 30 */ -1, + /* 31 */ -1, + /* 32 */ 57, + /* 33 */ 210, + /* 34 */ 201, + /* 35 */ 207, + /* 36 */ 199, + /* 37 */ 203, + /* 38 */ 200, + /* 39 */ 205, + /* 40 */ 208, + /* 41 */ 205, + /* 42 */ 208, + /* 43 */ -1, + /* 44 */ -1, + /* 45 */ 210, + /* 46 */ 211, + /* 47 */ 211, + /* 48 */ 11, + /* 49 */ 2, + /* 50 */ 3, + /* 51 */ 4, + /* 52 */ 5, + /* 53 */ 6, + /* 54 */ 7, + /* 55 */ 8, + /* 56 */ 9, + /* 57 */ 10, + /* 58 */ -1, + /* 59 */ -1, + /* 60 */ -1, + /* 61 */ -1, + /* 62 */ -1, + /* 63 */ -1, + /* 64 */ -1, + /* 65 */ 30, + /* 66 */ 48, + /* 67 */ 46, + /* 68 */ 32, + /* 69 */ 18, + /* 70 */ 33, + /* 71 */ 34, + /* 72 */ 35, + /* 73 */ 23, + /* 74 */ 36, + /* 75 */ 37, + /* 76 */ 38, + /* 77 */ 50, + /* 78 */ 49, + /* 79 */ 24, + /* 80 */ 25, + /* 81 */ 16, + /* 82 */ 19, + /* 83 */ 31, + /* 84 */ 20, + /* 85 */ 22, + /* 86 */ 47, + /* 87 */ 17, + /* 88 */ 45, + /* 89 */ 21, + /* 90 */ 44, + /* 91 */ -1, + /* 92 */ -1, + /* 93 */ -1, + /* 94 */ -1, + /* 95 */ -1, + /* 96 */ -1, + /* 97 */ -1, + /* 98 */ -1, + /* 99 */ -1, + /* 100 */ -1, + /* 101 */ -1, + /* 102 */ -1, + /* 103 */ -1, + /* 104 */ -1, + /* 105 */ -1, + /* 106 */ -1, + /* 107 */ -1, + /* 108 */ -1, + /* 109 */ 12, + /* 110 */ 52, + /* 111 */ 53, + /* 112 */ -1, + /* 113 */ -1, + /* 114 */ -1, + /* 115 */ -1, + /* 116 */ -1, + /* 117 */ -1, + /* 118 */ -1, + /* 119 */ -1, + /* 120 */ -1, + /* 121 */ -1, + /* 122 */ -1, + /* 123 */ -1, + /* 124 */ -1, + /* 125 */ -1, + /* 126 */ -1, + /* 127 */ -1, + /* 128 */ -1, + /* 129 */ -1, + /* 130 */ -1, + /* 131 */ -1, + /* 132 */ -1, + /* 133 */ -1, + /* 134 */ -1, + /* 135 */ -1, + /* 136 */ -1, + /* 137 */ -1, + /* 138 */ -1, + /* 139 */ -1, + /* 140 */ -1, + /* 141 */ -1, + /* 142 */ -1, + /* 143 */ -1, + /* 144 */ -1, + /* 145 */ -1, + /* 146 */ -1, + /* 147 */ -1, + /* 148 */ -1, + /* 149 */ -1, + /* 150 */ -1, + /* 151 */ -1, + /* 152 */ -1, + /* 153 */ -1, + /* 154 */ -1, + /* 155 */ -1, + /* 156 */ -1, + /* 157 */ -1, + /* 158 */ -1, + /* 159 */ -1, + /* 160 */ -1, + /* 161 */ -1, + /* 162 */ -1, + /* 163 */ -1, + /* 164 */ -1, + /* 165 */ -1, + /* 166 */ -1, + /* 167 */ -1, + /* 168 */ -1, + /* 169 */ -1, + /* 170 */ -1, + /* 171 */ -1, + /* 172 */ -1, + /* 173 */ -1, + /* 174 */ -1, + /* 175 */ -1, + /* 176 */ -1, + /* 177 */ -1, + /* 178 */ -1, + /* 179 */ -1, + /* 180 */ -1, + /* 181 */ -1, + /* 182 */ -1, + /* 183 */ -1, + /* 184 */ -1, + /* 185 */ -1, + /* 186 */ 39, + /* 187 */ 13, + /* 188 */ 51, + /* 189 */ 12, + /* 190 */ 52, + /* 191 */ 53, + /* 192 */ -1, + /* 193 */ -1, + /* 194 */ -1, + /* 195 */ -1, + /* 196 */ -1, + /* 197 */ -1, + /* 198 */ -1, + /* 199 */ -1, + /* 200 */ -1, + /* 200 */ -1, + /* 201 */ -1, + /* 202 */ -1, + /* 203 */ -1, + /* 204 */ -1, + /* 205 */ -1, + /* 206 */ -1, + /* 207 */ -1, + /* 208 */ -1, + /* 209 */ -1, + /* 210 */ -1, + /* 211 */ -1, + /* 212 */ -1, + /* 213 */ -1, + /* 214 */ -1, + /* 215 */ -1, + /* 216 */ -1, + /* 217 */ -1, + /* 218 */ -1, + /* 219 */ 26, + /* 220 */ 43, + /* 221 */ 27, + /* 222 */ 40 + }; + + public static final int _wArrayByteLength(Object obj) { + return ((Int32Array)obj).getByteLength(); + } + + public static final Object _wCreateLowLevelIntBuffer(int len) { + return Int32Array.create(len); + } + + private static int appendbufferindex = 0; + private static Int32Array appendbuffer = Int32Array.create(ArrayBuffer.create(525000*4)); + + public static final void _wAppendLowLevelBuffer(Object arr) { + Int32Array a = ((Int32Array)arr); + if(appendbufferindex + a.getLength() < appendbuffer.getLength()) { + appendbuffer.set(a, appendbufferindex); + appendbufferindex += a.getLength(); + } + } + + public static final Object _wGetLowLevelBuffersAppended() { + Int32Array ret = Int32Array.create(appendbuffer.getBuffer(), 0, appendbufferindex); + appendbufferindex = 0; + return ret; + } + + private static int remapKey(int k) { + return (k > LWJGLKeyCodes.length || k < 0) ? -1 : LWJGLKeyCodes[k]; + } + + @JSFunctor + private static interface StupidFunctionResolveString extends JSObject { + void resolveStr(String s); + } + + private static boolean unpressCTRL = false; + + @Async + public static native String getClipboard(); + + private static void getClipboard(final AsyncCallback cb) { + final long start = System.currentTimeMillis(); + getClipboard0(new StupidFunctionResolveString() { + @Override + public void resolveStr(String s) { + if(System.currentTimeMillis() - start > 500l) { + unpressCTRL = true; + } + cb.complete(s); + } + }); + } + + @JSBody(params = { "cb" }, script = "if(!window.navigator.clipboard) cb(null); else window.navigator.clipboard.readText().then(function(s) { cb(s); }, function(s) { cb(null); });") + private static native void getClipboard0(StupidFunctionResolveString cb); + + @JSBody(params = { "str" }, script = "if(window.navigator.clipboard) window.navigator.clipboard.writeText(str);") + public static native void setClipboard(String str); + + @JSBody(params = { "obj" }, script = "return typeof obj === \"string\";") + private static native boolean isString(JSObject obj); + + public static final boolean fileExists(String path) { + return IndexedDBFilesystem.fileExists(path); + } + + public static final boolean directoryExists(String path) { + return IndexedDBFilesystem.directoryExists(path); + } + + public static final boolean pathExists(String path) { + return IndexedDBFilesystem.pathExists(path); + } + + public static final void writeFile(String path, byte[] data) { + IndexedDBFilesystem.writeFile(path, data); + } + + public static final byte[] readFile(String path) { + return IndexedDBFilesystem.readFile(path); + } + + public static final long getLastModified(String path) { + return IndexedDBFilesystem.getLastModified(path); + } + + public static final int getFileSize(String path) { + return IndexedDBFilesystem.getFileSize(path); + } + + public static final void renameFile(String oldPath, String newPath) { + IndexedDBFilesystem.renameFile(oldPath, newPath); + } + + public static final void copyFile(String oldPath, String newPath) { + IndexedDBFilesystem.copyFile(oldPath, newPath); + } + + public static final void deleteFile(String path) { + IndexedDBFilesystem.deleteFile(path); + } + + public static final Collection listFiles(String path, boolean listDirs, boolean recursiveDirs) { + return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs); + } + + public static final Collection listFilesAndDirectories(String path) { + return listFiles(path, true, false); + } + + public static final Collection listFilesRecursive(String path) { + return listFiles(path, false, true); + } + + public static class FileEntry { + + public final String path; + public final boolean isDirectory; + public final long lastModified; + + public FileEntry(String path, boolean isDirectory, long lastModified) { + this.path = path; + this.isDirectory = isDirectory; + this.lastModified = lastModified; + } + + public String getName() { + int i = path.indexOf('/'); + if(i >= 0) { + return path.substring(i + 1); + }else { + return path; + } + } + + } + + private static String stripPath(String str) { + if(str.startsWith("/")) { + str = str.substring(1); + } + if(str.endsWith("/")) { + str = str.substring(0, str.length() - 1); + } + return str; + } + + @JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=URL.createObjectURL(new Blob([cvs],{type:\"application/octet-stream\"}));a.download=name;a.click();URL.revokeObjectURL(a.href);") + private static native void downloadFile0(String name, ArrayBuffer cvs); + + public static final void downloadFile(String filename, byte[] data) { + Uint8Array b = Uint8Array.create(data.length); + b.set(data); + downloadFile0(filename, b.getBuffer()); + } + +} \ No newline at end of file diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java new file mode 100644 index 0000000..6328954 --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java @@ -0,0 +1,349 @@ +package net.lax1dude.eaglercraft.adapter; + +import org.lwjgl.opengl.GL11; +import org.teavm.jso.typedarrays.ArrayBuffer; +import org.teavm.jso.typedarrays.Float32Array; +import org.teavm.jso.typedarrays.Int32Array; + +public class Tessellator { + + /** The byte buffer used for GL allocation. */ + private Int32Array intBuffer; + private Float32Array floatBuffer; + + /** + * The number of vertices to be drawn in the next draw call. Reset to 0 between + * draw calls. + */ + private int vertexCount = 0; + + /** The first coordinate to be used for the texture. */ + private float textureU; + + /** The second coordinate to be used for the texture. */ + private float textureV; + + /** The color (RGBA) value to be used for the following draw call. */ + private int color; + + /** + * Whether the current draw object for this tessellator has color values. + */ + private boolean hasColor = false; + + /** + * Whether the current draw object for this tessellator has texture coordinates. + */ + private boolean hasTexture = false; + + /** + * Whether the current draw object for this tessellator has normal values. + */ + private boolean hasNormals = false; + + /** The index into the raw buffer to be used for the next data. */ + private int rawBufferIndex = 0; + + /** + * The number of vertices manually added to the given draw call. This differs + * from vertexCount because it adds extra vertices when converting quads to + * triangles. + */ + private int addedVertices = 0; + + /** Disables all color information for the following draw call. */ + private boolean isColorDisabled = false; + + /** The draw mode currently being used by the tessellator. */ + private int drawMode; + + /** + * An offset to be applied along the x-axis for all vertices in this draw call. + */ + private double xOffset; + + /** + * An offset to be applied along the y-axis for all vertices in this draw call. + */ + private double yOffset; + + /** + * An offset to be applied along the z-axis for all vertices in this draw call. + */ + private double zOffset; + + /** The normal to be applied to the face being drawn. */ + private int normal; + + /** The static instance of the Tessellator. */ + public static final Tessellator instance = new Tessellator(525000); + + /** Whether this tessellator is currently in draw mode. */ + private boolean isDrawing = false; + + /** Whether we are currently using VBO or not. */ + private boolean useVBO = false; + + /** The size of the buffers used (in integers). */ + private int bufferSize; + + private Tessellator(int par1) { + this.bufferSize = par1; + ArrayBuffer a = ArrayBuffer.create(par1 * 4); + this.intBuffer = Int32Array.create(a); + this.floatBuffer = Float32Array.create(a); + } + + /** + * Draws the data set up in this tessellator and resets the state to prepare for + * new drawing. + */ + public int draw() { + if (!this.isDrawing) { + return 0; + } else { + this.isDrawing = false; + + if (this.vertexCount > 0) { + + if (this.hasTexture) { + GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); + } + + if (this.hasColor) { + GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY); + } + + if (this.hasNormals) { + GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY); + } + + GL11.glDrawArrays(this.drawMode, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7)); + + if (this.hasTexture) { + GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); + } + + if (this.hasColor) { + GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY); + } + + if (this.hasNormals) { + GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY); + } + } + + int var1 = this.rawBufferIndex * 4; + this.reset(); + return var1; + } + } + + /** + * Clears the tessellator state in preparation for new drawing. + */ + private void reset() { + this.vertexCount = 0; + //this.byteBuffer.clear(); + this.rawBufferIndex = 0; + this.addedVertices = 0; + } + + /** + * Sets draw mode in the tessellator to draw quads. + */ + public void startDrawingQuads() { + this.startDrawing(GL11.GL_QUADS); + } + + /** + * Resets tessellator state and prepares for drawing (with the specified draw + * mode). + */ + public void startDrawing(int par1) { + if (this.isDrawing) { + this.draw(); + } + this.isDrawing = true; + this.reset(); + this.drawMode = par1; + this.hasNormals = false; + this.hasColor = false; + this.hasTexture = false; + this.isColorDisabled = false; + } + + /** + * Sets the texture coordinates. + */ + public void setTextureUV(double par1, double par3) { + this.hasTexture = true; + this.textureU = (float) par1; + this.textureV = (float) par3; + } + + /** + * Sets the RGB values as specified, converting from floats between 0 and 1 to + * integers from 0-255. + */ + public void setColorOpaque_F(float par1, float par2, float par3) { + this.setColorOpaque((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F)); + } + + /** + * Sets the RGBA values for the color, converting from floats between 0 and 1 to + * integers from 0-255. + */ + public void setColorRGBA_F(float par1, float par2, float par3, float par4) { + this.setColorRGBA((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F), (int) (par4 * 255.0F)); + } + + /** + * Sets the RGB values as specified, and sets alpha to opaque. + */ + public void setColorOpaque(int par1, int par2, int par3) { + this.setColorRGBA(par1, par2, par3, 255); + } + + /** + * Sets the RGBA values for the color. Also clamps them to 0-255. + */ + public void setColorRGBA(int par1, int par2, int par3, int par4) { + if (!this.isColorDisabled) { + if (par1 > 255) { + par1 = 255; + } + + if (par2 > 255) { + par2 = 255; + } + + if (par3 > 255) { + par3 = 255; + } + + if (par4 > 255) { + par4 = 255; + } + + if (par1 < 0) { + par1 = 0; + } + + if (par2 < 0) { + par2 = 0; + } + + if (par3 < 0) { + par3 = 0; + } + + if (par4 < 0) { + par4 = 0; + } + + this.hasColor = true; + this.color = par4 << 24 | par3 << 16 | par2 << 8 | par1; + } + } + + /** + * Adds a vertex specifying both x,y,z and the texture u,v for it. + */ + public void addVertexWithUV(double par1, double par3, double par5, double par7, double par9) { + this.setTextureUV(par7, par9); + this.addVertex(par1, par3, par5); + } + + /** + * Adds a vertex with the specified x,y,z to the current draw call. It will + * trigger a draw() if the buffer gets full. + */ + public void addVertex(double par1, double par3, double par5) { + if(this.addedVertices > 65534) return; + ++this.addedVertices; + ++this.vertexCount; + + int bufferIndex = this.rawBufferIndex; + Int32Array intBuffer0 = intBuffer; + Float32Array floatBuffer0 = floatBuffer; + + floatBuffer0.set(bufferIndex + 0, (float) (par1 + this.xOffset)); + floatBuffer0.set(bufferIndex + 1, (float) (par3 + this.yOffset)); + floatBuffer0.set(bufferIndex + 2, (float) (par5 + this.zOffset)); + + if (this.hasTexture) { + floatBuffer0.set(bufferIndex + 3, this.textureU); + floatBuffer0.set(bufferIndex + 4, this.textureV); + } + + if (this.hasColor) { + intBuffer0.set(bufferIndex + 5, this.color); + } + + if (this.hasNormals) { + intBuffer0.set(bufferIndex + 6, this.normal); + } + + this.rawBufferIndex += 7; + } + + /** + * Sets the color to the given opaque value (stored as byte values packed in an + * integer). + */ + public void setColorOpaque_I(int par1) { + int var2 = par1 >> 16 & 255; + int var3 = par1 >> 8 & 255; + int var4 = par1 & 255; + this.setColorOpaque(var2, var3, var4); + } + + /** + * Sets the color to the given color (packed as bytes in integer) and alpha + * values. + */ + public void setColorRGBA_I(int par1, int par2) { + int var3 = par1 >> 16 & 255; + int var4 = par1 >> 8 & 255; + int var5 = par1 & 255; + this.setColorRGBA(var3, var4, var5, par2); + } + + /** + * Disables colors for the current draw call. + */ + public void disableColor() { + this.isColorDisabled = true; + } + + /** + * Sets the normal for the current draw call. + */ + public void setNormal(float par1, float par2, float par3) { + this.hasNormals = true; + float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3); + int var4 = (int)((par1 / len) * 127.0F) + 127; + int var5 = (int)((par2 / len) * 127.0F) + 127; + int var6 = (int)((par3 / len) * 127.0F) + 127; + this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16; + } + + /** + * Sets the translation for all vertices in the current draw call. + */ + public void setTranslationD(double par1, double par3, double par5) { + this.xOffset = par1; + this.yOffset = par3; + this.zOffset = par5; + } + + /** + * Offsets the translation for all vertices in the current draw call. + */ + public void setTranslationF(float par1, float par2, float par3) { + this.xOffset += (float) par1; + this.yOffset += (float) par2; + this.zOffset += (float) par3; + } +} diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java new file mode 100644 index 0000000..6125bc7 --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java @@ -0,0 +1,34 @@ +package net.lax1dude.eaglercraft.adapter.teavm; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; + +public class BufferConverter { + + public static final byte[] convertByteBuffer(ByteBuffer b) { + byte[] ret = new byte[b.limit() - b.position()]; + b.get(ret); + return ret; + } + + public static final short[] convertShortBuffer(ShortBuffer b) { + short[] ret = new short[b.limit() - b.position()]; + b.get(ret); + return ret; + } + + public static final int[] convertIntBuffer(IntBuffer b) { + int[] ret = new int[b.limit() - b.position()]; + b.get(ret); + return ret; + } + + public static final float[] convertFloatBuffer(FloatBuffer b) { + float[] ret = new float[b.limit() - b.position()]; + b.get(ret); + return ret; + } + +} diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IDBObjectStorePatched.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IDBObjectStorePatched.java new file mode 100644 index 0000000..963ee3a --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IDBObjectStorePatched.java @@ -0,0 +1,79 @@ +package net.lax1dude.eaglercraft.adapter.teavm; + +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; +import org.teavm.jso.core.JSString; +import org.teavm.jso.indexeddb.IDBCountRequest; +import org.teavm.jso.indexeddb.IDBCursorRequest; +import org.teavm.jso.indexeddb.IDBCursorSource; +import org.teavm.jso.indexeddb.IDBDatabase; +import org.teavm.jso.indexeddb.IDBGetRequest; +import org.teavm.jso.indexeddb.IDBIndex; +import org.teavm.jso.indexeddb.IDBKeyRange; +import org.teavm.jso.indexeddb.IDBObjectStoreParameters; +import org.teavm.jso.indexeddb.IDBRequest; +import org.teavm.jso.indexeddb.IDBTransaction; + +public abstract class IDBObjectStorePatched implements JSObject, IDBCursorSource { + + @JSBody(params = { "db", "name", "optionalParameters" }, script = "return db.createObjectStore(name, optionalParameters);") + public static native IDBObjectStorePatched createObjectStorePatch(IDBDatabase db, String name, IDBObjectStoreParameters optionalParameters); + + @JSBody(params = { "tx", "name" }, script = "return tx.objectStore(name);") + public static native IDBObjectStorePatched objectStorePatch(IDBTransaction tx, String name); + + @JSProperty + public abstract String getName(); + + @JSProperty("keyPath") + abstract JSObject getKeyPathImpl(); + + public final String[] getKeyPath() { + JSObject result = getKeyPathImpl(); + if (JSString.isInstance(result)) { + return new String[] { result.cast().stringValue() }; + } else { + return unwrapStringArray(result); + } + } + + @JSBody(params = { "obj" }, script = "return this;") + private static native String[] unwrapStringArray(JSObject obj); + + @JSProperty + public abstract String[] getIndexNames(); + + @JSProperty + public abstract boolean isAutoIncrement(); + + public abstract IDBRequest put(JSObject value, JSObject key); + + public abstract IDBRequest put(JSObject value); + + public abstract IDBRequest add(JSObject value, JSObject key); + + public abstract IDBRequest add(JSObject value); + + public abstract IDBRequest delete(JSObject key); + + public abstract IDBGetRequest get(JSObject key); + + public abstract IDBRequest clear(); + + public abstract IDBCursorRequest openCursor(); + + public abstract IDBCursorRequest openCursor(IDBKeyRange range); + + public abstract IDBIndex createIndex(String name, String key); + + public abstract IDBIndex createIndex(String name, String[] keys); + + public abstract IDBIndex index(String name); + + public abstract void deleteIndex(String name); + + public abstract IDBCountRequest count(); + + public abstract IDBCountRequest count(JSObject key); +} diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IndexedDBFilesystem.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IndexedDBFilesystem.java new file mode 100644 index 0000000..e404daf --- /dev/null +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/IndexedDBFilesystem.java @@ -0,0 +1,427 @@ +package net.lax1dude.eaglercraft.adapter.teavm; + +import java.util.Collection; +import java.util.LinkedList; + +import org.teavm.interop.Async; +import org.teavm.interop.AsyncCallback; +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; +import org.teavm.jso.dom.events.EventListener; +import org.teavm.jso.indexeddb.EventHandler; +import org.teavm.jso.indexeddb.IDBCountRequest; +import org.teavm.jso.indexeddb.IDBCursor; +import org.teavm.jso.indexeddb.IDBCursorRequest; +import org.teavm.jso.indexeddb.IDBDatabase; +import org.teavm.jso.indexeddb.IDBFactory; +import org.teavm.jso.indexeddb.IDBGetRequest; +import org.teavm.jso.indexeddb.IDBObjectStoreParameters; +import org.teavm.jso.indexeddb.IDBOpenDBRequest; +import org.teavm.jso.indexeddb.IDBRequest; +import org.teavm.jso.indexeddb.IDBTransaction; +import org.teavm.jso.indexeddb.IDBVersionChangeEvent; +import org.teavm.jso.typedarrays.ArrayBuffer; +import org.teavm.jso.typedarrays.Uint8Array; + +import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; +import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry; + +public class IndexedDBFilesystem { + + public static enum OpenState { + OPENED, LOCKED, ERROR + } + + private static String err = ""; + private static IDBDatabase db = null; + + public static final OpenState initialize() { + DatabaseOpen dbo = AsyncHandlers.openDB("_net_lax1dude_eaglercraft_beta_IndexedDBFilesystem_1_3"); + if(dbo == null) { + err = "Unknown Error"; + return OpenState.ERROR; + } + if(dbo.failedLocked) { + return OpenState.LOCKED; + } + if(dbo.failedInit || dbo.database == null) { + err = dbo.failedError == null ? "Initialization Failed" : dbo.failedError; + return OpenState.ERROR; + } + db = dbo.database; + return OpenState.OPENED; + } + + public static final String errorDetail() { + return err; + } + + public static final boolean fileExists(String path) { + return AsyncHandlers.fileGetType(db, path) == FileExists.FILE; + } + + public static final boolean directoryExists(String path) { + return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY; + } + + public static final boolean pathExists(String path) { + return AsyncHandlers.fileExists(db, path).bool; + } + + private static final void mkdir(String dir) { + if(directoryExists(dir)) { + return; + } + int i = dir.lastIndexOf('/'); + if(i > 0) { + mkdir(dir.substring(0, i)); + } + AsyncHandlers.writeWholeFile(db, dir, true, ArrayBuffer.create(0)); + } + + public static final void writeFile(String path, byte[] data) { + int i = path.lastIndexOf('/'); + if(i > 0) { + mkdir(path.substring(0, i)); + } + Uint8Array arr = Uint8Array.create(data.length); + arr.set(data); + AsyncHandlers.writeWholeFile(db, path, false, arr.getBuffer()); + } + + public static final byte[] readFile(String path) { + ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path); + if(arr == null) { + return null; + } + byte[] data = new byte[arr.getByteLength()]; + Uint8Array arrr = Uint8Array.create(arr); + for(int i = 0; i < data.length; ++i) { + data[i] = (byte) arrr.get(i); + } + return data; + } + + public static final long getLastModified(String path) { + int lm = AsyncHandlers.fileGetLastModified(db, path); + return lm == -1 ? -1l : AsyncHandlers.eaglercraftEpoch + lm; + } + + public static final int getFileSize(String path) { + ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path); + if(arr == null) { + return -1; + }else { + return arr.getByteLength(); + } + } + + public static final void renameFile(String oldPath, String newPath) { + copyFile(oldPath, newPath); + AsyncHandlers.deleteFile(db, oldPath); + } + + public static final void copyFile(String oldPath, String newPath) { + ArrayBuffer arr = AsyncHandlers.readWholeFile(db, oldPath); + int i = newPath.lastIndexOf('/'); + if(i > 0) { + mkdir(newPath.substring(0, i)); + } + AsyncHandlers.writeWholeFile(db, newPath, false, arr); + } + + public static final void deleteFile(String path) { + AsyncHandlers.deleteFile(db, path); + } + + public static final Collection listFiles(String path, boolean listDirs, boolean recursiveDirs) { + LinkedList lst = new LinkedList<>(); + AsyncHandlers.iterateFiles(db, path, listDirs, recursiveDirs, lst); + return lst; + } + + protected static class BooleanResult { + + protected static final BooleanResult TRUE = new BooleanResult(true); + protected static final BooleanResult FALSE = new BooleanResult(false); + + protected final boolean bool; + + private BooleanResult(boolean b) { + bool = b; + } + + protected static BooleanResult _new(boolean b) { + return b ? TRUE : FALSE; + } + + } + + protected static class DatabaseOpen { + + protected final boolean failedInit; + protected final boolean failedLocked; + protected final String failedError; + + protected final IDBDatabase database; + + protected DatabaseOpen(boolean init, boolean locked, String error, IDBDatabase db) { + failedInit = init; + failedLocked = locked; + failedError = error; + database = db; + } + + } + + protected static enum FileExists { + FILE, DIRECTORY, FALSE + } + + @JSBody(script = "return ((typeof indexedDB) !== 'undefined') ? indexedDB : null;") + protected static native IDBFactory createIDBFactory(); + + protected static class AsyncHandlers { + + protected static final long eaglercraftEpoch = 1645568542000l; + + @Async + protected static native DatabaseOpen openDB(String name); + + private static void openDB(String name, final AsyncCallback cb) { + IDBFactory i = createIDBFactory(); + if(i == null) { + cb.complete(new DatabaseOpen(false, false, "window.indexedDB was null or undefined", null)); + return; + } + final IDBOpenDBRequest f = i.open(name, 1); + f.setOnBlocked(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(new DatabaseOpen(false, true, null, null)); + } + }); + f.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(new DatabaseOpen(false, false, null, f.getResult())); + } + }); + f.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(new DatabaseOpen(true, false, "open error", null)); + } + }); + f.setOnUpgradeNeeded(new EventListener() { + @Override + public void handleEvent(IDBVersionChangeEvent evt) { + IDBObjectStorePatched.createObjectStorePatch(f.getResult(), "filesystem", IDBObjectStoreParameters.create().keyPath("path")); + } + }); + } + + @Async + protected static native BooleanResult deleteFile(IDBDatabase db, String name); + + private static void deleteFile(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readwrite"); + final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").delete(makeTheFuckingKeyWork(name)); + + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(BooleanResult._new(true)); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(BooleanResult._new(false)); + } + }); + } + + @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? null : ((typeof obj.data === 'undefined') ? null : obj.data);") + protected static native ArrayBuffer readRow(JSObject obj); + + @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? false : ((typeof obj.directory === 'undefined') ? false : obj.directory);") + protected static native boolean isRowDirectory(JSObject obj); + + @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? -1 : ((typeof obj.lastModified === 'undefined') ? -1 : obj.lastModified);") + protected static native int readLastModified(JSObject obj); + + @JSBody(params = { "obj" }, script = "return [obj];") + private static native JSObject makeTheFuckingKeyWork(String k); + + @Async + protected static native ArrayBuffer readWholeFile(IDBDatabase db, String name); + + private static void readWholeFile(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(isRowDirectory(r.getResult()) ? null : readRow(r.getResult())); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(null); + } + }); + + } + + @Async + protected static native Integer readLastModified(IDBDatabase db, String name); + + private static void readLastModified(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(readLastModified(r.getResult())); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(-1); + } + }); + + } + + @JSBody(params = { "k" }, script = "return ((typeof k) === \"string\") ? k : (((typeof k) === \"undefined\") ? null : (((typeof k[0]) === \"string\") ? k[0] : null));") + private static native String readKey(JSObject k); + + @Async + protected static native Integer iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection lst); + + private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection lst, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor(); + final int[] res = new int[1]; + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + IDBCursor c = r.getResult(); + if(c == null || c.getKey() == null || c.getValue() == null) { + cb.complete(res[0]); + return; + } + String k = readKey(c.getKey()); + if(k != null) { + if(k.startsWith(prefix)) { + if(recursiveDirs || k.indexOf('/', prefix.length() + 1) == -1) { + boolean dir = isRowDirectory(c.getValue()); + if(dir) { + if(listDirs) { + lst.add(new EaglerAdapterImpl2.FileEntry(k, true, -1)); + } + }else { + lst.add(new EaglerAdapterImpl2.FileEntry(k, false, eaglercraftEpoch + readLastModified(c.getValue()))); + } + } + } + } + c.doContinue(); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(res[0] > 0 ? res[0] : -1); + } + }); + } + + @Async + protected static native BooleanResult fileExists(IDBDatabase db, String name); + + private static void fileExists(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBCountRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").count(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(BooleanResult._new(r.getResult() > 0)); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(BooleanResult._new(false)); + } + }); + } + + @Async + protected static native Integer fileGetLastModified(IDBDatabase db, String name); + + private static void fileGetLastModified(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(readLastModified(r.getResult())); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(-1); + } + }); + } + + @Async + protected static native FileExists fileGetType(IDBDatabase db, String name); + + private static void fileGetType(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(r.getResult() == null ? FileExists.FALSE : (isRowDirectory(r.getResult()) ? FileExists.DIRECTORY : FileExists.FILE)); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(FileExists.FALSE); + } + }); + } + + @JSBody(params = { "pat", "dir", "lm", "dat" }, script = "return { path: pat, directory: dir, lastModified: lm, data: dat };") + protected static native JSObject writeRow(String name, boolean directory, int lm, ArrayBuffer data); + + @Async + protected static native BooleanResult writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data); + + private static void writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readwrite"); + final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").put(writeRow(name, directory, (int)(System.currentTimeMillis() - eaglercraftEpoch), data)); + r.setOnSuccess(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(BooleanResult._new(true)); + } + }); + r.setOnError(new EventHandler() { + @Override + public void handleEvent() { + cb.complete(BooleanResult._new(false)); + } + }); + } + } + +} diff --git a/src/main/java/net/PeytonPlayz585/teavm/WebGL2RenderingContext.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGL2RenderingContext.java similarity index 96% rename from src/main/java/net/PeytonPlayz585/teavm/WebGL2RenderingContext.java rename to src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGL2RenderingContext.java index 26c0ace..91c0487 100644 --- a/src/main/java/net/PeytonPlayz585/teavm/WebGL2RenderingContext.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGL2RenderingContext.java @@ -1,4 +1,4 @@ -package net.PeytonPlayz585.teavm; +package net.lax1dude.eaglercraft.adapter.teavm; import org.teavm.jso.webgl.WebGLRenderingContext; @@ -39,4 +39,4 @@ public interface WebGL2RenderingContext extends WebGLRenderingContext { void drawBuffers(int[] p1); -} \ No newline at end of file +} diff --git a/src/main/java/net/PeytonPlayz585/teavm/WebGLQuery.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGLQuery.java similarity index 61% rename from src/main/java/net/PeytonPlayz585/teavm/WebGLQuery.java rename to src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGLQuery.java index 035b43c..40c65c0 100644 --- a/src/main/java/net/PeytonPlayz585/teavm/WebGLQuery.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGLQuery.java @@ -1,6 +1,6 @@ -package net.PeytonPlayz585.teavm; +package net.lax1dude.eaglercraft.adapter.teavm; import org.teavm.jso.JSObject; public interface WebGLQuery extends JSObject { -} \ No newline at end of file +} diff --git a/src/main/java/net/PeytonPlayz585/teavm/WebGLVertexArray.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGLVertexArray.java similarity index 63% rename from src/main/java/net/PeytonPlayz585/teavm/WebGLVertexArray.java rename to src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGLVertexArray.java index 6ddffda..34d1c5f 100644 --- a/src/main/java/net/PeytonPlayz585/teavm/WebGLVertexArray.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/teavm/WebGLVertexArray.java @@ -1,6 +1,6 @@ -package net.PeytonPlayz585.teavm; +package net.lax1dude.eaglercraft.adapter.teavm; import org.teavm.jso.JSObject; public interface WebGLVertexArray extends JSObject { -} \ No newline at end of file +} diff --git a/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java b/src/teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java similarity index 93% rename from src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java rename to src/teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java index f93af32..e331172 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java +++ b/src/teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java @@ -1,18 +1,19 @@ -package net.PeytonPlayz585.minecraft; +package org.lwjgl.opengl; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.HashMap; import net.PeytonPlayz585.glemu.FixedFunctionShader; import net.PeytonPlayz585.glemu.GLObjectMap; -import net.PeytonPlayz585.glemu.vector.*; -import net.PeytonPlayz585.lwjgl.LWJGL; -import net.PeytonPlayz585.lwjgl.RealOpenGLEnums; -public class GlStateManager extends LWJGL { - +import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; +import net.PeytonPlayz585.glemu.vector.*; + +public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { + public static final int GL_ZERO = RealOpenGLEnums.GL_ZERO; public static final int GL_ONE = RealOpenGLEnums.GL_ONE; public static final int GL_TEXTURE_2D = RealOpenGLEnums.GL_TEXTURE_2D; @@ -62,19 +63,6 @@ public class GlStateManager extends LWJGL { public static final int GL_TEXTURE = RealOpenGLEnums.GL_TEXTURE; public static final int GL_FRONT = RealOpenGLEnums.GL_FRONT; public static final int GL_COMPILE = RealOpenGLEnums.GL_COMPILE; - public static final int GL_S = RealOpenGLEnums.GL_S; - public static final int GL_T = RealOpenGLEnums.GL_T; - public static final int GL_R = RealOpenGLEnums.GL_R; - public static final int GL_Q = RealOpenGLEnums.GL_Q; - public static final int GL_TEXTURE_GEN_S = RealOpenGLEnums.GL_TEXTURE_GEN_S; - public static final int GL_TEXTURE_GEN_T = RealOpenGLEnums.GL_TEXTURE_GEN_T; - public static final int GL_TEXTURE_GEN_R = RealOpenGLEnums.GL_TEXTURE_GEN_R; - public static final int GL_TEXTURE_GEN_Q = RealOpenGLEnums.GL_TEXTURE_GEN_Q; - public static final int GL_TEXTURE_GEN_MODE = RealOpenGLEnums.GL_TEXTURE_GEN_MODE; - public static final int GL_OBJECT_PLANE = RealOpenGLEnums.GL_OBJECT_PLANE; - public static final int GL_EYE_PLANE = RealOpenGLEnums.GL_EYE_PLANE; - public static final int GL_OBJECT_LINEAR = RealOpenGLEnums.GL_OBJECT_LINEAR; - public static final int GL_EYE_LINEAR = RealOpenGLEnums.GL_EYE_LINEAR; public static final int GL_NEAREST = RealOpenGLEnums.GL_NEAREST; public static final int GL_CLAMP = RealOpenGLEnums.GL_CLAMP_TO_EDGE; public static final int GL_TEXTURE_WRAP_S = RealOpenGLEnums.GL_TEXTURE_WRAP_S; @@ -83,10 +71,6 @@ public class GlStateManager extends LWJGL { public static final int GL_BGRA = RealOpenGLEnums.GL_BGRA; public static final int GL_UNSIGNED_INT_8_8_8_8_REV = RealOpenGLEnums.GL_UNSIGNED_INT_8_8_8_8_REV; public static final int GL_DST_COLOR = RealOpenGLEnums.GL_DST_COLOR; - public static final int GL_CONSTANT_COLOR = RealOpenGLEnums.GL_CONSTANT_COLOR; - public static final int GL_ONE_MINUS_CONSTANT_COLOR = RealOpenGLEnums.GL_ONE_MINUS_CONSTANT_COLOR; - public static final int GL_CONSTANT_ALPHA = RealOpenGLEnums.GL_CONSTANT_ALPHA; - public static final int GL_ONE_MINUS_CONSTANT_ALPHA = RealOpenGLEnums.GL_ONE_MINUS_CONSTANT_ALPHA; public static final int GL_POLYGON_OFFSET_FILL = RealOpenGLEnums.GL_POLYGON_OFFSET_FILL; public static final int GL_NORMALIZE = RealOpenGLEnums.GL_NORMALIZE; public static final int GL_DST_ALPHA = RealOpenGLEnums.GL_DST_ALPHA; @@ -108,26 +92,23 @@ public class GlStateManager extends LWJGL { public static final int GL_PACK_ALIGNMENT = RealOpenGLEnums.GL_PACK_ALIGNMENT; public static final int GL_UNPACK_ALIGNMENT = RealOpenGLEnums.GL_UNPACK_ALIGNMENT; public static final int GL_QUADS = RealOpenGLEnums.GL_QUADS; - public static final int GL_TEXTURE0 = RealOpenGLEnums.GL_TEXTURE0; - public static final int GL_TEXTURE1 = RealOpenGLEnums.GL_TEXTURE1; - public static final int GL_TEXTURE2 = RealOpenGLEnums.GL_TEXTURE2; - public static final int GL_TEXTURE3 = RealOpenGLEnums.GL_TEXTURE3; public static final int GL_INVALID_ENUM = RealOpenGLEnums.GL_INVALID_ENUM; public static final int GL_INVALID_VALUE = RealOpenGLEnums.GL_INVALID_VALUE; public static final int GL_INVALID_OPERATION = RealOpenGLEnums.GL_INVALID_OPERATION; public static final int GL_OUT_OF_MEMORY = RealOpenGLEnums.GL_OUT_OF_MEMORY; - public static final int GL_CONTEXT_LOST_WEBGL = -100; + public static final int GL_CONTEXT_LOST_WEBGL = -144; public static final int GL_TRIANGLE_FAN = RealOpenGLEnums.GL_TRIANGLE_FAN; public static final int GL_LINE_STRIP = RealOpenGLEnums.GL_LINE_STRIP; - public static final int EAG_SWAP_RB = -101; public static final int GL_LINES = RealOpenGLEnums.GL_LINES; public static final int GL_NEAREST_MIPMAP_LINEAR = RealOpenGLEnums.GL_NEAREST_MIPMAP_LINEAR; - public static final int GL_TEXTURE_MAX_ANISOTROPY = -103; + public static final int GL_TEXTURE_MAX_ANISOTROPY = -150; public static final int GL_TEXTURE_MAX_LEVEL = RealOpenGLEnums.GL_TEXTURE_MAX_LEVEL; public static final int GL_LINEAR_MIPMAP_LINEAR = RealOpenGLEnums.GL_LINEAR_MIPMAP_LINEAR; public static final int GL_LINEAR_MIPMAP_NEAREST = RealOpenGLEnums.GL_LINEAR_MIPMAP_NEAREST; public static final int GL_NEAREST_MIPMAP_NEAREST = RealOpenGLEnums.GL_NEAREST_MIPMAP_NEAREST; - + + public static final boolean isWebGL = _wisWebGL(); + private static final GLObjectMap texObjects = new GLObjectMap(256); private static boolean enableTexture2D = false; @@ -325,43 +306,43 @@ public class GlStateManager extends LWJGL { _wglClear(p1); } - public static final void glOrtho(double l, double r, double b, double t, double n, double f) { + public static final void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar) { Matrix4f res = getMatrix(); - res.m00 = (float) (2.0f / (r - l)); + res.m00 = (float) (2.0f / (right - left)); res.m01 = 0.0f; res.m02 = 0.0f; res.m03 = 0.0f; res.m10 = 0.0f; - res.m11 = (float) (2.0f / (t - b)); + res.m11 = (float) (2.0f / (top - bottom)); res.m12 = 0.0f; res.m13 = 0.0f; res.m20 = 0.0f; res.m21 = 0.0f; - res.m22 = (float) (2.0f / (f - n)); + res.m22 = (float) (2.0f / (zFar - zNear)); res.m23 = 0.0f; - res.m30 = (float) (-(r + l) / (r - l)); - res.m31 = (float) (-(t + b) / (t - b)); - res.m32 = (float) ((f + n) / (f - n)); + res.m30 = (float) (-(right + left) / (right - left)); + res.m31 = (float) (-(top + bottom) / (top - bottom)); + res.m32 = (float) ((zFar + zNear) / (zFar - zNear)); res.m33 = 1.0f; } - public static final void glOrtho(float l, float r, float b, float t, float n, float f) { + public static final void glOrtho(float left, float right, float bottom, float top, float zNear, float zFar) { Matrix4f res = getMatrix(); - res.m00 = 2.0f / (r - l); + res.m00 = 2.0f / (right - left); res.m01 = 0.0f; res.m02 = 0.0f; res.m03 = 0.0f; res.m10 = 0.0f; - res.m11 = 2.0f / (t - b); + res.m11 = 2.0f / (top - bottom); res.m12 = 0.0f; res.m13 = 0.0f; res.m20 = 0.0f; res.m21 = 0.0f; - res.m22 = 2.0f / (f - n); + res.m22 = 2.0f / (zFar - zNear); res.m23 = 0.0f; - res.m30 = -(r + l) / (r - l); - res.m31 = -(t + b) / (t - b); - res.m32 = (f + n) / (f - n); + res.m30 = -(right + left) / (right - left); + res.m31 = -(top + bottom) / (top - bottom); + res.m32 = (zFar + zNear) / (zFar - zNear); res.m33 = 1.0f; } @@ -429,7 +410,7 @@ public class GlStateManager extends LWJGL { } public static final void glFlush() { - _wglFlush(); + //...??? } public static final void glLineWidth(float p1) { @@ -913,7 +894,8 @@ public class GlStateManager extends LWJGL { private static final void _wglDrawQuadArrays(int p2, int p3) { if (quadsToTrianglesBuffer == null) { - IntBuffer upload = IntBuffer.wrap(new int[98400 / 2]); + IntBuffer upload = isWebGL ? IntBuffer.wrap(new int[98400 / 2]) + : ByteBuffer.allocateDirect(98400 * 2).order(ByteOrder.nativeOrder()).asIntBuffer(); for (int i = 0; i < 16384; ++i) { int v1 = i * 4; int v2 = i * 4 + 1; @@ -945,7 +927,8 @@ public class GlStateManager extends LWJGL { occlusion_vao = _wglCreateVertexArray(); occlusion_vbo = _wglCreateBuffer(); - IntBuffer upload = IntBuffer.wrap(new int[108]); + IntBuffer upload = (isWebGL ? IntBuffer.wrap(new int[108]) + : ByteBuffer.allocateDirect(108 << 2).order(ByteOrder.nativeOrder()).asIntBuffer()); float[] verts = new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, @@ -1131,7 +1114,7 @@ public class GlStateManager extends LWJGL { } } - public static final void glMultiTexCoord2f(float p2, float p3) { + public static final void glMultiTexCoord2f(int p1, float p2, float p3) { tex0X = p2; tex0Y = p3; } diff --git a/src/teavm/java/org/lwjgl/opengl/GL11.java b/src/teavm/java/org/lwjgl/opengl/GL11.java new file mode 100644 index 0000000..9f032f4 --- /dev/null +++ b/src/teavm/java/org/lwjgl/opengl/GL11.java @@ -0,0 +1,5 @@ +package org.lwjgl.opengl; + +public class GL11 extends EaglerAdapterGL30 { + +} diff --git a/src/main/java/net/PeytonPlayz585/lwjgl/RealOpenGLEnums.java b/src/teavm/java/org/lwjgl/opengl/RealOpenGLEnums.java similarity index 99% rename from src/main/java/net/PeytonPlayz585/lwjgl/RealOpenGLEnums.java rename to src/teavm/java/org/lwjgl/opengl/RealOpenGLEnums.java index d90b6b4..75a633b 100644 --- a/src/main/java/net/PeytonPlayz585/lwjgl/RealOpenGLEnums.java +++ b/src/teavm/java/org/lwjgl/opengl/RealOpenGLEnums.java @@ -1,4 +1,4 @@ -package net.PeytonPlayz585.lwjgl; +package org.lwjgl.opengl; public class RealOpenGLEnums {