diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..696cc96 --- /dev/null +++ b/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00a51af --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1b6985c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/.project b/.project new file mode 100644 index 0000000..44b7cf0 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + Alpha v1.2.6 + Project Alpha v1.2.6 created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e479558 --- /dev/null +++ b/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) +connection.project.dir= +eclipse.preferences.version=1 +gradle.user.home= +java.home= +jvm.arguments= +offline.mode=false +override.workspace.settings=false +show.console.view=false +show.executions.view=false diff --git a/bin/main/net/PeytonPlayz585/MinecraftMain$AbortedLaunchException.class b/bin/main/net/PeytonPlayz585/MinecraftMain$AbortedLaunchException.class new file mode 100644 index 0000000..32484a1 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/MinecraftMain$AbortedLaunchException.class differ diff --git a/bin/main/net/PeytonPlayz585/MinecraftMain.class b/bin/main/net/PeytonPlayz585/MinecraftMain.class new file mode 100644 index 0000000..4b84ac9 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/MinecraftMain.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/FixedFunctionShader.class b/bin/main/net/PeytonPlayz585/glemu/FixedFunctionShader.class new file mode 100644 index 0000000..ecb6807 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/FixedFunctionShader.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Matrix.class b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix.class new file mode 100644 index 0000000..154c13f Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Matrix2f.class b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix2f.class new file mode 100644 index 0000000..573d7c5 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix2f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Matrix3f.class b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix3f.class new file mode 100644 index 0000000..140cd4f Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix3f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Matrix4f.class b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix4f.class new file mode 100644 index 0000000..74724f7 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Matrix4f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Quaternion.class b/bin/main/net/PeytonPlayz585/glemu/vector/Quaternion.class new file mode 100644 index 0000000..a3cfe6e Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Quaternion.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector.class b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector.class new file mode 100644 index 0000000..c364911 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector2f.class b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector2f.class new file mode 100644 index 0000000..ad0cffd Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector2f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector3f.class b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector3f.class new file mode 100644 index 0000000..aba01b9 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector3f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector4f.class b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector4f.class new file mode 100644 index 0000000..148b035 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/ReadableVector4f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Vector.class b/bin/main/net/PeytonPlayz585/glemu/vector/Vector.class new file mode 100644 index 0000000..e2129c7 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Vector.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Vector2f.class b/bin/main/net/PeytonPlayz585/glemu/vector/Vector2f.class new file mode 100644 index 0000000..2389b9d Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Vector2f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Vector3f.class b/bin/main/net/PeytonPlayz585/glemu/vector/Vector3f.class new file mode 100644 index 0000000..83804e0 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Vector3f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/Vector4f.class b/bin/main/net/PeytonPlayz585/glemu/vector/Vector4f.class new file mode 100644 index 0000000..9290840 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/Vector4f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector2f.class b/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector2f.class new file mode 100644 index 0000000..49d201e Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector2f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector3f.class b/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector3f.class new file mode 100644 index 0000000..100ce27 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector3f.class differ diff --git a/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector4f.class b/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector4f.class new file mode 100644 index 0000000..30fbb49 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/glemu/vector/WritableVector4f.class differ diff --git a/bin/main/net/PeytonPlayz585/math/MathHelper.class b/bin/main/net/PeytonPlayz585/math/MathHelper.class new file mode 100644 index 0000000..fc74d0a Binary files /dev/null and b/bin/main/net/PeytonPlayz585/math/MathHelper.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/AWTColor.class b/bin/main/net/PeytonPlayz585/minecraft/AWTColor.class new file mode 100644 index 0000000..3048b1d Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/AWTColor.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/AssetRepository.class b/bin/main/net/PeytonPlayz585/minecraft/AssetRepository.class new file mode 100644 index 0000000..52bebc2 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/AssetRepository.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/Base64.class b/bin/main/net/PeytonPlayz585/minecraft/Base64.class new file mode 100644 index 0000000..452aaaf Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/Base64.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec$CodecPolicy.class b/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec$CodecPolicy.class new file mode 100644 index 0000000..1374f35 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec$CodecPolicy.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec$Context.class b/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec$Context.class new file mode 100644 index 0000000..62f96f5 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec$Context.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec.class b/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec.class new file mode 100644 index 0000000..73b1f73 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/BaseNCodec.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/GeneralDigest.class b/bin/main/net/PeytonPlayz585/minecraft/GeneralDigest.class new file mode 100644 index 0000000..0917c11 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/GeneralDigest.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/MinecraftImage.class b/bin/main/net/PeytonPlayz585/minecraft/MinecraftImage.class new file mode 100644 index 0000000..2f8da73 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/MinecraftImage.class differ diff --git a/bin/main/net/PeytonPlayz585/minecraft/SHA1Digest.class b/bin/main/net/PeytonPlayz585/minecraft/SHA1Digest.class new file mode 100644 index 0000000..e4768c6 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/minecraft/SHA1Digest.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTBase.class b/bin/main/net/PeytonPlayz585/nbt/NBTBase.class new file mode 100644 index 0000000..4e62848 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTBase.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagByte.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagByte.class new file mode 100644 index 0000000..14d8de4 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagByte.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagByteArray.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagByteArray.class new file mode 100644 index 0000000..72a27dd Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagByteArray.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagCompound.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagCompound.class new file mode 100644 index 0000000..537371b Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagCompound.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagDouble.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagDouble.class new file mode 100644 index 0000000..b68be8f Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagDouble.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagEnd.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagEnd.class new file mode 100644 index 0000000..f086055 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagEnd.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagFloat.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagFloat.class new file mode 100644 index 0000000..510f321 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagFloat.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagInt.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagInt.class new file mode 100644 index 0000000..ebd6919 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagInt.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagList.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagList.class new file mode 100644 index 0000000..c60dc14 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagList.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagLong.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagLong.class new file mode 100644 index 0000000..eca66ea Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagLong.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagShort.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagShort.class new file mode 100644 index 0000000..281416f Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagShort.class differ diff --git a/bin/main/net/PeytonPlayz585/nbt/NBTTagString.class b/bin/main/net/PeytonPlayz585/nbt/NBTTagString.class new file mode 100644 index 0000000..74f3c63 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/nbt/NBTTagString.class differ diff --git a/bin/main/net/PeytonPlayz585/storage/LocalStorageManager.class b/bin/main/net/PeytonPlayz585/storage/LocalStorageManager.class new file mode 100644 index 0000000..991b62b Binary files /dev/null and b/bin/main/net/PeytonPlayz585/storage/LocalStorageManager.class differ diff --git a/bin/main/net/PeytonPlayz585/teavm/WebGL2RenderingContext.class b/bin/main/net/PeytonPlayz585/teavm/WebGL2RenderingContext.class new file mode 100644 index 0000000..b59c8de Binary files /dev/null and b/bin/main/net/PeytonPlayz585/teavm/WebGL2RenderingContext.class differ diff --git a/bin/main/net/PeytonPlayz585/teavm/WebGLQuery.class b/bin/main/net/PeytonPlayz585/teavm/WebGLQuery.class new file mode 100644 index 0000000..d4da3ca Binary files /dev/null and b/bin/main/net/PeytonPlayz585/teavm/WebGLQuery.class differ diff --git a/bin/main/net/PeytonPlayz585/teavm/WebGLVertexArray.class b/bin/main/net/PeytonPlayz585/teavm/WebGLVertexArray.class new file mode 100644 index 0000000..7633776 Binary files /dev/null and b/bin/main/net/PeytonPlayz585/teavm/WebGLVertexArray.class differ diff --git a/bin/main/net/minecraft/client/CanvasMinecraftApplet.class b/bin/main/net/minecraft/client/CanvasMinecraftApplet.class new file mode 100644 index 0000000..bc3ae93 Binary files /dev/null and b/bin/main/net/minecraft/client/CanvasMinecraftApplet.class differ diff --git a/bin/main/net/minecraft/client/ChatLine.class b/bin/main/net/minecraft/client/ChatLine.class new file mode 100644 index 0000000..5e6e00d Binary files /dev/null and b/bin/main/net/minecraft/client/ChatLine.class differ diff --git a/bin/main/net/minecraft/client/EnumOS.class b/bin/main/net/minecraft/client/EnumOS.class new file mode 100644 index 0000000..893082a Binary files /dev/null and b/bin/main/net/minecraft/client/EnumOS.class differ diff --git a/bin/main/net/minecraft/client/EnumOSMappingHelper.class b/bin/main/net/minecraft/client/EnumOSMappingHelper.class new file mode 100644 index 0000000..764c3ce Binary files /dev/null and b/bin/main/net/minecraft/client/EnumOSMappingHelper.class differ diff --git a/bin/main/net/minecraft/client/GameSettings.class b/bin/main/net/minecraft/client/GameSettings.class new file mode 100644 index 0000000..f781904 Binary files /dev/null and b/bin/main/net/minecraft/client/GameSettings.class differ diff --git a/bin/main/net/minecraft/client/GuiMainMenu.class b/bin/main/net/minecraft/client/GuiMainMenu.class new file mode 100644 index 0000000..53598b8 Binary files /dev/null and b/bin/main/net/minecraft/client/GuiMainMenu.class differ diff --git a/bin/main/net/minecraft/client/KeyBinding.class b/bin/main/net/minecraft/client/KeyBinding.class new file mode 100644 index 0000000..bec07fa Binary files /dev/null and b/bin/main/net/minecraft/client/KeyBinding.class differ diff --git a/bin/main/net/minecraft/client/LoadingScreenRenderer.class b/bin/main/net/minecraft/client/LoadingScreenRenderer.class new file mode 100644 index 0000000..b309ec6 Binary files /dev/null and b/bin/main/net/minecraft/client/LoadingScreenRenderer.class differ diff --git a/bin/main/net/minecraft/client/Minecraft.class b/bin/main/net/minecraft/client/Minecraft.class new file mode 100644 index 0000000..a2d8ec5 Binary files /dev/null and b/bin/main/net/minecraft/client/Minecraft.class differ diff --git a/bin/main/net/minecraft/client/MinecraftApplet.class b/bin/main/net/minecraft/client/MinecraftApplet.class new file mode 100644 index 0000000..0b219a0 Binary files /dev/null and b/bin/main/net/minecraft/client/MinecraftApplet.class differ diff --git a/bin/main/net/minecraft/client/MinecraftError.class b/bin/main/net/minecraft/client/MinecraftError.class new file mode 100644 index 0000000..bd9a646 Binary files /dev/null and b/bin/main/net/minecraft/client/MinecraftError.class differ diff --git a/bin/main/net/minecraft/client/MouseHelper.class b/bin/main/net/minecraft/client/MouseHelper.class new file mode 100644 index 0000000..f213d13 Binary files /dev/null and b/bin/main/net/minecraft/client/MouseHelper.class differ diff --git a/bin/main/net/minecraft/client/OpenGlCapsChecker.class b/bin/main/net/minecraft/client/OpenGlCapsChecker.class new file mode 100644 index 0000000..e57c593 Binary files /dev/null and b/bin/main/net/minecraft/client/OpenGlCapsChecker.class differ diff --git a/bin/main/net/minecraft/client/PlayerLoader.class b/bin/main/net/minecraft/client/PlayerLoader.class new file mode 100644 index 0000000..6e21542 Binary files /dev/null and b/bin/main/net/minecraft/client/PlayerLoader.class differ diff --git a/bin/main/net/minecraft/client/RenderHelper.class b/bin/main/net/minecraft/client/RenderHelper.class new file mode 100644 index 0000000..b4445d7 Binary files /dev/null and b/bin/main/net/minecraft/client/RenderHelper.class differ diff --git a/bin/main/net/minecraft/client/Session.class b/bin/main/net/minecraft/client/Session.class new file mode 100644 index 0000000..9b6304c Binary files /dev/null and b/bin/main/net/minecraft/client/Session.class differ diff --git a/bin/main/net/minecraft/client/ThreadSleepForever.class b/bin/main/net/minecraft/client/ThreadSleepForever.class new file mode 100644 index 0000000..4d2f70a Binary files /dev/null and b/bin/main/net/minecraft/client/ThreadSleepForever.class differ diff --git a/bin/main/net/minecraft/client/Timer.class b/bin/main/net/minecraft/client/Timer.class new file mode 100644 index 0000000..9c6d3fc Binary files /dev/null and b/bin/main/net/minecraft/client/Timer.class differ diff --git a/bin/main/net/minecraft/client/controller/PlayerController.class b/bin/main/net/minecraft/client/controller/PlayerController.class new file mode 100644 index 0000000..e3b8932 Binary files /dev/null and b/bin/main/net/minecraft/client/controller/PlayerController.class differ diff --git a/bin/main/net/minecraft/client/controller/PlayerControllerCreative.class b/bin/main/net/minecraft/client/controller/PlayerControllerCreative.class new file mode 100644 index 0000000..d183073 Binary files /dev/null and b/bin/main/net/minecraft/client/controller/PlayerControllerCreative.class differ diff --git a/bin/main/net/minecraft/client/controller/PlayerControllerSP.class b/bin/main/net/minecraft/client/controller/PlayerControllerSP.class new file mode 100644 index 0000000..a1daaf1 Binary files /dev/null and b/bin/main/net/minecraft/client/controller/PlayerControllerSP.class differ diff --git a/bin/main/net/minecraft/client/effect/EffectRenderer.class b/bin/main/net/minecraft/client/effect/EffectRenderer.class new file mode 100644 index 0000000..c7e7b13 Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EffectRenderer.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityBubbleFX.class b/bin/main/net/minecraft/client/effect/EntityBubbleFX.class new file mode 100644 index 0000000..8a3d0ff Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityBubbleFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityDiggingFX.class b/bin/main/net/minecraft/client/effect/EntityDiggingFX.class new file mode 100644 index 0000000..38e5e45 Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityDiggingFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityExplodeFX.class b/bin/main/net/minecraft/client/effect/EntityExplodeFX.class new file mode 100644 index 0000000..9571cdc Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityExplodeFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityFX.class b/bin/main/net/minecraft/client/effect/EntityFX.class new file mode 100644 index 0000000..7beb1bb Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityFlameFX.class b/bin/main/net/minecraft/client/effect/EntityFlameFX.class new file mode 100644 index 0000000..8316a6b Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityFlameFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityLavaFX.class b/bin/main/net/minecraft/client/effect/EntityLavaFX.class new file mode 100644 index 0000000..d9cdc6d Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityLavaFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityPickupFX.class b/bin/main/net/minecraft/client/effect/EntityPickupFX.class new file mode 100644 index 0000000..b9b8025 Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityPickupFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntityRainFX.class b/bin/main/net/minecraft/client/effect/EntityRainFX.class new file mode 100644 index 0000000..704720a Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntityRainFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntitySmokeFX.class b/bin/main/net/minecraft/client/effect/EntitySmokeFX.class new file mode 100644 index 0000000..288a076 Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntitySmokeFX.class differ diff --git a/bin/main/net/minecraft/client/effect/EntitySplashFX.class b/bin/main/net/minecraft/client/effect/EntitySplashFX.class new file mode 100644 index 0000000..6e3ef08 Binary files /dev/null and b/bin/main/net/minecraft/client/effect/EntitySplashFX.class differ diff --git a/bin/main/net/minecraft/client/gui/FilenameFilterLevel.class b/bin/main/net/minecraft/client/gui/FilenameFilterLevel.class new file mode 100644 index 0000000..8858d00 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/FilenameFilterLevel.class differ diff --git a/bin/main/net/minecraft/client/gui/FontRenderer.class b/bin/main/net/minecraft/client/gui/FontRenderer.class new file mode 100644 index 0000000..a8226e5 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/FontRenderer.class differ diff --git a/bin/main/net/minecraft/client/gui/Gui.class b/bin/main/net/minecraft/client/gui/Gui.class new file mode 100644 index 0000000..093b8b9 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/Gui.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiButton.class b/bin/main/net/minecraft/client/gui/GuiButton.class new file mode 100644 index 0000000..5dc0998 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiButton.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiControls.class b/bin/main/net/minecraft/client/gui/GuiControls.class new file mode 100644 index 0000000..07b3227 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiControls.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiErrorScreen.class b/bin/main/net/minecraft/client/gui/GuiErrorScreen.class new file mode 100644 index 0000000..ae90d39 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiErrorScreen.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiGameOver.class b/bin/main/net/minecraft/client/gui/GuiGameOver.class new file mode 100644 index 0000000..b05c2f8 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiGameOver.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiIngame.class b/bin/main/net/minecraft/client/gui/GuiIngame.class new file mode 100644 index 0000000..1091bb4 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiIngame.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiIngameMenu.class b/bin/main/net/minecraft/client/gui/GuiIngameMenu.class new file mode 100644 index 0000000..1cec5ec Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiIngameMenu.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiLevelDialog.class b/bin/main/net/minecraft/client/gui/GuiLevelDialog.class new file mode 100644 index 0000000..792e3a5 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiLevelDialog.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiLoadLevel.class b/bin/main/net/minecraft/client/gui/GuiLoadLevel.class new file mode 100644 index 0000000..5ed72e8 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiLoadLevel.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiNameLevel.class b/bin/main/net/minecraft/client/gui/GuiNameLevel.class new file mode 100644 index 0000000..60e99d4 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiNameLevel.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiNewLevel.class b/bin/main/net/minecraft/client/gui/GuiNewLevel.class new file mode 100644 index 0000000..f8d8bc7 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiNewLevel.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiOptions.class b/bin/main/net/minecraft/client/gui/GuiOptions.class new file mode 100644 index 0000000..0d680f7 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiOptions.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiSaveLevel.class b/bin/main/net/minecraft/client/gui/GuiSaveLevel.class new file mode 100644 index 0000000..478963f Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiSaveLevel.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiScreen.class b/bin/main/net/minecraft/client/gui/GuiScreen.class new file mode 100644 index 0000000..0804051 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiScreen.class differ diff --git a/bin/main/net/minecraft/client/gui/GuiSmallButton.class b/bin/main/net/minecraft/client/gui/GuiSmallButton.class new file mode 100644 index 0000000..0752724 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/GuiSmallButton.class differ diff --git a/bin/main/net/minecraft/client/gui/ScaledResolution.class b/bin/main/net/minecraft/client/gui/ScaledResolution.class new file mode 100644 index 0000000..63cb86b Binary files /dev/null and b/bin/main/net/minecraft/client/gui/ScaledResolution.class differ diff --git a/bin/main/net/minecraft/client/gui/container/GuiChest.class b/bin/main/net/minecraft/client/gui/container/GuiChest.class new file mode 100644 index 0000000..073cd24 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/GuiChest.class differ diff --git a/bin/main/net/minecraft/client/gui/container/GuiContainer.class b/bin/main/net/minecraft/client/gui/container/GuiContainer.class new file mode 100644 index 0000000..a8499ee Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/GuiContainer.class differ diff --git a/bin/main/net/minecraft/client/gui/container/GuiCrafting.class b/bin/main/net/minecraft/client/gui/container/GuiCrafting.class new file mode 100644 index 0000000..54aeff2 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/GuiCrafting.class differ diff --git a/bin/main/net/minecraft/client/gui/container/GuiFurnace.class b/bin/main/net/minecraft/client/gui/container/GuiFurnace.class new file mode 100644 index 0000000..d874fc0 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/GuiFurnace.class differ diff --git a/bin/main/net/minecraft/client/gui/container/GuiInventory.class b/bin/main/net/minecraft/client/gui/container/GuiInventory.class new file mode 100644 index 0000000..5434fa0 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/GuiInventory.class differ diff --git a/bin/main/net/minecraft/client/gui/container/InventoryCraftResult.class b/bin/main/net/minecraft/client/gui/container/InventoryCraftResult.class new file mode 100644 index 0000000..21a533f Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/InventoryCraftResult.class differ diff --git a/bin/main/net/minecraft/client/gui/container/InventoryCrafting.class b/bin/main/net/minecraft/client/gui/container/InventoryCrafting.class new file mode 100644 index 0000000..b7ca1f2 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/InventoryCrafting.class differ diff --git a/bin/main/net/minecraft/client/gui/container/Slot.class b/bin/main/net/minecraft/client/gui/container/Slot.class new file mode 100644 index 0000000..1c4492b Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/Slot.class differ diff --git a/bin/main/net/minecraft/client/gui/container/SlotArmor.class b/bin/main/net/minecraft/client/gui/container/SlotArmor.class new file mode 100644 index 0000000..fd8d3a7 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/SlotArmor.class differ diff --git a/bin/main/net/minecraft/client/gui/container/SlotCrafting.class b/bin/main/net/minecraft/client/gui/container/SlotCrafting.class new file mode 100644 index 0000000..188fc38 Binary files /dev/null and b/bin/main/net/minecraft/client/gui/container/SlotCrafting.class differ diff --git a/bin/main/net/minecraft/client/model/ModelBase.class b/bin/main/net/minecraft/client/model/ModelBase.class new file mode 100644 index 0000000..774c937 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelBase.class differ diff --git a/bin/main/net/minecraft/client/model/ModelBiped.class b/bin/main/net/minecraft/client/model/ModelBiped.class new file mode 100644 index 0000000..b39e83e Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelBiped.class differ diff --git a/bin/main/net/minecraft/client/model/ModelCreeper.class b/bin/main/net/minecraft/client/model/ModelCreeper.class new file mode 100644 index 0000000..2a1f509 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelCreeper.class differ diff --git a/bin/main/net/minecraft/client/model/ModelPig.class b/bin/main/net/minecraft/client/model/ModelPig.class new file mode 100644 index 0000000..2c08d93 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelPig.class differ diff --git a/bin/main/net/minecraft/client/model/ModelQuadruped.class b/bin/main/net/minecraft/client/model/ModelQuadruped.class new file mode 100644 index 0000000..53d56e4 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelQuadruped.class differ diff --git a/bin/main/net/minecraft/client/model/ModelRenderer.class b/bin/main/net/minecraft/client/model/ModelRenderer.class new file mode 100644 index 0000000..aa0aeba Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelRenderer.class differ diff --git a/bin/main/net/minecraft/client/model/ModelSheep.class b/bin/main/net/minecraft/client/model/ModelSheep.class new file mode 100644 index 0000000..e047b54 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelSheep.class differ diff --git a/bin/main/net/minecraft/client/model/ModelSheepFur.class b/bin/main/net/minecraft/client/model/ModelSheepFur.class new file mode 100644 index 0000000..3d7c427 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelSheepFur.class differ diff --git a/bin/main/net/minecraft/client/model/ModelSkeleton.class b/bin/main/net/minecraft/client/model/ModelSkeleton.class new file mode 100644 index 0000000..36f8bca Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelSkeleton.class differ diff --git a/bin/main/net/minecraft/client/model/ModelSpider.class b/bin/main/net/minecraft/client/model/ModelSpider.class new file mode 100644 index 0000000..e619ac4 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelSpider.class differ diff --git a/bin/main/net/minecraft/client/model/ModelZombie.class b/bin/main/net/minecraft/client/model/ModelZombie.class new file mode 100644 index 0000000..6ecfc02 Binary files /dev/null and b/bin/main/net/minecraft/client/model/ModelZombie.class differ diff --git a/bin/main/net/minecraft/client/model/PositionTextureVertex.class b/bin/main/net/minecraft/client/model/PositionTextureVertex.class new file mode 100644 index 0000000..5312bb8 Binary files /dev/null and b/bin/main/net/minecraft/client/model/PositionTextureVertex.class differ diff --git a/bin/main/net/minecraft/client/model/TexturedQuad.class b/bin/main/net/minecraft/client/model/TexturedQuad.class new file mode 100644 index 0000000..c9401f7 Binary files /dev/null and b/bin/main/net/minecraft/client/model/TexturedQuad.class differ diff --git a/bin/main/net/minecraft/client/player/EntityPlayerSP.class b/bin/main/net/minecraft/client/player/EntityPlayerSP.class new file mode 100644 index 0000000..c4ea422 Binary files /dev/null and b/bin/main/net/minecraft/client/player/EntityPlayerSP.class differ diff --git a/bin/main/net/minecraft/client/player/MovementInput.class b/bin/main/net/minecraft/client/player/MovementInput.class new file mode 100644 index 0000000..5c8a5eb Binary files /dev/null and b/bin/main/net/minecraft/client/player/MovementInput.class differ diff --git a/bin/main/net/minecraft/client/player/MovementInputFromOptions.class b/bin/main/net/minecraft/client/player/MovementInputFromOptions.class new file mode 100644 index 0000000..2fc9ac1 Binary files /dev/null and b/bin/main/net/minecraft/client/player/MovementInputFromOptions.class differ diff --git a/bin/main/net/minecraft/client/render/EntityRenderer.class b/bin/main/net/minecraft/client/render/EntityRenderer.class new file mode 100644 index 0000000..6c0bc4b Binary files /dev/null and b/bin/main/net/minecraft/client/render/EntityRenderer.class differ diff --git a/bin/main/net/minecraft/client/render/EntitySorter.class b/bin/main/net/minecraft/client/render/EntitySorter.class new file mode 100644 index 0000000..c26e92a Binary files /dev/null and b/bin/main/net/minecraft/client/render/EntitySorter.class differ diff --git a/bin/main/net/minecraft/client/render/ImageBufferDownload.class b/bin/main/net/minecraft/client/render/ImageBufferDownload.class new file mode 100644 index 0000000..c86051a Binary files /dev/null and b/bin/main/net/minecraft/client/render/ImageBufferDownload.class differ diff --git a/bin/main/net/minecraft/client/render/ItemRenderer.class b/bin/main/net/minecraft/client/render/ItemRenderer.class new file mode 100644 index 0000000..2de8916 Binary files /dev/null and b/bin/main/net/minecraft/client/render/ItemRenderer.class differ diff --git a/bin/main/net/minecraft/client/render/RenderBlocks.class b/bin/main/net/minecraft/client/render/RenderBlocks.class new file mode 100644 index 0000000..4816ccf Binary files /dev/null and b/bin/main/net/minecraft/client/render/RenderBlocks.class differ diff --git a/bin/main/net/minecraft/client/render/RenderEngine.class b/bin/main/net/minecraft/client/render/RenderEngine.class new file mode 100644 index 0000000..e2e5ffe Binary files /dev/null and b/bin/main/net/minecraft/client/render/RenderEngine.class differ diff --git a/bin/main/net/minecraft/client/render/RenderGlobal.class b/bin/main/net/minecraft/client/render/RenderGlobal.class new file mode 100644 index 0000000..2101a93 Binary files /dev/null and b/bin/main/net/minecraft/client/render/RenderGlobal.class differ diff --git a/bin/main/net/minecraft/client/render/RenderSorter.class b/bin/main/net/minecraft/client/render/RenderSorter.class new file mode 100644 index 0000000..53c903a Binary files /dev/null and b/bin/main/net/minecraft/client/render/RenderSorter.class differ diff --git a/bin/main/net/minecraft/client/render/Tessellator.class b/bin/main/net/minecraft/client/render/Tessellator.class new file mode 100644 index 0000000..871f6ac Binary files /dev/null and b/bin/main/net/minecraft/client/render/Tessellator.class differ diff --git a/bin/main/net/minecraft/client/render/ThreadDownloadImage.class b/bin/main/net/minecraft/client/render/ThreadDownloadImage.class new file mode 100644 index 0000000..fd504c7 Binary files /dev/null and b/bin/main/net/minecraft/client/render/ThreadDownloadImage.class differ diff --git a/bin/main/net/minecraft/client/render/ThreadDownloadImageData.class b/bin/main/net/minecraft/client/render/ThreadDownloadImageData.class new file mode 100644 index 0000000..4c4d65d Binary files /dev/null and b/bin/main/net/minecraft/client/render/ThreadDownloadImageData.class differ diff --git a/bin/main/net/minecraft/client/render/WorldRenderer.class b/bin/main/net/minecraft/client/render/WorldRenderer.class new file mode 100644 index 0000000..c174adc Binary files /dev/null and b/bin/main/net/minecraft/client/render/WorldRenderer.class differ diff --git a/bin/main/net/minecraft/client/render/camera/ClippingHelper.class b/bin/main/net/minecraft/client/render/camera/ClippingHelper.class new file mode 100644 index 0000000..90b93d3 Binary files /dev/null and b/bin/main/net/minecraft/client/render/camera/ClippingHelper.class differ diff --git a/bin/main/net/minecraft/client/render/camera/ClippingHelperImplementation.class b/bin/main/net/minecraft/client/render/camera/ClippingHelperImplementation.class new file mode 100644 index 0000000..001695c Binary files /dev/null and b/bin/main/net/minecraft/client/render/camera/ClippingHelperImplementation.class differ diff --git a/bin/main/net/minecraft/client/render/camera/Frustrum.class b/bin/main/net/minecraft/client/render/camera/Frustrum.class new file mode 100644 index 0000000..dca14a5 Binary files /dev/null and b/bin/main/net/minecraft/client/render/camera/Frustrum.class differ diff --git a/bin/main/net/minecraft/client/render/camera/ICamera.class b/bin/main/net/minecraft/client/render/camera/ICamera.class new file mode 100644 index 0000000..f282176 Binary files /dev/null and b/bin/main/net/minecraft/client/render/camera/ICamera.class differ diff --git a/bin/main/net/minecraft/client/render/camera/IsomCamera.class b/bin/main/net/minecraft/client/render/camera/IsomCamera.class new file mode 100644 index 0000000..20c9e66 Binary files /dev/null and b/bin/main/net/minecraft/client/render/camera/IsomCamera.class differ diff --git a/bin/main/net/minecraft/client/render/entity/Render.class b/bin/main/net/minecraft/client/render/entity/Render.class new file mode 100644 index 0000000..5cafccc Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/Render.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderArrow.class b/bin/main/net/minecraft/client/render/entity/RenderArrow.class new file mode 100644 index 0000000..13dfaf2 Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderArrow.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderCreeper.class b/bin/main/net/minecraft/client/render/entity/RenderCreeper.class new file mode 100644 index 0000000..fde1997 Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderCreeper.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderEntity.class b/bin/main/net/minecraft/client/render/entity/RenderEntity.class new file mode 100644 index 0000000..3dac6fe Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderEntity.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderGiantZombie.class b/bin/main/net/minecraft/client/render/entity/RenderGiantZombie.class new file mode 100644 index 0000000..236870c Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderGiantZombie.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderItem.class b/bin/main/net/minecraft/client/render/entity/RenderItem.class new file mode 100644 index 0000000..ac66284 Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderItem.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderLiving.class b/bin/main/net/minecraft/client/render/entity/RenderLiving.class new file mode 100644 index 0000000..37ab4af Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderLiving.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderManager.class b/bin/main/net/minecraft/client/render/entity/RenderManager.class new file mode 100644 index 0000000..4732596 Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderManager.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderPainting.class b/bin/main/net/minecraft/client/render/entity/RenderPainting.class new file mode 100644 index 0000000..455d247 Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderPainting.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderPlayer.class b/bin/main/net/minecraft/client/render/entity/RenderPlayer.class new file mode 100644 index 0000000..0e5a8a0 Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderPlayer.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderSheep.class b/bin/main/net/minecraft/client/render/entity/RenderSheep.class new file mode 100644 index 0000000..5875ffc Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderSheep.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderSpider.class b/bin/main/net/minecraft/client/render/entity/RenderSpider.class new file mode 100644 index 0000000..c4aef8a Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderSpider.class differ diff --git a/bin/main/net/minecraft/client/render/entity/RenderTNTPrimed.class b/bin/main/net/minecraft/client/render/entity/RenderTNTPrimed.class new file mode 100644 index 0000000..4810973 Binary files /dev/null and b/bin/main/net/minecraft/client/render/entity/RenderTNTPrimed.class differ diff --git a/bin/main/net/minecraft/client/render/texture/TextureFX.class b/bin/main/net/minecraft/client/render/texture/TextureFX.class new file mode 100644 index 0000000..d9400db Binary files /dev/null and b/bin/main/net/minecraft/client/render/texture/TextureFX.class differ diff --git a/bin/main/net/minecraft/client/render/texture/TextureFlamesFX.class b/bin/main/net/minecraft/client/render/texture/TextureFlamesFX.class new file mode 100644 index 0000000..21c845e Binary files /dev/null and b/bin/main/net/minecraft/client/render/texture/TextureFlamesFX.class differ diff --git a/bin/main/net/minecraft/client/render/texture/TextureGearsFX.class b/bin/main/net/minecraft/client/render/texture/TextureGearsFX.class new file mode 100644 index 0000000..b5a5cae Binary files /dev/null and b/bin/main/net/minecraft/client/render/texture/TextureGearsFX.class differ diff --git a/bin/main/net/minecraft/client/render/texture/TextureLavaFX.class b/bin/main/net/minecraft/client/render/texture/TextureLavaFX.class new file mode 100644 index 0000000..2042c94 Binary files /dev/null and b/bin/main/net/minecraft/client/render/texture/TextureLavaFX.class differ diff --git a/bin/main/net/minecraft/client/render/texture/TextureWaterFX.class b/bin/main/net/minecraft/client/render/texture/TextureWaterFX.class new file mode 100644 index 0000000..575888f Binary files /dev/null and b/bin/main/net/minecraft/client/render/texture/TextureWaterFX.class differ diff --git a/bin/main/net/minecraft/client/render/texture/TextureWaterFlowFX.class b/bin/main/net/minecraft/client/render/texture/TextureWaterFlowFX.class new file mode 100644 index 0000000..ae307c3 Binary files /dev/null and b/bin/main/net/minecraft/client/render/texture/TextureWaterFlowFX.class differ diff --git a/bin/main/net/minecraft/game/IInventory.class b/bin/main/net/minecraft/game/IInventory.class new file mode 100644 index 0000000..fc833f2 Binary files /dev/null and b/bin/main/net/minecraft/game/IInventory.class differ diff --git a/bin/main/net/minecraft/game/InventoryLargeChest.class b/bin/main/net/minecraft/game/InventoryLargeChest.class new file mode 100644 index 0000000..96b6861 Binary files /dev/null and b/bin/main/net/minecraft/game/InventoryLargeChest.class differ diff --git a/bin/main/net/minecraft/game/entity/Entity.class b/bin/main/net/minecraft/game/entity/Entity.class new file mode 100644 index 0000000..ed972a3 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/Entity.class differ diff --git a/bin/main/net/minecraft/game/entity/EntityCreature.class b/bin/main/net/minecraft/game/entity/EntityCreature.class new file mode 100644 index 0000000..2c9f8b1 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/EntityCreature.class differ diff --git a/bin/main/net/minecraft/game/entity/EntityLiving.class b/bin/main/net/minecraft/game/entity/EntityLiving.class new file mode 100644 index 0000000..1a65a7d Binary files /dev/null and b/bin/main/net/minecraft/game/entity/EntityLiving.class differ diff --git a/bin/main/net/minecraft/game/entity/EntityPainting.class b/bin/main/net/minecraft/game/entity/EntityPainting.class new file mode 100644 index 0000000..30624aa Binary files /dev/null and b/bin/main/net/minecraft/game/entity/EntityPainting.class differ diff --git a/bin/main/net/minecraft/game/entity/EnumArt.class b/bin/main/net/minecraft/game/entity/EnumArt.class new file mode 100644 index 0000000..1b1cccc Binary files /dev/null and b/bin/main/net/minecraft/game/entity/EnumArt.class differ diff --git a/bin/main/net/minecraft/game/entity/animal/EntityAnimal.class b/bin/main/net/minecraft/game/entity/animal/EntityAnimal.class new file mode 100644 index 0000000..01af833 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/animal/EntityAnimal.class differ diff --git a/bin/main/net/minecraft/game/entity/animal/EntityPig.class b/bin/main/net/minecraft/game/entity/animal/EntityPig.class new file mode 100644 index 0000000..9a2237d Binary files /dev/null and b/bin/main/net/minecraft/game/entity/animal/EntityPig.class differ diff --git a/bin/main/net/minecraft/game/entity/animal/EntitySheep.class b/bin/main/net/minecraft/game/entity/animal/EntitySheep.class new file mode 100644 index 0000000..afa24e3 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/animal/EntitySheep.class differ diff --git a/bin/main/net/minecraft/game/entity/misc/EntityItem.class b/bin/main/net/minecraft/game/entity/misc/EntityItem.class new file mode 100644 index 0000000..5621c03 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/misc/EntityItem.class differ diff --git a/bin/main/net/minecraft/game/entity/misc/EntityTNTPrimed.class b/bin/main/net/minecraft/game/entity/misc/EntityTNTPrimed.class new file mode 100644 index 0000000..d70a1be Binary files /dev/null and b/bin/main/net/minecraft/game/entity/misc/EntityTNTPrimed.class differ diff --git a/bin/main/net/minecraft/game/entity/monster/EntityCreeper.class b/bin/main/net/minecraft/game/entity/monster/EntityCreeper.class new file mode 100644 index 0000000..ba2b362 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/monster/EntityCreeper.class differ diff --git a/bin/main/net/minecraft/game/entity/monster/EntityGiantZombie.class b/bin/main/net/minecraft/game/entity/monster/EntityGiantZombie.class new file mode 100644 index 0000000..4cc8dc5 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/monster/EntityGiantZombie.class differ diff --git a/bin/main/net/minecraft/game/entity/monster/EntityMob.class b/bin/main/net/minecraft/game/entity/monster/EntityMob.class new file mode 100644 index 0000000..c489f47 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/monster/EntityMob.class differ diff --git a/bin/main/net/minecraft/game/entity/monster/EntitySkeleton.class b/bin/main/net/minecraft/game/entity/monster/EntitySkeleton.class new file mode 100644 index 0000000..16e8b6f Binary files /dev/null and b/bin/main/net/minecraft/game/entity/monster/EntitySkeleton.class differ diff --git a/bin/main/net/minecraft/game/entity/monster/EntitySpider.class b/bin/main/net/minecraft/game/entity/monster/EntitySpider.class new file mode 100644 index 0000000..4f22e28 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/monster/EntitySpider.class differ diff --git a/bin/main/net/minecraft/game/entity/monster/EntityZombie.class b/bin/main/net/minecraft/game/entity/monster/EntityZombie.class new file mode 100644 index 0000000..c8e2111 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/monster/EntityZombie.class differ diff --git a/bin/main/net/minecraft/game/entity/player/EntityPlayer.class b/bin/main/net/minecraft/game/entity/player/EntityPlayer.class new file mode 100644 index 0000000..9d686ea Binary files /dev/null and b/bin/main/net/minecraft/game/entity/player/EntityPlayer.class differ diff --git a/bin/main/net/minecraft/game/entity/player/InventoryPlayer.class b/bin/main/net/minecraft/game/entity/player/InventoryPlayer.class new file mode 100644 index 0000000..d7ee19d Binary files /dev/null and b/bin/main/net/minecraft/game/entity/player/InventoryPlayer.class differ diff --git a/bin/main/net/minecraft/game/entity/projectile/EntityArrow.class b/bin/main/net/minecraft/game/entity/projectile/EntityArrow.class new file mode 100644 index 0000000..5a78415 Binary files /dev/null and b/bin/main/net/minecraft/game/entity/projectile/EntityArrow.class differ diff --git a/bin/main/net/minecraft/game/item/Item.class b/bin/main/net/minecraft/game/item/Item.class new file mode 100644 index 0000000..c7cb32a Binary files /dev/null and b/bin/main/net/minecraft/game/item/Item.class differ diff --git a/bin/main/net/minecraft/game/item/ItemArmor.class b/bin/main/net/minecraft/game/item/ItemArmor.class new file mode 100644 index 0000000..d117027 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemArmor.class differ diff --git a/bin/main/net/minecraft/game/item/ItemAxe.class b/bin/main/net/minecraft/game/item/ItemAxe.class new file mode 100644 index 0000000..aa6b48b Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemAxe.class differ diff --git a/bin/main/net/minecraft/game/item/ItemBlock.class b/bin/main/net/minecraft/game/item/ItemBlock.class new file mode 100644 index 0000000..6916220 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemBlock.class differ diff --git a/bin/main/net/minecraft/game/item/ItemBow.class b/bin/main/net/minecraft/game/item/ItemBow.class new file mode 100644 index 0000000..b727915 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemBow.class differ diff --git a/bin/main/net/minecraft/game/item/ItemFlintAndSteel.class b/bin/main/net/minecraft/game/item/ItemFlintAndSteel.class new file mode 100644 index 0000000..89946ed Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemFlintAndSteel.class differ diff --git a/bin/main/net/minecraft/game/item/ItemFood.class b/bin/main/net/minecraft/game/item/ItemFood.class new file mode 100644 index 0000000..48943fe Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemFood.class differ diff --git a/bin/main/net/minecraft/game/item/ItemHoe.class b/bin/main/net/minecraft/game/item/ItemHoe.class new file mode 100644 index 0000000..1c31400 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemHoe.class differ diff --git a/bin/main/net/minecraft/game/item/ItemPainting.class b/bin/main/net/minecraft/game/item/ItemPainting.class new file mode 100644 index 0000000..78ce834 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemPainting.class differ diff --git a/bin/main/net/minecraft/game/item/ItemPickaxe.class b/bin/main/net/minecraft/game/item/ItemPickaxe.class new file mode 100644 index 0000000..c02ed0a Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemPickaxe.class differ diff --git a/bin/main/net/minecraft/game/item/ItemSeeds.class b/bin/main/net/minecraft/game/item/ItemSeeds.class new file mode 100644 index 0000000..af0df34 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemSeeds.class differ diff --git a/bin/main/net/minecraft/game/item/ItemSoup.class b/bin/main/net/minecraft/game/item/ItemSoup.class new file mode 100644 index 0000000..60092f3 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemSoup.class differ diff --git a/bin/main/net/minecraft/game/item/ItemSpade.class b/bin/main/net/minecraft/game/item/ItemSpade.class new file mode 100644 index 0000000..f5e9abd Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemSpade.class differ diff --git a/bin/main/net/minecraft/game/item/ItemStack.class b/bin/main/net/minecraft/game/item/ItemStack.class new file mode 100644 index 0000000..4a369c6 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemStack.class differ diff --git a/bin/main/net/minecraft/game/item/ItemSword.class b/bin/main/net/minecraft/game/item/ItemSword.class new file mode 100644 index 0000000..7c9e44c Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemSword.class differ diff --git a/bin/main/net/minecraft/game/item/ItemTool.class b/bin/main/net/minecraft/game/item/ItemTool.class new file mode 100644 index 0000000..72a8df4 Binary files /dev/null and b/bin/main/net/minecraft/game/item/ItemTool.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/CraftingManager.class b/bin/main/net/minecraft/game/item/recipe/CraftingManager.class new file mode 100644 index 0000000..7739be7 Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/CraftingManager.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/CraftingRecipe.class b/bin/main/net/minecraft/game/item/recipe/CraftingRecipe.class new file mode 100644 index 0000000..6ad2937 Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/CraftingRecipe.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/RecipeSorter.class b/bin/main/net/minecraft/game/item/recipe/RecipeSorter.class new file mode 100644 index 0000000..a4b1672 Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/RecipeSorter.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/RecipesArmor.class b/bin/main/net/minecraft/game/item/recipe/RecipesArmor.class new file mode 100644 index 0000000..ef2ecfc Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/RecipesArmor.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/RecipesCrafting.class b/bin/main/net/minecraft/game/item/recipe/RecipesCrafting.class new file mode 100644 index 0000000..581eddb Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/RecipesCrafting.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/RecipesFood.class b/bin/main/net/minecraft/game/item/recipe/RecipesFood.class new file mode 100644 index 0000000..6d7f239 Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/RecipesFood.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/RecipesIngots.class b/bin/main/net/minecraft/game/item/recipe/RecipesIngots.class new file mode 100644 index 0000000..8af3092 Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/RecipesIngots.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/RecipesTools.class b/bin/main/net/minecraft/game/item/recipe/RecipesTools.class new file mode 100644 index 0000000..897b4a8 Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/RecipesTools.class differ diff --git a/bin/main/net/minecraft/game/item/recipe/RecipesWeapons.class b/bin/main/net/minecraft/game/item/recipe/RecipesWeapons.class new file mode 100644 index 0000000..711b596 Binary files /dev/null and b/bin/main/net/minecraft/game/item/recipe/RecipesWeapons.class differ diff --git a/bin/main/net/minecraft/game/level/EntityMap.class b/bin/main/net/minecraft/game/level/EntityMap.class new file mode 100644 index 0000000..3b85bdc Binary files /dev/null and b/bin/main/net/minecraft/game/level/EntityMap.class differ diff --git a/bin/main/net/minecraft/game/level/EntityMapSlot.class b/bin/main/net/minecraft/game/level/EntityMapSlot.class new file mode 100644 index 0000000..632c7ee Binary files /dev/null and b/bin/main/net/minecraft/game/level/EntityMapSlot.class differ diff --git a/bin/main/net/minecraft/game/level/IWorldAccess.class b/bin/main/net/minecraft/game/level/IWorldAccess.class new file mode 100644 index 0000000..8a3ecae Binary files /dev/null and b/bin/main/net/minecraft/game/level/IWorldAccess.class differ diff --git a/bin/main/net/minecraft/game/level/LevelLoader.class b/bin/main/net/minecraft/game/level/LevelLoader.class new file mode 100644 index 0000000..8c9f1e6 Binary files /dev/null and b/bin/main/net/minecraft/game/level/LevelLoader.class differ diff --git a/bin/main/net/minecraft/game/level/Light.class b/bin/main/net/minecraft/game/level/Light.class new file mode 100644 index 0000000..c6681e0 Binary files /dev/null and b/bin/main/net/minecraft/game/level/Light.class differ diff --git a/bin/main/net/minecraft/game/level/MetadataChunkBlock.class b/bin/main/net/minecraft/game/level/MetadataChunkBlock.class new file mode 100644 index 0000000..375593f Binary files /dev/null and b/bin/main/net/minecraft/game/level/MetadataChunkBlock.class differ diff --git a/bin/main/net/minecraft/game/level/MobSpawner.class b/bin/main/net/minecraft/game/level/MobSpawner.class new file mode 100644 index 0000000..de07177 Binary files /dev/null and b/bin/main/net/minecraft/game/level/MobSpawner.class differ diff --git a/bin/main/net/minecraft/game/level/NextTickListEntry.class b/bin/main/net/minecraft/game/level/NextTickListEntry.class new file mode 100644 index 0000000..e441107 Binary files /dev/null and b/bin/main/net/minecraft/game/level/NextTickListEntry.class differ diff --git a/bin/main/net/minecraft/game/level/World.class b/bin/main/net/minecraft/game/level/World.class new file mode 100644 index 0000000..0dc9a67 Binary files /dev/null and b/bin/main/net/minecraft/game/level/World.class differ diff --git a/bin/main/net/minecraft/game/level/block/Block.class b/bin/main/net/minecraft/game/level/block/Block.class new file mode 100644 index 0000000..555daec Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/Block.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockBookshelf.class b/bin/main/net/minecraft/game/level/block/BlockBookshelf.class new file mode 100644 index 0000000..92da9ee Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockBookshelf.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockBreakable.class b/bin/main/net/minecraft/game/level/block/BlockBreakable.class new file mode 100644 index 0000000..56ffcdc Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockBreakable.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockChest.class b/bin/main/net/minecraft/game/level/block/BlockChest.class new file mode 100644 index 0000000..945d422 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockChest.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockContainer.class b/bin/main/net/minecraft/game/level/block/BlockContainer.class new file mode 100644 index 0000000..f5a3667 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockContainer.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockCrops.class b/bin/main/net/minecraft/game/level/block/BlockCrops.class new file mode 100644 index 0000000..44f05c8 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockCrops.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockDirt.class b/bin/main/net/minecraft/game/level/block/BlockDirt.class new file mode 100644 index 0000000..9664c21 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockDirt.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockFarmland.class b/bin/main/net/minecraft/game/level/block/BlockFarmland.class new file mode 100644 index 0000000..3975239 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockFarmland.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockFire.class b/bin/main/net/minecraft/game/level/block/BlockFire.class new file mode 100644 index 0000000..38cd550 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockFire.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockFlower.class b/bin/main/net/minecraft/game/level/block/BlockFlower.class new file mode 100644 index 0000000..aa0d86f Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockFlower.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockFlowing.class b/bin/main/net/minecraft/game/level/block/BlockFlowing.class new file mode 100644 index 0000000..6e62aa8 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockFlowing.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockFluid.class b/bin/main/net/minecraft/game/level/block/BlockFluid.class new file mode 100644 index 0000000..c0be7e4 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockFluid.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockFurnace.class b/bin/main/net/minecraft/game/level/block/BlockFurnace.class new file mode 100644 index 0000000..0534350 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockFurnace.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockGears.class b/bin/main/net/minecraft/game/level/block/BlockGears.class new file mode 100644 index 0000000..1feefa2 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockGears.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockGlass.class b/bin/main/net/minecraft/game/level/block/BlockGlass.class new file mode 100644 index 0000000..93805cb Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockGlass.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockGrass.class b/bin/main/net/minecraft/game/level/block/BlockGrass.class new file mode 100644 index 0000000..92bb11b Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockGrass.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockGravel.class b/bin/main/net/minecraft/game/level/block/BlockGravel.class new file mode 100644 index 0000000..d910ade Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockGravel.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockLeaves.class b/bin/main/net/minecraft/game/level/block/BlockLeaves.class new file mode 100644 index 0000000..e824036 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockLeaves.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockLeavesBase.class b/bin/main/net/minecraft/game/level/block/BlockLeavesBase.class new file mode 100644 index 0000000..74da423 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockLeavesBase.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockLog.class b/bin/main/net/minecraft/game/level/block/BlockLog.class new file mode 100644 index 0000000..c3e1c02 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockLog.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockMushroom.class b/bin/main/net/minecraft/game/level/block/BlockMushroom.class new file mode 100644 index 0000000..3d5433c Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockMushroom.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockOre.class b/bin/main/net/minecraft/game/level/block/BlockOre.class new file mode 100644 index 0000000..9755b58 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockOre.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockOreBlock.class b/bin/main/net/minecraft/game/level/block/BlockOreBlock.class new file mode 100644 index 0000000..8edc207 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockOreBlock.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockSand.class b/bin/main/net/minecraft/game/level/block/BlockSand.class new file mode 100644 index 0000000..e01144f Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockSand.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockSapling.class b/bin/main/net/minecraft/game/level/block/BlockSapling.class new file mode 100644 index 0000000..612c7bd Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockSapling.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockSource.class b/bin/main/net/minecraft/game/level/block/BlockSource.class new file mode 100644 index 0000000..5739712 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockSource.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockSponge.class b/bin/main/net/minecraft/game/level/block/BlockSponge.class new file mode 100644 index 0000000..d2814d9 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockSponge.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockStationary.class b/bin/main/net/minecraft/game/level/block/BlockStationary.class new file mode 100644 index 0000000..6ac5ae4 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockStationary.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockStep.class b/bin/main/net/minecraft/game/level/block/BlockStep.class new file mode 100644 index 0000000..69ddd33 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockStep.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockStone.class b/bin/main/net/minecraft/game/level/block/BlockStone.class new file mode 100644 index 0000000..4fd3b36 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockStone.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockTNT.class b/bin/main/net/minecraft/game/level/block/BlockTNT.class new file mode 100644 index 0000000..6410406 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockTNT.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockTorch.class b/bin/main/net/minecraft/game/level/block/BlockTorch.class new file mode 100644 index 0000000..5b1efa5 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockTorch.class differ diff --git a/bin/main/net/minecraft/game/level/block/BlockWorkbench.class b/bin/main/net/minecraft/game/level/block/BlockWorkbench.class new file mode 100644 index 0000000..516035e Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/BlockWorkbench.class differ diff --git a/bin/main/net/minecraft/game/level/block/StepSound.class b/bin/main/net/minecraft/game/level/block/StepSound.class new file mode 100644 index 0000000..097a7f6 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/StepSound.class differ diff --git a/bin/main/net/minecraft/game/level/block/StepSoundGlass.class b/bin/main/net/minecraft/game/level/block/StepSoundGlass.class new file mode 100644 index 0000000..f9c1273 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/StepSoundGlass.class differ diff --git a/bin/main/net/minecraft/game/level/block/StepSoundSand.class b/bin/main/net/minecraft/game/level/block/StepSoundSand.class new file mode 100644 index 0000000..4a6c7ee Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/StepSoundSand.class differ diff --git a/bin/main/net/minecraft/game/level/block/tileentity/TileEntity.class b/bin/main/net/minecraft/game/level/block/tileentity/TileEntity.class new file mode 100644 index 0000000..4bab9e5 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/tileentity/TileEntity.class differ diff --git a/bin/main/net/minecraft/game/level/block/tileentity/TileEntityChest.class b/bin/main/net/minecraft/game/level/block/tileentity/TileEntityChest.class new file mode 100644 index 0000000..44b1730 Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/tileentity/TileEntityChest.class differ diff --git a/bin/main/net/minecraft/game/level/block/tileentity/TileEntityFurnace.class b/bin/main/net/minecraft/game/level/block/tileentity/TileEntityFurnace.class new file mode 100644 index 0000000..d185e4d Binary files /dev/null and b/bin/main/net/minecraft/game/level/block/tileentity/TileEntityFurnace.class differ diff --git a/bin/main/net/minecraft/game/level/generator/LevelGenerator.class b/bin/main/net/minecraft/game/level/generator/LevelGenerator.class new file mode 100644 index 0000000..932cbc0 Binary files /dev/null and b/bin/main/net/minecraft/game/level/generator/LevelGenerator.class differ diff --git a/bin/main/net/minecraft/game/level/generator/noise/NoiseGenerator.class b/bin/main/net/minecraft/game/level/generator/noise/NoiseGenerator.class new file mode 100644 index 0000000..841e631 Binary files /dev/null and b/bin/main/net/minecraft/game/level/generator/noise/NoiseGenerator.class differ diff --git a/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.class b/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.class new file mode 100644 index 0000000..d53eb3e Binary files /dev/null and b/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.class differ diff --git a/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.class b/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.class new file mode 100644 index 0000000..8896391 Binary files /dev/null and b/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.class differ diff --git a/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.class b/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.class new file mode 100644 index 0000000..a15c931 Binary files /dev/null and b/bin/main/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.class differ diff --git a/bin/main/net/minecraft/game/level/material/Material.class b/bin/main/net/minecraft/game/level/material/Material.class new file mode 100644 index 0000000..1ddc26d Binary files /dev/null and b/bin/main/net/minecraft/game/level/material/Material.class differ diff --git a/bin/main/net/minecraft/game/level/material/MaterialLiquid.class b/bin/main/net/minecraft/game/level/material/MaterialLiquid.class new file mode 100644 index 0000000..334fa3d Binary files /dev/null and b/bin/main/net/minecraft/game/level/material/MaterialLiquid.class differ diff --git a/bin/main/net/minecraft/game/level/material/MaterialLogic.class b/bin/main/net/minecraft/game/level/material/MaterialLogic.class new file mode 100644 index 0000000..7a24f30 Binary files /dev/null and b/bin/main/net/minecraft/game/level/material/MaterialLogic.class differ diff --git a/bin/main/net/minecraft/game/level/material/MaterialTransparent.class b/bin/main/net/minecraft/game/level/material/MaterialTransparent.class new file mode 100644 index 0000000..2d1cc6a Binary files /dev/null and b/bin/main/net/minecraft/game/level/material/MaterialTransparent.class differ diff --git a/bin/main/net/minecraft/game/level/path/Path.class b/bin/main/net/minecraft/game/level/path/Path.class new file mode 100644 index 0000000..12a8759 Binary files /dev/null and b/bin/main/net/minecraft/game/level/path/Path.class differ diff --git a/bin/main/net/minecraft/game/level/path/PathEntity.class b/bin/main/net/minecraft/game/level/path/PathEntity.class new file mode 100644 index 0000000..bf2c195 Binary files /dev/null and b/bin/main/net/minecraft/game/level/path/PathEntity.class differ diff --git a/bin/main/net/minecraft/game/level/path/PathPoint.class b/bin/main/net/minecraft/game/level/path/PathPoint.class new file mode 100644 index 0000000..7889414 Binary files /dev/null and b/bin/main/net/minecraft/game/level/path/PathPoint.class differ diff --git a/bin/main/net/minecraft/game/level/path/Pathfinder.class b/bin/main/net/minecraft/game/level/path/Pathfinder.class new file mode 100644 index 0000000..814f5f0 Binary files /dev/null and b/bin/main/net/minecraft/game/level/path/Pathfinder.class differ diff --git a/bin/main/net/minecraft/game/physics/AxisAlignedBB.class b/bin/main/net/minecraft/game/physics/AxisAlignedBB.class new file mode 100644 index 0000000..e643607 Binary files /dev/null and b/bin/main/net/minecraft/game/physics/AxisAlignedBB.class differ diff --git a/bin/main/net/minecraft/game/physics/MovingObjectPosition.class b/bin/main/net/minecraft/game/physics/MovingObjectPosition.class new file mode 100644 index 0000000..06c6bac Binary files /dev/null and b/bin/main/net/minecraft/game/physics/MovingObjectPosition.class differ diff --git a/bin/main/net/minecraft/game/physics/Vec3D.class b/bin/main/net/minecraft/game/physics/Vec3D.class new file mode 100644 index 0000000..cd612a0 Binary files /dev/null and b/bin/main/net/minecraft/game/physics/Vec3D.class differ diff --git a/bin/main/org/lwjgl/BufferUtils.class b/bin/main/org/lwjgl/BufferUtils.class new file mode 100644 index 0000000..e2d4967 Binary files /dev/null and b/bin/main/org/lwjgl/BufferUtils.class differ diff --git a/bin/main/org/lwjgl/GLAllocation.class b/bin/main/org/lwjgl/GLAllocation.class new file mode 100644 index 0000000..bd34298 Binary files /dev/null and b/bin/main/org/lwjgl/GLAllocation.class differ diff --git a/bin/main/org/lwjgl/opengl/GL11.class b/bin/main/org/lwjgl/opengl/GL11.class new file mode 100644 index 0000000..feab496 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/GL11.class differ diff --git a/bin/main/org/lwjgl/opengl/GLObjectMap.class b/bin/main/org/lwjgl/opengl/GLObjectMap.class new file mode 100644 index 0000000..86d4bc0 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/GLObjectMap.class differ diff --git a/bin/main/org/lwjgl/opengl/RealOpenGLEnums.class b/bin/main/org/lwjgl/opengl/RealOpenGLEnums.class new file mode 100644 index 0000000..3267d6e Binary files /dev/null and b/bin/main/org/lwjgl/opengl/RealOpenGLEnums.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$1.class b/bin/main/org/lwjgl/opengl/WebGL$1.class new file mode 100644 index 0000000..a4676be Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$1.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$10.class b/bin/main/org/lwjgl/opengl/WebGL$10.class new file mode 100644 index 0000000..3c4a0b0 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$10.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$11.class b/bin/main/org/lwjgl/opengl/WebGL$11.class new file mode 100644 index 0000000..f796bf2 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$11.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$12.class b/bin/main/org/lwjgl/opengl/WebGL$12.class new file mode 100644 index 0000000..6df2a96 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$12.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$13.class b/bin/main/org/lwjgl/opengl/WebGL$13.class new file mode 100644 index 0000000..e530b3f Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$13.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$14$1.class b/bin/main/org/lwjgl/opengl/WebGL$14$1.class new file mode 100644 index 0000000..93fd06b Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$14$1.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$14.class b/bin/main/org/lwjgl/opengl/WebGL$14.class new file mode 100644 index 0000000..1732fdf Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$14.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$15.class b/bin/main/org/lwjgl/opengl/WebGL$15.class new file mode 100644 index 0000000..239e862 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$15.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$16.class b/bin/main/org/lwjgl/opengl/WebGL$16.class new file mode 100644 index 0000000..996fc30 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$16.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$17.class b/bin/main/org/lwjgl/opengl/WebGL$17.class new file mode 100644 index 0000000..6edc992 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$17.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$18.class b/bin/main/org/lwjgl/opengl/WebGL$18.class new file mode 100644 index 0000000..f5063ac Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$18.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$19.class b/bin/main/org/lwjgl/opengl/WebGL$19.class new file mode 100644 index 0000000..62eef97 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$19.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$2.class b/bin/main/org/lwjgl/opengl/WebGL$2.class new file mode 100644 index 0000000..67f6baf Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$2.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$20.class b/bin/main/org/lwjgl/opengl/WebGL$20.class new file mode 100644 index 0000000..9dad30b Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$20.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$21.class b/bin/main/org/lwjgl/opengl/WebGL$21.class new file mode 100644 index 0000000..051dde4 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$21.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$22.class b/bin/main/org/lwjgl/opengl/WebGL$22.class new file mode 100644 index 0000000..acf5d99 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$22.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$3.class b/bin/main/org/lwjgl/opengl/WebGL$3.class new file mode 100644 index 0000000..b2426d8 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$3.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$4.class b/bin/main/org/lwjgl/opengl/WebGL$4.class new file mode 100644 index 0000000..9a6fab1 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$4.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$5.class b/bin/main/org/lwjgl/opengl/WebGL$5.class new file mode 100644 index 0000000..a4ce6b9 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$5.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$6.class b/bin/main/org/lwjgl/opengl/WebGL$6.class new file mode 100644 index 0000000..3e7c38d Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$6.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$7.class b/bin/main/org/lwjgl/opengl/WebGL$7.class new file mode 100644 index 0000000..40c4161 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$7.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$8.class b/bin/main/org/lwjgl/opengl/WebGL$8.class new file mode 100644 index 0000000..aba2462 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$8.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$9.class b/bin/main/org/lwjgl/opengl/WebGL$9.class new file mode 100644 index 0000000..cedd8c5 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$9.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$AudioBufferSourceNodeX.class b/bin/main/org/lwjgl/opengl/WebGL$AudioBufferSourceNodeX.class new file mode 100644 index 0000000..734af18 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$AudioBufferSourceNodeX.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$AudioBufferX.class b/bin/main/org/lwjgl/opengl/WebGL$AudioBufferX.class new file mode 100644 index 0000000..671c8e4 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$AudioBufferX.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$BufferArrayGL.class b/bin/main/org/lwjgl/opengl/WebGL$BufferArrayGL.class new file mode 100644 index 0000000..8891ae7 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$BufferArrayGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$BufferGL.class b/bin/main/org/lwjgl/opengl/WebGL$BufferGL.class new file mode 100644 index 0000000..57900f7 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$BufferGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$FileEntry.class b/bin/main/org/lwjgl/opengl/WebGL$FileEntry.class new file mode 100644 index 0000000..7748397 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$FileEntry.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$FramebufferGL.class b/bin/main/org/lwjgl/opengl/WebGL$FramebufferGL.class new file mode 100644 index 0000000..33a056b Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$FramebufferGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$ProgramGL.class b/bin/main/org/lwjgl/opengl/WebGL$ProgramGL.class new file mode 100644 index 0000000..54c2f4f Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$ProgramGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$QueryGL.class b/bin/main/org/lwjgl/opengl/WebGL$QueryGL.class new file mode 100644 index 0000000..d3a548d Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$QueryGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$RateLimit.class b/bin/main/org/lwjgl/opengl/WebGL$RateLimit.class new file mode 100644 index 0000000..8c67a5e Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$RateLimit.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$RenderbufferGL.class b/bin/main/org/lwjgl/opengl/WebGL$RenderbufferGL.class new file mode 100644 index 0000000..bdb0df9 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$RenderbufferGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$ShaderGL.class b/bin/main/org/lwjgl/opengl/WebGL$ShaderGL.class new file mode 100644 index 0000000..47c5cd3 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$ShaderGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$StupidFunctionResolveString.class b/bin/main/org/lwjgl/opengl/WebGL$StupidFunctionResolveString.class new file mode 100644 index 0000000..fb68ff6 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$StupidFunctionResolveString.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$TextureGL.class b/bin/main/org/lwjgl/opengl/WebGL$TextureGL.class new file mode 100644 index 0000000..14edfac Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$TextureGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL$UniformGL.class b/bin/main/org/lwjgl/opengl/WebGL$UniformGL.class new file mode 100644 index 0000000..50c6692 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL$UniformGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGL.class b/bin/main/org/lwjgl/opengl/WebGL.class new file mode 100644 index 0000000..34f45e1 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGL.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGLManager$DisplayList.class b/bin/main/org/lwjgl/opengl/WebGLManager$DisplayList.class new file mode 100644 index 0000000..b0f305a Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGLManager$DisplayList.class differ diff --git a/bin/main/org/lwjgl/opengl/WebGLManager.class b/bin/main/org/lwjgl/opengl/WebGLManager.class new file mode 100644 index 0000000..321fda4 Binary files /dev/null and b/bin/main/org/lwjgl/opengl/WebGLManager.class differ diff --git a/bin/main/util/IProgressUpdate.class b/bin/main/util/IProgressUpdate.class new file mode 100644 index 0000000..af1c287 Binary files /dev/null and b/bin/main/util/IProgressUpdate.class differ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..ffa909b --- /dev/null +++ b/build.gradle @@ -0,0 +1,83 @@ + +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath 'io.github.zebalu:teavm-gradle-plugin:1.0.0' + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'io.github.zebalu.teavm-gradle-plugin' + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +sourceSets { + main { + java { + srcDir 'src/teavm/java' + } + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.teavm:teavm-platform:0.6.1' + implementation 'org.teavm:teavm-classlib:0.6.1' + implementation 'com.jcraft:jzlib:1.1.3' +} + +teavm { + + compileScopes = null; + minifying = false; + maxTopLevelNames = 10000; + properties = null; + debugInformationGenerated = false; + sourceMapsGenerated = true; + sourceFilesCopied = false; + incremental = false; + transformers = null; + + /** Where to save the result */ + targetDirectory = file("js"); + + /** The directory to monitor to decide if compile is up-to-date or not */ + sourceDirectory = file("src"); + + /** How to name the result file. */ + targetFileName = "app.js"; + + /** Which class holds your public static void main(Strin[] args) method */ + mainClass = 'net.PeytonPlayz585.MinecraftMain'; + + /** This will be the name of your main method after compilation. */ + entryPointName = 'main'; + + classesToPreserve = null; + stopOnErrors = false; + optimizationLevel = "ADVANCED"; //org.teavm.vm.TeaVMOptimizationLevel.SIMPLE; + fastGlobalAnalysis = false; + targetType = "JAVASCRIPT"; //org.teavm.tooling.TeaVMTargetType.JAVASCRIPT; + cacheDirectory = null; + wasmVersion = "V_0x1"; //org.teavm.backend.wasm.render.WasmBinaryVersion.V_0x1; + minHeapSize = 4; + maxHeapSize = 128; + outOfProcess = false; + processMemory = 512; + longjmpSupported = true; + heapDump = false; + + /** Add name of configurations here where to look for jarfiles. */ + includeJarsFrom = []; + + /** By default teavmc taskd epends on javaCompile task, unless this varaibale is true. */ + skipJavaCompile = false; +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..41d9927 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..aa991fc --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..1a257bd --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/7.4.2/userguide/multi_project_builds.html + */ + +rootProject.name = 'Indev' diff --git a/src/teavm/java/net/PeytonPlayz585/MinecraftMain.java b/src/teavm/java/net/PeytonPlayz585/MinecraftMain.java new file mode 100644 index 0000000..d4f3f2f --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/MinecraftMain.java @@ -0,0 +1,124 @@ +package net.PeytonPlayz585; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.WebGL; +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 net.PeytonPlayz585.storage.LocalStorageManager; + +public class MinecraftMain { + public static Thread thread = null; + + public static class AbortedLaunchException extends RuntimeException { + // yee + } + + public static HTMLElement rootElement = null; + public static void main(String[] args) { + registerErrorHandler(); + String[] e = getOpts(); + try { + try { + WebGL.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 -------- "); + LocalStorageManager.loadStorage(); + run1(); + } + + private static void run1() { + } + + @JSBody(params = { }, script = "return window.classicConfig;") + 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.PeytonPlayz585.MinecraftMain.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 div = doc.createElement("div"); + 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(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/teavm/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java b/src/teavm/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java new file mode 100644 index 0000000..5056a5e --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/FixedFunctionShader.java @@ -0,0 +1,397 @@ +package net.PeytonPlayz585.glemu; + +import static org.lwjgl.opengl.GL11.*; + +import net.PeytonPlayz585.glemu.vector.*; + +public class FixedFunctionShader { + + private static final FixedFunctionShader[] instances = new FixedFunctionShader[128]; + + public static void refreshCoreGL() { + for (int i = 0; i < instances.length; ++i) { + if (instances[i] != null) { + _wglDeleteProgram(instances[i].globject); + instances[i] = null; + } + } + shaderSource = null; + } + + public static final int COLOR = 1; + public static final int NORMAL = 2; + public static final int TEXTURE0 = 4; + public static final int LIGHTING = 8; + public static final int FOG = 16; + public static final int ALPHATEST = 32; + public static final int UNIT0 = 64; + + public static FixedFunctionShader instance(int i) { + FixedFunctionShader s = instances[i]; + if (s == null) { + boolean CC_a_color = false; + boolean CC_a_normal = false; + boolean CC_a_texture0 = false; + boolean CC_lighting = false; + boolean CC_fog = false; + boolean CC_alphatest = false; + boolean CC_unit0 = false; + if ((i & COLOR) == COLOR) { + CC_a_color = true; + } + if ((i & NORMAL) == NORMAL) { + CC_a_normal = true; + } + if ((i & TEXTURE0) == TEXTURE0) { + CC_a_texture0 = true; + } + if ((i & LIGHTING) == LIGHTING) { + CC_lighting = true; + } + if ((i & FOG) == FOG) { + CC_fog = true; + } + if ((i & ALPHATEST) == ALPHATEST) { + CC_alphatest = true; + } + if ((i & UNIT0) == UNIT0) { + CC_unit0 = true; + } + s = new FixedFunctionShader(i, CC_a_color, CC_a_normal, CC_a_texture0, CC_lighting, CC_fog, CC_alphatest, CC_unit0); + instances[i] = s; + } + return s; + } + + private static String shaderSource = null; + + private final boolean enable_color; + private final boolean enable_normal; + private final boolean enable_texture0; + private final boolean enable_lighting; + private final boolean enable_fog; + private final boolean enable_alphatest; + private final boolean enable_unit0; + private final ProgramGL globject; + + private UniformGL u_matrix_m = null; + private UniformGL u_matrix_p = null; + private UniformGL u_matrix_t = null; + + private UniformGL u_fogColor = null; + private UniformGL u_fogMode = null; + private UniformGL u_fogStart = null; + private UniformGL u_fogEnd = null; + private UniformGL u_fogDensity = null; + private UniformGL u_fogPremultiply = null; + + private UniformGL u_colorUniform = null; + private UniformGL u_normalUniform = null; + + private UniformGL u_alphaTestF = null; + + private UniformGL u_texCoordV0 = null; + + private UniformGL u_light0Pos = null; + private UniformGL u_light1Pos = null; + + private final int a_position; + private final int a_texture0; + private final int a_color; + private final int a_normal; + + private final int attributeIndexesToEnable; + + public final BufferArrayGL genericArray; + public final BufferGL genericBuffer; + public boolean bufferIsInitialized = false; + + private FixedFunctionShader(int j, boolean CC_a_color, boolean CC_a_normal, boolean CC_a_texture0, + boolean CC_lighting, boolean CC_fog, boolean CC_alphatest, boolean CC_unit0) { + enable_color = CC_a_color; + enable_normal = CC_a_normal; + enable_texture0 = CC_a_texture0; + enable_lighting = CC_lighting; + enable_fog = CC_fog; + enable_alphatest = CC_alphatest; + enable_unit0 = CC_unit0; + + if (shaderSource == null) { + shaderSource = fileContents("/glsl/core.glsl"); + } + + String source = ""; + if (enable_color) + source += "\n#define CC_a_color\n"; + if (enable_normal) + source += "#define CC_a_normal\n"; + if (enable_texture0) + source += "#define CC_a_texture0\n"; + if (enable_lighting) + source += "#define CC_lighting\n"; + if (enable_fog) + source += "#define CC_fog\n"; + if (enable_alphatest) + source += "#define CC_alphatest\n"; + if (enable_unit0) + source += "#define CC_unit0\n"; + source += shaderSource; + + ShaderGL v = _wglCreateShader(_wGL_VERTEX_SHADER); + _wglShaderSource(v, _wgetShaderHeader() + "\n#define CC_VERT\n" + source); + _wglCompileShader(v); + + if (!_wglGetShaderCompiled(v)) { + System.err.println(("\n\n" + _wglGetShaderInfoLog(v)).replace("\n", "\n[/glsl/core.glsl][CC_VERT] ")); + throw new RuntimeException("broken shader file"); + } + + ShaderGL f = _wglCreateShader(_wGL_FRAGMENT_SHADER); + _wglShaderSource(f, _wgetShaderHeader() + "\n#define CC_FRAG\n" + source); + _wglCompileShader(f); + + if (!_wglGetShaderCompiled(f)) { + System.err.println(("\n\n" + _wglGetShaderInfoLog(f)).replace("\n", "\n[/glsl/core.glsl][CC_FRAG] ")); + throw new RuntimeException("broken shader file"); + } + + globject = _wglCreateProgram(); + _wglAttachShader(globject, v); + _wglAttachShader(globject, f); + + int i = 0; + a_position = i++; + _wglBindAttributeLocation(globject, a_position, "a_position"); + + if (enable_texture0) { + a_texture0 = i++; + _wglBindAttributeLocation(globject, a_texture0, "a_texture0"); + } else { + a_texture0 = -1; + } + if (enable_color) { + a_color = i++; + _wglBindAttributeLocation(globject, a_color, "a_color"); + } else { + a_color = -1; + } + if (enable_normal) { + a_normal = i++; + _wglBindAttributeLocation(globject, a_normal, "a_normal"); + } else { + a_normal = -1; + } + + attributeIndexesToEnable = i; + + _wglLinkProgram(globject); + + _wglDetachShader(globject, v); + _wglDetachShader(globject, f); + _wglDeleteShader(v); + _wglDeleteShader(f); + + if (!_wglGetProgramLinked(globject)) { + System.err.println(("\n\n" + _wglGetProgramInfoLog(globject)).replace("\n", "\n[LINKER] ")); + throw new RuntimeException("broken shader file"); + } + + _wglUseProgram(globject); + + u_matrix_m = _wglGetUniformLocation(globject, "matrix_m"); + u_matrix_p = _wglGetUniformLocation(globject, "matrix_p"); + u_matrix_t = _wglGetUniformLocation(globject, "matrix_t"); + + u_colorUniform = _wglGetUniformLocation(globject, "colorUniform"); + + if (enable_lighting) { + u_normalUniform = _wglGetUniformLocation(globject, "normalUniform"); + // u_invertNormals = _wglGetUniformLocation(globject, "invertNormals"); + u_light0Pos = _wglGetUniformLocation(globject, "light0Pos"); + u_light1Pos = _wglGetUniformLocation(globject, "light1Pos"); + } + + if (enable_fog) { + u_fogColor = _wglGetUniformLocation(globject, "fogColor"); + u_fogMode = _wglGetUniformLocation(globject, "fogMode"); + u_fogStart = _wglGetUniformLocation(globject, "fogStart"); + u_fogEnd = _wglGetUniformLocation(globject, "fogEnd"); + u_fogDensity = _wglGetUniformLocation(globject, "fogDensity"); + u_fogPremultiply = _wglGetUniformLocation(globject, "fogPremultiply"); + } + + if (enable_alphatest) { + u_alphaTestF = _wglGetUniformLocation(globject, "alphaTestF"); + } + + _wglUniform1i(_wglGetUniformLocation(globject, "tex0"), 0); + u_texCoordV0 = _wglGetUniformLocation(globject, "texCoordV0"); + + genericArray = _wglCreateVertexArray(); + genericBuffer = _wglCreateBuffer(); + _wglBindVertexArray(genericArray); + _wglBindBuffer(_wGL_ARRAY_BUFFER, genericBuffer); + setupArrayForProgram(); + + } + + public void setupArrayForProgram() { + _wglEnableVertexAttribArray(a_position); + _wglVertexAttribPointer(a_position, 3, _wGL_FLOAT, false, 28, 0); + if (enable_texture0) { + _wglEnableVertexAttribArray(a_texture0); + _wglVertexAttribPointer(a_texture0, 2, _wGL_FLOAT, false, 28, 12); + } + if (enable_color) { + _wglEnableVertexAttribArray(a_color); + _wglVertexAttribPointer(a_color, 4, _wGL_UNSIGNED_BYTE, true, 28, 20); + } + if (enable_normal) { + _wglEnableVertexAttribArray(a_normal); + _wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 28, 24); + } + } + + public void useProgram() { + _wglUseProgram(globject); + } + + public void unuseProgram() { + + } + + private float[] modelBuffer = new float[16]; + private float[] projectionBuffer = new float[16]; + private float[] textureBuffer = new float[16]; + + private Matrix4f modelMatrix = (Matrix4f) new Matrix4f().setZero(); + private Matrix4f projectionMatrix = (Matrix4f) new Matrix4f().setZero(); + private Matrix4f textureMatrix = (Matrix4f) new Matrix4f().setZero(); + private Vector4f light0Pos = new Vector4f(); + private Vector4f light1Pos = new Vector4f(); + + public void setModelMatrix(Matrix4f mat) { + if (!mat.equals(modelMatrix)) { + modelMatrix.load(mat).store(modelBuffer); + _wglUniformMat4fv(u_matrix_m, modelBuffer); + } + } + + public void setProjectionMatrix(Matrix4f mat) { + if (!mat.equals(projectionMatrix)) { + projectionMatrix.load(mat).store(projectionBuffer); + _wglUniformMat4fv(u_matrix_p, projectionBuffer); + } + } + + public void setTextureMatrix(Matrix4f mat) { + if (!mat.equals(textureMatrix)) { + textureMatrix.load(mat).store(textureBuffer); + _wglUniformMat4fv(u_matrix_t, textureBuffer); + } + } + + public void setLightPositions(Vector4f pos0, Vector4f pos1) { + if (!pos0.equals(light0Pos) || !pos1.equals(light1Pos)) { + light0Pos.set(pos0); + light1Pos.set(pos1); + _wglUniform3f(u_light0Pos, light0Pos.x, light0Pos.y, light0Pos.z); + _wglUniform3f(u_light1Pos, light1Pos.x, light1Pos.y, light1Pos.z); + } + } + + private int fogMode = 0; + + public void setFogMode(int mode) { + if (fogMode != mode) { + fogMode = mode; + _wglUniform1i(u_fogMode, mode % 2); + _wglUniform1f(u_fogPremultiply, mode / 2); + } + } + + private float fogColorR = 0.0f; + private float fogColorG = 0.0f; + private float fogColorB = 0.0f; + private float fogColorA = 0.0f; + + public void setFogColor(float r, float g, float b, float a) { + if (fogColorR != r || fogColorG != g || fogColorB != b || fogColorA != a) { + fogColorR = r; + fogColorG = g; + fogColorB = b; + fogColorA = a; + _wglUniform4f(u_fogColor, fogColorR, fogColorG, fogColorB, fogColorA); + } + } + + private float fogStart = 0.0f; + private float fogEnd = 0.0f; + + public void setFogStartEnd(float s, float e) { + if (fogStart != s || fogEnd != e) { + fogStart = s; + fogEnd = e; + _wglUniform1f(u_fogStart, fogStart); + _wglUniform1f(u_fogEnd, fogEnd); + } + } + + private float fogDensity = 0.0f; + + public void setFogDensity(float d) { + if (fogDensity != d) { + fogDensity = d; + _wglUniform1f(u_fogDensity, fogDensity); + } + } + + private float alphaTestValue = 0.0f; + + public void setAlphaTest(float limit) { + if (alphaTestValue != limit) { + alphaTestValue = limit; + _wglUniform1f(u_alphaTestF, alphaTestValue); + } + } + + private float tex0x = 0.0f; + private float tex0y = 0.0f; + + public void setTex0Coords(float x, float y) { + if (tex0x != x || tex0y != y) { + tex0x = x; + tex0y = y; + _wglUniform2f(u_texCoordV0, tex0x, tex0y); + } + } + + private float colorUniformR = 0.0f; + private float colorUniformG = 0.0f; + private float colorUniformB = 0.0f; + private float colorUniformA = 0.0f; + + public void setColor(float r, float g, float b, float a) { + if (colorUniformR != r || colorUniformG != g || colorUniformB != b || colorUniformA != a) { + colorUniformR = r; + colorUniformG = g; + colorUniformB = b; + colorUniformA = a; + _wglUniform4f(u_colorUniform, colorUniformR, colorUniformG, colorUniformB, colorUniformA); + } + } + + private float normalUniformX = 0.0f; + private float normalUniformY = 0.0f; + private float normalUniformZ = 0.0f; + + public void setNormal(float x, float y, float z) { + if (normalUniformX != x || normalUniformY != y || normalUniformZ != z) { + normalUniformX = x; + normalUniformY = y; + normalUniformZ = z; + _wglUniform3f(u_normalUniform, normalUniformX, normalUniformY, normalUniformZ); + } + } + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix.java new file mode 100644 index 0000000..d3e962d --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Base class for matrices. When a matrix is constructed it will be the identity + * matrix unless otherwise stated. + * + * @author cix_foo + * @version $Revision$ $Id$ + */ +public abstract class Matrix implements Serializable { + + /** + * Constructor for Matrix. + */ + protected Matrix() { + super(); + } + + /** + * Set this matrix to be the identity matrix. + * + * @return this + */ + public abstract Matrix setIdentity(); + + /** + * Invert this matrix + * + * @return this + */ + public abstract Matrix invert(); + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public abstract Matrix load(FloatBuffer buf); + + /** + * Load from a float buffer. The buffer stores the matrix in row major + * (mathematical) order. + * + * @param buf A float buffer to read from + * @return this + */ + public abstract Matrix loadTranspose(FloatBuffer buf); + + /** + * Negate this matrix + * + * @return this + */ + public abstract Matrix negate(); + + /** + * Store this matrix in a float buffer. The matrix is stored in column major + * (openGL) order. + * + * @param buf The buffer to store this matrix in + * @return this + */ + public abstract Matrix store(FloatBuffer buf); + + /** + * Store this matrix in a float buffer. The matrix is stored in row major + * (maths) order. + * + * @param buf The buffer to store this matrix in + * @return this + */ + public abstract Matrix storeTranspose(FloatBuffer buf); + + /** + * Transpose this matrix + * + * @return this + */ + public abstract Matrix transpose(); + + /** + * Set this matrix to 0. + * + * @return this + */ + public abstract Matrix setZero(); + + /** + * @return the determinant of the matrix + */ + public abstract float determinant(); + +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java new file mode 100644 index 0000000..e48997e --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix2f.java @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 2x2 matrix + * + * @author cix_foo + * @version $Revision$ $Id$ + */ + +public class Matrix2f extends Matrix implements Serializable { + + private static final long serialVersionUID = 1L; + + public float m00, m01, m10, m11; + + /** + * Constructor for Matrix2f. The matrix is initialised to the identity. + */ + public Matrix2f() { + setIdentity(); + } + + /** + * Constructor + */ + public Matrix2f(Matrix2f src) { + load(src); + } + + /** + * Load from another matrix + * + * @param src The source matrix + * @return this + */ + public Matrix2f load(Matrix2f src) { + return load(src, this); + } + + /** + * Copy the source matrix to the destination matrix. + * + * @param src The source matrix + * @param dest The destination matrix, or null if a new one should be created. + * @return The copied matrix + */ + public static Matrix2f load(Matrix2f src, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = src.m00; + dest.m01 = src.m01; + dest.m10 = src.m10; + dest.m11 = src.m11; + + return dest; + } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix load(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + + return this; + } + + /** + * Load from a float buffer. The buffer stores the matrix in row major + * (mathematical) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column major + * (openGL) order. + * + * @param buf The buffer to store this matrix in + */ + public Matrix store(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m10); + buf.put(m11); + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in row major + * (maths) order. + * + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m01); + buf.put(m11); + return this; + } + + /** + * Add two matrices together and place the result in a third matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix2f add(Matrix2f left, Matrix2f right, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = left.m00 + right.m00; + dest.m01 = left.m01 + right.m01; + dest.m10 = left.m10 + right.m10; + dest.m11 = left.m11 + right.m11; + + return dest; + } + + /** + * Subtract the right matrix from the left and place the result in a third + * matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix2f sub(Matrix2f left, Matrix2f right, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = left.m00 - right.m00; + dest.m01 = left.m01 - right.m01; + dest.m10 = left.m10 - right.m10; + dest.m11 = left.m11 - right.m11; + + return dest; + } + + /** + * Multiply the right matrix by the left and place the result in a third matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix2f mul(Matrix2f left, Matrix2f right, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + float m00 = left.m00 * right.m00 + left.m10 * right.m01; + float m01 = left.m01 * right.m00 + left.m11 * right.m01; + float m10 = left.m00 * right.m10 + left.m10 * right.m11; + float m11 = left.m01 * right.m10 + left.m11 * right.m11; + + dest.m00 = m00; + dest.m01 = m01; + dest.m10 = m10; + dest.m11 = m11; + + return dest; + } + + /** + * Transform a Vector by a matrix and return the result in a destination vector. + * + * @param left The left matrix + * @param right The right vector + * @param dest The destination vector, or null if a new one is to be created + * @return the destination vector + */ + public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) { + if (dest == null) + dest = new Vector2f(); + + float x = left.m00 * right.x + left.m10 * right.y; + float y = left.m01 * right.x + left.m11 * right.y; + + dest.x = x; + dest.y = y; + + return dest; + } + + /** + * Transpose this matrix + * + * @return this + */ + public Matrix transpose() { + return transpose(this); + } + + /** + * Transpose this matrix and place the result in another matrix. + * + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public Matrix2f transpose(Matrix2f dest) { + return transpose(this, dest); + } + + /** + * Transpose the source matrix and place the result in the destination matrix. + * + * @param src The source matrix or null if a new matrix is to be created + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public static Matrix2f transpose(Matrix2f src, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + float m01 = src.m10; + float m10 = src.m01; + + dest.m01 = m01; + dest.m10 = m10; + + return dest; + } + + /** + * Invert this matrix + * + * @return this if successful, null otherwise + */ + public Matrix invert() { + return invert(this, this); + } + + /** + * Invert the source matrix and place the result in the destination matrix. + * + * @param src The source matrix to be inverted + * @param dest The destination matrix or null if a new matrix is to be created + * @return The inverted matrix, or null if source can't be reverted. + */ + public static Matrix2f invert(Matrix2f src, Matrix2f dest) { + /* + * inv(A) = 1/det(A) * adj(A); + */ + + float determinant = src.determinant(); + if (determinant != 0) { + if (dest == null) + dest = new Matrix2f(); + float determinant_inv = 1f / determinant; + float t00 = src.m11 * determinant_inv; + float t01 = -src.m01 * determinant_inv; + float t11 = src.m00 * determinant_inv; + float t10 = -src.m10 * determinant_inv; + + dest.m00 = t00; + dest.m01 = t01; + dest.m10 = t10; + dest.m11 = t11; + return dest; + } else + return null; + } + + /** + * Returns a string representation of this matrix + */ + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append(m00).append(' ').append(m10).append(' ').append('\n'); + buf.append(m01).append(' ').append(m11).append(' ').append('\n'); + return buf.toString(); + } + + /** + * Negate this matrix + * + * @return this + */ + public Matrix negate() { + return negate(this); + } + + /** + * Negate this matrix and stash the result in another matrix. + * + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public Matrix2f negate(Matrix2f dest) { + return negate(this, dest); + } + + /** + * Negate the source matrix and stash the result in the destination matrix. + * + * @param src The source matrix to be negated + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public static Matrix2f negate(Matrix2f src, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = -src.m00; + dest.m01 = -src.m01; + dest.m10 = -src.m10; + dest.m11 = -src.m11; + + return dest; + } + + /** + * Set this matrix to be the identity matrix. + * + * @return this + */ + public Matrix setIdentity() { + return setIdentity(this); + } + + /** + * Set the source matrix to be the identity matrix. + * + * @param src The matrix to set to the identity. + * @return The source matrix + */ + public static Matrix2f setIdentity(Matrix2f src) { + src.m00 = 1.0f; + src.m01 = 0.0f; + src.m10 = 0.0f; + src.m11 = 1.0f; + return src; + } + + /** + * Set this matrix to 0. + * + * @return this + */ + public Matrix setZero() { + return setZero(this); + } + + public static Matrix2f setZero(Matrix2f src) { + src.m00 = 0.0f; + src.m01 = 0.0f; + src.m10 = 0.0f; + src.m11 = 0.0f; + return src; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Matrix#determinant() + */ + public float determinant() { + return m00 * m11 - m01 * m10; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java new file mode 100644 index 0000000..06ccf59 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix3f.java @@ -0,0 +1,529 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 3x3 matrix. + * + * @author cix_foo + * @version $Revision$ $Id$ + */ + +public class Matrix3f extends Matrix implements Serializable { + + private static final long serialVersionUID = 1L; + + public float m00, m01, m02, m10, m11, m12, m20, m21, m22; + + /** + * Constructor for Matrix3f. Matrix is initialised to the identity. + */ + public Matrix3f() { + super(); + setIdentity(); + } + + /** + * Load from another matrix + * + * @param src The source matrix + * @return this + */ + public Matrix3f load(Matrix3f src) { + return load(src, this); + } + + /** + * Copy source matrix to destination matrix + * + * @param src The source matrix + * @param dest The destination matrix, or null of a new matrix is to be created + * @return The copied matrix + */ + public static Matrix3f load(Matrix3f src, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = src.m00; + dest.m10 = src.m10; + dest.m20 = src.m20; + dest.m01 = src.m01; + dest.m11 = src.m11; + dest.m21 = src.m21; + dest.m02 = src.m02; + dest.m12 = src.m12; + dest.m22 = src.m22; + + return dest; + } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix load(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m02 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); + + return this; + } + + /** + * Load from a float buffer. The buffer stores the matrix in row major (maths) + * order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m20 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column major + * (openGL) order. + * + * @param buf The buffer to store this matrix in + */ + public Matrix store(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m20); + buf.put(m21); + buf.put(m22); + return this; + } + + public Matrix store(float[] buf) { + buf[0] = m00; + buf[1] = m01; + buf[2] = m02; + buf[3] = m10; + buf[4] = m11; + buf[5] = m12; + buf[6] = m20; + buf[7] = m21; + buf[8] = m22; + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in row major + * (maths) order. + * + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m20); + buf.put(m01); + buf.put(m11); + buf.put(m21); + buf.put(m02); + buf.put(m12); + buf.put(m22); + return this; + } + + /** + * Add two matrices together and place the result in a third matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix3f add(Matrix3f left, Matrix3f right, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = left.m00 + right.m00; + dest.m01 = left.m01 + right.m01; + dest.m02 = left.m02 + right.m02; + dest.m10 = left.m10 + right.m10; + dest.m11 = left.m11 + right.m11; + dest.m12 = left.m12 + right.m12; + dest.m20 = left.m20 + right.m20; + dest.m21 = left.m21 + right.m21; + dest.m22 = left.m22 + right.m22; + + return dest; + } + + /** + * Subtract the right matrix from the left and place the result in a third + * matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix3f sub(Matrix3f left, Matrix3f right, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = left.m00 - right.m00; + dest.m01 = left.m01 - right.m01; + dest.m02 = left.m02 - right.m02; + dest.m10 = left.m10 - right.m10; + dest.m11 = left.m11 - right.m11; + dest.m12 = left.m12 - right.m12; + dest.m20 = left.m20 - right.m20; + dest.m21 = left.m21 - right.m21; + dest.m22 = left.m22 - right.m22; + + return dest; + } + + /** + * Multiply the right matrix by the left and place the result in a third matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix3f mul(Matrix3f left, Matrix3f right, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + float m00 = left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02; + float m01 = left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02; + float m02 = left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02; + float m10 = left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12; + float m11 = left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12; + float m12 = left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12; + float m20 = left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22; + float m21 = left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22; + float m22 = left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + + return dest; + } + + /** + * Transform a Vector by a matrix and return the result in a destination vector. + * + * @param left The left matrix + * @param right The right vector + * @param dest The destination vector, or null if a new one is to be created + * @return the destination vector + */ + public static Vector3f transform(Matrix3f left, Vector3f right, Vector3f dest) { + if (dest == null) + dest = new Vector3f(); + + float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z; + float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z; + float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z; + + dest.x = x; + dest.y = y; + dest.z = z; + + return dest; + } + + /** + * Transpose this matrix + * + * @return this + */ + public Matrix transpose() { + return transpose(this, this); + } + + /** + * Transpose this matrix and place the result in another matrix + * + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public Matrix3f transpose(Matrix3f dest) { + return transpose(this, dest); + } + + /** + * Transpose the source matrix and place the result into the destination matrix + * + * @param src The source matrix to be transposed + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public static Matrix3f transpose(Matrix3f src, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + float m00 = src.m00; + float m01 = src.m10; + float m02 = src.m20; + float m10 = src.m01; + float m11 = src.m11; + float m12 = src.m21; + float m20 = src.m02; + float m21 = src.m12; + float m22 = src.m22; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + return dest; + } + + /** + * @return the determinant of the matrix + */ + public float determinant() { + float f = m00 * (m11 * m22 - m12 * m21) + m01 * (m12 * m20 - m10 * m22) + m02 * (m10 * m21 - m11 * m20); + return f; + } + + /** + * Returns a string representation of this matrix + */ + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append('\n'); + buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append('\n'); + buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append('\n'); + return buf.toString(); + } + + /** + * Invert this matrix + * + * @return this if successful, null otherwise + */ + public Matrix invert() { + return invert(this, this); + } + + /** + * Invert the source matrix and put the result into the destination matrix + * + * @param src The source matrix to be inverted + * @param dest The destination matrix, or null if a new one is to be created + * @return The inverted matrix if successful, null otherwise + */ + public static Matrix3f invert(Matrix3f src, Matrix3f dest) { + float determinant = src.determinant(); + + if (determinant != 0) { + if (dest == null) + dest = new Matrix3f(); + /* + * do it the ordinary way + * + * inv(A) = 1/det(A) * adj(T), where adj(T) = transpose(Conjugate Matrix) + * + * m00 m01 m02 m10 m11 m12 m20 m21 m22 + */ + float determinant_inv = 1f / determinant; + + // get the conjugate matrix + float t00 = src.m11 * src.m22 - src.m12 * src.m21; + float t01 = -src.m10 * src.m22 + src.m12 * src.m20; + float t02 = src.m10 * src.m21 - src.m11 * src.m20; + float t10 = -src.m01 * src.m22 + src.m02 * src.m21; + float t11 = src.m00 * src.m22 - src.m02 * src.m20; + float t12 = -src.m00 * src.m21 + src.m01 * src.m20; + float t20 = src.m01 * src.m12 - src.m02 * src.m11; + float t21 = -src.m00 * src.m12 + src.m02 * src.m10; + float t22 = src.m00 * src.m11 - src.m01 * src.m10; + + dest.m00 = t00 * determinant_inv; + dest.m11 = t11 * determinant_inv; + dest.m22 = t22 * determinant_inv; + dest.m01 = t10 * determinant_inv; + dest.m10 = t01 * determinant_inv; + dest.m20 = t02 * determinant_inv; + dest.m02 = t20 * determinant_inv; + dest.m12 = t21 * determinant_inv; + dest.m21 = t12 * determinant_inv; + return dest; + } else + return null; + } + + /** + * Negate this matrix + * + * @return this + */ + public Matrix negate() { + return negate(this); + } + + /** + * Negate this matrix and place the result in a destination matrix. + * + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public Matrix3f negate(Matrix3f dest) { + return negate(this, dest); + } + + /** + * Negate the source matrix and place the result in the destination matrix. + * + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public static Matrix3f negate(Matrix3f src, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = -src.m00; + dest.m01 = -src.m02; + dest.m02 = -src.m01; + dest.m10 = -src.m10; + dest.m11 = -src.m12; + dest.m12 = -src.m11; + dest.m20 = -src.m20; + dest.m21 = -src.m22; + dest.m22 = -src.m21; + return dest; + } + + /** + * Set this matrix to be the identity matrix. + * + * @return this + */ + public Matrix setIdentity() { + return setIdentity(this); + } + + /** + * Set the matrix to be the identity matrix. + * + * @param m The matrix to be set to the identity + * @return m + */ + public static Matrix3f setIdentity(Matrix3f m) { + m.m00 = 1.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m10 = 0.0f; + m.m11 = 1.0f; + m.m12 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 1.0f; + return m; + } + + /** + * Set this matrix to 0. + * + * @return this + */ + public Matrix setZero() { + return setZero(this); + } + + /** + * Set the matrix matrix to 0. + * + * @param m The matrix to be set to 0 + * @return m + */ + public static Matrix3f setZero(Matrix3f m) { + m.m00 = 0.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m10 = 0.0f; + m.m11 = 0.0f; + m.m12 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 0.0f; + return m; + } + + public boolean equals(Object m) { + return (m instanceof Matrix3f) && equal(this, (Matrix3f) m); + } + + public static boolean equal(Matrix3f a, Matrix3f b) { + return a.m00 == b.m00 && a.m01 == b.m01 && a.m02 == b.m02 && a.m10 == b.m10 && a.m11 == b.m11 && a.m12 == b.m12 + && a.m20 == b.m20 && a.m21 == b.m21 && a.m22 == b.m22; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java new file mode 100644 index 0000000..cdca438 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Matrix4f.java @@ -0,0 +1,902 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * Holds a 4x4 float matrix. + * + * @author foo + */ +public class Matrix4f extends Matrix implements Serializable { + private static final long serialVersionUID = 1L; + + public float m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33; + + /** + * Construct a new matrix, initialized to the identity. + */ + public Matrix4f() { + super(); + setIdentity(); + } + + public Matrix4f(final Matrix4f src) { + super(); + load(src); + } + + /** + * Returns a string representation of this matrix + */ + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append(m30).append('\n'); + buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append(m31).append('\n'); + buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append(m32).append('\n'); + buf.append(m03).append(' ').append(m13).append(' ').append(m23).append(' ').append(m33).append('\n'); + return buf.toString(); + } + + /** + * Set this matrix to be the identity matrix. + * + * @return this + */ + public Matrix setIdentity() { + return setIdentity(this); + } + + /** + * Set the given matrix to be the identity matrix. + * + * @param m The matrix to set to the identity + * @return m + */ + public static Matrix4f setIdentity(Matrix4f m) { + m.m00 = 1.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m03 = 0.0f; + m.m10 = 0.0f; + m.m11 = 1.0f; + m.m12 = 0.0f; + m.m13 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 1.0f; + m.m23 = 0.0f; + m.m30 = 0.0f; + m.m31 = 0.0f; + m.m32 = 0.0f; + m.m33 = 1.0f; + + return m; + } + + /** + * Set this matrix to 0. + * + * @return this + */ + public Matrix setZero() { + return setZero(this); + } + + /** + * Set the given matrix to 0. + * + * @param m The matrix to set to 0 + * @return m + */ + public static Matrix4f setZero(Matrix4f m) { + m.m00 = 0.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m03 = 0.0f; + m.m10 = 0.0f; + m.m11 = 0.0f; + m.m12 = 0.0f; + m.m13 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 0.0f; + m.m23 = 0.0f; + m.m30 = 0.0f; + m.m31 = 0.0f; + m.m32 = 0.0f; + m.m33 = 0.0f; + + return m; + } + + /** + * Load from another matrix4f + * + * @param src The source matrix + * @return this + */ + public Matrix4f load(Matrix4f src) { + return load(src, this); + } + + /** + * Copy the source matrix to the destination matrix + * + * @param src The source matrix + * @param dest The destination matrix, or null of a new one is to be created + * @return The copied matrix + */ + public static Matrix4f load(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + dest.m00 = src.m00; + dest.m01 = src.m01; + dest.m02 = src.m02; + dest.m03 = src.m03; + dest.m10 = src.m10; + dest.m11 = src.m11; + dest.m12 = src.m12; + dest.m13 = src.m13; + dest.m20 = src.m20; + dest.m21 = src.m21; + dest.m22 = src.m22; + dest.m23 = src.m23; + dest.m30 = src.m30; + dest.m31 = src.m31; + dest.m32 = src.m32; + dest.m33 = src.m33; + + return dest; + } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix load(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m02 = buf.get(); + m03 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); + m13 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); + m23 = buf.get(); + m30 = buf.get(); + m31 = buf.get(); + m32 = buf.get(); + m33 = buf.get(); + + return this; + } + + /** + * Load from a float buffer. The buffer stores the matrix in row major (maths) + * order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m20 = buf.get(); + m30 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); + m31 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); + m32 = buf.get(); + m03 = buf.get(); + m13 = buf.get(); + m23 = buf.get(); + m33 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column major + * (openGL) order. + * + * @param buf The buffer to store this matrix in + */ + public Matrix store(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m03); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m13); + buf.put(m20); + buf.put(m21); + buf.put(m22); + buf.put(m23); + buf.put(m30); + buf.put(m31); + buf.put(m32); + buf.put(m33); + return this; + } + + public Matrix store(float[] buf) { + buf[0] = m00; + buf[1] = m01; + buf[2] = m02; + buf[3] = m03; + buf[4] = m10; + buf[5] = m11; + buf[6] = m12; + buf[7] = m13; + buf[8] = m20; + buf[9] = m21; + buf[10] = m22; + buf[11] = m23; + buf[12] = m30; + buf[13] = m31; + buf[14] = m32; + buf[15] = m33; + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in row major + * (maths) order. + * + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m20); + buf.put(m30); + buf.put(m01); + buf.put(m11); + buf.put(m21); + buf.put(m31); + buf.put(m02); + buf.put(m12); + buf.put(m22); + buf.put(m32); + buf.put(m03); + buf.put(m13); + buf.put(m23); + buf.put(m33); + return this; + } + + /** + * Store the rotation portion of this matrix in a float buffer. The matrix is + * stored in column major (openGL) order. + * + * @param buf The buffer to store this matrix in + */ + public Matrix store3f(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m20); + buf.put(m21); + buf.put(m22); + return this; + } + + /** + * Add two matrices together and place the result in a third matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix4f add(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = left.m00 + right.m00; + dest.m01 = left.m01 + right.m01; + dest.m02 = left.m02 + right.m02; + dest.m03 = left.m03 + right.m03; + dest.m10 = left.m10 + right.m10; + dest.m11 = left.m11 + right.m11; + dest.m12 = left.m12 + right.m12; + dest.m13 = left.m13 + right.m13; + dest.m20 = left.m20 + right.m20; + dest.m21 = left.m21 + right.m21; + dest.m22 = left.m22 + right.m22; + dest.m23 = left.m23 + right.m23; + dest.m30 = left.m30 + right.m30; + dest.m31 = left.m31 + right.m31; + dest.m32 = left.m32 + right.m32; + dest.m33 = left.m33 + right.m33; + + return dest; + } + + /** + * Subtract the right matrix from the left and place the result in a third + * matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix4f sub(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = left.m00 - right.m00; + dest.m01 = left.m01 - right.m01; + dest.m02 = left.m02 - right.m02; + dest.m03 = left.m03 - right.m03; + dest.m10 = left.m10 - right.m10; + dest.m11 = left.m11 - right.m11; + dest.m12 = left.m12 - right.m12; + dest.m13 = left.m13 - right.m13; + dest.m20 = left.m20 - right.m20; + dest.m21 = left.m21 - right.m21; + dest.m22 = left.m22 - right.m22; + dest.m23 = left.m23 - right.m23; + dest.m30 = left.m30 - right.m30; + dest.m31 = left.m31 - right.m31; + dest.m32 = left.m32 - right.m32; + dest.m33 = left.m33 - right.m33; + + return dest; + } + + /** + * Multiply the right matrix by the left and place the result in a third matrix. + * + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix4f mul(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + float m00 = left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02 + left.m30 * right.m03; + float m01 = left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02 + left.m31 * right.m03; + float m02 = left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02 + left.m32 * right.m03; + float m03 = left.m03 * right.m00 + left.m13 * right.m01 + left.m23 * right.m02 + left.m33 * right.m03; + float m10 = left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12 + left.m30 * right.m13; + float m11 = left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12 + left.m31 * right.m13; + float m12 = left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12 + left.m32 * right.m13; + float m13 = left.m03 * right.m10 + left.m13 * right.m11 + left.m23 * right.m12 + left.m33 * right.m13; + float m20 = left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22 + left.m30 * right.m23; + float m21 = left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22 + left.m31 * right.m23; + float m22 = left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22 + left.m32 * right.m23; + float m23 = left.m03 * right.m20 + left.m13 * right.m21 + left.m23 * right.m22 + left.m33 * right.m23; + float m30 = left.m00 * right.m30 + left.m10 * right.m31 + left.m20 * right.m32 + left.m30 * right.m33; + float m31 = left.m01 * right.m30 + left.m11 * right.m31 + left.m21 * right.m32 + left.m31 * right.m33; + float m32 = left.m02 * right.m30 + left.m12 * right.m31 + left.m22 * right.m32 + left.m32 * right.m33; + float m33 = left.m03 * right.m30 + left.m13 * right.m31 + left.m23 * right.m32 + left.m33 * right.m33; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m03 = m03; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m13 = m13; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + dest.m23 = m23; + dest.m30 = m30; + dest.m31 = m31; + dest.m32 = m32; + dest.m33 = m33; + + return dest; + } + + /** + * Transform a Vector by a matrix and return the result in a destination vector. + * + * @param left The left matrix + * @param right The right vector + * @param dest The destination vector, or null if a new one is to be created + * @return the destination vector + */ + public static Vector4f transform(Matrix4f left, Vector4f right, Vector4f dest) { + if (dest == null) + dest = new Vector4f(); + + float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z + left.m30 * right.w; + float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z + left.m31 * right.w; + float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z + left.m32 * right.w; + float w = left.m03 * right.x + left.m13 * right.y + left.m23 * right.z + left.m33 * right.w; + + dest.x = x; + dest.y = y; + dest.z = z; + dest.w = w; + + return dest; + } + + /** + * Transpose this matrix + * + * @return this + */ + public Matrix transpose() { + return transpose(this); + } + + /** + * Translate this matrix + * + * @param vec The vector to translate by + * @return this + */ + public Matrix4f translate(Vector2f vec) { + return translate(vec, this); + } + + /** + * Translate this matrix + * + * @param vec The vector to translate by + * @return this + */ + public Matrix4f translate(Vector3f vec) { + return translate(vec, this); + } + + /** + * Scales this matrix + * + * @param vec The vector to scale by + * @return this + */ + public Matrix4f scale(Vector3f vec) { + return scale(vec, this, this); + } + + /** + * Scales the source matrix and put the result in the destination matrix + * + * @param vec The vector to scale by + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return The scaled matrix + */ + public static Matrix4f scale(Vector3f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + dest.m00 = src.m00 * vec.x; + dest.m01 = src.m01 * vec.x; + dest.m02 = src.m02 * vec.x; + dest.m03 = src.m03 * vec.x; + dest.m10 = src.m10 * vec.y; + dest.m11 = src.m11 * vec.y; + dest.m12 = src.m12 * vec.y; + dest.m13 = src.m13 * vec.y; + dest.m20 = src.m20 * vec.z; + dest.m21 = src.m21 * vec.z; + dest.m22 = src.m22 * vec.z; + dest.m23 = src.m23 * vec.z; + return dest; + } + + /** + * Rotates the matrix around the given axis the specified angle + * + * @param angle the angle, in radians. + * @param axis The vector representing the rotation axis. Must be normalized. + * @return this + */ + public Matrix4f rotate(float angle, Vector3f axis) { + return rotate(angle, axis, this); + } + + /** + * Rotates the matrix around the given axis the specified angle + * + * @param angle the angle, in radians. + * @param axis The vector representing the rotation axis. Must be normalized. + * @param dest The matrix to put the result, or null if a new matrix is to be + * created + * @return The rotated matrix + */ + public Matrix4f rotate(float angle, Vector3f axis, Matrix4f dest) { + return rotate(angle, axis, this, dest); + } + + /** + * Rotates the source matrix around the given axis the specified angle and put + * the result in the destination matrix. + * + * @param angle the angle, in radians. + * @param axis The vector representing the rotation axis. Must be normalized. + * @param src The matrix to rotate + * @param dest The matrix to put the result, or null if a new matrix is to be + * created + * @return The rotated matrix + */ + public static Matrix4f rotate(float angle, Vector3f axis, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + float c = (float) Math.cos(angle); + float s = (float) Math.sin(angle); + float oneminusc = 1.0f - c; + float xy = axis.x * axis.y; + float yz = axis.y * axis.z; + float xz = axis.x * axis.z; + float xs = axis.x * s; + float ys = axis.y * s; + float zs = axis.z * s; + + float f00 = axis.x * axis.x * oneminusc + c; + float f01 = xy * oneminusc + zs; + float f02 = xz * oneminusc - ys; + // n[3] not used + float f10 = xy * oneminusc - zs; + float f11 = axis.y * axis.y * oneminusc + c; + float f12 = yz * oneminusc + xs; + // n[7] not used + float f20 = xz * oneminusc + ys; + float f21 = yz * oneminusc - xs; + float f22 = axis.z * axis.z * oneminusc + c; + + float t00 = src.m00 * f00 + src.m10 * f01 + src.m20 * f02; + float t01 = src.m01 * f00 + src.m11 * f01 + src.m21 * f02; + float t02 = src.m02 * f00 + src.m12 * f01 + src.m22 * f02; + float t03 = src.m03 * f00 + src.m13 * f01 + src.m23 * f02; + float t10 = src.m00 * f10 + src.m10 * f11 + src.m20 * f12; + float t11 = src.m01 * f10 + src.m11 * f11 + src.m21 * f12; + float t12 = src.m02 * f10 + src.m12 * f11 + src.m22 * f12; + float t13 = src.m03 * f10 + src.m13 * f11 + src.m23 * f12; + dest.m20 = src.m00 * f20 + src.m10 * f21 + src.m20 * f22; + dest.m21 = src.m01 * f20 + src.m11 * f21 + src.m21 * f22; + dest.m22 = src.m02 * f20 + src.m12 * f21 + src.m22 * f22; + dest.m23 = src.m03 * f20 + src.m13 * f21 + src.m23 * f22; + dest.m00 = t00; + dest.m01 = t01; + dest.m02 = t02; + dest.m03 = t03; + dest.m10 = t10; + dest.m11 = t11; + dest.m12 = t12; + dest.m13 = t13; + return dest; + } + + /** + * Translate this matrix and stash the result in another matrix + * + * @param vec The vector to translate by + * @param dest The destination matrix or null if a new matrix is to be created + * @return the translated matrix + */ + public Matrix4f translate(Vector3f vec, Matrix4f dest) { + return translate(vec, this, dest); + } + + /** + * Translate the source matrix and stash the result in the destination matrix + * + * @param vec The vector to translate by + * @param src The source matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return The translated matrix + */ + public static Matrix4f translate(Vector3f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m30 += src.m00 * vec.x + src.m10 * vec.y + src.m20 * vec.z; + dest.m31 += src.m01 * vec.x + src.m11 * vec.y + src.m21 * vec.z; + dest.m32 += src.m02 * vec.x + src.m12 * vec.y + src.m22 * vec.z; + dest.m33 += src.m03 * vec.x + src.m13 * vec.y + src.m23 * vec.z; + + return dest; + } + + /** + * Translate this matrix and stash the result in another matrix + * + * @param vec The vector to translate by + * @param dest The destination matrix or null if a new matrix is to be created + * @return the translated matrix + */ + public Matrix4f translate(Vector2f vec, Matrix4f dest) { + return translate(vec, this, dest); + } + + /** + * Translate the source matrix and stash the result in the destination matrix + * + * @param vec The vector to translate by + * @param src The source matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return The translated matrix + */ + public static Matrix4f translate(Vector2f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m30 += src.m00 * vec.x + src.m10 * vec.y; + dest.m31 += src.m01 * vec.x + src.m11 * vec.y; + dest.m32 += src.m02 * vec.x + src.m12 * vec.y; + dest.m33 += src.m03 * vec.x + src.m13 * vec.y; + + return dest; + } + + /** + * Transpose this matrix and place the result in another matrix + * + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public Matrix4f transpose(Matrix4f dest) { + return transpose(this, dest); + } + + /** + * Transpose the source matrix and place the result in the destination matrix + * + * @param src The source matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public static Matrix4f transpose(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + float m00 = src.m00; + float m01 = src.m10; + float m02 = src.m20; + float m03 = src.m30; + float m10 = src.m01; + float m11 = src.m11; + float m12 = src.m21; + float m13 = src.m31; + float m20 = src.m02; + float m21 = src.m12; + float m22 = src.m22; + float m23 = src.m32; + float m30 = src.m03; + float m31 = src.m13; + float m32 = src.m23; + float m33 = src.m33; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m03 = m03; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m13 = m13; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + dest.m23 = m23; + dest.m30 = m30; + dest.m31 = m31; + dest.m32 = m32; + dest.m33 = m33; + + return dest; + } + + /** + * @return the determinant of the matrix + */ + public float determinant() { + float f = m00 * ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32) - m13 * m22 * m31 - m11 * m23 * m32 + - m12 * m21 * m33); + f -= m01 * ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32) - m13 * m22 * m30 - m10 * m23 * m32 + - m12 * m20 * m33); + f += m02 * ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31) - m13 * m21 * m30 - m10 * m23 * m31 + - m11 * m20 * m33); + f -= m03 * ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31) - m12 * m21 * m30 - m10 * m22 * m31 + - m11 * m20 * m32); + return f; + } + + /** + * Calculate the determinant of a 3x3 matrix + * + * @return result + */ + + private static float determinant3x3(float t00, float t01, float t02, float t10, float t11, float t12, float t20, + float t21, float t22) { + return t00 * (t11 * t22 - t12 * t21) + t01 * (t12 * t20 - t10 * t22) + t02 * (t10 * t21 - t11 * t20); + } + + /** + * Invert this matrix + * + * @return this if successful, null otherwise + */ + public Matrix invert() { + return invert(this, this); + } + + /** + * Invert the source matrix and put the result in the destination + * + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return The inverted matrix if successful, null otherwise + */ + public static Matrix4f invert(Matrix4f src, Matrix4f dest) { + float determinant = src.determinant(); + + if (determinant != 0) { + /* + * m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33 + */ + if (dest == null) + dest = new Matrix4f(); + float determinant_inv = 1f / determinant; + + // first row + float t00 = determinant3x3(src.m11, src.m12, src.m13, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33); + float t01 = -determinant3x3(src.m10, src.m12, src.m13, src.m20, src.m22, src.m23, src.m30, src.m32, + src.m33); + float t02 = determinant3x3(src.m10, src.m11, src.m13, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33); + float t03 = -determinant3x3(src.m10, src.m11, src.m12, src.m20, src.m21, src.m22, src.m30, src.m31, + src.m32); + // second row + float t10 = -determinant3x3(src.m01, src.m02, src.m03, src.m21, src.m22, src.m23, src.m31, src.m32, + src.m33); + float t11 = determinant3x3(src.m00, src.m02, src.m03, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33); + float t12 = -determinant3x3(src.m00, src.m01, src.m03, src.m20, src.m21, src.m23, src.m30, src.m31, + src.m33); + float t13 = determinant3x3(src.m00, src.m01, src.m02, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32); + // third row + float t20 = determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m31, src.m32, src.m33); + float t21 = -determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m30, src.m32, + src.m33); + float t22 = determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m30, src.m31, src.m33); + float t23 = -determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m30, src.m31, + src.m32); + // fourth row + float t30 = -determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m21, src.m22, + src.m23); + float t31 = determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m20, src.m22, src.m23); + float t32 = -determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m20, src.m21, + src.m23); + float t33 = determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m20, src.m21, src.m22); + + // transpose and divide by the determinant + dest.m00 = t00 * determinant_inv; + dest.m11 = t11 * determinant_inv; + dest.m22 = t22 * determinant_inv; + dest.m33 = t33 * determinant_inv; + dest.m01 = t10 * determinant_inv; + dest.m10 = t01 * determinant_inv; + dest.m20 = t02 * determinant_inv; + dest.m02 = t20 * determinant_inv; + dest.m12 = t21 * determinant_inv; + dest.m21 = t12 * determinant_inv; + dest.m03 = t30 * determinant_inv; + dest.m30 = t03 * determinant_inv; + dest.m13 = t31 * determinant_inv; + dest.m31 = t13 * determinant_inv; + dest.m32 = t23 * determinant_inv; + dest.m23 = t32 * determinant_inv; + return dest; + } else + return null; + } + + /** + * Negate this matrix + * + * @return this + */ + public Matrix negate() { + return negate(this); + } + + /** + * Negate this matrix and place the result in a destination matrix. + * + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public Matrix4f negate(Matrix4f dest) { + return negate(this, dest); + } + + /** + * Negate this matrix and place the result in a destination matrix. + * + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return The negated matrix + */ + public static Matrix4f negate(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = -src.m00; + dest.m01 = -src.m01; + dest.m02 = -src.m02; + dest.m03 = -src.m03; + dest.m10 = -src.m10; + dest.m11 = -src.m11; + dest.m12 = -src.m12; + dest.m13 = -src.m13; + dest.m20 = -src.m20; + dest.m21 = -src.m21; + dest.m22 = -src.m22; + dest.m23 = -src.m23; + dest.m30 = -src.m30; + dest.m31 = -src.m31; + dest.m32 = -src.m32; + dest.m33 = -src.m33; + + return dest; + } + + public boolean equals(Object m) { + return (m instanceof Matrix4f) && equal(this, (Matrix4f) m); + } + + public static boolean equal(Matrix4f a, Matrix4f b) { + return a.m00 == b.m00 && a.m01 == b.m01 && a.m02 == b.m02 && a.m03 == b.m03 && a.m10 == b.m10 && a.m11 == b.m11 + && a.m12 == b.m12 && a.m13 == b.m13 && a.m20 == b.m20 && a.m21 == b.m21 && a.m22 == b.m22 + && a.m23 == b.m23 && a.m30 == b.m30 && a.m31 == b.m31 && a.m32 == b.m32 && a.m33 == b.m33; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Quaternion.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Quaternion.java new file mode 100644 index 0000000..663448f --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Quaternion.java @@ -0,0 +1,506 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +/** + * + * Quaternions for LWJGL! + * + * @author fbi + * @version $Revision$ + * $Id$ + */ + +import java.nio.FloatBuffer; + +public class Quaternion extends Vector implements ReadableVector4f { + private static final long serialVersionUID = 1L; + + public float x, y, z, w; + + /** + * C'tor. The quaternion will be initialized to the identity. + */ + public Quaternion() { + super(); + setIdentity(); + } + + /** + * C'tor + * + * @param src + */ + public Quaternion(ReadableVector4f src) { + set(src); + } + + /** + * C'tor + * + */ + public Quaternion(float x, float y, float z, float w) { + set(x, y, z, w); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) + */ + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float, float) + */ + public void set(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** + * Load from another Vector4f + * + * @param src The source vector + * @return this + */ + public Quaternion set(ReadableVector4f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + w = src.getW(); + return this; + } + + /** + * Set this quaternion to the multiplication identity. + * + * @return this + */ + public Quaternion setIdentity() { + return setIdentity(this); + } + + /** + * Set the given quaternion to the multiplication identity. + * + * @param q The quaternion + * @return q + */ + public static Quaternion setIdentity(Quaternion q) { + q.x = 0; + q.y = 0; + q.z = 0; + q.w = 1; + return q; + } + + /** + * @return the length squared of the quaternion + */ + public float lengthSquared() { + return x * x + y * y + z * z + w * w; + } + + /** + * Normalise the source quaternion and place the result in another quaternion. + * + * @param src The source quaternion + * @param dest The destination quaternion, or null if a new quaternion is to be + * created + * @return The normalised quaternion + */ + public static Quaternion normalise(Quaternion src, Quaternion dest) { + float inv_l = 1f / src.length(); + + if (dest == null) + dest = new Quaternion(); + + dest.set(src.x * inv_l, src.y * inv_l, src.z * inv_l, src.w * inv_l); + + return dest; + } + + /** + * Normalise this quaternion and place the result in another quaternion. + * + * @param dest The destination quaternion, or null if a new quaternion is to be + * created + * @return the normalised quaternion + */ + public Quaternion normalise(Quaternion dest) { + return normalise(this, dest); + } + + /** + * The dot product of two quaternions + * + * @param left The LHS quat + * @param right The RHS quat + * @return left dot right + */ + public static float dot(Quaternion left, Quaternion right) { + return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; + } + + /** + * Calculate the conjugate of this quaternion and put it into the given one + * + * @param dest The quaternion which should be set to the conjugate of this + * quaternion + */ + public Quaternion negate(Quaternion dest) { + return negate(this, dest); + } + + /** + * Calculate the conjugate of this quaternion and put it into the given one + * + * @param src The source quaternion + * @param dest The quaternion which should be set to the conjugate of this + * quaternion + */ + public static Quaternion negate(Quaternion src, Quaternion dest) { + if (dest == null) + dest = new Quaternion(); + + dest.x = -src.x; + dest.y = -src.y; + dest.z = -src.z; + dest.w = src.w; + + return dest; + } + + /** + * Calculate the conjugate of this quaternion + */ + public Vector negate() { + return negate(this, this); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.Vector#load(java.nio.FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + w = buf.get(); + return this; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + return scale(scale, this, this); + } + + /** + * Scale the source quaternion by scale and put the result in the destination + * + * @param scale The amount to scale by + * @param src The source quaternion + * @param dest The destination quaternion, or null if a new quaternion is to be + * created + * @return The scaled quaternion + */ + public static Quaternion scale(float scale, Quaternion src, Quaternion dest) { + if (dest == null) + dest = new Quaternion(); + dest.x = src.x * scale; + dest.y = src.y * scale; + dest.z = src.z * scale; + dest.w = src.w * scale; + return dest; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.ReadableVector#store(java.nio.FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + buf.put(x); + buf.put(y); + buf.put(z); + buf.put(w); + + return this; + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * + * @param y + */ + public final void setY(float y) { + this.y = y; + } + + /** + * Set Z + * + * @param z + */ + public void setZ(float z) { + this.z = z; + } + + /* + * (Overrides) + * + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getZ() { + return z; + } + + /** + * Set W + * + * @param w + */ + public void setW(float w) { + this.w = w; + } + + /* + * (Overrides) + * + * @see org.lwjgl.vector.ReadableVector3f#getW() + */ + public float getW() { + return w; + } + + public String toString() { + return "Quaternion: " + x + " " + y + " " + z + " " + w; + } + + /** + * Sets the value of this quaternion to the quaternion product of quaternions + * left and right (this = left * right). Note that this is safe for aliasing + * (e.g. this can be left or right). + * + * @param left the first quaternion + * @param right the second quaternion + */ + public static Quaternion mul(Quaternion left, Quaternion right, Quaternion dest) { + if (dest == null) + dest = new Quaternion(); + dest.set(left.x * right.w + left.w * right.x + left.y * right.z - left.z * right.y, + left.y * right.w + left.w * right.y + left.z * right.x - left.x * right.z, + left.z * right.w + left.w * right.z + left.x * right.y - left.y * right.x, + left.w * right.w - left.x * right.x - left.y * right.y - left.z * right.z); + return dest; + } + + /** + * + * Multiplies quaternion left by the inverse of quaternion right and places the + * value into this quaternion. The value of both argument quaternions is + * preservered (this = left * right^-1). + * + * @param left the left quaternion + * @param right the right quaternion + */ + public static Quaternion mulInverse(Quaternion left, Quaternion right, Quaternion dest) { + float n = right.lengthSquared(); + // zero-div may occur. + n = (n == 0.0 ? n : 1 / n); + // store on stack once for aliasing-safty + if (dest == null) + dest = new Quaternion(); + dest.set((left.x * right.w - left.w * right.x - left.y * right.z + left.z * right.y) * n, + (left.y * right.w - left.w * right.y - left.z * right.x + left.x * right.z) * n, + (left.z * right.w - left.w * right.z - left.x * right.y + left.y * right.x) * n, + (left.w * right.w + left.x * right.x + left.y * right.y + left.z * right.z) * n); + + return dest; + } + + /** + * Sets the value of this quaternion to the equivalent rotation of the + * Axis-Angle argument. + * + * @param a1 the axis-angle: (x,y,z) is the axis and w is the angle + */ + public final void setFromAxisAngle(Vector4f a1) { + x = a1.x; + y = a1.y; + z = a1.z; + float n = (float) Math.sqrt(x * x + y * y + z * z); + // zero-div may occur. + float s = (float) (Math.sin(0.5 * a1.w) / n); + x *= s; + y *= s; + z *= s; + w = (float) Math.cos(0.5 * a1.w); + } + + /** + * Sets the value of this quaternion using the rotational component of the + * passed matrix. + * + * @param m The matrix + * @return this + */ + public final Quaternion setFromMatrix(Matrix4f m) { + return setFromMatrix(m, this); + } + + /** + * Sets the value of the source quaternion using the rotational component of the + * passed matrix. + * + * @param m The source matrix + * @param q The destination quaternion, or null if a new quaternion is to be + * created + * @return q + */ + public static Quaternion setFromMatrix(Matrix4f m, Quaternion q) { + return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, m.m21, m.m22); + } + + /** + * Sets the value of this quaternion using the rotational component of the + * passed matrix. + * + * @param m The source matrix + */ + public final Quaternion setFromMatrix(Matrix3f m) { + return setFromMatrix(m, this); + } + + /** + * Sets the value of the source quaternion using the rotational component of the + * passed matrix. + * + * @param m The source matrix + * @param q The destination quaternion, or null if a new quaternion is to be + * created + * @return q + */ + public static Quaternion setFromMatrix(Matrix3f m, Quaternion q) { + return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, m.m21, m.m22); + } + + /** + * Private method to perform the matrix-to-quaternion conversion + */ + private Quaternion setFromMat(float m00, float m01, float m02, float m10, float m11, float m12, float m20, + float m21, float m22) { + + float s; + float tr = m00 + m11 + m22; + if (tr >= 0.0) { + s = (float) Math.sqrt(tr + 1.0); + w = s * 0.5f; + s = 0.5f / s; + x = (m21 - m12) * s; + y = (m02 - m20) * s; + z = (m10 - m01) * s; + } else { + float max = Math.max(Math.max(m00, m11), m22); + if (max == m00) { + s = (float) Math.sqrt(m00 - (m11 + m22) + 1.0); + x = s * 0.5f; + s = 0.5f / s; + y = (m01 + m10) * s; + z = (m20 + m02) * s; + w = (m21 - m12) * s; + } else if (max == m11) { + s = (float) Math.sqrt(m11 - (m22 + m00) + 1.0); + y = s * 0.5f; + s = 0.5f / s; + z = (m12 + m21) * s; + x = (m01 + m10) * s; + w = (m02 - m20) * s; + } else { + s = (float) Math.sqrt(m22 - (m00 + m11) + 1.0); + z = s * 0.5f; + s = 0.5f / s; + x = (m20 + m02) * s; + y = (m12 + m21) * s; + w = (m10 - m01) * s; + } + } + return this; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java new file mode 100644 index 0000000..e72d312 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.nio.FloatBuffer; + +/** + * @author foo + */ +public interface ReadableVector { + /** + * @return the length of the vector + */ + float length(); + + /** + * @return the length squared of the vector + */ + float lengthSquared(); + + /** + * Store this vector in a FloatBuffer + * + * @param buf The buffer to store it in, at the current position + * @return this + */ + Vector store(FloatBuffer buf); +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java new file mode 100644 index 0000000..f857c6f --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +/** + * @author foo + */ +public interface ReadableVector2f extends ReadableVector { + /** + * @return x + */ + float getX(); + + /** + * @return y + */ + float getY(); +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java new file mode 100644 index 0000000..6eae2ec --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +/** + * @author foo + */ +public interface ReadableVector3f extends ReadableVector2f { + /** + * @return z + */ + float getZ(); +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java new file mode 100644 index 0000000..feedc20 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +/** + * @author foo + */ +public interface ReadableVector4f extends ReadableVector3f { + + /** + * @return w + */ + float getW(); + +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector.java new file mode 100644 index 0000000..61dfb43 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Base class for vectors. + * + * @author cix_foo + * @version $Revision$ $Id$ + */ +public abstract class Vector implements Serializable, ReadableVector { + + /** + * Constructor for Vector. + */ + protected Vector() { + super(); + } + + /** + * @return the length of the vector + */ + public final float length() { + return (float) Math.sqrt(lengthSquared()); + } + + /** + * @return the length squared of the vector + */ + public abstract float lengthSquared(); + + /** + * Load this vector from a FloatBuffer + * + * @param buf The buffer to load it from, at the current position + * @return this + */ + public abstract Vector load(FloatBuffer buf); + + /** + * Negate a vector + * + * @return this + */ + public abstract Vector negate(); + + /** + * Normalise this vector + * + * @return this + */ + public final Vector normalise() { + float len = length(); + if (len != 0.0f) { + float l = 1.0f / len; + return scale(l); + } else + throw new IllegalStateException("Zero length vector"); + } + + /** + * Store this vector in a FloatBuffer + * + * @param buf The buffer to store it in, at the current position + * @return this + */ + public abstract Vector store(FloatBuffer buf); + + /** + * Scale this vector + * + * @param scale The scale factor + * @return this + */ + public abstract Vector scale(float scale); + +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector2f.java new file mode 100644 index 0000000..4201c7a --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector2f.java @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 2-tuple vector. + * + * @author cix_foo + * @version $Revision$ $Id$ + */ + +public class Vector2f extends Vector implements Serializable, ReadableVector2f, WritableVector2f { + + private static final long serialVersionUID = 1L; + + public float x, y; + + /** + * Constructor for Vector2f. + */ + public Vector2f() { + super(); + } + + /** + * Constructor. + */ + public Vector2f(ReadableVector2f src) { + set(src); + } + + /** + * Constructor. + */ + public Vector2f(float x, float y) { + set(x, y); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /** + * Load from another Vector2f + * + * @param src The source vector + * @return this + */ + public Vector2f set(ReadableVector2f src) { + x = src.getX(); + y = src.getY(); + return this; + } + + /** + * @return the length squared of the vector + */ + public float lengthSquared() { + return x * x + y * y; + } + + /** + * Translate a vector + * + * @param x The translation in x + * @param y the translation in y + * @return this + */ + public Vector2f translate(float x, float y) { + this.x += x; + this.y += y; + return this; + } + + /** + * Negate a vector + * + * @return this + */ + public Vector negate() { + x = -x; + y = -y; + return this; + } + + /** + * Negate a vector and place the result in a destination vector. + * + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector + */ + public Vector2f negate(Vector2f dest) { + if (dest == null) + dest = new Vector2f(); + dest.x = -x; + dest.y = -y; + return dest; + } + + /** + * Normalise this vector and place the result in another vector. + * + * @param dest The destination vector, or null if a new vector is to be created + * @return the normalised vector + */ + public Vector2f normalise(Vector2f dest) { + float l = length(); + + if (dest == null) + dest = new Vector2f(x / l, y / l); + else + dest.set(x / l, y / l); + + return dest; + } + + /** + * The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + + * v1.z * v2.z + * + * @param left The LHS vector + * @param right The RHS vector + * @return left dot right + */ + public static float dot(Vector2f left, Vector2f right) { + return left.x * right.x + left.y * right.y; + } + + /** + * Calculate the angle between two vectors, in radians + * + * @param a A vector + * @param b The other vector + * @return the angle between the two vectors, in radians + */ + public static float angle(Vector2f a, Vector2f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float) Math.acos(dls); + } + + /** + * Add a vector to another vector and place the result in a destination vector. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector2f add(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x + right.x, left.y + right.y); + else { + dest.set(left.x + right.x, left.y + right.y); + return dest; + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector2f sub(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x - right.x, left.y - right.y); + else { + dest.set(left.x - right.x, left.y - right.y); + return dest; + } + } + + /** + * Store this vector in a FloatBuffer + * + * @param buf The buffer to store it in, at the current position + * @return this + */ + public Vector store(FloatBuffer buf) { + buf.put(x); + buf.put(y); + return this; + } + + /** + * Load this vector from a FloatBuffer + * + * @param buf The buffer to load it from, at the current position + * @return this + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + return this; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + + x *= scale; + y *= scale; + + return this; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuilder sb = new StringBuilder(64); + + sb.append("Vector2f["); + sb.append(x); + sb.append(", "); + sb.append(y); + sb.append(']'); + return sb.toString(); + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * + * @param y + */ + public final void setY(float y) { + this.y = y; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Vector2f other = (Vector2f) obj; + + if (x == other.x && y == other.y) + return true; + + return false; + } + +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector3f.java new file mode 100644 index 0000000..282170f --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector3f.java @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 3-tuple vector. + * + * @author cix_foo + * @version $Revision$ $Id$ + */ + +public class Vector3f extends Vector implements Serializable, ReadableVector3f, WritableVector3f { + + private static final long serialVersionUID = 1L; + + public float x, y, z; + + /** + * Constructor for Vector3f. + */ + public Vector3f() { + super(); + } + + /** + * Constructor + */ + public Vector3f(ReadableVector3f src) { + set(src); + } + + /** + * Constructor + */ + public Vector3f(float x, float y, float z) { + set(x, y, z); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) + */ + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Load from another Vector3f + * + * @param src The source vector + * @return this + */ + public Vector3f set(ReadableVector3f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + return this; + } + + /** + * @return the length squared of the vector + */ + public float lengthSquared() { + return x * x + y * y + z * z; + } + + /** + * Translate a vector + * + * @param x The translation in x + * @param y the translation in y + * @return this + */ + public Vector3f translate(float x, float y, float z) { + this.x += x; + this.y += y; + this.z += z; + return this; + } + + /** + * Add a vector to another vector and place the result in a destination vector. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x + right.x, left.y + right.y, left.z + right.z); + else { + dest.set(left.x + right.x, left.y + right.y, left.z + right.z); + return dest; + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector3f sub(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x - right.x, left.y - right.y, left.z - right.z); + else { + dest.set(left.x - right.x, left.y - right.y, left.z - right.z); + return dest; + } + } + + /** + * The cross product of two vectors. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination result, or null if a new vector is to be created + * @return left cross right + */ + public static Vector3f cross(Vector3f left, Vector3f right, Vector3f dest) { + + if (dest == null) + dest = new Vector3f(); + + dest.set(left.y * right.z - left.z * right.y, right.x * left.z - right.z * left.x, + left.x * right.y - left.y * right.x); + + return dest; + } + + /** + * Negate a vector + * + * @return this + */ + public Vector negate() { + x = -x; + y = -y; + z = -z; + return this; + } + + /** + * Negate a vector and place the result in a destination vector. + * + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector + */ + public Vector3f negate(Vector3f dest) { + if (dest == null) + dest = new Vector3f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + return dest; + } + + /** + * Normalise this vector and place the result in another vector. + * + * @param dest The destination vector, or null if a new vector is to be created + * @return the normalised vector + */ + public Vector3f normalise(Vector3f dest) { + float l = length(); + + if (dest == null) + dest = new Vector3f(x / l, y / l, z / l); + else + dest.set(x / l, y / l, z / l); + + return dest; + } + + /** + * The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + + * v1.z * v2.z + * + * @param left The LHS vector + * @param right The RHS vector + * @return left dot right + */ + public static float dot(Vector3f left, Vector3f right) { + return left.x * right.x + left.y * right.y + left.z * right.z; + } + + /** + * Calculate the angle between two vectors, in radians + * + * @param a A vector + * @param b The other vector + * @return the angle between the two vectors, in radians + */ + public static float angle(Vector3f a, Vector3f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float) Math.acos(dls); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#load(FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + return this; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + + x *= scale; + y *= scale; + z *= scale; + + return this; + + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#store(FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + + return this; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuilder sb = new StringBuilder(64); + + sb.append("Vector3f["); + sb.append(x); + sb.append(", "); + sb.append(y); + sb.append(", "); + sb.append(z); + sb.append(']'); + return sb.toString(); + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * + * @param y + */ + public final void setY(float y) { + this.y = y; + } + + /** + * Set Z + * + * @param z + */ + public void setZ(float z) { + this.z = z; + } + + /* + * (Overrides) + * + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getZ() { + return z; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Vector3f other = (Vector3f) obj; + + if (x == other.x && y == other.y && z == other.z) + return true; + + return false; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector4f.java new file mode 100644 index 0000000..7582396 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/Vector4f.java @@ -0,0 +1,377 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 4-tuple vector. + * + * @author cix_foo + * @version $Revision$ $Id$ + */ + +public class Vector4f extends Vector implements Serializable, ReadableVector4f, WritableVector4f { + + private static final long serialVersionUID = 1L; + + public float x, y, z, w; + + /** + * Constructor for Vector4f. + */ + public Vector4f() { + super(); + } + + /** + * Constructor + */ + public Vector4f(ReadableVector4f src) { + set(src); + } + + /** + * Constructor + */ + public Vector4f(float x, float y, float z, float w) { + set(x, y, z, w); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) + */ + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float, float) + */ + public void set(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** + * Load from another Vector4f + * + * @param src The source vector + * @return this + */ + public Vector4f set(ReadableVector4f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + w = src.getW(); + return this; + } + + /** + * @return the length squared of the vector + */ + public float lengthSquared() { + return x * x + y * y + z * z + w * w; + } + + /** + * Translate a vector + * + * @param x The translation in x + * @param y the translation in y + * @return this + */ + public Vector4f translate(float x, float y, float z, float w) { + this.x += x; + this.y += y; + this.z += z; + this.w += w; + return this; + } + + /** + * Add a vector to another vector and place the result in a destination vector. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + else { + dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + return dest; + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + else { + dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + return dest; + } + } + + /** + * Negate a vector + * + * @return this + */ + public Vector negate() { + x = -x; + y = -y; + z = -z; + w = -w; + return this; + } + + /** + * Negate a vector and place the result in a destination vector. + * + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector + */ + public Vector4f negate(Vector4f dest) { + if (dest == null) + dest = new Vector4f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + dest.w = -w; + return dest; + } + + /** + * Normalise this vector and place the result in another vector. + * + * @param dest The destination vector, or null if a new vector is to be created + * @return the normalised vector + */ + public Vector4f normalise(Vector4f dest) { + float l = length(); + + if (dest == null) + dest = new Vector4f(x / l, y / l, z / l, w / l); + else + dest.set(x / l, y / l, z / l, w / l); + + return dest; + } + + /** + * The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + + * v1.z * v2.z + v1.w * v2.w + * + * @param left The LHS vector + * @param right The RHS vector + * @return left dot right + */ + public static float dot(Vector4f left, Vector4f right) { + return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; + } + + /** + * Calculate the angle between two vectors, in radians + * + * @param a A vector + * @param b The other vector + * @return the angle between the two vectors, in radians + */ + public static float angle(Vector4f a, Vector4f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float) Math.acos(dls); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#load(FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + w = buf.get(); + return this; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + x *= scale; + y *= scale; + z *= scale; + w *= scale; + return this; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#store(FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + buf.put(w); + + return this; + } + + public String toString() { + return "Vector4f: " + x + " " + y + " " + z + " " + w; + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * + * @param y + */ + public final void setY(float y) { + this.y = y; + } + + /** + * Set Z + * + * @param z + */ + public void setZ(float z) { + this.z = z; + } + + /* + * (Overrides) + * + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getZ() { + return z; + } + + /** + * Set W + * + * @param w + */ + public void setW(float w) { + this.w = w; + } + + /* + * (Overrides) + * + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getW() { + return w; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Vector4f other = (Vector4f) obj; + + if (x == other.x && y == other.y && z == other.z && w == other.w) + return true; + + return false; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java new file mode 100644 index 0000000..faa6c71 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector2f.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +/** + * Writable interface to Vector2fs + * + * @author $author$ + * @version $revision$ $Id$ + */ +public interface WritableVector2f { + + /** + * Set the X value + * + * @param x + */ + void setX(float x); + + /** + * Set the Y value + * + * @param y + */ + void setY(float y); + + /** + * Set the X,Y values + * + * @param x + * @param y + */ + void set(float x, float y); + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java new file mode 100644 index 0000000..6c6e004 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector3f.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +/** + * Writable interface to Vector3fs + * + * @author $author$ + * @version $revision$ $Id$ + */ +public interface WritableVector3f extends WritableVector2f { + + /** + * Set the Z value + * + * @param z + */ + void setZ(float z); + + /** + * Set the X,Y,Z values + * + * @param x + * @param y + * @param z + */ + void set(float x, float y, float z); + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java new file mode 100644 index 0000000..9870654 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/glemu/vector/WritableVector4f.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.PeytonPlayz585.glemu.vector; + +/** + * Writable interface to Vector4fs + * + * @author $author$ + * @version $revision$ $Id$ + */ +public interface WritableVector4f extends WritableVector3f { + + /** + * Set the W value + * + * @param w + */ + void setW(float w); + + /** + * Set the X,Y,Z,W values + * + * @param x + * @param y + * @param z + * @param w + */ + void set(float x, float y, float z, float w); + +} \ No newline at end of file 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..681ac6e --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/math/MathHelper.java @@ -0,0 +1,61 @@ +package net.PeytonPlayz585.math; + +public 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(float var0) { + return (float)Math.sqrt((double)var0); + } + + public static final float sqrt_double(double var0) { + return (float)Math.sqrt(var0); + } + + public static int floor_float(float var0) { + int var1 = (int)var0; + return var0 < (float)var1 ? var1 - 1 : var1; + } + + public static int floor_double(double var0) { + int var2 = (int)var0; + return var0 < (double)var2 ? var2 - 1 : var2; + } + + public static float abs(float var0) { + return var0 >= 0.0F ? var0 : -var0; + } + + public static double abs_max(double var0, double var2) { + if(var0 < 0.0D) { + var0 = -var0; + } + + if(var2 < 0.0D) { + var2 = -var2; + } + + return var0 > var2 ? var0 : var2; + } + + public static int bucketInt(int var0, int var1) { + return var0 < 0 ? -((-var0 - 1) / var1) - 1 : var0 / var1; + } + + 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/teavm/java/net/PeytonPlayz585/minecraft/AWTColor.java b/src/teavm/java/net/PeytonPlayz585/minecraft/AWTColor.java new file mode 100644 index 0000000..ca06a3e --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/minecraft/AWTColor.java @@ -0,0 +1,51 @@ +package net.PeytonPlayz585.minecraft; + +public class AWTColor { + + public static int HSBtoRGB(float hue, float saturation, float brightness) { + int r = 0, g = 0, b = 0; + if (saturation == 0) { + r = g = b = (int) (brightness * 255.0f + 0.5f); + } else { + float h = (hue - (float) Math.floor(hue)) * 6.0f; + float f = h - (float) java.lang.Math.floor(h); + float p = brightness * (1.0f - saturation); + float q = brightness * (1.0f - saturation * f); + float t = brightness * (1.0f - (saturation * (1.0f - f))); + switch ((int) h) { + case 0: + r = (int) (brightness * 255.0f + 0.5f); + g = (int) (t * 255.0f + 0.5f); + b = (int) (p * 255.0f + 0.5f); + break; + case 1: + r = (int) (q * 255.0f + 0.5f); + g = (int) (brightness * 255.0f + 0.5f); + b = (int) (p * 255.0f + 0.5f); + break; + case 2: + r = (int) (p * 255.0f + 0.5f); + g = (int) (brightness * 255.0f + 0.5f); + b = (int) (t * 255.0f + 0.5f); + break; + case 3: + r = (int) (p * 255.0f + 0.5f); + g = (int) (q * 255.0f + 0.5f); + b = (int) (brightness * 255.0f + 0.5f); + break; + case 4: + r = (int) (t * 255.0f + 0.5f); + g = (int) (p * 255.0f + 0.5f); + b = (int) (brightness * 255.0f + 0.5f); + break; + case 5: + r = (int) (brightness * 255.0f + 0.5f); + g = (int) (p * 255.0f + 0.5f); + b = (int) (q * 255.0f + 0.5f); + break; + } + } + return 0xff000000 | (r << 16) | (g << 8) | (b << 0); + } + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/minecraft/AssetRepository.java b/src/teavm/java/net/PeytonPlayz585/minecraft/AssetRepository.java new file mode 100644 index 0000000..753c9fe --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/minecraft/AssetRepository.java @@ -0,0 +1,55 @@ +package net.PeytonPlayz585.minecraft; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.HashMap; + +import com.jcraft.jzlib.InflaterInputStream; + +public class AssetRepository { + + private static final HashMap filePool = new HashMap(); + + public static final void install(byte[] pkg) throws IOException { + ByteArrayInputStream in2 = new ByteArrayInputStream(pkg); + DataInputStream in = new DataInputStream(in2); + byte[] header = new byte[8]; + in.read(header); + if (!"EAGPKG!!".equals(new String(header, Charset.forName("UTF-8")))) + throw new IOException("invalid epk file"); + in.readUTF(); + in = new DataInputStream(new InflaterInputStream(in2)); + String s = null; + SHA1Digest dg = new SHA1Digest(); + while ("".equals(s = in.readUTF())) { + String path = in.readUTF(); + byte[] digest = new byte[20]; + byte[] digest2 = new byte[20]; + in.read(digest); + int len = in.readInt(); + byte[] file = new byte[len]; + in.read(file); + if (filePool.containsKey(path)) + continue; + dg.update(file, 0, len); + dg.doFinal(digest2, 0); + if (!Arrays.equals(digest, digest2)) + throw new IOException("invalid file hash for " + path); + filePool.put(path, file); + if (!"".equals(in.readUTF())) + throw new IOException("invalid epk file"); + } + 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/teavm/java/net/PeytonPlayz585/minecraft/Base64.java b/src/teavm/java/net/PeytonPlayz585/minecraft/Base64.java new file mode 100644 index 0000000..ab0b0ec --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/minecraft/Base64.java @@ -0,0 +1,857 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.PeytonPlayz585.minecraft; + +import java.math.BigInteger; +import java.nio.charset.Charset; + +/** + * Provides Base64 encoding and decoding as defined by + * RFC 2045. + * + *

+ * This class implements section 6.8. Base64 + * Content-Transfer-Encoding from RFC 2045 Multipurpose Internet + * Mail Extensions (MIME) Part One: Format of Internet Message Bodies by + * Freed and Borenstein. + *

+ *

+ * The class can be parameterized in the following manner with various + * constructors: + *

+ *
    + *
  • URL-safe mode: Default off.
  • + *
  • Line length: Default 76. Line length that aren't multiples of 4 will + * still essentially end up being multiples of 4 in the encoded data. + *
  • Line separator: Default is CRLF ("\r\n")
  • + *
+ *

+ * The URL-safe parameter is only applied to encode operations. Decoding + * seamlessly handles both modes. + *

+ *

+ * Since this class operates directly on byte streams, and not character + * streams, it is hard-coded to only encode/decode character encodings which are + * compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, + * etc). + *

+ *

+ * This class is thread-safe. + *

+ * + * @see RFC 2045 + * @since 1.0 + */ +public class Base64 extends BaseNCodec { + + /** + * BASE32 characters are 6 bits in length. They are formed by taking a block of + * 3 octets to form a 24-bit string, which is converted into 4 BASE64 + * characters. + */ + private static final int BITS_PER_ENCODED_BYTE = 6; + private static final int BYTES_PER_UNENCODED_BLOCK = 3; + private static final int BYTES_PER_ENCODED_BLOCK = 4; + + /** + * This array is a lookup table that translates 6-bit positive integer index + * values into their "Base64 Alphabet" equivalents as specified in Table 1 of + * RFC 2045. + * + * Thanks to "commons" project in ws.apache.org for this code. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + */ + private static final byte[] STANDARD_ENCODE_TABLE = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; + + /** + * This is a copy of the STANDARD_ENCODE_TABLE above, but with + and / changed + * to - and _ to make the encoded Base64 results more URL-SAFE. This table is + * only used when the Base64's mode is set to URL-SAFE. + */ + private static final byte[] URL_SAFE_ENCODE_TABLE = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' }; + + /** + * This array is a lookup table that translates Unicode characters drawn from + * the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into their 6-bit + * positive integer equivalents. Characters that are not in the Base64 alphabet + * but fall within the bounds of the array are translated to -1. + * + * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This + * means decoder seamlessly handles both URL_SAFE and STANDARD base64. (The + * encoder, on the other hand, needs to know ahead of time what to emit). + * + * Thanks to "commons" project in ws.apache.org for this code. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + */ + private static final byte[] DECODE_TABLE = { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, // 20-2f + - / + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, // 30-3f 0-9 + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40-4f A-O + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, // 50-5f P-Z _ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 60-6f a-o + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 // 70-7a p-z + }; + + /** + * Base64 uses 6-bit fields. + */ + /** Mask used to extract 6 bits, used when encoding */ + private static final int MASK_6BITS = 0x3f; + /** Mask used to extract 4 bits, used when decoding final trailing character. */ + private static final int MASK_4BITS = 0xf; + /** Mask used to extract 2 bits, used when decoding final trailing character. */ + private static final int MASK_2BITS = 0x3; + + // The static final fields above are used for the original static byte[] methods + // on Base64. + // The private member fields below are used with the new streaming approach, + // which requires + // some state be preserved between calls of encode() and decode(). + + /** + * Decodes Base64 data into octets. + *

+ * Note: this method seamlessly handles data encoded in URL-safe or + * normal mode. + *

+ * + * @param base64Data Byte array containing Base64 data + * @return Array containing decoded data. + */ + public static byte[] decodeBase64(final byte[] base64Data) { + return new Base64().decode(base64Data); + } + + /** + * Decodes a Base64 String into octets. + *

+ * Note: this method seamlessly handles data encoded in URL-safe or + * normal mode. + *

+ * + * @param base64String String containing Base64 data + * @return Array containing decoded data. + * @since 1.4 + */ + public static byte[] decodeBase64(final String base64String) { + return new Base64().decode(base64String); + } + + // Implementation of integer encoding used for crypto + /** + * Decodes a byte64-encoded integer according to crypto standards such as W3C's + * XML-Signature. + * + * @param pArray a byte array containing base64 character data + * @return A BigInteger + * @since 1.4 + */ + public static BigInteger decodeInteger(final byte[] pArray) { + return new BigInteger(1, decodeBase64(pArray)); + } + + /** + * Encodes binary data using the base64 algorithm but does not chunk the output. + * + * @param binaryData binary data to encode + * @return byte[] containing Base64 characters in their UTF-8 representation. + */ + public static byte[] encodeBase64(final byte[] binaryData) { + return encodeBase64(binaryData, false); + } + + /** + * Encodes binary data using the base64 algorithm, optionally chunking the + * output into 76 character blocks. + * + * @param binaryData Array containing binary data to encode. + * @param isChunked if {@code true} this encoder will chunk the base64 output + * into 76 character blocks + * @return Base64-encoded data. + * @throws IllegalArgumentException Thrown when the input array needs an output + * array bigger than {@link Integer#MAX_VALUE} + */ + public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) { + return encodeBase64(binaryData, isChunked, false); + } + + /** + * Encodes binary data using the base64 algorithm, optionally chunking the + * output into 76 character blocks. + * + * @param binaryData Array containing binary data to encode. + * @param isChunked if {@code true} this encoder will chunk the base64 output + * into 76 character blocks + * @param urlSafe if {@code true} this encoder will emit - and _ instead of + * the usual + and / characters. Note: no padding is added + * when encoding using the URL-safe alphabet. + * @return Base64-encoded data. + * @throws IllegalArgumentException Thrown when the input array needs an output + * array bigger than {@link Integer#MAX_VALUE} + * @since 1.4 + */ + public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) { + return encodeBase64(binaryData, isChunked, urlSafe, Integer.MAX_VALUE); + } + + /** + * Encodes binary data using the base64 algorithm, optionally chunking the + * output into 76 character blocks. + * + * @param binaryData Array containing binary data to encode. + * @param isChunked if {@code true} this encoder will chunk the base64 + * output into 76 character blocks + * @param urlSafe if {@code true} this encoder will emit - and _ instead + * of the usual + and / characters. Note: no padding is + * added when encoding using the URL-safe alphabet. + * @param maxResultSize The maximum result size to accept. + * @return Base64-encoded data. + * @throws IllegalArgumentException Thrown when the input array needs an output + * array bigger than maxResultSize + * @since 1.4 + */ + public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe, + final int maxResultSize) { + if (binaryData == null || binaryData.length == 0) { + return binaryData; + } + + // Create this so can use the super-class method + // Also ensures that the same roundings are performed by the ctor and the code + final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe); + final long len = b64.getEncodedLength(binaryData); + if (len > maxResultSize) { + throw new IllegalArgumentException("Input array too big, the output array would be bigger (" + len + + ") than the specified maximum size of " + maxResultSize); + } + + return b64.encode(binaryData); + } + + /** + * Encodes binary data using the base64 algorithm and chunks the encoded output + * into 76 character blocks + * + * @param binaryData binary data to encode + * @return Base64 characters chunked in 76 character blocks + */ + public static byte[] encodeBase64Chunked(final byte[] binaryData) { + return encodeBase64(binaryData, true); + } + + /** + * Encodes binary data using the base64 algorithm but does not chunk the output. + * + * NOTE: We changed the behavior of this method from multi-line chunking + * (commons-codec-1.4) to single-line non-chunking (commons-codec-1.5). + * + * @param binaryData binary data to encode + * @return String containing Base64 characters. + * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). + */ + public static String encodeBase64String(final byte[] binaryData) { + return new String(encodeBase64(binaryData, false), Charset.forName("UTF-8")); + } + + /** + * Encodes binary data using a URL-safe variation of the base64 algorithm but + * does not chunk the output. The url-safe variation emits - and _ instead of + + * and / characters. Note: no padding is added. + * + * @param binaryData binary data to encode + * @return byte[] containing Base64 characters in their UTF-8 representation. + * @since 1.4 + */ + public static byte[] encodeBase64URLSafe(final byte[] binaryData) { + return encodeBase64(binaryData, false, true); + } + + /** + * Encodes binary data using a URL-safe variation of the base64 algorithm but + * does not chunk the output. The url-safe variation emits - and _ instead of + + * and / characters. Note: no padding is added. + * + * @param binaryData binary data to encode + * @return String containing Base64 characters + * @since 1.4 + */ + public static String encodeBase64URLSafeString(final byte[] binaryData) { + return new String(encodeBase64(binaryData, false, true), Charset.forName("UTF-8")); + } + + /** + * Encodes to a byte64-encoded integer according to crypto standards such as + * W3C's XML-Signature. + * + * @param bigInteger a BigInteger + * @return A byte array containing base64 character data + * @throws NullPointerException if null is passed in + * @since 1.4 + */ + public static byte[] encodeInteger(final BigInteger bigInteger) { + return encodeBase64(toIntegerBytes(bigInteger), false); + } + + /** + * Tests a given byte array to see if it contains only valid characters within + * the Base64 alphabet. Currently the method treats whitespace as valid. + * + * @param arrayOctet byte array to test + * @return {@code true} if all bytes are valid characters in the Base64 alphabet + * or if the byte array is empty; {@code false}, otherwise + * @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0. + */ + @Deprecated + public static boolean isArrayByteBase64(final byte[] arrayOctet) { + return isBase64(arrayOctet); + } + + /** + * Returns whether or not the {@code octet} is in the base 64 alphabet. + * + * @param octet The value to test + * @return {@code true} if the value is defined in the the base 64 alphabet, + * {@code false} otherwise. + * @since 1.4 + */ + public static boolean isBase64(final byte octet) { + return octet == PAD_DEFAULT || (octet >= 0 && octet < DECODE_TABLE.length && DECODE_TABLE[octet] != -1); + } + + /** + * Tests a given byte array to see if it contains only valid characters within + * the Base64 alphabet. Currently the method treats whitespace as valid. + * + * @param arrayOctet byte array to test + * @return {@code true} if all bytes are valid characters in the Base64 alphabet + * or if the byte array is empty; {@code false}, otherwise + * @since 1.5 + */ + public static boolean isBase64(final byte[] arrayOctet) { + for (int i = 0; i < arrayOctet.length; i++) { + if (!isBase64(arrayOctet[i]) && !isWhiteSpace(arrayOctet[i])) { + return false; + } + } + return true; + } + + /** + * Tests a given String to see if it contains only valid characters within the + * Base64 alphabet. Currently the method treats whitespace as valid. + * + * @param base64 String to test + * @return {@code true} if all characters in the String are valid characters in + * the Base64 alphabet or if the String is empty; {@code false}, + * otherwise + * @since 1.5 + */ + public static boolean isBase64(final String base64) { + return isBase64(base64.getBytes(Charset.forName("UTF-8"))); + } + + /** + * Returns a byte-array representation of a {@code BigInteger} without sign bit. + * + * @param bigInt {@code BigInteger} to be converted + * @return a byte array representation of the BigInteger parameter + */ + static byte[] toIntegerBytes(final BigInteger bigInt) { + int bitlen = bigInt.bitLength(); + // round bitlen + bitlen = ((bitlen + 7) >> 3) << 3; + final byte[] bigBytes = bigInt.toByteArray(); + + if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) { + return bigBytes; + } + // set up params for copying everything but sign bit + int startSrc = 0; + int len = bigBytes.length; + + // if bigInt is exactly byte-aligned, just skip signbit in copy + if ((bigInt.bitLength() % 8) == 0) { + startSrc = 1; + len--; + } + final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec + final byte[] resizedBytes = new byte[bitlen / 8]; + System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len); + return resizedBytes; + } + + /** + * Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE + * above remains static because it is able to decode both STANDARD and URL_SAFE + * streams, but the encodeTable must be a member variable so we can switch + * between the two modes. + */ + private final byte[] encodeTable; + + // Only one decode table currently; keep for consistency with Base32 code + private final byte[] decodeTable = DECODE_TABLE; + + /** + * Line separator for encoding. Not used when decoding. Only used if lineLength + * > 0. + */ + private final byte[] lineSeparator; + + /** + * Convenience variable to help us determine when our buffer is going to run out + * of room and needs resizing. {@code decodeSize = 3 + lineSeparator.length;} + */ + private final int decodeSize; + + /** + * Convenience variable to help us determine when our buffer is going to run out + * of room and needs resizing. {@code encodeSize = 4 + lineSeparator.length;} + */ + private final int encodeSize; + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in + * URL-unsafe mode. + *

+ * When encoding the line length is 0 (no chunking), and the encoding table is + * STANDARD_ENCODE_TABLE. + *

+ * + *

+ * When decoding all variants are supported. + *

+ */ + public Base64() { + this(0); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in the + * given URL-safe mode. + *

+ * When encoding the line length is 76, the line separator is CRLF, and the + * encoding table is STANDARD_ENCODE_TABLE. + *

+ * + *

+ * When decoding all variants are supported. + *

+ * + * @param urlSafe if {@code true}, URL-safe encoding is used. In most cases this + * should be set to {@code false}. + * @since 1.4 + */ + public Base64(final boolean urlSafe) { + this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in + * URL-unsafe mode. + *

+ * When encoding the line length is given in the constructor, the line separator + * is CRLF, and the encoding table is STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being + * multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength Each line of encoded data will be at most of the given + * length (rounded down to nearest multiple of 4). If + * lineLength <= 0, then the output will not be divided + * into lines (chunks). Ignored when decoding. + * @since 1.4 + */ + public Base64(final int lineLength) { + this(lineLength, CHUNK_SEPARATOR); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in + * URL-unsafe mode. + *

+ * When encoding the line length and line separator are given in the + * constructor, and the encoding table is STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being + * multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength Each line of encoded data will be at most of the given + * length (rounded down to nearest multiple of 4). If + * lineLength <= 0, then the output will not be divided + * into lines (chunks). Ignored when decoding. + * @param lineSeparator Each line of encoded data will end with this sequence of + * bytes. + * @throws IllegalArgumentException Thrown when the provided lineSeparator + * included some base64 characters. + * @since 1.4 + */ + public Base64(final int lineLength, final byte[] lineSeparator) { + this(lineLength, lineSeparator, false); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in + * URL-unsafe mode. + *

+ * When encoding the line length and line separator are given in the + * constructor, and the encoding table is STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being + * multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength Each line of encoded data will be at most of the given + * length (rounded down to nearest multiple of 4). If + * lineLength <= 0, then the output will not be divided + * into lines (chunks). Ignored when decoding. + * @param lineSeparator Each line of encoded data will end with this sequence of + * bytes. + * @param urlSafe Instead of emitting '+' and '/' we emit '-' and '_' + * respectively. urlSafe is only applied to encode + * operations. Decoding seamlessly handles both modes. + * Note: no padding is added when using the URL-safe + * alphabet. + * @throws IllegalArgumentException Thrown when the {@code lineSeparator} + * contains Base64 characters. + * @since 1.4 + */ + public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe) { + this(lineLength, lineSeparator, urlSafe, CodecPolicy.LENIANT); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in + * URL-unsafe mode. + *

+ * When encoding the line length and line separator are given in the + * constructor, and the encoding table is STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being + * multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength Each line of encoded data will be at most of the given + * length (rounded down to nearest multiple of 4). If + * lineLength <= 0, then the output will not be divided + * into lines (chunks). Ignored when decoding. + * @param lineSeparator Each line of encoded data will end with this sequence + * of bytes. + * @param urlSafe Instead of emitting '+' and '/' we emit '-' and '_' + * respectively. urlSafe is only applied to encode + * operations. Decoding seamlessly handles both modes. + * Note: no padding is added when using the URL-safe + * alphabet. + * @param decodingPolicy The decoding policy. + * @throws IllegalArgumentException Thrown when the {@code lineSeparator} + * contains Base64 characters. + * @since 1.15 + */ + public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe, + final CodecPolicy decodingPolicy) { + super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, + lineSeparator == null ? 0 : lineSeparator.length, PAD_DEFAULT, decodingPolicy); + // TODO could be simplified if there is no requirement to reject invalid line + // sep when length <=0 + // @see test case Base64Test.testConstructors() + if (lineSeparator != null) { + if (containsAlphabetOrPad(lineSeparator)) { + final String sep = new String(lineSeparator, Charset.forName("UTF-8")); + throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]"); + } + if (lineLength > 0) { // null line-sep forces no chunking rather than throwing IAE + this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length; + this.lineSeparator = new byte[lineSeparator.length]; + System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length); + } else { + this.encodeSize = BYTES_PER_ENCODED_BLOCK; + this.lineSeparator = null; + } + } else { + this.encodeSize = BYTES_PER_ENCODED_BLOCK; + this.lineSeparator = null; + } + this.decodeSize = this.encodeSize - 1; + this.encodeTable = urlSafe ? URL_SAFE_ENCODE_TABLE : STANDARD_ENCODE_TABLE; + } + + // Implementation of the Encoder Interface + + /** + *

+ * Decodes all of the provided data, starting at inPos, for inAvail bytes. + * Should be called at least twice: once with the data to decode, and once with + * inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" call + * is not necessary when decoding, but it doesn't hurt, either. + *

+ *

+ * Ignores all non-base64 characters. This is how chunked (e.g. 76 character) + * data is handled, since CR and LF are silently ignored, but has implications + * for other bytes, too. This method subscribes to the garbage-in, garbage-out + * philosophy: it will not check the provided data for validity. + *

+ *

+ * Thanks to "commons" project in ws.apache.org for the bitwise operations, and + * general approach. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + *

+ * + * @param in byte[] array of ascii data to base64 decode. + * @param inPos Position to start reading data from. + * @param inAvail Amount of bytes available from input for decoding. + * @param context the context to be used + */ + @Override + void decode(final byte[] in, int inPos, final int inAvail, final Context context) { + if (context.eof) { + return; + } + if (inAvail < 0) { + context.eof = true; + } + for (int i = 0; i < inAvail; i++) { + final byte[] buffer = ensureBufferSize(decodeSize, context); + final byte b = in[inPos++]; + if (b == pad) { + // We're done. + context.eof = true; + break; + } + if (b >= 0 && b < DECODE_TABLE.length) { + final int result = DECODE_TABLE[b]; + if (result >= 0) { + context.modulus = (context.modulus + 1) % BYTES_PER_ENCODED_BLOCK; + context.ibitWorkArea = (context.ibitWorkArea << BITS_PER_ENCODED_BYTE) + result; + if (context.modulus == 0) { + buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 16) & MASK_8BITS); + buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); + buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS); + } + } + } + } + + // Two forms of EOF as far as base64 decoder is concerned: actual + // EOF (-1) and first time '=' character is encountered in stream. + // This approach makes the '=' padding characters completely optional. + if (context.eof && context.modulus != 0) { + final byte[] buffer = ensureBufferSize(decodeSize, context); + + // We have some spare bits remaining + // Output all whole multiples of 8 bits and ignore the rest + switch (context.modulus) { +// case 0 : // impossible, as excluded above + case 1: // 6 bits - either ignore entirely, or raise an exception + validateTrailingCharacter(); + break; + case 2: // 12 bits = 8 + 4 + validateCharacter(MASK_4BITS, context); + context.ibitWorkArea = context.ibitWorkArea >> 4; // dump the extra 4 bits + buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); + break; + case 3: // 18 bits = 8 + 8 + 2 + validateCharacter(MASK_2BITS, context); + context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 2 bits + buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); + buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); + break; + default: + throw new IllegalStateException("Impossible modulus " + context.modulus); + } + } + } + + /** + *

+ * Encodes all of the provided data, starting at inPos, for inAvail bytes. Must + * be called at least twice: once with the data to encode, and once with inAvail + * set to "-1" to alert encoder that EOF has been reached, to flush last + * remaining bytes (if not multiple of 3). + *

+ *

+ * Note: no padding is added when encoding using the URL-safe alphabet. + *

+ *

+ * Thanks to "commons" project in ws.apache.org for the bitwise operations, and + * general approach. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + *

+ * + * @param in byte[] array of binary data to base64 encode. + * @param inPos Position to start reading data from. + * @param inAvail Amount of bytes available from input for encoding. + * @param context the context to be used + */ + @Override + void encode(final byte[] in, int inPos, final int inAvail, final Context context) { + if (context.eof) { + return; + } + // inAvail < 0 is how we're informed of EOF in the underlying data we're + // encoding. + if (inAvail < 0) { + context.eof = true; + if (0 == context.modulus && lineLength == 0) { + return; // no leftovers to process and not using chunking + } + final byte[] buffer = ensureBufferSize(encodeSize, context); + final int savedPos = context.pos; + switch (context.modulus) { // 0-2 + case 0: // nothing to do here + break; + case 1: // 8 bits = 6 + 2 + // top 6 bits: + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS]; + // remaining 2: + buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4) & MASK_6BITS]; + // URL-SAFE skips the padding to further reduce size. + if (encodeTable == STANDARD_ENCODE_TABLE) { + buffer[context.pos++] = pad; + buffer[context.pos++] = pad; + } + break; + + case 2: // 16 bits = 6 + 6 + 4 + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 10) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 4) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 2) & MASK_6BITS]; + // URL-SAFE skips the padding to further reduce size. + if (encodeTable == STANDARD_ENCODE_TABLE) { + buffer[context.pos++] = pad; + } + break; + default: + throw new IllegalStateException("Impossible modulus " + context.modulus); + } + context.currentLinePos += context.pos - savedPos; // keep track of current line position + // if currentPos == 0 we are at the start of a line, so don't add CRLF + if (lineLength > 0 && context.currentLinePos > 0) { + System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); + context.pos += lineSeparator.length; + } + } else { + for (int i = 0; i < inAvail; i++) { + final byte[] buffer = ensureBufferSize(encodeSize, context); + context.modulus = (context.modulus + 1) % BYTES_PER_UNENCODED_BLOCK; + int b = in[inPos++]; + if (b < 0) { + b += 256; + } + context.ibitWorkArea = (context.ibitWorkArea << 8) + b; // BITS_PER_BYTE + if (0 == context.modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 18) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 12) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 6) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6BITS]; + context.currentLinePos += BYTES_PER_ENCODED_BLOCK; + if (lineLength > 0 && lineLength <= context.currentLinePos) { + System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); + context.pos += lineSeparator.length; + context.currentLinePos = 0; + } + } + } + } + } + + /** + * Returns whether or not the {@code octet} is in the Base64 alphabet. + * + * @param octet The value to test + * @return {@code true} if the value is defined in the the Base64 alphabet + * {@code false} otherwise. + */ + @Override + protected boolean isInAlphabet(final byte octet) { + return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1; + } + + /** + * Returns our current encode mode. True if we're URL-SAFE, false otherwise. + * + * @return true if we're in URL-SAFE mode, false otherwise. + * @since 1.4 + */ + public boolean isUrlSafe() { + return this.encodeTable == URL_SAFE_ENCODE_TABLE; + } + + /** + * Validates whether decoding the final trailing character is possible in the + * context of the set of possible base 64 values. + * + *

+ * The character is valid if the lower bits within the provided mask are zero. + * This is used to test the final trailing base-64 digit is zero in the bits + * that will be discarded. + * + * @param emptyBitsMask The mask of the lower bits that should be empty + * @param context the context to be used + * + * @throws IllegalArgumentException if the bits being checked contain any + * non-zero value + */ + private void validateCharacter(final int emptyBitsMask, final Context context) { + if (isStrictDecoding() && (context.ibitWorkArea & emptyBitsMask) != 0) { + throw new IllegalArgumentException( + "Strict decoding: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible encoding. " + + "Expected the discarded bits from the character to be zero."); + } + } + + /** + * Validates whether decoding allows an entire final trailing character that + * cannot be used for a complete byte. + * + * @throws IllegalArgumentException if strict decoding is enabled + */ + private void validateTrailingCharacter() { + if (isStrictDecoding()) { + throw new IllegalArgumentException( + "Strict decoding: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible encoding. " + + "Decoding requires at least two trailing 6-bit characters to create bytes."); + } + } + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/minecraft/BaseNCodec.java b/src/teavm/java/net/PeytonPlayz585/minecraft/BaseNCodec.java new file mode 100644 index 0000000..8fbeceb --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/minecraft/BaseNCodec.java @@ -0,0 +1,692 @@ +package net.PeytonPlayz585.minecraft; + +import java.nio.charset.Charset; +import java.util.Arrays; + +public abstract class BaseNCodec { + + static enum CodecPolicy { + STRICT, LENIANT; + } + + /** + * Holds thread context so classes can be thread-safe. + * + * This class is not itself thread-safe; each thread must allocate its own copy. + * + * @since 1.7 + */ + static class Context { + + /** + * Place holder for the bytes we're dealing with for our based logic. Bitwise + * operations store and extract the encoding or decoding from this variable. + */ + int ibitWorkArea; + + /** + * Place holder for the bytes we're dealing with for our based logic. Bitwise + * operations store and extract the encoding or decoding from this variable. + */ + long lbitWorkArea; + + /** + * Buffer for streaming. + */ + byte[] buffer; + + /** + * Position where next character should be written in the buffer. + */ + int pos; + + /** + * Position where next character should be read from the buffer. + */ + int readPos; + + /** + * Boolean flag to indicate the EOF has been reached. Once EOF has been reached, + * this object becomes useless, and must be thrown away. + */ + boolean eof; + + /** + * Variable tracks how many characters have been written to the current line. + * Only used when encoding. We use it to make sure each encoded line never goes + * beyond lineLength (if lineLength > 0). + */ + int currentLinePos; + + /** + * Writes to the buffer only occur after every 3/5 reads when encoding, and + * every 4/8 reads when decoding. This variable helps track that. + */ + int modulus; + + Context() { + } + + /** + * Returns a String useful for debugging (especially within a debugger.) + * + * @return a String useful for debugging. + */ + @SuppressWarnings("boxing") // OK to ignore boxing here + @Override + public String toString() { + return String.format( + "%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " + + "modulus=%s, pos=%s, readPos=%s]", + this.getClass().getSimpleName(), Arrays.toString(buffer), currentLinePos, eof, ibitWorkArea, + lbitWorkArea, modulus, pos, readPos); + } + } + + /** + * EOF + * + * @since 1.7 + */ + static final int EOF = -1; + + /** + * MIME chunk size per RFC 2045 section 6.8. + * + *

+ * The {@value} character limit does not count the trailing CRLF, but counts all + * other characters, including any equal signs. + *

+ * + * @see RFC 2045 section 6.8 + */ + public static final int MIME_CHUNK_SIZE = 76; + + /** + * PEM chunk size per RFC 1421 section 4.3.2.4. + * + *

+ * The {@value} character limit does not count the trailing CRLF, but counts all + * other characters, including any equal signs. + *

+ * + * @see RFC 1421 section + * 4.3.2.4 + */ + public static final int PEM_CHUNK_SIZE = 64; + + private static final int DEFAULT_BUFFER_RESIZE_FACTOR = 2; + + /** + * Defines the default buffer size - currently {@value} - must be large enough + * for at least one encoded block+separator + */ + private static final int DEFAULT_BUFFER_SIZE = 8192; + + /** + * The maximum size buffer to allocate. + * + *

+ * This is set to the same size used in the JDK {@code java.util.ArrayList}: + *

+ *
Some VMs reserve some header words in an array. Attempts to + * allocate larger arrays may result in OutOfMemoryError: Requested array size + * exceeds VM limit.
+ */ + private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; + + /** Mask used to extract 8 bits, used in decoding bytes */ + protected static final int MASK_8BITS = 0xff; + + /** + * Byte used to pad output. + */ + protected static final byte PAD_DEFAULT = '='; // Allow static access to default + + /** + * Chunk separator per RFC 2045 section 2.1. + * + * @see RFC 2045 section 2.1 + */ + static final byte[] CHUNK_SEPARATOR = { '\r', '\n' }; + + /** + * Compares two {@code int} values numerically treating the values as unsigned. + * Taken from JDK 1.8. + * + *

+ * TODO: Replace with JDK 1.8 Integer::compareUnsigned(int, int). + *

+ * + * @param x the first {@code int} to compare + * @param y the second {@code int} to compare + * @return the value {@code 0} if {@code x == y}; a value less than {@code 0} if + * {@code x < y} as unsigned values; and a value greater than {@code 0} + * if {@code x > y} as unsigned values + */ + private static int compareUnsigned(final int xx, final int yy) { + int x = xx + Integer.MIN_VALUE; + int y = yy + Integer.MIN_VALUE; + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + + /** + * Create a positive capacity at least as large the minimum required capacity. + * If the minimum capacity is negative then this throws an OutOfMemoryError as + * no array can be allocated. + * + * @param minCapacity the minimum capacity + * @return the capacity + * @throws OutOfMemoryError if the {@code minCapacity} is negative + */ + private static int createPositiveCapacity(final int minCapacity) { + if (minCapacity < 0) { + // overflow + throw new OutOfMemoryError("Unable to allocate array size: " + (minCapacity & 0xffffffffL)); + } + // This is called when we require buffer expansion to a very big array. + // Use the conservative maximum buffer size if possible, otherwise the biggest + // required. + // + // Note: In this situation JDK 1.8 java.util.ArrayList returns + // Integer.MAX_VALUE. + // This excludes some VMs that can exceed MAX_BUFFER_SIZE but not allocate a + // full + // Integer.MAX_VALUE length array. + // The result is that we may have to allocate an array of this size more than + // once if + // the capacity must be expanded again. + return (minCapacity > MAX_BUFFER_SIZE) ? minCapacity : MAX_BUFFER_SIZE; + } + + /** + * Gets a copy of the chunk separator per RFC 2045 section 2.1. + * + * @return the chunk separator + * @see RFC 2045 section 2.1 + * @since 1.15 + */ + public static byte[] getChunkSeparator() { + return CHUNK_SEPARATOR.clone(); + } + + /** + * Checks if a byte value is whitespace or not. Whitespace is taken to mean: + * space, tab, CR, LF + * + * @param byteToCheck the byte to check + * @return true if byte is whitespace, false otherwise + */ + protected static boolean isWhiteSpace(final byte byteToCheck) { + switch (byteToCheck) { + case ' ': + case '\n': + case '\r': + case '\t': + return true; + default: + return false; + } + } + + /** + * Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}. + * + * @param context the context to be used + * @param minCapacity the minimum required capacity + * @return the resized byte[] buffer + * @throws OutOfMemoryError if the {@code minCapacity} is negative + */ + private static byte[] resizeBuffer(final Context context, final int minCapacity) { + // Overflow-conscious code treats the min and new capacity as unsigned. + final int oldCapacity = context.buffer.length; + int newCapacity = oldCapacity * DEFAULT_BUFFER_RESIZE_FACTOR; + if (compareUnsigned(newCapacity, minCapacity) < 0) { + newCapacity = minCapacity; + } + if (compareUnsigned(newCapacity, MAX_BUFFER_SIZE) > 0) { + newCapacity = createPositiveCapacity(minCapacity); + } + + final byte[] b = new byte[newCapacity]; + System.arraycopy(context.buffer, 0, b, 0, context.buffer.length); + context.buffer = b; + return b; + } + + /** + * @deprecated Use {@link #pad}. Will be removed in 2.0. + */ + @Deprecated + protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later + + protected final byte pad; // instance variable just in case it needs to vary later + + /** + * Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 + * for Base32 + */ + private final int unencodedBlockSize; + + /** + * Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 + * for Base32 + */ + private final int encodedBlockSize; + + /** + * Chunksize for encoding. Not used when decoding. A value of zero or less + * implies no chunking of the encoded data. Rounded down to nearest multiple of + * encodedBlockSize. + */ + protected final int lineLength; + + /** + * Size of chunk separator. Not used unless {@link #lineLength} > 0. + */ + private final int chunkSeparatorLength; + + /** + * Defines the decoding behavior when the input bytes contain leftover trailing + * bits that cannot be created by a valid encoding. These can be bits that are + * unused from the final character or entire characters. The default mode is + * lenient decoding. Set this to {@code true} to enable strict decoding. + *
    + *
  • Lenient: Any trailing bits are composed into 8-bit bytes where possible. + * The remainder are discarded. + *
  • Strict: The decoding will raise an {@link IllegalArgumentException} if + * trailing bits are not part of a valid encoding. Any unused bits from the + * final character must be zero. Impossible counts of entire final characters + * are not allowed. + *
+ * + *

+ * When strict decoding is enabled it is expected that the decoded bytes will be + * re-encoded to a byte array that matches the original, i.e. no changes occur + * on the final character. This requires that the input bytes use the same + * padding and alphabet as the encoder. + */ + private final CodecPolicy decodingPolicy; + + /** + * Note {@code lineLength} is rounded down to the nearest multiple of the + * encoded block size. If {@code chunkSeparatorLength} is zero, then chunking is + * disabled. + * + * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) + * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param lineLength if > 0, use chunking with a length + * {@code lineLength} + * @param chunkSeparatorLength the chunk separator length, if relevant + */ + protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, + final int chunkSeparatorLength) { + this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, PAD_DEFAULT); + } + + /** + * Note {@code lineLength} is rounded down to the nearest multiple of the + * encoded block size. If {@code chunkSeparatorLength} is zero, then chunking is + * disabled. + * + * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) + * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param lineLength if > 0, use chunking with a length + * {@code lineLength} + * @param chunkSeparatorLength the chunk separator length, if relevant + * @param pad byte used as padding byte. + */ + protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, + final int chunkSeparatorLength, final byte pad) { + this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, pad, CodecPolicy.LENIANT); + } + + /** + * Note {@code lineLength} is rounded down to the nearest multiple of the + * encoded block size. If {@code chunkSeparatorLength} is zero, then chunking is + * disabled. + * + * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) + * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param lineLength if > 0, use chunking with a length + * {@code lineLength} + * @param chunkSeparatorLength the chunk separator length, if relevant + * @param pad byte used as padding byte. + * @param decodingPolicy Decoding policy. + * @since 1.15 + */ + protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, + final int chunkSeparatorLength, final byte pad, final CodecPolicy decodingPolicy) { + this.unencodedBlockSize = unencodedBlockSize; + this.encodedBlockSize = encodedBlockSize; + final boolean useChunking = lineLength > 0 && chunkSeparatorLength > 0; + this.lineLength = useChunking ? (lineLength / encodedBlockSize) * encodedBlockSize : 0; + this.chunkSeparatorLength = chunkSeparatorLength; + this.pad = pad; + this.decodingPolicy = decodingPolicy; + } + + /** + * Returns the amount of buffered data available for reading. + * + * @param context the context to be used + * @return The amount of buffered data available for reading. + */ + int available(final Context context) { // package protected for access from I/O streams + return context.buffer != null ? context.pos - context.readPos : 0; + } + + /** + * Tests a given byte array to see if it contains any characters within the + * alphabet or PAD. + * + * Intended for use in checking line-ending arrays + * + * @param arrayOctet byte array to test + * @return {@code true} if any byte is a valid character in the alphabet or PAD; + * {@code false} otherwise + */ + protected boolean containsAlphabetOrPad(final byte[] arrayOctet) { + if (arrayOctet == null) { + return false; + } + for (final byte element : arrayOctet) { + if (pad == element || isInAlphabet(element)) { + return true; + } + } + return false; + } + + /** + * Decodes a byte[] containing characters in the Base-N alphabet. + * + * @param pArray A byte array containing Base-N character data + * @return a byte array containing binary data + */ + public byte[] decode(final byte[] pArray) { + if (pArray == null || pArray.length == 0) { + return pArray; + } + final Context context = new Context(); + decode(pArray, 0, pArray.length, context); + decode(pArray, 0, EOF, context); // Notify decoder of EOF. + final byte[] result = new byte[context.pos]; + readResults(result, 0, result.length, context); + return result; + } + + // package protected for access from I/O streams + abstract void decode(byte[] pArray, int i, int length, Context context); + + /** + * Decodes an Object using the Base-N algorithm. This method is provided in + * order to satisfy the requirements of the Decoder interface, and will throw a + * DecoderException if the supplied object is not of type byte[] or String. + * + * @param obj Object to decode + * @return An object (of type byte[]) containing the binary data which + * corresponds to the byte[] or String supplied. + * @throws DecoderException if the parameter supplied is not of type byte[] + */ + public Object decode(final Object obj) { + if (obj instanceof byte[]) { + return decode((byte[]) obj); + } else if (obj instanceof String) { + return decode((String) obj); + } else { + return null; + } + } + + /** + * Decodes a String containing characters in the Base-N alphabet. + * + * @param pArray A String containing Base-N character data + * @return a byte array containing binary data + */ + public byte[] decode(final String pArray) { + return decode(pArray.getBytes(Charset.forName("UTF-8"))); + } + + /** + * Encodes a byte[] containing binary data, into a byte[] containing characters + * in the alphabet. + * + * @param pArray a byte array containing binary data + * @return A byte array containing only the base N alphabetic character data + */ + public byte[] encode(final byte[] pArray) { + if (pArray == null || pArray.length == 0) { + return pArray; + } + return encode(pArray, 0, pArray.length); + } + + /** + * Encodes a byte[] containing binary data, into a byte[] containing characters + * in the alphabet. + * + * @param pArray a byte array containing binary data + * @param offset initial offset of the subarray. + * @param length length of the subarray. + * @return A byte array containing only the base N alphabetic character data + * @since 1.11 + */ + public byte[] encode(final byte[] pArray, final int offset, final int length) { + if (pArray == null || pArray.length == 0) { + return pArray; + } + final Context context = new Context(); + encode(pArray, offset, length, context); + encode(pArray, offset, EOF, context); // Notify encoder of EOF. + final byte[] buf = new byte[context.pos - context.readPos]; + readResults(buf, 0, buf.length, context); + return buf; + } + + // package protected for access from I/O streams + abstract void encode(byte[] pArray, int i, int length, Context context); + + /** + * Encodes an Object using the Base-N algorithm. This method is provided in + * order to satisfy the requirements of the Encoder interface, and will throw an + * EncoderException if the supplied object is not of type byte[]. + * + * @param obj Object to encode + * @return An object (of type byte[]) containing the Base-N encoded data which + * corresponds to the byte[] supplied. + * @throws EncoderException if the parameter supplied is not of type byte[] + */ + public Object encode(final Object obj) { + return encode((byte[]) obj); + } + + /** + * Encodes a byte[] containing binary data, into a String containing characters + * in the appropriate alphabet. Uses UTF8 encoding. + * + * @param pArray a byte array containing binary data + * @return String containing only character data in the appropriate alphabet. + * @since 1.5 This is a duplicate of {@link #encodeToString(byte[])}; it was + * merged during refactoring. + */ + public String encodeAsString(final byte[] pArray) { + return new String(encode(pArray), Charset.forName("UTF-8")); + } + + /** + * Encodes a byte[] containing binary data, into a String containing characters + * in the Base-N alphabet. Uses UTF8 encoding. + * + * @param pArray a byte array containing binary data + * @return A String containing only Base-N character data + */ + public String encodeToString(final byte[] pArray) { + return new String(encode(pArray), Charset.forName("UTF-8")); + } + + /** + * Ensure that the buffer has room for {@code size} bytes + * + * @param size minimum spare space required + * @param context the context to be used + * @return the buffer + */ + protected byte[] ensureBufferSize(final int size, final Context context) { + if (context.buffer == null) { + context.buffer = new byte[Math.max(size, getDefaultBufferSize())]; + context.pos = 0; + context.readPos = 0; + + // Overflow-conscious: + // x + y > z == x + y - z > 0 + } else if (context.pos + size - context.buffer.length > 0) { + return resizeBuffer(context, context.pos + size); + } + return context.buffer; + } + + /** + * Returns the decoding behavior policy. + * + *

+ * The default is lenient. If the decoding policy is strict, then decoding will + * raise an {@link IllegalArgumentException} if trailing bits are not part of a + * valid encoding. Decoding will compose trailing bits into 8-bit bytes and + * discard the remainder. + *

+ * + * @return true if using strict decoding + * @since 1.15 + */ + public CodecPolicy getCodecPolicy() { + return decodingPolicy; + } + + /** + * Get the default buffer size. Can be overridden. + * + * @return the default buffer size. + */ + protected int getDefaultBufferSize() { + return DEFAULT_BUFFER_SIZE; + } + + /** + * Calculates the amount of space needed to encode the supplied array. + * + * @param pArray byte[] array which will later be encoded + * + * @return amount of space needed to encoded the supplied array. Returns a long + * since a max-len array will require > Integer.MAX_VALUE + */ + public long getEncodedLength(final byte[] pArray) { + // Calculate non-chunked size - rounded up to allow for padding + // cast to long is needed to avoid possibility of overflow + long len = ((pArray.length + unencodedBlockSize - 1) / unencodedBlockSize) * (long) encodedBlockSize; + if (lineLength > 0) { // We're using chunking + // Round up to nearest multiple + len += ((len + lineLength - 1) / lineLength) * chunkSeparatorLength; + } + return len; + } + + /** + * Returns true if this object has buffered data for reading. + * + * @param context the context to be used + * @return true if there is data still available for reading. + */ + boolean hasData(final Context context) { // package protected for access from I/O streams + return context.buffer != null; + } + + /** + * Returns whether or not the {@code octet} is in the current alphabet. Does not + * allow whitespace or pad. + * + * @param value The value to test + * + * @return {@code true} if the value is defined in the current alphabet, + * {@code false} otherwise. + */ + protected abstract boolean isInAlphabet(byte value); + + /** + * Tests a given byte array to see if it contains only valid characters within + * the alphabet. The method optionally treats whitespace and pad as valid. + * + * @param arrayOctet byte array to test + * @param allowWSPad if {@code true}, then whitespace and PAD are also allowed + * + * @return {@code true} if all bytes are valid characters in the alphabet or if + * the byte array is empty; {@code false}, otherwise + */ + public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) { + for (final byte octet : arrayOctet) { + if (!isInAlphabet(octet) && (!allowWSPad || (octet != pad) && !isWhiteSpace(octet))) { + return false; + } + } + return true; + } + + /** + * Tests a given String to see if it contains only valid characters within the + * alphabet. The method treats whitespace and PAD as valid. + * + * @param basen String to test + * @return {@code true} if all characters in the String are valid characters in + * the alphabet or if the String is empty; {@code false}, otherwise + * @see #isInAlphabet(byte[], boolean) + */ + public boolean isInAlphabet(final String basen) { + return isInAlphabet(basen.getBytes(Charset.forName("UTF-8")), true); + } + + /** + * Returns true if decoding behavior is strict. Decoding will raise an + * {@link IllegalArgumentException} if trailing bits are not part of a valid + * encoding. + * + *

+ * The default is false for lenient decoding. Decoding will compose trailing + * bits into 8-bit bytes and discard the remainder. + *

+ * + * @return true if using strict decoding + * @since 1.15 + */ + public boolean isStrictDecoding() { + return decodingPolicy == CodecPolicy.STRICT; + } + + /** + * Extracts buffered data into the provided byte[] array, starting at position + * bPos, up to a maximum of bAvail bytes. Returns how many bytes were actually + * extracted. + *

+ * Package protected for access from I/O streams. + * + * @param b byte[] array to extract the buffered data into. + * @param bPos position in byte[] array to start extraction at. + * @param bAvail amount of bytes we're allowed to extract. We may extract fewer + * (if fewer are available). + * @param context the context to be used + * @return The number of bytes successfully extracted into the provided byte[] + * array. + */ + int readResults(final byte[] b, final int bPos, final int bAvail, final Context context) { + if (context.buffer != null) { + final int len = Math.min(available(context), bAvail); + System.arraycopy(context.buffer, context.readPos, b, bPos, len); + context.readPos += len; + if (context.readPos >= context.pos) { + context.buffer = null; // so hasData() will return false, and this method can return -1 + } + return len; + } + return context.eof ? EOF : 0; + } +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/minecraft/GeneralDigest.java b/src/teavm/java/net/PeytonPlayz585/minecraft/GeneralDigest.java new file mode 100644 index 0000000..c7054e1 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/minecraft/GeneralDigest.java @@ -0,0 +1,108 @@ +package net.PeytonPlayz585.minecraft; + +/** + * base implementation of MD4 family style digest as outlined in "Handbook of + * Applied Cryptography", pages 344 - 347. + */ +public abstract class GeneralDigest { + private byte[] xBuf; + private int xBufOff; + + private long byteCount; + + /** + * Standard constructor + */ + protected GeneralDigest() { + xBuf = new byte[4]; + xBufOff = 0; + } + + /** + * Copy constructor. We are using copy constructors in place of the + * Object.clone() interface as this interface is not supported by J2ME. + */ + protected GeneralDigest(GeneralDigest t) { + xBuf = new byte[t.xBuf.length]; + System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length); + + xBufOff = t.xBufOff; + byteCount = t.byteCount; + } + + public void update(byte in) { + xBuf[xBufOff++] = in; + + if (xBufOff == xBuf.length) { + processWord(xBuf, 0); + xBufOff = 0; + } + + byteCount++; + } + + public void update(byte[] in, int inOff, int len) { + // + // fill the current word + // + while ((xBufOff != 0) && (len > 0)) { + update(in[inOff]); + + inOff++; + len--; + } + + // + // process whole words. + // + while (len > xBuf.length) { + processWord(in, inOff); + + inOff += xBuf.length; + len -= xBuf.length; + byteCount += xBuf.length; + } + + // + // load in the remainder. + // + while (len > 0) { + update(in[inOff]); + + inOff++; + len--; + } + } + + public void finish() { + long bitLength = (byteCount << 3); + + // + // add the pad bytes. + // + update((byte) 128); + + while (xBufOff != 0) { + update((byte) 0); + } + + processLength(bitLength); + + processBlock(); + } + + public void reset() { + byteCount = 0; + + xBufOff = 0; + for (int i = 0; i < xBuf.length; i++) { + xBuf[i] = 0; + } + } + + protected abstract void processWord(byte[] in, int inOff); + + protected abstract void processLength(long bitLength); + + protected abstract void processBlock(); +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/minecraft/MinecraftImage.java b/src/teavm/java/net/PeytonPlayz585/minecraft/MinecraftImage.java new file mode 100644 index 0000000..88532c1 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/minecraft/MinecraftImage.java @@ -0,0 +1,40 @@ +package net.PeytonPlayz585.minecraft; + +public class MinecraftImage { + + public final int[] data; + public final int w; + public final int h; + public final boolean alpha; + + public MinecraftImage(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) { + if (pdata.length != pw * ph) { + throw new IllegalArgumentException("array size does not equal image size"); + } + this.w = pw; + this.h = ph; + this.alpha = palpha; + if (!palpha) { + for (int i = 0; i < pdata.length; ++i) { + pdata[i] = pdata[i] | 0xFF000000; + } + } + this.data = pdata; + } + + public MinecraftImage 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); + } + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/minecraft/SHA1Digest.java b/src/teavm/java/net/PeytonPlayz585/minecraft/SHA1Digest.java new file mode 100644 index 0000000..c93990a --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/minecraft/SHA1Digest.java @@ -0,0 +1,213 @@ +package net.PeytonPlayz585.minecraft; + +/** + * implementation of SHA-1 as outlined in "Handbook of Applied Cryptography", + * pages 346 - 349. + * + * It is interesting to ponder why the, apart from the extra IV, the other + * difference here from MD5 is the "endienness" of the word processing! + */ +public class SHA1Digest extends GeneralDigest { + private static final int DIGEST_LENGTH = 20; + + private int H1, H2, H3, H4, H5; + + private int[] X = new int[80]; + private int xOff; + + /** + * Standard constructor + */ + public SHA1Digest() { + reset(); + } + + /** + * Copy constructor. This will copy the state of the provided message digest. + */ + public SHA1Digest(SHA1Digest t) { + super(t); + + H1 = t.H1; + H2 = t.H2; + H3 = t.H3; + H4 = t.H4; + H5 = t.H5; + + System.arraycopy(t.X, 0, X, 0, t.X.length); + xOff = t.xOff; + } + + public String getAlgorithmName() { + return "SHA-1"; + } + + public int getDigestSize() { + return DIGEST_LENGTH; + } + + protected void processWord(byte[] in, int inOff) { + X[xOff++] = ((in[inOff] & 0xff) << 24) | ((in[inOff + 1] & 0xff) << 16) | ((in[inOff + 2] & 0xff) << 8) + | ((in[inOff + 3] & 0xff)); + + if (xOff == 16) { + processBlock(); + } + } + + private void unpackWord(int word, byte[] out, int outOff) { + out[outOff] = (byte) (word >>> 24); + out[outOff + 1] = (byte) (word >>> 16); + out[outOff + 2] = (byte) (word >>> 8); + out[outOff + 3] = (byte) word; + } + + protected void processLength(long bitLength) { + if (xOff > 14) { + processBlock(); + } + + X[14] = (int) (bitLength >>> 32); + X[15] = (int) (bitLength & 0xffffffff); + } + + public int doFinal(byte[] out, int outOff) { + finish(); + + unpackWord(H1, out, outOff); + unpackWord(H2, out, outOff + 4); + unpackWord(H3, out, outOff + 8); + unpackWord(H4, out, outOff + 12); + unpackWord(H5, out, outOff + 16); + + reset(); + + return DIGEST_LENGTH; + } + + /** + * reset the chaining variables + */ + public void reset() { + super.reset(); + + H1 = 0x67452301; + H2 = 0xefcdab89; + H3 = 0x98badcfe; + H4 = 0x10325476; + H5 = 0xc3d2e1f0; + + xOff = 0; + for (int i = 0; i != X.length; i++) { + X[i] = 0; + } + } + + // + // Additive constants + // + private static final int Y1 = 0x5a827999; + private static final int Y2 = 0x6ed9eba1; + private static final int Y3 = 0x8f1bbcdc; + private static final int Y4 = 0xca62c1d6; + + private int f(int u, int v, int w) { + return ((u & v) | ((~u) & w)); + } + + private int h(int u, int v, int w) { + return (u ^ v ^ w); + } + + private int g(int u, int v, int w) { + return ((u & v) | (u & w) | (v & w)); + } + + private int rotateLeft(int x, int n) { + return (x << n) | (x >>> (32 - n)); + } + + protected void processBlock() { + // + // expand 16 word block into 80 word block. + // + for (int i = 16; i <= 79; i++) { + X[i] = rotateLeft((X[i - 3] ^ X[i - 8] ^ X[i - 14] ^ X[i - 16]), 1); + } + + // + // set up working variables. + // + int A = H1; + int B = H2; + int C = H3; + int D = H4; + int E = H5; + + // + // round 1 + // + for (int j = 0; j <= 19; j++) { + int t = rotateLeft(A, 5) + f(B, C, D) + E + X[j] + Y1; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + // + // round 2 + // + for (int j = 20; j <= 39; j++) { + int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y2; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + // + // round 3 + // + for (int j = 40; j <= 59; j++) { + int t = rotateLeft(A, 5) + g(B, C, D) + E + X[j] + Y3; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + // + // round 4 + // + for (int j = 60; j <= 79; j++) { + int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y4; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + H1 += A; + H2 += B; + H3 += C; + H4 += D; + H5 += E; + + // + // reset the offset and clean out the word buffer. + // + xOff = 0; + for (int i = 0; i != X.length; i++) { + X[i] = 0; + } + } +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTBase.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTBase.java new file mode 100644 index 0000000..f40e439 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTBase.java @@ -0,0 +1,78 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public abstract class NBTBase { + private String key = null; + + abstract void writeTagContents(DataOutput var1) throws IOException; + + abstract void readTagContents(DataInput var1) throws IOException; + + public abstract byte getType(); + + public final String getKey() { + return this.key == null ? "" : this.key; + } + + public final NBTBase setKey(String var1) { + this.key = var1; + return this; + } + + public static NBTBase readTag(DataInput var0) throws IOException { + byte var1 = var0.readByte(); + if(var1 == 0) { + return new NBTTagEnd(); + } else { + NBTBase var3 = createTagOfType(var1); + short var2 = var0.readShort(); + byte[] var4 = new byte[var2]; + var0.readFully(var4); + var3.key = new String(var4, "UTF-8"); + var3.readTagContents(var0); + return var3; + } + } + + public static void writeTag(NBTBase var0, DataOutput var1) throws IOException { + var1.writeByte(var0.getType()); + if(var0.getType() != 0) { + byte[] var2 = var0.getKey().getBytes("UTF-8"); + var1.writeShort(var2.length); + var1.write(var2); + var0.writeTagContents(var1); + } + } + + public static NBTBase createTagOfType(byte var0) { + switch(var0) { + case 0: + return new NBTTagEnd(); + case 1: + return new NBTTagByte(); + case 2: + return new NBTTagShort(); + case 3: + return new NBTTagInt(); + case 4: + return new NBTTagLong(); + case 5: + return new NBTTagFloat(); + case 6: + return new NBTTagDouble(); + case 7: + return new NBTTagByteArray(); + case 8: + return new NBTTagString(); + case 9: + return new NBTTagList(); + case 10: + return new NBTTagCompound(); + default: + return null; + } + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagByte.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagByte.java new file mode 100644 index 0000000..0505550 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagByte.java @@ -0,0 +1,32 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagByte extends NBTBase { + public byte byteValue; + + public NBTTagByte() { + } + + public NBTTagByte(byte var1) { + this.byteValue = var1; + } + + final void writeTagContents(DataOutput var1) throws IOException { + var1.writeByte(this.byteValue); + } + + final void readTagContents(DataInput var1) throws IOException { + this.byteValue = var1.readByte(); + } + + public final byte getType() { + return (byte)1; + } + + public final String toString() { + return "" + this.byteValue; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagByteArray.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagByteArray.java new file mode 100644 index 0000000..a805db9 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagByteArray.java @@ -0,0 +1,35 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagByteArray extends NBTBase { + public byte[] byteArray; + + public NBTTagByteArray() { + } + + public NBTTagByteArray(byte[] var1) { + this.byteArray = var1; + } + + final void writeTagContents(DataOutput var1) throws IOException { + var1.writeInt(this.byteArray.length); + var1.write(this.byteArray); + } + + final void readTagContents(DataInput var1) throws IOException { + int var2 = var1.readInt(); + this.byteArray = new byte[var2]; + var1.readFully(this.byteArray); + } + + public final byte getType() { + return (byte)7; + } + + public final String toString() { + return "[" + this.byteArray.length + " bytes]"; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagCompound.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagCompound.java new file mode 100644 index 0000000..65024ea --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagCompound.java @@ -0,0 +1,132 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public final class NBTTagCompound extends NBTBase { + private Map tagMap = new HashMap(); + + final void writeTagContents(DataOutput var1) throws IOException { + Iterator var2 = this.tagMap.values().iterator(); + + while(var2.hasNext()) { + NBTBase var3 = (NBTBase)var2.next(); + NBTBase.writeTag(var3, var1); + } + + var1.writeByte(0); + } + + final void readTagContents(DataInput var1) throws IOException { + this.tagMap.clear(); + + while(true) { + NBTBase var2 = NBTBase.readTag(var1); + if(var2.getType() == 0) { + return; + } + + this.tagMap.put(var2.getKey(), var2); + } + } + + public final byte getType() { + return (byte)10; + } + + public final void setTag(String var1, NBTBase var2) { + this.tagMap.put(var1, var2.setKey(var1)); + } + + public final void setByte(String var1, byte var2) { + this.tagMap.put(var1, (new NBTTagByte(var2)).setKey(var1)); + } + + public final void setShort(String var1, short var2) { + this.tagMap.put(var1, (new NBTTagShort(var2)).setKey(var1)); + } + + public final void setInteger(String var1, int var2) { + this.tagMap.put(var1, (new NBTTagInt(var2)).setKey(var1)); + } + + public final void setLong(String var1, long var2) { + this.tagMap.put(var1, (new NBTTagLong(var2)).setKey(var1)); + } + + public final void setFloat(String var1, float var2) { + this.tagMap.put(var1, (new NBTTagFloat(var2)).setKey(var1)); + } + + public final void setString(String var1, String var2) { + this.tagMap.put(var1, (new NBTTagString(var2)).setKey(var1)); + } + + public final void setByteArray(String var1, byte[] var2) { + this.tagMap.put(var1, (new NBTTagByteArray(var2)).setKey(var1)); + } + + public final void setCompoundTag(String var1, NBTTagCompound var2) { + this.tagMap.put(var1, var2.setKey(var1)); + } + + public final void setBoolean(String var1, boolean var2) { + this.setByte(var1, (byte)(var2 ? 1 : 0)); + } + + public final boolean hasKey(String var1) { + return this.tagMap.containsKey(var1); + } + + public final byte getByte(String var1) { + return !this.tagMap.containsKey(var1) ? 0 : ((NBTTagByte)this.tagMap.get(var1)).byteValue; + } + + public final short getShort(String var1) { + return !this.tagMap.containsKey(var1) ? 0 : ((NBTTagShort)this.tagMap.get(var1)).shortValue; + } + + public final int getInteger(String var1) { + return !this.tagMap.containsKey(var1) ? 0 : ((NBTTagInt)this.tagMap.get(var1)).intValue; + } + + public final long getLong(String var1) { + return !this.tagMap.containsKey(var1) ? 0L : ((NBTTagLong)this.tagMap.get(var1)).longValue; + } + + public final float getFloat(String var1) { + return !this.tagMap.containsKey(var1) ? 0.0F : ((NBTTagFloat)this.tagMap.get(var1)).floatValue; + } + + public final String getString(String var1) { + return !this.tagMap.containsKey(var1) ? "" : ((NBTTagString)this.tagMap.get(var1)).stringValue; + } + + public final byte[] getByteArray(String var1) { + return !this.tagMap.containsKey(var1) ? new byte[0] : ((NBTTagByteArray)this.tagMap.get(var1)).byteArray; + } + + public final NBTTagCompound getCompoundTag(String var1) { + return !this.tagMap.containsKey(var1) ? new NBTTagCompound() : (NBTTagCompound)this.tagMap.get(var1); + } + + public final NBTTagList getTagList(String var1) { + return !this.tagMap.containsKey(var1) ? new NBTTagList() : (NBTTagList)this.tagMap.get(var1); + } + + public final boolean getBoolean(String var1) { + return this.getByte(var1) != 0; + } + + public final String toString() { + return "" + this.tagMap.size() + " entries"; + } + + public final boolean emptyNBTMap() { + return this.tagMap.isEmpty(); + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagDouble.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagDouble.java new file mode 100644 index 0000000..6045f85 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagDouble.java @@ -0,0 +1,25 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagDouble extends NBTBase { + private double doubleValue; + + final void writeTagContents(DataOutput var1) throws IOException { + var1.writeDouble(this.doubleValue); + } + + final void readTagContents(DataInput var1) throws IOException { + this.doubleValue = var1.readDouble(); + } + + public final byte getType() { + return (byte)6; + } + + public final String toString() { + return "" + this.doubleValue; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagEnd.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagEnd.java new file mode 100644 index 0000000..1f67fdd --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagEnd.java @@ -0,0 +1,21 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagEnd extends NBTBase { + final void readTagContents(DataInput var1) throws IOException { + } + + final void writeTagContents(DataOutput var1) throws IOException { + } + + public final byte getType() { + return (byte)0; + } + + public final String toString() { + return "END"; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagFloat.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagFloat.java new file mode 100644 index 0000000..afeef31 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagFloat.java @@ -0,0 +1,32 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagFloat extends NBTBase { + public float floatValue; + + public NBTTagFloat() { + } + + public NBTTagFloat(float var1) { + this.floatValue = var1; + } + + final void writeTagContents(DataOutput var1) throws IOException { + var1.writeFloat(this.floatValue); + } + + final void readTagContents(DataInput var1) throws IOException { + this.floatValue = var1.readFloat(); + } + + public final byte getType() { + return (byte)5; + } + + public final String toString() { + return "" + this.floatValue; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagInt.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagInt.java new file mode 100644 index 0000000..6d94e00 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagInt.java @@ -0,0 +1,32 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagInt extends NBTBase { + public int intValue; + + public NBTTagInt() { + } + + public NBTTagInt(int var1) { + this.intValue = var1; + } + + final void writeTagContents(DataOutput var1) throws IOException { + var1.writeInt(this.intValue); + } + + final void readTagContents(DataInput var1) throws IOException { + this.intValue = var1.readInt(); + } + + public final byte getType() { + return (byte)3; + } + + public final String toString() { + return "" + this.intValue; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagList.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagList.java new file mode 100644 index 0000000..cada9f2 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagList.java @@ -0,0 +1,103 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public final class NBTTagList extends NBTBase { + private List tagList = new ArrayList(); + private byte tagType; + + final void writeTagContents(DataOutput var1) throws IOException { + if(this.tagList.size() > 0) { + this.tagType = ((NBTBase)this.tagList.get(0)).getType(); + } else { + this.tagType = 1; + } + + var1.writeByte(this.tagType); + var1.writeInt(this.tagList.size()); + + for(int var2 = 0; var2 < this.tagList.size(); ++var2) { + ((NBTBase)this.tagList.get(var2)).writeTagContents(var1); + } + + } + + final void readTagContents(DataInput var1) throws IOException { + this.tagType = var1.readByte(); + int var2 = var1.readInt(); + this.tagList = new ArrayList(); + + for(int var3 = 0; var3 < var2; ++var3) { + NBTBase var4 = NBTBase.createTagOfType(this.tagType); + var4.readTagContents(var1); + this.tagList.add(var4); + } + + } + + public final byte getType() { + return (byte)9; + } + + public final String toString() { + StringBuilder var10000 = (new StringBuilder()).append("").append(this.tagList.size()).append(" entries of type "); + byte var1 = this.tagType; + String var10001; + switch(var1) { + case 0: + var10001 = "TAG_End"; + break; + case 1: + var10001 = "TAG_Byte"; + break; + case 2: + var10001 = "TAG_Short"; + break; + case 3: + var10001 = "TAG_Int"; + break; + case 4: + var10001 = "TAG_Long"; + break; + case 5: + var10001 = "TAG_Float"; + break; + case 6: + var10001 = "TAG_Double"; + break; + case 7: + var10001 = "TAG_Byte_Array"; + break; + case 8: + var10001 = "TAG_String"; + break; + case 9: + var10001 = "TAG_List"; + break; + case 10: + var10001 = "TAG_Compound"; + break; + default: + var10001 = "UNKNOWN"; + } + + return var10000.append(var10001).toString(); + } + + public final void setTag(NBTBase var1) { + this.tagType = var1.getType(); + this.tagList.add(var1); + } + + public final NBTBase tagAt(int var1) { + return (NBTBase)this.tagList.get(var1); + } + + public final int tagCount() { + return this.tagList.size(); + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagLong.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagLong.java new file mode 100644 index 0000000..4a46db9 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagLong.java @@ -0,0 +1,32 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagLong extends NBTBase { + public long longValue; + + public NBTTagLong() { + } + + public NBTTagLong(long var1) { + this.longValue = var1; + } + + final void writeTagContents(DataOutput var1) throws IOException { + var1.writeLong(this.longValue); + } + + final void readTagContents(DataInput var1) throws IOException { + this.longValue = var1.readLong(); + } + + public final byte getType() { + return (byte)4; + } + + public final String toString() { + return "" + this.longValue; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagShort.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagShort.java new file mode 100644 index 0000000..240334a --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagShort.java @@ -0,0 +1,32 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagShort extends NBTBase { + public short shortValue; + + public NBTTagShort() { + } + + public NBTTagShort(short var1) { + this.shortValue = var1; + } + + final void writeTagContents(DataOutput var1) throws IOException { + var1.writeShort(this.shortValue); + } + + final void readTagContents(DataInput var1) throws IOException { + this.shortValue = var1.readShort(); + } + + public final byte getType() { + return (byte)2; + } + + public final String toString() { + return "" + this.shortValue; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagString.java b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagString.java new file mode 100644 index 0000000..c5fffcd --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/nbt/NBTTagString.java @@ -0,0 +1,37 @@ +package net.PeytonPlayz585.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public final class NBTTagString extends NBTBase { + public String stringValue; + + public NBTTagString() { + } + + public NBTTagString(String var1) { + this.stringValue = var1; + } + + final void writeTagContents(DataOutput var1) throws IOException { + byte[] var2 = this.stringValue.getBytes("UTF-8"); + var1.writeShort(var2.length); + var1.write(var2); + } + + final void readTagContents(DataInput var1) throws IOException { + short var2 = var1.readShort(); + byte[] var3 = new byte[var2]; + var1.readFully(var3); + this.stringValue = new String(var3, "UTF-8"); + } + + public final byte getType() { + return (byte)8; + } + + public final String toString() { + return "" + this.stringValue; + } +} diff --git a/src/teavm/java/net/PeytonPlayz585/storage/LocalStorageManager.java b/src/teavm/java/net/PeytonPlayz585/storage/LocalStorageManager.java new file mode 100644 index 0000000..f6d45cf --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/storage/LocalStorageManager.java @@ -0,0 +1,81 @@ +package net.PeytonPlayz585.storage; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.lwjgl.opengl.WebGL; + +import net.PeytonPlayz585.minecraft.Base64; +import net.PeytonPlayz585.nbt.NBTBase; +import net.PeytonPlayz585.nbt.NBTTagCompound; + +public class LocalStorageManager { + + public static NBTTagCompound gameSettingsStorage = null; + public static NBTTagCompound profileSettingsStorage = null; + + public static void loadStorage() { + byte[] g = WebGL.loadLocalStorage("g"); + byte[] p = WebGL.loadLocalStorage("p"); + + if(g != null) { + try { + NBTBase t = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(g))); + if(t != null && t instanceof NBTTagCompound) { + gameSettingsStorage = (NBTTagCompound)t; + } + }catch(IOException e) { + ; + } + } + + if(p != null) { + try { + NBTBase t = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(p))); + if(t != null && t instanceof NBTTagCompound) { + profileSettingsStorage = (NBTTagCompound)t; + } + }catch(IOException e) { + ; + } + } + + if(gameSettingsStorage == null) gameSettingsStorage = new NBTTagCompound(); + if(profileSettingsStorage == null) profileSettingsStorage = new NBTTagCompound(); + + } + + public static void saveStorageG() { + try { + ByteArrayOutputStream s = new ByteArrayOutputStream(); + NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s)); + WebGL.saveLocalStorage("g", s.toByteArray()); + } catch (IOException e) { + ; + } + } + + public static void saveStorageP() { + try { + ByteArrayOutputStream s = new ByteArrayOutputStream(); + NBTBase.writeTag(profileSettingsStorage, new DataOutputStream(s)); + WebGL.saveLocalStorage("p", s.toByteArray()); + } catch (IOException e) { + ; + } + } + + public static String dumpConfiguration() { + try { + ByteArrayOutputStream s = new ByteArrayOutputStream(); + NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s)); + return Base64.encodeBase64String(s.toByteArray()); + } catch(Throwable e) { + return ""; + } + } + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/teavm/IDBObjectStorePatched.java b/src/teavm/java/net/PeytonPlayz585/teavm/IDBObjectStorePatched.java new file mode 100644 index 0000000..fbac818 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/teavm/IDBObjectStorePatched.java @@ -0,0 +1,79 @@ +//package net.PeytonPlayz585.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); +//} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/teavm/IndexedDBFilesystem.java b/src/teavm/java/net/PeytonPlayz585/teavm/IndexedDBFilesystem.java new file mode 100644 index 0000000..d173a27 --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/teavm/IndexedDBFilesystem.java @@ -0,0 +1,427 @@ +//package net.PeytonPlayz585.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 org.lwjgl.opengl.WebGL; +//import org.lwjgl.opengl.WebGL.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_PeytonPlayz585_minecraft_alpha_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.epoch + 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 epoch = 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 WebGL.FileEntry(k, true, -1)); +// } +// }else { +// lst.add(new WebGL.FileEntry(k, false, epoch + 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() - epoch), 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)); +// } +// }); +// } +// } +// +//} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/teavm/WebGL2RenderingContext.java b/src/teavm/java/net/PeytonPlayz585/teavm/WebGL2RenderingContext.java new file mode 100644 index 0000000..26c0ace --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/teavm/WebGL2RenderingContext.java @@ -0,0 +1,42 @@ +package net.PeytonPlayz585.teavm; + +import org.teavm.jso.webgl.WebGLRenderingContext; + +public interface WebGL2RenderingContext extends WebGLRenderingContext { + + int TEXTURE_MAX_LEVEL = 0x0000813D; + int TEXTURE_MAX_ANISOTROPY_EXT = 0x000084FE; + int UNSIGNED_INT_24_8 = 0x000084FA; + int ANY_SAMPLES_PASSED = 0x00008D6A; + int QUERY_RESULT = 0x00008866; + int QUERY_RESULT_AVAILABLE = 0x00008867; + int DEPTH24_STENCIL8 = 0x000088F0; + int DEPTH_COMPONENT32F = 0x00008CAC; + int READ_FRAMEBUFFER = 0x00008CA8; + int DRAW_FRAMEBUFFER = 0x00008CA9; + int RGB8 = 0x00008051; + int RGBA8 = 0x00008058; + + WebGLQuery createQuery(); + + void beginQuery(int p1, WebGLQuery obj); + + void endQuery(int p1); + + void deleteQuery(WebGLQuery obj); + + int getQueryParameter(WebGLQuery obj, int p2); + + WebGLVertexArray createVertexArray(); + + void deleteVertexArray(WebGLVertexArray obj); + + void bindVertexArray(WebGLVertexArray obj); + + void renderbufferStorageMultisample(int p1, int p2, int p3, int p4, int p5); + + void blitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10); + + void drawBuffers(int[] p1); + +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/teavm/WebGLQuery.java b/src/teavm/java/net/PeytonPlayz585/teavm/WebGLQuery.java new file mode 100644 index 0000000..035b43c --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/teavm/WebGLQuery.java @@ -0,0 +1,6 @@ +package net.PeytonPlayz585.teavm; + +import org.teavm.jso.JSObject; + +public interface WebGLQuery extends JSObject { +} \ No newline at end of file diff --git a/src/teavm/java/net/PeytonPlayz585/teavm/WebGLVertexArray.java b/src/teavm/java/net/PeytonPlayz585/teavm/WebGLVertexArray.java new file mode 100644 index 0000000..6ddffda --- /dev/null +++ b/src/teavm/java/net/PeytonPlayz585/teavm/WebGLVertexArray.java @@ -0,0 +1,6 @@ +package net.PeytonPlayz585.teavm; + +import org.teavm.jso.JSObject; + +public interface WebGLVertexArray extends JSObject { +} \ No newline at end of file diff --git a/src/teavm/java/net/minecraft/client/CanvasMinecraftApplet.java b/src/teavm/java/net/minecraft/client/CanvasMinecraftApplet.java new file mode 100644 index 0000000..e37cd52 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/CanvasMinecraftApplet.java @@ -0,0 +1,21 @@ +package net.minecraft.client; + +import java.awt.Canvas; + +final class CanvasMinecraftApplet extends Canvas { + private MinecraftApplet mcApplet; + + CanvasMinecraftApplet(MinecraftApplet var1) { + this.mcApplet = var1; + } + + public final synchronized void addNotify() { + super.addNotify(); + this.mcApplet.startMainThread(); + } + + public final synchronized void removeNotify() { + this.mcApplet.shutdown(); + super.removeNotify(); + } +} diff --git a/src/teavm/java/net/minecraft/client/ChatLine.java b/src/teavm/java/net/minecraft/client/ChatLine.java new file mode 100644 index 0000000..a6931ff --- /dev/null +++ b/src/teavm/java/net/minecraft/client/ChatLine.java @@ -0,0 +1,5 @@ +package net.minecraft.client; + +public final class ChatLine { + public int updateCounter; +} diff --git a/src/teavm/java/net/minecraft/client/EnumOS.java b/src/teavm/java/net/minecraft/client/EnumOS.java new file mode 100644 index 0000000..fdb8f65 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/EnumOS.java @@ -0,0 +1,9 @@ +package net.minecraft.client; + +enum EnumOS { + linux, + solaris, + windows, + macos, + unknown; +} diff --git a/src/teavm/java/net/minecraft/client/EnumOSMappingHelper.java b/src/teavm/java/net/minecraft/client/EnumOSMappingHelper.java new file mode 100644 index 0000000..255f4e9 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/EnumOSMappingHelper.java @@ -0,0 +1,27 @@ +package net.minecraft.client; + +final class EnumOSMappingHelper { + static final int[] osValues = new int[EnumOS.values().length]; + + static { + try { + osValues[EnumOS.linux.ordinal()] = 1; + } catch (NoSuchFieldError var3) { + } + + try { + osValues[EnumOS.solaris.ordinal()] = 2; + } catch (NoSuchFieldError var2) { + } + + try { + osValues[EnumOS.windows.ordinal()] = 3; + } catch (NoSuchFieldError var1) { + } + + try { + osValues[EnumOS.macos.ordinal()] = 4; + } catch (NoSuchFieldError var0) { + } + } +} diff --git a/src/teavm/java/net/minecraft/client/GameSettings.java b/src/teavm/java/net/minecraft/client/GameSettings.java new file mode 100644 index 0000000..479ad8a --- /dev/null +++ b/src/teavm/java/net/minecraft/client/GameSettings.java @@ -0,0 +1,179 @@ +package net.minecraft.client; + +import org.lwjgl.opengl.GL11; + +public final class GameSettings { + private static final String[] RENDER_DISTANCES = new String[]{"FAR", "NORMAL", "SHORT", "TINY"}; + private static final String[] DIFFICULTIES = new String[]{"Peaceful", "Easy", "Normal", "Hard"}; + public boolean music = true; + public boolean sound = true; + public boolean invertMouse = false; + public boolean showFPS = false; + public int renderDistance = 0; + public boolean fancyGraphics = true; + public boolean anaglyph = false; + public boolean limitFramerate = false; + public KeyBinding keyBindForward = new KeyBinding("Forward", 17); + public KeyBinding keyBindLeft = new KeyBinding("Left", 30); + public KeyBinding keyBindBack = new KeyBinding("Back", 31); + public KeyBinding keyBindRight = new KeyBinding("Right", 32); + public KeyBinding keyBindJump = new KeyBinding("Jump", 57); + public KeyBinding keyBindInventory = new KeyBinding("Inventory", 23); + public KeyBinding keyBindDrop = new KeyBinding("Drop", 16); + private KeyBinding keyBindChat = new KeyBinding("Chat", 20); + public KeyBinding keyBindToggleFog = new KeyBinding("Toggle fog", 33); + public KeyBinding keyBindSave = new KeyBinding("Save location", 28); + public KeyBinding keyBindLoad = new KeyBinding("Load location", 19); + public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog, this.keyBindSave, this.keyBindLoad}; + private Minecraft mc; +// private File optionsFile; + public int numberOfOptions = 9; + public int difficulty = 2; + public boolean thirdPersonView = false; + + public GameSettings(Minecraft var1) { + this.mc = var1; +// this.optionsFile = new File(var2, "options.txt"); + this.loadOptions(); + } + + public final String setKeyBindingString(int var1) { + return this.keyBindings[var1].keyDescription + ": " + GL11.getKeyName(this.keyBindings[var1].keyCode); + } + + public final void setKeyBinding(int var1, int var2) { + this.keyBindings[var1].keyCode = var2; + this.saveOptions(); + } + + public final void setOptionValue(int var1, int var2) { + if(var1 == 0) { + this.music = !this.music; + } + + if(var1 == 1) { + this.sound = !this.sound; + } + + if(var1 == 2) { + this.invertMouse = !this.invertMouse; + } + + if(var1 == 3) { + this.showFPS = !this.showFPS; + } + + if(var1 == 4) { + this.renderDistance = this.renderDistance + var2 & 3; + } + + if(var1 == 5) { + this.fancyGraphics = !this.fancyGraphics; + } + + if(var1 == 6) { + this.anaglyph = !this.anaglyph; + this.mc.renderEngine.refreshTextures(); + } + + if(var1 == 7) { + this.limitFramerate = !this.limitFramerate; + } + + if(var1 == 8) { + this.difficulty = this.difficulty + var2 & 3; + } + + this.saveOptions(); + } + + public final String setOptionString(int var1) { + return var1 == 0 ? "Music: " + (this.music ? "ON" : "OFF") : (var1 == 1 ? "Sound: " + (this.sound ? "ON" : "OFF") : (var1 == 2 ? "Invert mouse: " + (this.invertMouse ? "ON" : "OFF") : (var1 == 3 ? "Show FPS: " + (this.showFPS ? "ON" : "OFF") : (var1 == 4 ? "Render distance: " + RENDER_DISTANCES[this.renderDistance] : (var1 == 5 ? "View bobbing: " + (this.fancyGraphics ? "ON" : "OFF") : (var1 == 6 ? "3d anaglyph: " + (this.anaglyph ? "ON" : "OFF") : (var1 == 7 ? "Limit framerate: " + (this.limitFramerate ? "ON" : "OFF") : (var1 == 8 ? "Difficulty: " + DIFFICULTIES[this.difficulty] : "")))))))); + } + + private void loadOptions() { +// try { +// if(this.optionsFile.exists()) { +// BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile)); +// +// while(true) { +// String var2 = var1.readLine(); +// if(var2 == null) { +// var1.close(); +// return; +// } +// +// String[] var5 = var2.split(":"); +// if(var5[0].equals("music")) { +// this.music = var5[1].equals("true"); +// } +// +// if(var5[0].equals("sound")) { +// this.sound = var5[1].equals("true"); +// } +// +// if(var5[0].equals("invertYMouse")) { +// this.invertMouse = var5[1].equals("true"); +// } +// +// if(var5[0].equals("showFrameRate")) { +// this.showFPS = var5[1].equals("true"); +// } +// +// if(var5[0].equals("viewDistance")) { +// this.renderDistance = Integer.parseInt(var5[1]); +// } +// +// if(var5[0].equals("bobView")) { +// this.fancyGraphics = var5[1].equals("true"); +// } +// +// if(var5[0].equals("anaglyph3d")) { +// this.anaglyph = var5[1].equals("true"); +// } +// +// if(var5[0].equals("limitFramerate")) { +// this.limitFramerate = var5[1].equals("true"); +// } +// +// if(var5[0].equals("difficulty")) { +// this.difficulty = Integer.parseInt(var5[1]); +// } +// +// for(int var3 = 0; var3 < this.keyBindings.length; ++var3) { +// if(var5[0].equals("key_" + this.keyBindings[var3].keyDescription)) { +// this.keyBindings[var3].keyCode = Integer.parseInt(var5[1]); +// } +// } +// } +// } +// } catch (Exception var4) { +// System.out.println("Failed to load options"); +// var4.printStackTrace(); +// } + } + + public final void saveOptions() { +// try { +// PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile)); +// var1.println("music:" + this.music); +// var1.println("sound:" + this.sound); +// var1.println("invertYMouse:" + this.invertMouse); +// var1.println("showFrameRate:" + this.showFPS); +// var1.println("viewDistance:" + this.renderDistance); +// var1.println("bobView:" + this.fancyGraphics); +// var1.println("anaglyph3d:" + this.anaglyph); +// var1.println("limitFramerate:" + this.limitFramerate); +// var1.println("difficulty:" + this.difficulty); +// +// for(int var2 = 0; var2 < this.keyBindings.length; ++var2) { +// var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode); +// } +// +// var1.close(); +// } catch (Exception var3) { +// System.out.println("Failed to save options"); +// var3.printStackTrace(); +// } + } +} diff --git a/src/teavm/java/net/minecraft/client/GuiMainMenu.java b/src/teavm/java/net/minecraft/client/GuiMainMenu.java new file mode 100644 index 0000000..8d21e40 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/GuiMainMenu.java @@ -0,0 +1,79 @@ +package net.minecraft.client; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiLoadLevel; +import net.minecraft.client.gui.GuiNewLevel; +import net.minecraft.client.gui.GuiOptions; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.render.Tessellator; +import org.lwjgl.opengl.GL11; + +public final class GuiMainMenu extends GuiScreen { + private float updateCounter = 0.0F; + private String[] splashes = new String[]{"Pre-beta!", "As seen on TV!", "Awesome!", "100% pure!", "May contain nuts!", "Better than Prey!", "More polygons!", "Sexy!", "Limited edition!", "Flashing letters!", "Made by Notch!", "Coming soon!", "Best in class!", "When it\'s finished!", "Absolutely dragon free!", "Excitement!", "More than 5000 sold!", "One of a kind!", "700+ hits on YouTube!", "Indev!", "Spiders everywhere!", "Check it out!", "Holy cow, man!", "It\'s a game!", "Made in Sweden!", "Uses LWJGL!", "Reticulating splines!", "Minecraft!", "Yaaay!", "Alpha version!", "Singleplayer!", "Keyboard compatible!", "Undocumented!", "Ingots!", "Exploding creepers!", "That\'s not a moon!", "l33t!", "Create!", "Survive!", "Dungeon!", "Exclusive!", "The bee\'s knees!", "Down with O.P.P.!", "Closed source!", "Classy!", "Wow!", "Not on steam!", "9.95 euro!", "Half price!", "Oh man!", "Check it out!", "Awesome community!", "Pixels!", "Teetsuuuuoooo!", "Kaaneeeedaaaa!", "Now with difficulty!", "Enhanced!", "90% bug free!", "Pretty!", "12 herbs and spices!", "Fat free!", "Absolutely no memes!", "Free dental!", "Ask your doctor!", "Minors welcome!", "Cloud computing!", "Legal in Finland!", "Hard to label!", "Technically good!", "Bringing home the bacon!", "Indie!", "GOTY!", "Ceci n\'est pas une title screen!", "Euclidian!", "Now in 3D!", "Inspirational!", "Herregud!", "Complex cellular automata!", "Yes, sir!", "Played by cowboys!", "OpenGL 1.1!", "Thousands of colors!", "Try it!", "Age of Wonders is better!", "Try the mushroom stew!", "Sensational!", "Hot tamale, hot hot tamale!", "Play him off, keyboard cat!", "Guaranteed!", "Macroscopic!", "Bring it on!", "Random splash!", "Call your mother!", "Monster infighting!", "Loved by millions!", "Ultimate edition!", "Freaky!", "You\'ve got a brand new key!", "Water proof!", "Uninflammable!", "Whoa, dude!", "All inclusive!", "Tell your friends!", "NP is not in P!", "Notch <3 Ez!", "Music by C418!"}; + private String currentSplash = this.splashes[(int)(Math.random() * (double)this.splashes.length)]; + + public final void updateScreen() { + this.updateCounter += 0.01F; + } + + protected final void keyTyped(char var1, int var2) { + } + + public final void initGui() { + this.controlList.clear(); + this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 48, "Generate new level...")); + this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, "Load level..")); + this.controlList.add(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 96, "Play tutorial level")); + this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Options...")); + ((GuiButton)this.controlList.get(2)).enabled = false; + if(this.mc.session == null) { + ((GuiButton)this.controlList.get(1)).enabled = false; + } + + } + + protected final void actionPerformed(GuiButton var1) { + if(var1.id == 0) { + this.mc.displayGuiScreen(new GuiOptions(this, this.mc.options)); + } + + if(var1.id == 1) { + this.mc.displayGuiScreen(new GuiNewLevel(this)); + } + + if(this.mc.session != null && var1.id == 2) { + this.mc.displayGuiScreen(new GuiLoadLevel(this)); + } + + } + + public final void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + Tessellator var4 = Tessellator.instance; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/logo.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + var4.setColorOpaque_I(16777215); + this.drawTexturedModalRect((this.width - 256) / 2, 30, 0, 0, 256, 49); + GL11.glPushMatrix(); + GL11.glTranslatef((float)(this.width / 2 + 90), 70.0F, 0.0F); + GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); + float var15 = 1.8F - MathHelper.abs(MathHelper.sin((float)(System.currentTimeMillis() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F); + var15 = var15 * 100.0F / (float)(this.fontRenderer.getStringWidth(this.currentSplash) + 32); + GL11.glScalef(var15, var15, var15); + drawCenteredString(this.fontRenderer, this.currentSplash, 0, -8, 16776960); + GL11.glPopMatrix(); + String var16 = "Copyright Mojang Specifications. Do not distribute."; + drawString(this.fontRenderer, var16, this.width - this.fontRenderer.getStringWidth(var16) - 2, this.height - 10, 16777215); + long var7 = Runtime.getRuntime().maxMemory(); + long var9 = Runtime.getRuntime().totalMemory(); + long var11 = Runtime.getRuntime().freeMemory(); + long var13 = var7 - var11; + var16 = "Free memory: " + var13 * 100L / var7 + "% of " + var7 / 1024L / 1024L + "MB"; + drawString(this.fontRenderer, var16, this.width - this.fontRenderer.getStringWidth(var16) - 2, 2, 8421504); + var16 = "Allocated memory: " + var9 * 100L / var7 + "% (" + var9 / 1024L / 1024L + "MB)"; + drawString(this.fontRenderer, var16, this.width - this.fontRenderer.getStringWidth(var16) - 2, 12, 8421504); + super.drawScreen(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/client/KeyBinding.java b/src/teavm/java/net/minecraft/client/KeyBinding.java new file mode 100644 index 0000000..ffffe9d --- /dev/null +++ b/src/teavm/java/net/minecraft/client/KeyBinding.java @@ -0,0 +1,11 @@ +package net.minecraft.client; + +public final class KeyBinding { + public String keyDescription; + public int keyCode; + + public KeyBinding(String var1, int var2) { + this.keyDescription = var1; + this.keyCode = var2; + } +} diff --git a/src/teavm/java/net/minecraft/client/LoadingScreenRenderer.java b/src/teavm/java/net/minecraft/client/LoadingScreenRenderer.java new file mode 100644 index 0000000..6a2222f --- /dev/null +++ b/src/teavm/java/net/minecraft/client/LoadingScreenRenderer.java @@ -0,0 +1,136 @@ +package net.minecraft.client; + +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPInputStream; + +import net.PeytonPlayz585.nbt.NBTBase; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.render.Tessellator; +import org.lwjgl.opengl.GL11; +import util.IProgressUpdate; + +public class LoadingScreenRenderer implements IProgressUpdate { + private String text; + private Minecraft mc; + private String title; + private long start; + + public LoadingScreenRenderer(Minecraft var1) { + this.text = ""; + this.title = ""; + this.start = System.currentTimeMillis(); + this.mc = var1; + } + + public final void displayProgressMessage(String var1) { + if(!this.mc.running) { + throw new MinecraftError(); + } else { + this.title = var1; + ScaledResolution var3 = new ScaledResolution(this.mc.displayWidth, this.mc.displayHeight); + int var2 = var3.getScaledWidth(); + int var4 = var3.getScaledHeight(); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, (double)var2, (double)var4, 0.0D, 100.0D, 300.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -200.0F); + } + } + + public final void displayLoadingString(String var1) { + if(!this.mc.running) { + throw new MinecraftError(); + } else { + this.start = 0L; + this.text = var1; + this.setLoadingProgress(-1); + this.start = 0L; + } + } + + public final void setLoadingProgress(int var1) { + if(!this.mc.running) { + throw new MinecraftError(); + } else { + long var2 = System.currentTimeMillis(); + if(var2 - this.start >= 20L) { + this.start = var2; + ScaledResolution var8 = new ScaledResolution(this.mc.displayWidth, this.mc.displayHeight); + int var3 = var8.getScaledWidth(); + int var9 = var8.getScaledHeight(); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, (double)var3, (double)var9, 0.0D, 100.0D, 300.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -200.0F); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT); + Tessellator var4 = Tessellator.instance; + int var5 = this.mc.renderEngine.getTexture("/dirt.png"); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5); + var4.startDrawingQuads(); + var4.setColorOpaque_I(4210752); + var4.addVertexWithUV(0.0F, (float)var9, 0.0F, 0.0F, (float)var9 / 32.0F); + var4.addVertexWithUV((float)var3, (float)var9, 0.0F, (float)var3 / 32.0F, (float)var9 / 32.0F); + var4.addVertexWithUV((float)var3, 0.0F, 0.0F, (float)var3 / 32.0F, 0.0F); + var4.addVertexWithUV(0.0F, 0.0F, 0.0F, 0.0F, 0.0F); + var4.draw(); + if(var1 >= 0) { + var5 = var3 / 2 - 50; + int var6 = var9 / 2 + 16; + GL11.glDisable(GL11.GL_TEXTURE_2D); + var4.startDrawingQuads(); + var4.setColorOpaque_I(8421504); + var4.addVertex((float)var5, (float)var6, 0.0F); + var4.addVertex((float)var5, (float)(var6 + 2), 0.0F); + var4.addVertex((float)(var5 + 100), (float)(var6 + 2), 0.0F); + var4.addVertex((float)(var5 + 100), (float)var6, 0.0F); + var4.setColorOpaque_I(8454016); + var4.addVertex((float)var5, (float)var6, 0.0F); + var4.addVertex((float)var5, (float)(var6 + 2), 0.0F); + var4.addVertex((float)(var5 + var1), (float)(var6 + 2), 0.0F); + var4.addVertex((float)(var5 + var1), (float)var6, 0.0F); + var4.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.mc.fontRenderer.drawStringWithShadow(this.title, (var3 - this.mc.fontRenderer.getStringWidth(this.title)) / 2, var9 / 2 - 4 - 16, 16777215); + this.mc.fontRenderer.drawStringWithShadow(this.text, (var3 - this.mc.fontRenderer.getStringWidth(this.text)) / 2, var9 / 2 - 4 + 8, 16777215); + GL11.updateDisplay(); + + try { + Thread.yield(); + } catch (Exception var7) { + } + } + } + } + + public LoadingScreenRenderer() { + } + + public static NBTTagCompound writeLevelTags(InputStream var0) throws IOException { + DataInputStream var4 = new DataInputStream(new GZIPInputStream(var0)); + + NBTTagCompound var5; + try { + NBTBase var1 = NBTBase.readTag(var4); + if(!(var1 instanceof NBTTagCompound)) { + throw new IOException("Root tag must be a named compound tag"); + } + + var5 = (NBTTagCompound)var1; + } finally { + var4.close(); + } + + return var5; + } +} diff --git a/src/teavm/java/net/minecraft/client/Minecraft.java b/src/teavm/java/net/minecraft/client/Minecraft.java new file mode 100644 index 0000000..0cacb79 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/Minecraft.java @@ -0,0 +1,879 @@ +package net.minecraft.client; + +import java.awt.Canvas; +import java.awt.Component; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import javax.swing.JOptionPane; +import net.minecraft.client.controller.PlayerController; +import net.minecraft.client.controller.PlayerControllerCreative; +import net.minecraft.client.controller.PlayerControllerSP; +import net.minecraft.client.effect.EffectRenderer; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiErrorScreen; +import net.minecraft.client.gui.GuiGameOver; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.client.gui.GuiIngameMenu; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.container.GuiInventory; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.player.EntityPlayerSP; +import net.minecraft.client.player.MovementInputFromOptions; +import net.minecraft.client.render.EntityRenderer; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.client.render.RenderGlobal; +import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.texture.TextureFlamesFX; +import net.minecraft.client.render.texture.TextureGearsFX; +import net.minecraft.client.render.texture.TextureLavaFX; +import net.minecraft.client.render.texture.TextureWaterFX; +import net.minecraft.client.render.texture.TextureWaterFlowFX; +import net.minecraft.client.sound.SoundManager; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.player.InventoryPlayer; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.generator.LevelGenerator; +import net.minecraft.game.physics.MovingObjectPosition; +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.input.Controllers; +import org.lwjgl.input.Cursor; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.ContextCapabilities; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; + +public final class Minecraft implements Runnable { + public PlayerController playerController = new PlayerControllerSP(this); + private boolean fullscreen = false; + public int displayWidth; + public int displayHeight; + private OpenGlCapsChecker glCapabilities; + private Timer timer = new Timer(20.0F); + public World theWorld; + public RenderGlobal renderGlobal; + public EntityPlayerSP thePlayer; + public EffectRenderer effectRenderer; + public Session session = null; + public String minecraftUri; + public Canvas mcCanvas; + public boolean appletMode = true; + public volatile boolean isGamePaused = false; + public RenderEngine renderEngine; + public FontRenderer fontRenderer; + public GuiScreen currentScreen = null; + public LoadingScreenRenderer loadingScreen = new LoadingScreenRenderer(this); + public EntityRenderer entityRenderer = new EntityRenderer(this); + private ThreadDownloadResources downloadResourcesThread; + private int ticksRan = 0; + private int leftClickCounter = 0; + private int tempDisplayWidth; + private int tempDisplayHeight; + public String loadMapUser = null; + public int loadMapID = 0; + public GuiIngame ingameGUI; + public boolean skipRenderWorld = false; + public MovingObjectPosition objectMouseOver; + public GameSettings options; + private MinecraftApplet mcApplet; + public SoundManager sndManager; + public MouseHelper mouseHelper; + public File mcDataDir; + private String server; + private TextureWaterFX textureWaterFX; + private TextureLavaFX textureLavaFX; + volatile boolean running; + public String debug; + public boolean inventoryScreen; + private int prevFrameTime; + public boolean inGameHasFocus; + + public Minecraft(Canvas var1, MinecraftApplet var2, int var3, int var4, boolean var5) { + new ModelBiped(0.0F); + this.objectMouseOver = null; + this.sndManager = new SoundManager(); + this.server = null; + this.textureWaterFX = new TextureWaterFX(); + this.textureLavaFX = new TextureLavaFX(); + this.running = false; + this.debug = ""; + this.inventoryScreen = false; + this.prevFrameTime = 0; + this.inGameHasFocus = false; + this.tempDisplayWidth = var3; + this.tempDisplayHeight = var4; + this.fullscreen = var5; + this.mcApplet = var2; + new ThreadSleepForever(this, "Timer hack thread"); + this.mcCanvas = var1; + this.displayWidth = var3; + this.displayHeight = var4; + this.fullscreen = var5; + } + + public final void setServer(String var1, int var2) { + this.server = var1; + } + + public final void displayGuiScreen(GuiScreen var1) { + if(!(this.currentScreen instanceof GuiErrorScreen)) { + if(this.currentScreen != null) { + this.currentScreen.onGuiClosed(); + } + + if(var1 == null && this.theWorld == null) { + var1 = new GuiMainMenu(); + } else if(var1 == null && this.thePlayer.health <= 0) { + var1 = new GuiGameOver(); + } + + this.currentScreen = (GuiScreen)var1; + if(var1 != null) { + this.inputLock(); + ScaledResolution var2 = new ScaledResolution(this.displayWidth, this.displayHeight); + int var3 = var2.getScaledWidth(); + int var4 = var2.getScaledHeight(); + ((GuiScreen)var1).setWorldAndResolution(this, var3, var4); + this.skipRenderWorld = false; + } else { + this.setIngameFocus(); + } + } + } + + public final void shutdownMinecraftApplet() { + try { + if(this.downloadResourcesThread != null) { + this.downloadResourcesThread.closeMinecraft(); + } + } catch (Exception var5) { + } + + try { + this.sndManager.closeMinecraft(); + Mouse.destroy(); + Keyboard.destroy(); + } finally { + Display.destroy(); + } + + } + + public final void run() { + this.running = true; + + try { + Minecraft var1 = this; + if(this.mcCanvas != null) { + Display.setParent(this.mcCanvas); + } else if(this.fullscreen) { + Display.setFullscreen(true); + this.displayWidth = Display.getDisplayMode().getWidth(); + this.displayHeight = Display.getDisplayMode().getHeight(); + } else { + Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight)); + } + + Display.setTitle("Minecraft Minecraft Indev"); + + IntBuffer var24; + try { + Display.create(); + System.out.println("LWJGL version: " + Sys.getVersion()); + System.out.println("GL RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + System.out.println("GL VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); + System.out.println("GL VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + ContextCapabilities var2 = GLContext.getCapabilities(); + System.out.println("OpenGL 3.0: " + var2.OpenGL30); + System.out.println("OpenGL 3.1: " + var2.OpenGL31); + System.out.println("OpenGL 3.2: " + var2.OpenGL32); + System.out.println("ARB_compatibility: " + var2.GL_ARB_compatibility); + if(var2.OpenGL32) { + var24 = ByteBuffer.allocateDirect(64).order(ByteOrder.nativeOrder()).asIntBuffer(); + GL11.glGetInteger('\u9126', var24); + int var25 = var24.get(0); + System.out.println("PROFILE MASK: " + Integer.toBinaryString(var25)); + System.out.println("CORE PROFILE: " + ((var25 & 1) != 0)); + System.out.println("COMPATIBILITY PROFILE: " + ((var25 & 2) != 0)); + } + } catch (LWJGLException var17) { + var17.printStackTrace(); + + try { + Thread.sleep(1000L); + } catch (InterruptedException var16) { + } + + Display.create(); + } + + Keyboard.create(); + Mouse.create(); + this.mouseHelper = new MouseHelper(this.mcCanvas); + + try { + Controllers.create(); + } catch (Exception var15) { + var15.printStackTrace(); + } + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glClearDepth(1.0D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glCullFace(GL11.GL_BACK); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + this.glCapabilities = new OpenGlCapsChecker(); + String var3 = "minecraft"; + String var26 = System.getProperty("user.home", "."); + int[] var10001 = EnumOSMappingHelper.osValues; + String var4 = System.getProperty("os.name").toLowerCase(); + File var27; + switch(var10001[(var4.contains("win") ? EnumOS.windows : (var4.contains("mac") ? EnumOS.macos : (var4.contains("solaris") ? EnumOS.solaris : (var4.contains("sunos") ? EnumOS.solaris : (var4.contains("linux") ? EnumOS.linux : (var4.contains("unix") ? EnumOS.linux : EnumOS.unknown)))))).ordinal()]) { + case 1: + case 2: + var27 = new File(var26, '.' + var3 + '/'); + break; + case 3: + var4 = System.getenv("APPDATA"); + if(var4 != null) { + var27 = new File(var4, "." + var3 + '/'); + } else { + var27 = new File(var26, '.' + var3 + '/'); + } + break; + case 4: + var27 = new File(var26, "Library/Application Support/" + var3); + break; + default: + var27 = new File(var26, var3 + '/'); + } + + if(!var27.exists() && !var27.mkdirs()) { + throw new RuntimeException("The working directory could not be created: " + var27); + } + + this.mcDataDir = var27; + this.options = new GameSettings(this, this.mcDataDir); + this.sndManager.loadSoundSettings(this.options); + this.renderEngine = new RenderEngine(this.options); + this.renderEngine.registerTextureFX(this.textureLavaFX); + this.renderEngine.registerTextureFX(this.textureWaterFX); + this.renderEngine.registerTextureFX(new TextureWaterFlowFX()); + this.renderEngine.registerTextureFX(new TextureFlamesFX(0)); + this.renderEngine.registerTextureFX(new TextureFlamesFX(1)); + this.renderEngine.registerTextureFX(new TextureGearsFX(0)); + this.renderEngine.registerTextureFX(new TextureGearsFX(1)); + this.fontRenderer = new FontRenderer(this.options, "/default.png", this.renderEngine); + var24 = BufferUtils.createIntBuffer(256); + var24.clear().limit(256); + this.renderGlobal = new RenderGlobal(this, this.renderEngine); + GL11.glViewport(0, 0, this.displayWidth, this.displayHeight); + if(this.server != null && this.session != null) { + World var31 = new World(); + var31.generate(8, 8, 8, new byte[512], new byte[512]); + this.setLevel(var31); + } else if(this.theWorld == null) { + this.displayGuiScreen(new GuiMainMenu()); + } + + this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine); + + try { + var1.downloadResourcesThread = new ThreadDownloadResources(var1.mcDataDir, var1); + var1.downloadResourcesThread.start(); + } catch (Exception var14) { + } + + this.ingameGUI = new GuiIngame(this); + } catch (Exception var22) { + var22.printStackTrace(); + JOptionPane.showMessageDialog((Component)null, var22.toString(), "Failed to start Minecraft", 0); + return; + } + + long var23 = System.currentTimeMillis(); + int var28 = 0; + + try { + while(this.running) { + if(this.theWorld != null) { + this.theWorld.updateLighting(); + } + + if(this.mcCanvas == null && Display.isCloseRequested()) { + this.running = false; + } + + try { + if(this.isGamePaused) { + float var29 = this.timer.renderPartialTicks; + this.timer.updateTimer(); + this.timer.renderPartialTicks = var29; + } else { + this.timer.updateTimer(); + } + + for(int var30 = 0; var30 < this.timer.elapsedTicks; ++var30) { + ++this.ticksRan; + this.runTick(); + } + + this.sndManager.setListener(this.thePlayer, this.timer.renderPartialTicks); + GL11.glEnable(GL11.GL_TEXTURE_2D); + this.playerController.setPartialTime(this.timer.renderPartialTicks); + this.entityRenderer.updateCameraAndRender(this.timer.renderPartialTicks); + if(!Display.isActive()) { + if(this.fullscreen) { + this.toggleFullscreen(); + } + + Thread.sleep(10L); + } + + if(this.mcCanvas != null && !this.fullscreen && (this.mcCanvas.getWidth() != this.displayWidth || this.mcCanvas.getHeight() != this.displayHeight)) { + this.displayWidth = this.mcCanvas.getWidth(); + this.displayHeight = this.mcCanvas.getHeight(); + this.resize(this.displayWidth, this.displayHeight); + } + + if(this.options.limitFramerate) { + Thread.sleep(5L); + } + + ++var28; + this.isGamePaused = this.currentScreen != null && this.currentScreen.doesGuiPauseGame(); + } catch (Exception var18) { + this.displayGuiScreen(new GuiErrorScreen("Client error", "The game broke! [" + var18 + "]")); + var18.printStackTrace(); + return; + } + + while(System.currentTimeMillis() >= var23 + 1000L) { + this.debug = var28 + " fps, " + WorldRenderer.chunksUpdated + " chunk updates"; + WorldRenderer.chunksUpdated = 0; + var23 += 1000L; + var28 = 0; + } + } + + return; + } catch (MinecraftError var19) { + return; + } catch (Exception var20) { + var20.printStackTrace(); + } finally { + this.shutdownMinecraftApplet(); + } + + } + + public final void setIngameFocus() { + if(Display.isActive()) { + if(!this.inventoryScreen) { + this.inventoryScreen = true; + this.mouseHelper.grabMouseCursor(); + this.displayGuiScreen((GuiScreen)null); + this.prevFrameTime = this.ticksRan + 10000; + } + } + } + + private void inputLock() { + if(this.inventoryScreen) { + if(this.thePlayer != null) { + EntityPlayerSP var1 = this.thePlayer; + var1.movementInput.resetKeyState(); + } + + this.inventoryScreen = false; + + try { + Mouse.setNativeCursor((Cursor)null); + } catch (LWJGLException var2) { + var2.printStackTrace(); + } + } + } + + public final void displayInGameMenu() { + if(this.currentScreen == null) { + this.displayGuiScreen(new GuiIngameMenu()); + } + } + + private void clickMouse(int var1) { + if(var1 != 0 || this.leftClickCounter <= 0) { + if(var1 == 0) { + this.entityRenderer.itemRenderer.equippedItemRender(); + } + + ItemStack var2; + int var3; + World var5; + if(var1 == 1) { + var2 = this.thePlayer.inventory.getCurrentItem(); + if(var2 != null) { + var3 = var2.stackSize; + EntityPlayerSP var7 = this.thePlayer; + var5 = this.theWorld; + ItemStack var4 = var2.getItem().onItemRightClick(var2, var5, var7); + if(var4 != var2 || var4 != null && var4.stackSize != var3) { + this.thePlayer.inventory.mainInventory[this.thePlayer.inventory.currentItem] = var4; + this.entityRenderer.itemRenderer.resetEquippedProgress(); + if(var4.stackSize == 0) { + this.thePlayer.inventory.mainInventory[this.thePlayer.inventory.currentItem] = null; + } + } + } + } + + if(this.objectMouseOver == null) { + if(var1 == 0 && !(this.playerController instanceof PlayerControllerCreative)) { + this.leftClickCounter = 10; + } + + } else { + ItemStack var9; + if(this.objectMouseOver.typeOfHit == 1) { + if(var1 == 0) { + Entity var14 = this.objectMouseOver.entityHit; + EntityPlayerSP var12 = this.thePlayer; + InventoryPlayer var11 = var12.inventory; + var9 = var11.getStackInSlot(var11.currentItem); + int var17 = var9 != null ? Item.itemsList[var9.itemID].getDamageVsEntity() : 1; + if(var17 > 0) { + var14.attackEntityFrom(var12, var17); + var2 = var12.inventory.getCurrentItem(); + if(var2 != null && var14 instanceof EntityLiving) { + EntityLiving var8 = (EntityLiving)var14; + Item.itemsList[var2.itemID].hitEntity(var2); + if(var2.stackSize <= 0) { + var12.destroyCurrentEquippedItem(); + } + } + } + + return; + } + } else if(this.objectMouseOver.typeOfHit == 0) { + int var10 = this.objectMouseOver.blockX; + var3 = this.objectMouseOver.blockY; + int var13 = this.objectMouseOver.blockZ; + int var15 = this.objectMouseOver.sideHit; + Block var6 = Block.blocksList[this.theWorld.getBlockId(var10, var3, var13)]; + if(var1 == 0) { + this.theWorld.extinguishFire(var10, var3, var13, this.objectMouseOver.sideHit); + if(var6 != Block.bedrock) { + this.playerController.clickBlock(var10, var3, var13); + return; + } + } else { + var9 = this.thePlayer.inventory.getCurrentItem(); + int var16 = this.theWorld.getBlockId(var10, var3, var13); + if(var16 > 0 && Block.blocksList[var16].blockActivated(this.theWorld, var10, var3, var13, this.thePlayer)) { + return; + } + + if(var9 == null) { + return; + } + + var16 = var9.stackSize; + int var18 = var15; + var5 = this.theWorld; + if(var9.getItem().onItemUse(var9, var5, var10, var3, var13, var18)) { + this.entityRenderer.itemRenderer.equippedItemRender(); + } + + if(var9.stackSize == 0) { + this.thePlayer.inventory.mainInventory[this.thePlayer.inventory.currentItem] = null; + return; + } + + if(var9.stackSize != var16) { + this.entityRenderer.itemRenderer.equipAnimationSpeed(); + } + } + } + + } + } + } + + public final void toggleFullscreen() { + try { + this.fullscreen = !this.fullscreen; + System.out.println("Toggle fullscreen!"); + if(this.fullscreen) { + Display.setDisplayMode(Display.getDesktopDisplayMode()); + this.displayWidth = Display.getDisplayMode().getWidth(); + this.displayHeight = Display.getDisplayMode().getHeight(); + } else { + if(this.mcCanvas != null) { + this.displayWidth = this.mcCanvas.getWidth(); + this.displayHeight = this.mcCanvas.getHeight(); + } else { + this.displayWidth = this.tempDisplayWidth; + this.displayHeight = this.tempDisplayHeight; + } + + Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight)); + } + + this.inputLock(); + Display.setFullscreen(this.fullscreen); + Display.update(); + Thread.sleep(1000L); + if(this.fullscreen) { + this.setIngameFocus(); + } + + if(this.currentScreen != null) { + this.inputLock(); + this.resize(this.displayWidth, this.displayHeight); + } + + System.out.println("Size: " + this.displayWidth + ", " + this.displayHeight); + } catch (Exception var2) { + var2.printStackTrace(); + } + } + + private void resize(int var1, int var2) { + this.displayWidth = var1; + this.displayHeight = var2; + if(this.currentScreen != null) { + ScaledResolution var3 = new ScaledResolution(var1, var2); + var2 = var3.getScaledWidth(); + var1 = var3.getScaledHeight(); + this.currentScreen.setWorldAndResolution(this, var2, var1); + } + + } + + private void runTick() { + this.ingameGUI.addChatMessage(); + if(!this.isGamePaused && this.theWorld != null) { + this.playerController.onUpdate(); + } + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain.png")); + if(!this.isGamePaused) { + this.renderEngine.updateDynamicTextures(); + } + + if(this.currentScreen == null && this.thePlayer != null && this.thePlayer.health <= 0) { + this.displayGuiScreen((GuiScreen)null); + } + + if(this.currentScreen == null || this.currentScreen.allowUserInput) { + label286: + while(true) { + while(true) { + int var1; + int var2; + while(Mouse.next()) { + var1 = Mouse.getEventDWheel(); + if(var1 != 0) { + var2 = var1; + InventoryPlayer var5 = this.thePlayer.inventory; + if(var1 > 0) { + var2 = 1; + } + + if(var2 < 0) { + var2 = -1; + } + + for(var5.currentItem -= var2; var5.currentItem < 0; var5.currentItem += 9) { + } + + while(var5.currentItem >= 9) { + var5.currentItem -= 9; + } + } + + if(this.currentScreen == null) { + if(!this.inventoryScreen && Mouse.getEventButtonState()) { + this.setIngameFocus(); + } else { + if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) { + this.clickMouse(0); + this.prevFrameTime = this.ticksRan; + } + + if(Mouse.getEventButton() == 1 && Mouse.getEventButtonState()) { + this.clickMouse(1); + this.prevFrameTime = this.ticksRan; + } + + if(Mouse.getEventButton() == 2 && Mouse.getEventButtonState() && this.objectMouseOver != null) { + var2 = this.theWorld.getBlockId(this.objectMouseOver.blockX, this.objectMouseOver.blockY, this.objectMouseOver.blockZ); + if(var2 == Block.grass.blockID) { + var2 = Block.dirt.blockID; + } + + if(var2 == Block.stairDouble.blockID) { + var2 = Block.stairSingle.blockID; + } + + if(var2 == Block.bedrock.blockID) { + var2 = Block.stone.blockID; + } + + this.thePlayer.inventory.getFirstEmptyStack(var2); + } + } + } else if(this.currentScreen != null) { + this.currentScreen.handleMouseInput(); + } + } + + if(this.leftClickCounter > 0) { + --this.leftClickCounter; + } + + while(true) { + while(true) { + do { + boolean var3; + if(!Keyboard.next()) { + if(this.currentScreen == null) { + if(Mouse.isButtonDown(0) && (float)(this.ticksRan - this.prevFrameTime) >= this.timer.ticksPerSecond / 4.0F && this.inventoryScreen) { + this.clickMouse(0); + this.prevFrameTime = this.ticksRan; + } + + if(Mouse.isButtonDown(1) && (float)(this.ticksRan - this.prevFrameTime) >= this.timer.ticksPerSecond / 4.0F && this.inventoryScreen) { + this.clickMouse(1); + this.prevFrameTime = this.ticksRan; + } + } + + var3 = this.currentScreen == null && Mouse.isButtonDown(0) && this.inventoryScreen; + boolean var9 = false; + if(!this.playerController.isInTestMode && this.leftClickCounter <= 0) { + if(var3 && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == 0) { + var2 = this.objectMouseOver.blockX; + int var8 = this.objectMouseOver.blockY; + int var4 = this.objectMouseOver.blockZ; + this.playerController.sendBlockRemoving(var2, var8, var4, this.objectMouseOver.sideHit); + this.effectRenderer.addBlockHitEffects(var2, var8, var4, this.objectMouseOver.sideHit); + } else { + this.playerController.resetBlockRemoving(); + } + } + break label286; + } + + EntityPlayerSP var10000 = this.thePlayer; + int var10001 = Keyboard.getEventKey(); + var3 = Keyboard.getEventKeyState(); + var2 = var10001; + EntityPlayerSP var6 = var10000; + var6.movementInput.checkKeyForMovementInput(var2, var3); + } while(!Keyboard.getEventKeyState()); + + if(Keyboard.getEventKey() == Keyboard.KEY_F11) { + this.toggleFullscreen(); + } else { + if(this.currentScreen != null) { + this.currentScreen.handleKeyboardInput(); + } else { + if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { + this.displayInGameMenu(); + } + + if(Keyboard.getEventKey() == Keyboard.KEY_F7) { + this.entityRenderer.grabLargeScreenshot(); + } + + if(this.playerController instanceof PlayerControllerCreative) { + if(Keyboard.getEventKey() == this.options.keyBindLoad.keyCode) { + this.thePlayer.preparePlayerToSpawn(); + } + + if(Keyboard.getEventKey() == this.options.keyBindSave.keyCode) { + this.theWorld.setSpawnLocation((int)this.thePlayer.posX, (int)this.thePlayer.posY, (int)this.thePlayer.posZ, this.thePlayer.rotationYaw); + this.thePlayer.preparePlayerToSpawn(); + } + } + + if(Keyboard.getEventKey() == Keyboard.KEY_F5) { + this.options.thirdPersonView = !this.options.thirdPersonView; + } + + if(Keyboard.getEventKey() == this.options.keyBindInventory.keyCode) { + this.displayGuiScreen(new GuiInventory(this.thePlayer.inventory)); + } + + if(Keyboard.getEventKey() == this.options.keyBindDrop.keyCode) { + this.thePlayer.dropPlayerItemWithRandomChoice(this.thePlayer.inventory.decrStackSize(this.thePlayer.inventory.currentItem, 1), false); + } + } + + for(var1 = 0; var1 < 9; ++var1) { + if(Keyboard.getEventKey() == var1 + 2) { + this.thePlayer.inventory.currentItem = var1; + } + } + + if(Keyboard.getEventKey() == this.options.keyBindToggleFog.keyCode) { + this.options.setOptionValue(4, !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) ? 1 : -1); + } + } + } + } + } + } + } + + if(this.currentScreen != null) { + this.prevFrameTime = this.ticksRan + 10000; + } + + if(this.currentScreen != null) { + GuiScreen var7 = this.currentScreen; + + while(Mouse.next()) { + var7.handleMouseInput(); + } + + while(Keyboard.next()) { + var7.handleKeyboardInput(); + } + + if(this.currentScreen != null) { + this.currentScreen.updateScreen(); + } + } + + if(this.theWorld != null) { + this.theWorld.difficultySetting = this.options.difficulty; + if(!this.isGamePaused) { + this.entityRenderer.updateRenderer(); + } + + if(!this.isGamePaused) { + this.renderGlobal.updateClouds(); + } + + if(!this.isGamePaused) { + this.theWorld.updateEntities(); + } + + if(!this.isGamePaused) { + this.theWorld.tick(); + } + + if(!this.isGamePaused) { + this.theWorld.randomDisplayUpdates((int)this.thePlayer.posX, (int)this.thePlayer.posY, (int)this.thePlayer.posZ); + } + + if(!this.isGamePaused) { + this.effectRenderer.updateEffects(); + } + } + + } + + public final void generateLevel(int var1, int var2, int var3, int var4) { + this.setLevel((World)null); + System.gc(); + String var5 = this.session != null ? this.session.username : "anonymous"; + LevelGenerator var6 = new LevelGenerator(this.loadingScreen); + var6.islandGen = var3 == 1; + var6.floatingGen = var3 == 2; + var6.flatGen = var3 == 3; + var6.levelType = var4; + var1 = 128 << var1; + var3 = var1; + short var8 = 64; + if(var2 == 1) { + var1 /= 2; + var3 <<= 1; + } else if(var2 == 2) { + var1 /= 2; + var3 = var1; + var8 = 256; + } + + World var7 = var6.generate(var5, var1, var3, var8); + this.setLevel(var7); + } + + public final void setLevel(World var1) { + if(this.theWorld != null) { + this.theWorld.setLevel(); + } + + try { + BufferedReader var2 = new BufferedReader(new InputStreamReader((new URL(this.mcApplet.getDocumentBase() + "?n=" + this.session.username + "&i=" + this.session.sessionId)).openStream())); + Integer.parseInt(var2.readLine()); + var2.close(); + if(this.mcApplet.getDocumentBase().toString().startsWith("http://www.minecraft.net/") || this.mcApplet.getDocumentBase().toString().startsWith("http://minecraft.net/")) { + this.theWorld = var1; + } + } catch (Throwable var3) { + } + + if(var1 != null) { + var1.load(); + this.playerController.onWorldChange(var1); + this.thePlayer = (EntityPlayerSP)var1.findSubclassOf(EntityPlayerSP.class); + var1.playerEntity = this.thePlayer; + if(this.thePlayer == null) { + this.thePlayer = new EntityPlayerSP(this, var1, this.session); + this.thePlayer.preparePlayerToSpawn(); + if(var1 != null) { + var1.spawnEntityInWorld(this.thePlayer); + var1.playerEntity = this.thePlayer; + } + } + + if(this.thePlayer != null) { + this.thePlayer.movementInput = new MovementInputFromOptions(this.options); + this.playerController.onRespawn(this.thePlayer); + } + + if(this.renderGlobal != null) { + this.renderGlobal.changeWorld(var1); + } + + if(this.effectRenderer != null) { + this.effectRenderer.clearEffects(var1); + } + + this.textureWaterFX.textureId = 0; + this.textureLavaFX.textureId = 0; + int var4 = this.renderEngine.getTexture("/water.png"); + if(var1.defaultFluid == Block.waterMoving.blockID) { + this.textureWaterFX.textureId = var4; + } else { + this.textureLavaFX.textureId = var4; + } + } + + System.gc(); + } +} diff --git a/src/teavm/java/net/minecraft/client/MinecraftApplet.java b/src/teavm/java/net/minecraft/client/MinecraftApplet.java new file mode 100644 index 0000000..5f496c0 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/MinecraftApplet.java @@ -0,0 +1,83 @@ +package net.minecraft.client; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Canvas; + +public class MinecraftApplet extends Applet { + private Canvas mcCanvas; + private Minecraft mc; + private Thread mcThread = null; + + public void init() { + this.mcCanvas = new CanvasMinecraftApplet(this); + boolean var1 = false; + if(this.getParameter("fullscreen") != null) { + var1 = this.getParameter("fullscreen").equalsIgnoreCase("true"); + } + + this.mc = new Minecraft(this.mcCanvas, this, this.getWidth(), this.getHeight(), var1); + this.mc.minecraftUri = this.getDocumentBase().getHost(); + if(this.getDocumentBase().getPort() > 0) { + this.mc.minecraftUri = this.mc.minecraftUri + ":" + this.getDocumentBase().getPort(); + } + + if(this.getParameter("username") != null && this.getParameter("sessionid") != null) { + this.mc.session = new Session(this.getParameter("username"), this.getParameter("sessionid")); + if(this.getParameter("mppass") != null) { + this.getParameter("mppass"); + } + } + + if(this.getParameter("loadmap_user") != null && this.getParameter("loadmap_id") != null) { + this.mc.loadMapUser = this.getParameter("loadmap_user"); + this.mc.loadMapID = Integer.parseInt(this.getParameter("loadmap_id")); + } else if(this.getParameter("server") != null && this.getParameter("port") != null) { + this.mc.setServer(this.getParameter("server"), Integer.parseInt(this.getParameter("port"))); + } + + this.mc.appletMode = true; + this.setLayout(new BorderLayout()); + this.add(this.mcCanvas, "Center"); + this.mcCanvas.setFocusable(true); + this.validate(); + } + + public final void startMainThread() { + if(this.mcThread == null) { + this.mcThread = new Thread(this.mc, "Minecraft main thread"); + this.mcThread.start(); + } + } + + public void start() { + this.mc.isGamePaused = false; + } + + public void stop() { + this.mc.isGamePaused = true; + } + + public void destroy() { + this.shutdown(); + } + + public final void shutdown() { + if(this.mcThread != null) { + Minecraft var1 = this.mc; + var1.running = false; + + try { + this.mcThread.join(1000L); + } catch (InterruptedException var3) { + try { + this.mc.shutdownMinecraftApplet(); + } catch (Exception var2) { + var2.printStackTrace(); + } + } + + this.mcThread = null; + } + } +} diff --git a/src/teavm/java/net/minecraft/client/MinecraftError.java b/src/teavm/java/net/minecraft/client/MinecraftError.java new file mode 100644 index 0000000..da64a51 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/MinecraftError.java @@ -0,0 +1,4 @@ +package net.minecraft.client; + +public final class MinecraftError extends Error { +} diff --git a/src/teavm/java/net/minecraft/client/MouseHelper.java b/src/teavm/java/net/minecraft/client/MouseHelper.java new file mode 100644 index 0000000..e03aad4 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/MouseHelper.java @@ -0,0 +1,30 @@ +package net.minecraft.client; + +import org.lwjgl.opengl.GL11; + +public class MouseHelper { + + public void grabMouse() { + GL11.mouseSetGrabbed(true); + deltaX = 0; + deltaY = 0; + } + + public void ungrabMouse() { + GL11.mouseSetCursorPosition(GL11.getCanvasWidth() / 2, GL11.getCanvasHeight() / 2); + GL11.mouseSetGrabbed(false); + } + + public void mouseXYChange() { + if(GL11.isPointerLocked2()) { + deltaX = GL11.mouseGetDX(); + deltaY = GL11.mouseGetDY(); + }else { + deltaX = 0; + deltaY = 0; + } + } + + public int deltaX; + public int deltaY; +} \ No newline at end of file diff --git a/src/teavm/java/net/minecraft/client/OpenGlCapsChecker.java b/src/teavm/java/net/minecraft/client/OpenGlCapsChecker.java new file mode 100644 index 0000000..f7afce9 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/OpenGlCapsChecker.java @@ -0,0 +1,4 @@ +package net.minecraft.client; + +public final class OpenGlCapsChecker { +} diff --git a/src/teavm/java/net/minecraft/client/PlayerLoader.java b/src/teavm/java/net/minecraft/client/PlayerLoader.java new file mode 100644 index 0000000..ddf623a --- /dev/null +++ b/src/teavm/java/net/minecraft/client/PlayerLoader.java @@ -0,0 +1,20 @@ +package net.minecraft.client; + +import net.minecraft.client.player.EntityPlayerSP; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.level.LevelLoader; +import net.minecraft.game.level.World; +import util.IProgressUpdate; + +public final class PlayerLoader extends LevelLoader { + private Minecraft mc; + + public PlayerLoader(Minecraft var1, IProgressUpdate var2) { + super(var2); + this.mc = var1; + } + + protected final Entity loadEntity(World var1, String var2) { + return (Entity)(var2.equals("LocalPlayer") ? new EntityPlayerSP(this.mc, var1, this.mc.session) : super.loadEntity(var1, var2)); + } +} diff --git a/src/teavm/java/net/minecraft/client/RenderHelper.java b/src/teavm/java/net/minecraft/client/RenderHelper.java new file mode 100644 index 0000000..d785015 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/RenderHelper.java @@ -0,0 +1,44 @@ +package net.minecraft.client; + +import java.nio.FloatBuffer; +import net.minecraft.game.physics.Vec3D; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +public final class RenderHelper { + private static FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(16); + + public static void disableStandardItemLighting() { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHT0); + GL11.glDisable(GL11.GL_LIGHT1); + GL11.glDisable(GL11.GL_COLOR_MATERIAL); + } + + public static void enableStandardItemLighting() { + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_LIGHT1); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE); + Vec3D var0 = new Vec3D(0.3F, 1.0F, -0.7F); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, setColorBuffer(var0.xCoord, var0.yCoord, var0.zCoord, 0.0F)); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, setColorBuffer(0.5F, 0.5F, 0.5F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + var0 = new Vec3D(-0.7F, 1.0F, 0.2F); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, setColorBuffer(var0.xCoord, var0.yCoord, var0.zCoord, 0.0F)); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, setColorBuffer(0.5F, 0.5F, 0.5F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_SPECULAR, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, setColorBuffer(0.5F, 0.5F, 0.5F, 1.0F)); + } + + private static FloatBuffer setColorBuffer(float var0, float var1, float var2, float var3) { + colorBuffer.clear(); + colorBuffer.put(var0).put(var1).put(var2).put(var3); + colorBuffer.flip(); + return colorBuffer; + } +} diff --git a/src/teavm/java/net/minecraft/client/Session.java b/src/teavm/java/net/minecraft/client/Session.java new file mode 100644 index 0000000..1d29ca9 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/Session.java @@ -0,0 +1,63 @@ +package net.minecraft.client; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.game.level.block.Block; + +public final class Session { + public static List registeredBlocksList; + public String username; + public String sessionId; + + public Session(String var1, String var2) { + this.username = var1; + this.sessionId = var2; + } + + static { + (registeredBlocksList = new ArrayList()).add(Block.stone); + registeredBlocksList.add(Block.cobblestone); + registeredBlocksList.add(Block.brick); + registeredBlocksList.add(Block.dirt); + registeredBlocksList.add(Block.planks); + registeredBlocksList.add(Block.wood); + registeredBlocksList.add(Block.leaves); + registeredBlocksList.add(Block.torch); + registeredBlocksList.add(Block.stairSingle); + registeredBlocksList.add(Block.glass); + registeredBlocksList.add(Block.cobblestoneMossy); + registeredBlocksList.add(Block.sapling); + registeredBlocksList.add(Block.plantYellow); + registeredBlocksList.add(Block.plantRed); + registeredBlocksList.add(Block.mushroomBrown); + registeredBlocksList.add(Block.mushroomRed); + registeredBlocksList.add(Block.sand); + registeredBlocksList.add(Block.gravel); + registeredBlocksList.add(Block.sponge); + registeredBlocksList.add(Block.clothRed); + registeredBlocksList.add(Block.clothOrange); + registeredBlocksList.add(Block.clothYellow); + registeredBlocksList.add(Block.clothChartreuse); + registeredBlocksList.add(Block.clothGreen); + registeredBlocksList.add(Block.clothSpringGreen); + registeredBlocksList.add(Block.clothCyan); + registeredBlocksList.add(Block.clothCapri); + registeredBlocksList.add(Block.clothUltramarine); + registeredBlocksList.add(Block.clothViolet); + registeredBlocksList.add(Block.clothPurple); + registeredBlocksList.add(Block.clothMagenta); + registeredBlocksList.add(Block.clothRose); + registeredBlocksList.add(Block.clothDarkGray); + registeredBlocksList.add(Block.clothGray); + registeredBlocksList.add(Block.clothWhite); + registeredBlocksList.add(Block.oreCoal); + registeredBlocksList.add(Block.oreIron); + registeredBlocksList.add(Block.oreGold); + registeredBlocksList.add(Block.blockSteel); + registeredBlocksList.add(Block.blockGold); + registeredBlocksList.add(Block.bookShelf); + registeredBlocksList.add(Block.tnt); + registeredBlocksList.add(Block.obsidian); + System.out.println(registeredBlocksList.size()); + } +} diff --git a/src/teavm/java/net/minecraft/client/ThreadSleepForever.java b/src/teavm/java/net/minecraft/client/ThreadSleepForever.java new file mode 100644 index 0000000..e2e9fae --- /dev/null +++ b/src/teavm/java/net/minecraft/client/ThreadSleepForever.java @@ -0,0 +1,18 @@ +package net.minecraft.client; + +final class ThreadSleepForever extends Thread { + ThreadSleepForever(Minecraft var1, String var2) { + super(var2); + this.setDaemon(true); + this.start(); + } + + public final void run() { + while(true) { + try { + Thread.sleep(2147483647L); + } catch (InterruptedException var1) { + } + } + } +} diff --git a/src/teavm/java/net/minecraft/client/Timer.java b/src/teavm/java/net/minecraft/client/Timer.java new file mode 100644 index 0000000..53a7ec1 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/Timer.java @@ -0,0 +1,55 @@ +package net.minecraft.client; + +public final class Timer { + float ticksPerSecond = 20.0F; + private double lastHRTime; + public int elapsedTicks; + public float renderPartialTicks; + private float timerSpeed = 1.0F; + private float elapsedPartialTicks = 0.0F; + private long lastSyncSysClock = System.currentTimeMillis(); + private long lastSyncHRClock = System.nanoTime() / 1000000L; + private double timeSyncAdjustment = 1.0D; + + public Timer(float var1) { + } + + public final void updateTimer() { + long var1 = System.currentTimeMillis(); + long var3 = var1 - this.lastSyncSysClock; + long var5 = System.nanoTime() / 1000000L; + double var9; + if(var3 > 1000L) { + long var7 = var5 - this.lastSyncHRClock; + var9 = (double)var3 / (double)var7; + this.timeSyncAdjustment += (var9 - this.timeSyncAdjustment) * (double)0.2F; + this.lastSyncSysClock = var1; + this.lastSyncHRClock = var5; + } + + if(var3 < 0L) { + this.lastSyncSysClock = var1; + this.lastSyncHRClock = var5; + } + + double var11 = (double)var5 / 1000.0D; + var9 = (var11 - this.lastHRTime) * this.timeSyncAdjustment; + this.lastHRTime = var11; + if(var9 < 0.0D) { + var9 = 0.0D; + } + + if(var9 > 1.0D) { + var9 = 1.0D; + } + + this.elapsedPartialTicks = (float)((double)this.elapsedPartialTicks + var9 * (double)this.timerSpeed * (double)this.ticksPerSecond); + this.elapsedTicks = (int)this.elapsedPartialTicks; + this.elapsedPartialTicks -= (float)this.elapsedTicks; + if(this.elapsedTicks > 10) { + this.elapsedTicks = 10; + } + + this.renderPartialTicks = this.elapsedPartialTicks; + } +} diff --git a/src/teavm/java/net/minecraft/client/controller/PlayerController.java b/src/teavm/java/net/minecraft/client/controller/PlayerController.java new file mode 100644 index 0000000..7d07c3e --- /dev/null +++ b/src/teavm/java/net/minecraft/client/controller/PlayerController.java @@ -0,0 +1,58 @@ +package net.minecraft.client.controller; + +import net.minecraft.client.Minecraft; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public class PlayerController { + protected final Minecraft mc; + public boolean isInTestMode = false; + + public PlayerController(Minecraft var1) { + this.mc = var1; + } + + public void onWorldChange(World var1) { + } + + public void clickBlock(int var1, int var2, int var3) { + this.sendBlockRemoved(var1, var2, var3); + } + + public boolean sendBlockRemoved(int var1, int var2, int var3) { + this.mc.effectRenderer.addBlockDestroyEffects(var1, var2, var3); + World var4 = this.mc.theWorld; + Block var5 = Block.blocksList[var4.getBlockId(var1, var2, var3)]; + byte var6 = var4.getBlockMetadata(var1, var2, var3); + boolean var7 = var4.setBlockWithNotify(var1, var2, var3, 0); + if(var5 != null && var7) { + var5.onBlockDestroyedByPlayer(var4, var1, var2, var3, var6); + } + + return var7; + } + + public void sendBlockRemoving(int var1, int var2, int var3, int var4) { + } + + public void resetBlockRemoving() { + } + + public void setPartialTime(float var1) { + } + + public float getBlockReachDistance() { + return 5.0F; + } + + public void onUpdate() { + } + + public boolean shouldDrawHUD() { + return true; + } + + public void onRespawn(EntityPlayer var1) { + } +} diff --git a/src/teavm/java/net/minecraft/client/controller/PlayerControllerCreative.java b/src/teavm/java/net/minecraft/client/controller/PlayerControllerCreative.java new file mode 100644 index 0000000..7116dfa --- /dev/null +++ b/src/teavm/java/net/minecraft/client/controller/PlayerControllerCreative.java @@ -0,0 +1,42 @@ +package net.minecraft.client.controller; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.Session; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.MobSpawner; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public final class PlayerControllerCreative extends PlayerController { + private MobSpawner mobSpawner; + + private PlayerControllerCreative(Minecraft var1) { + super(var1); + } + + public final void onRespawn(EntityPlayer var1) { + for(int var2 = 0; var2 < 9; ++var2) { + if(var1.inventory.mainInventory[var2] == null) { + this.mc.thePlayer.inventory.mainInventory[var2] = new ItemStack(((Block)Session.registeredBlocksList.get(var2)).blockID); + } else { + this.mc.thePlayer.inventory.mainInventory[var2].stackSize = 1; + } + } + + } + + public final boolean shouldDrawHUD() { + return false; + } + + public final void onWorldChange(World var1) { + super.onWorldChange(var1); + var1.survivalWorld = false; + this.mobSpawner = new MobSpawner(var1); + } + + public final void onUpdate() { + this.mobSpawner.performSpawning(); + } +} diff --git a/src/teavm/java/net/minecraft/client/controller/PlayerControllerSP.java b/src/teavm/java/net/minecraft/client/controller/PlayerControllerSP.java new file mode 100644 index 0000000..ad20adf --- /dev/null +++ b/src/teavm/java/net/minecraft/client/controller/PlayerControllerSP.java @@ -0,0 +1,113 @@ +package net.minecraft.client.controller; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.player.EntityPlayerSP; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.MobSpawner; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.StepSound; + +public final class PlayerControllerSP extends PlayerController { + private int curBlockX = -1; + private int curBlockY = -1; + private int curBlockZ = -1; + private float curBlockDamage = 0.0F; + private float prevBlockDamage = 0.0F; + private float blockDestroySoundCounter = 0.0F; + private int blockHitWait = 0; + private MobSpawner mobSpawner; + + public PlayerControllerSP(Minecraft var1) { + super(var1); + } + + public final boolean sendBlockRemoved(int var1, int var2, int var3) { + int var4 = this.mc.theWorld.getBlockId(var1, var2, var3); + byte var5 = this.mc.theWorld.getBlockMetadata(var1, var2, var3); + boolean var6 = super.sendBlockRemoved(var1, var2, var3); + EntityPlayerSP var7 = this.mc.thePlayer; + ItemStack var9 = var7.inventory.getCurrentItem(); + if(var9 != null) { + Item.itemsList[var9.itemID].onBlockDestroyed(var9); + if(var9.stackSize == 0) { + this.mc.thePlayer.destroyCurrentEquippedItem(); + } + } + + if(var6 && this.mc.thePlayer.canHarvestBlock(Block.blocksList[var4])) { + Block.blocksList[var4].dropBlockAsItem(this.mc.theWorld, var1, var2, var3, var5); + } + + return var6; + } + + public final void clickBlock(int var1, int var2, int var3) { + int var4 = this.mc.theWorld.getBlockId(var1, var2, var3); + if(var4 > 0 && Block.blocksList[var4].blockStrength(this.mc.thePlayer) >= 1.0F) { + this.sendBlockRemoved(var1, var2, var3); + } + + } + + public final void resetBlockRemoving() { + this.curBlockDamage = 0.0F; + this.blockHitWait = 0; + } + + public final void sendBlockRemoving(int var1, int var2, int var3, int var4) { + if(this.blockHitWait > 0) { + --this.blockHitWait; + } else { + super.sendBlockRemoving(var1, var2, var3, var4); + if(var1 == this.curBlockX && var2 == this.curBlockY && var3 == this.curBlockZ) { + var4 = this.mc.theWorld.getBlockId(var1, var2, var3); + if(var4 != 0) { + Block var6 = Block.blocksList[var4]; + this.curBlockDamage += var6.blockStrength(this.mc.thePlayer); + + ++this.blockDestroySoundCounter; + if(this.curBlockDamage >= 1.0F) { + this.sendBlockRemoved(var1, var2, var3); + this.curBlockDamage = 0.0F; + this.prevBlockDamage = 0.0F; + this.blockDestroySoundCounter = 0.0F; + this.blockHitWait = 5; + } + + } + } else { + this.curBlockDamage = 0.0F; + this.prevBlockDamage = 0.0F; + this.blockDestroySoundCounter = 0.0F; + this.curBlockX = var1; + this.curBlockY = var2; + this.curBlockZ = var3; + } + } + } + + public final void setPartialTime(float var1) { + if(this.curBlockDamage <= 0.0F) { + this.mc.renderGlobal.damagePartialTime = 0.0F; + } else { + var1 = this.prevBlockDamage + (this.curBlockDamage - this.prevBlockDamage) * var1; + this.mc.renderGlobal.damagePartialTime = var1; + } + } + + public final float getBlockReachDistance() { + return 4.0F; + } + + public final void onWorldChange(World var1) { + super.onWorldChange(var1); + this.mobSpawner = new MobSpawner(var1); + } + + public final void onUpdate() { + this.prevBlockDamage = this.curBlockDamage; + this.mobSpawner.performSpawning(); + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EffectRenderer.java b/src/teavm/java/net/minecraft/client/effect/EffectRenderer.java new file mode 100644 index 0000000..6901e55 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EffectRenderer.java @@ -0,0 +1,163 @@ +package net.minecraft.client.effect; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import org.lwjgl.opengl.GL11; + +public final class EffectRenderer { + private World worldObj; + private List[] fxLayers = new List[3]; + private RenderEngine renderEngine; + private Random rand = new Random(); + + public EffectRenderer(World var1, RenderEngine var2) { + if(var1 != null) { + this.worldObj = var1; + } + + this.renderEngine = var2; + + for(int var3 = 0; var3 < 3; ++var3) { + this.fxLayers[var3] = new ArrayList(); + } + + } + + public final void addEffect(EntityFX var1) { + int var2 = var1.getFXLayer(); + this.fxLayers[var2].add(var1); + } + + public final void updateEffects() { + for(int var1 = 0; var1 < 3; ++var1) { + for(int var2 = 0; var2 < this.fxLayers[var1].size(); ++var2) { + EntityFX var3 = (EntityFX)this.fxLayers[var1].get(var2); + var3.onEntityUpdate(); + if(var3.isDead) { + this.fxLayers[var1].remove(var2--); + } + } + } + + } + + public final void renderParticles(Entity var1, float var2) { + float var3 = MathHelper.cos(var1.rotationYaw * (float)Math.PI / 180.0F); + float var4 = MathHelper.sin(var1.rotationYaw * (float)Math.PI / 180.0F); + float var5 = -var4 * MathHelper.sin(var1.rotationPitch * (float)Math.PI / 180.0F); + float var6 = var3 * MathHelper.sin(var1.rotationPitch * (float)Math.PI / 180.0F); + float var11 = MathHelper.cos(var1.rotationPitch * (float)Math.PI / 180.0F); + + for(int var7 = 0; var7 < 2; ++var7) { + if(this.fxLayers[var7].size() != 0) { + int var8 = 0; + if(var7 == 0) { + var8 = this.renderEngine.getTexture("/particles.png"); + } + + if(var7 == 1) { + var8 = this.renderEngine.getTexture("/terrain.png"); + } + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var8); + Tessellator var12 = Tessellator.instance; + var12.startDrawingQuads(); + + for(int var9 = 0; var9 < this.fxLayers[var7].size(); ++var9) { + EntityFX var10 = (EntityFX)this.fxLayers[var7].get(var9); + var10.renderParticle(var12, var2, var3, var11, var4, var5, var6); + } + + var12.draw(); + } + } + + } + + public final void renderLitParticles(float var1) { + if(this.fxLayers[2].size() != 0) { + Tessellator var2 = Tessellator.instance; + + for(int var3 = 0; var3 < this.fxLayers[2].size(); ++var3) { + EntityFX var4 = (EntityFX)this.fxLayers[2].get(var3); + var4.renderParticle(var2, var1, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F); + } + + } + } + + public final void clearEffects(World var1) { + this.worldObj = var1; + + for(int var2 = 0; var2 < 3; ++var2) { + this.fxLayers[var2].clear(); + } + + } + + public final void addBlockDestroyEffects(int var1, int var2, int var3) { + int var4 = this.worldObj.getBlockId(var1, var2, var3); + if(var4 != 0) { + Block var11 = Block.blocksList[var4]; + + for(int var5 = 0; var5 < 4; ++var5) { + for(int var6 = 0; var6 < 4; ++var6) { + for(int var7 = 0; var7 < 4; ++var7) { + float var8 = (float)var1 + ((float)var5 + 0.5F) / 4.0F; + float var9 = (float)var2 + ((float)var6 + 0.5F) / 4.0F; + float var10 = (float)var3 + ((float)var7 + 0.5F) / 4.0F; + this.addEffect(new EntityDiggingFX(this.worldObj, var8, var9, var10, var8 - (float)var1 - 0.5F, var9 - (float)var2 - 0.5F, var10 - (float)var3 - 0.5F, var11)); + } + } + } + + } + } + + public final void addBlockHitEffects(int var1, int var2, int var3, int var4) { + int var5 = this.worldObj.getBlockId(var1, var2, var3); + if(var5 != 0) { + Block var9 = Block.blocksList[var5]; + float var6 = (float)var1 + this.rand.nextFloat() * (var9.maxX - var9.minX - 0.2F) + 0.1F + var9.minX; + float var7 = (float)var2 + this.rand.nextFloat() * (var9.maxY - var9.minY - 0.2F) + 0.1F + var9.minY; + float var8 = (float)var3 + this.rand.nextFloat() * (var9.maxZ - var9.minZ - 0.2F) + 0.1F + var9.minZ; + if(var4 == 0) { + var7 = (float)var2 + var9.minY - 0.1F; + } + + if(var4 == 1) { + var7 = (float)var2 + var9.maxY + 0.1F; + } + + if(var4 == 2) { + var8 = (float)var3 + var9.minZ - 0.1F; + } + + if(var4 == 3) { + var8 = (float)var3 + var9.maxZ + 0.1F; + } + + if(var4 == 4) { + var6 = (float)var1 + var9.minX - 0.1F; + } + + if(var4 == 5) { + var6 = (float)var1 + var9.maxX + 0.1F; + } + + this.addEffect((new EntityDiggingFX(this.worldObj, var6, var7, var8, 0.0F, 0.0F, 0.0F, var9)).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); + } + } + + public final String getStatistics() { + return "" + (this.fxLayers[0].size() + this.fxLayers[1].size() + this.fxLayers[2].size()); + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityBubbleFX.java b/src/teavm/java/net/minecraft/client/effect/EntityBubbleFX.java new file mode 100644 index 0000000..e1e6e76 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityBubbleFX.java @@ -0,0 +1,39 @@ +package net.minecraft.client.effect; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class EntityBubbleFX extends EntityFX { + public EntityBubbleFX(World var1, float var2, float var3, float var4, float var5, float var6, float var7) { + super(var1, var2, var3, var4, var5, var6, var7); + this.particleRed = 1.0F; + this.particleGreen = 1.0F; + this.particleBlue = 1.0F; + this.particleTextureIndex = 32; + this.setSize(0.02F, 0.02F); + this.particleScale *= this.rand.nextFloat() * 0.6F + 0.2F; + this.motionX1 = var5 * 0.2F + (float)(Math.random() * 2.0D - 1.0D) * 0.02F; + this.motionY1 = var6 * 0.2F + (float)(Math.random() * 2.0D - 1.0D) * 0.02F; + this.motionZ1 = var7 * 0.2F + (float)(Math.random() * 2.0D - 1.0D) * 0.02F; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + } + + public final void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY1 = (float)((double)this.motionY1 + 0.002D); + this.moveEntity(this.motionX1, this.motionY1, this.motionZ1); + this.motionX1 *= 0.85F; + this.motionY1 *= 0.85F; + this.motionZ1 *= 0.85F; + if(this.worldObj.getBlockMaterial((int)this.posX, (int)this.posY, (int)this.posZ) != Material.water) { + this.setEntityDead(); + } + + if(this.particleMaxAge-- <= 0) { + this.setEntityDead(); + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityDiggingFX.java b/src/teavm/java/net/minecraft/client/effect/EntityDiggingFX.java new file mode 100644 index 0000000..9f0fb23 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityDiggingFX.java @@ -0,0 +1,36 @@ +package net.minecraft.client.effect; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public final class EntityDiggingFX extends EntityFX { + public EntityDiggingFX(World var1, float var2, float var3, float var4, float var5, float var6, float var7, Block var8) { + super(var1, var2, var3, var4, var5, var6, var7); + this.particleTextureIndex = var8.blockIndexInTexture; + this.particleGravity = var8.blockParticleGravity; + this.particleRed = this.particleGreen = this.particleBlue = 0.6F; + this.particleScale /= 2.0F; + } + + public final int getFXLayer() { + return 1; + } + + public final void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + float var8 = ((float)(this.particleTextureIndex % 16) + this.particleTextureJitterX / 4.0F) / 16.0F; + float var9 = var8 + 0.999F / 64.0F; + float var10 = ((float)(this.particleTextureIndex / 16) + this.particleTextureJitterY / 4.0F) / 16.0F; + float var11 = var10 + 0.999F / 64.0F; + float var12 = 0.1F * this.particleScale; + float var13 = this.prevPosX + (this.posX - this.prevPosX) * var2; + float var14 = this.prevPosY + (this.posY - this.prevPosY) * var2; + float var15 = this.prevPosZ + (this.posZ - this.prevPosZ) * var2; + var2 = this.getEntityBrightness(var2); + var1.setColorOpaque_F(var2 * this.particleRed, var2 * this.particleGreen, var2 * this.particleBlue); + var1.addVertexWithUV(var13 - var3 * var12 - var6 * var12, var14 - var4 * var12, var15 - var5 * var12 - var7 * var12, var8, var11); + var1.addVertexWithUV(var13 - var3 * var12 + var6 * var12, var14 + var4 * var12, var15 - var5 * var12 + var7 * var12, var8, var10); + var1.addVertexWithUV(var13 + var3 * var12 + var6 * var12, var14 + var4 * var12, var15 + var5 * var12 + var7 * var12, var9, var10); + var1.addVertexWithUV(var13 + var3 * var12 - var6 * var12, var14 - var4 * var12, var15 + var5 * var12 - var7 * var12, var9, var11); + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityExplodeFX.java b/src/teavm/java/net/minecraft/client/effect/EntityExplodeFX.java new file mode 100644 index 0000000..3305643 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityExplodeFX.java @@ -0,0 +1,41 @@ +package net.minecraft.client.effect; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.level.World; + +public final class EntityExplodeFX extends EntityFX { + public EntityExplodeFX(World var1, float var2, float var3, float var4, float var5, float var6, float var7) { + super(var1, var2, var3, var4, var5, var6, var7); + this.motionX1 = var5 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; + this.motionY1 = var6 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; + this.motionZ1 = var7 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; + this.particleRed = this.particleGreen = this.particleBlue = this.rand.nextFloat() * 0.3F + 0.7F; + this.particleScale = this.rand.nextFloat() * this.rand.nextFloat() * 6.0F + 1.0F; + this.particleMaxAge = (int)(16.0D / ((double)this.rand.nextFloat() * 0.8D + 0.2D)) + 2; + } + + public final void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + super.renderParticle(var1, var2, var3, var4, var5, var6, var7); + } + + public final void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + if(this.particleAge++ >= this.particleMaxAge) { + this.setEntityDead(); + } + + this.particleTextureIndex = 7 - (this.particleAge << 3) / this.particleMaxAge; + this.motionY1 = (float)((double)this.motionY1 + 0.004D); + this.moveEntity(this.motionX1, this.motionY1, this.motionZ1); + this.motionX1 *= 0.9F; + this.motionY1 *= 0.9F; + this.motionZ1 *= 0.9F; + if(this.onGround) { + this.motionX1 *= 0.7F; + this.motionZ1 *= 0.7F; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityFX.java b/src/teavm/java/net/minecraft/client/effect/EntityFX.java new file mode 100644 index 0000000..a567483 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityFX.java @@ -0,0 +1,109 @@ +package net.minecraft.client.effect; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.level.World; + +public class EntityFX extends Entity { + protected float motionX1; + protected float motionY1; + protected float motionZ1; + protected int particleTextureIndex; + protected float particleTextureJitterX; + protected float particleTextureJitterY; + protected int particleAge = 0; + protected int particleMaxAge = 0; + protected float particleScale; + protected float particleGravity; + protected float particleRed; + protected float particleGreen; + protected float particleBlue; + + public EntityFX(World var1, float var2, float var3, float var4, float var5, float var6, float var7) { + super(var1); + this.setSize(0.2F, 0.2F); + this.yOffset = this.height / 2.0F; + this.setPosition(var2, var3, var4); + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.motionX1 = var5 + (float)(Math.random() * 2.0D - 1.0D) * 0.4F; + this.motionY1 = var6 + (float)(Math.random() * 2.0D - 1.0D) * 0.4F; + this.motionZ1 = var7 + (float)(Math.random() * 2.0D - 1.0D) * 0.4F; + float var8 = (float)(Math.random() + Math.random() + 1.0D) * 0.15F; + var2 = MathHelper.sqrt_float(this.motionX1 * this.motionX1 + this.motionY1 * this.motionY1 + this.motionZ1 * this.motionZ1); + this.motionX1 = this.motionX1 / var2 * var8 * 0.4F; + this.motionY1 = this.motionY1 / var2 * var8 * 0.4F + 0.1F; + this.motionZ1 = this.motionZ1 / var2 * var8 * 0.4F; + this.particleTextureJitterX = this.rand.nextFloat() * 3.0F; + this.particleTextureJitterY = this.rand.nextFloat() * 3.0F; + this.particleScale = (this.rand.nextFloat() * 0.5F + 0.5F) * 2.0F; + this.particleMaxAge = (int)(4.0F / (this.rand.nextFloat() * 0.9F + 0.1F)); + this.particleAge = 0; + this.canTriggerWalking = false; + } + + public final EntityFX multiplyVelocity(float var1) { + this.motionX1 *= 0.2F; + this.motionY1 = (this.motionY1 - 0.1F) * 0.2F + 0.1F; + this.motionZ1 *= 0.2F; + return this; + } + + public final EntityFX multipleParticleScaleBy(float var1) { + this.setSize(0.120000005F, 0.120000005F); + this.particleScale *= 0.6F; + return this; + } + + public void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + if(this.particleAge++ >= this.particleMaxAge) { + this.setEntityDead(); + } + + this.motionY1 = (float)((double)this.motionY1 - 0.04D * (double)this.particleGravity); + this.moveEntity(this.motionX1, this.motionY1, this.motionZ1); + this.motionX1 *= 0.98F; + this.motionY1 *= 0.98F; + this.motionZ1 *= 0.98F; + if(this.onGround) { + this.motionX1 *= 0.7F; + this.motionZ1 *= 0.7F; + } + + } + + public void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + float var8 = (float)(this.particleTextureIndex % 16) / 16.0F; + float var9 = var8 + 0.999F / 16.0F; + float var10 = (float)(this.particleTextureIndex / 16) / 16.0F; + float var11 = var10 + 0.999F / 16.0F; + float var12 = 0.1F * this.particleScale; + float var13 = this.prevPosX + (this.posX - this.prevPosX) * var2; + float var14 = this.prevPosY + (this.posY - this.prevPosY) * var2; + float var15 = this.prevPosZ + (this.posZ - this.prevPosZ) * var2; + var2 = this.getEntityBrightness(var2); + var1.setColorOpaque_F(this.particleRed * var2, this.particleGreen * var2, this.particleBlue * var2); + var1.addVertexWithUV(var13 - var3 * var12 - var6 * var12, var14 - var4 * var12, var15 - var5 * var12 - var7 * var12, var8, var11); + var1.addVertexWithUV(var13 - var3 * var12 + var6 * var12, var14 + var4 * var12, var15 - var5 * var12 + var7 * var12, var8, var10); + var1.addVertexWithUV(var13 + var3 * var12 + var6 * var12, var14 + var4 * var12, var15 + var5 * var12 + var7 * var12, var9, var10); + var1.addVertexWithUV(var13 + var3 * var12 - var6 * var12, var14 - var4 * var12, var15 + var5 * var12 - var7 * var12, var9, var11); + } + + public int getFXLayer() { + return 0; + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + } + + protected final String getEntityString() { + return null; + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityFlameFX.java b/src/teavm/java/net/minecraft/client/effect/EntityFlameFX.java new file mode 100644 index 0000000..bfe55f2 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityFlameFX.java @@ -0,0 +1,65 @@ +package net.minecraft.client.effect; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.level.World; + +public final class EntityFlameFX extends EntityFX { + private float flameScale; + + public EntityFlameFX(World var1, float var2, float var3, float var4) { + super(var1, var2, var3, var4, 0.0F, 0.0F, 0.0F); + this.motionX1 *= 0.01F; + this.motionY1 *= 0.01F; + this.motionZ1 *= 0.01F; + this.rand.nextFloat(); + this.rand.nextFloat(); + this.rand.nextFloat(); + this.rand.nextFloat(); + this.rand.nextFloat(); + this.rand.nextFloat(); + this.flameScale = this.particleScale; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)) + 4; + this.noClip = true; + this.particleTextureIndex = 48; + } + + public final void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + float var8 = ((float)this.particleAge + var2) / (float)this.particleMaxAge; + this.particleScale = this.flameScale * (1.0F - var8 * var8 * 0.5F); + super.renderParticle(var1, var2, var3, var4, var5, var6, var7); + } + + public final float getEntityBrightness(float var1) { + float var2 = ((float)this.particleAge + var1) / (float)this.particleMaxAge; + if(var2 < 0.0F) { + var2 = 0.0F; + } + + if(var2 > 1.0F) { + var2 = 1.0F; + } + + var1 = super.getEntityBrightness(var1); + return var1 * var2 + (1.0F - var2); + } + + public final void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + if(this.particleAge++ >= this.particleMaxAge) { + this.setEntityDead(); + } + + this.moveEntity(this.motionX1, this.motionY1, this.motionZ1); + this.motionX1 *= 0.96F; + this.motionY1 *= 0.96F; + this.motionZ1 *= 0.96F; + if(this.onGround) { + this.motionX1 *= 0.7F; + this.motionZ1 *= 0.7F; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityLavaFX.java b/src/teavm/java/net/minecraft/client/effect/EntityLavaFX.java new file mode 100644 index 0000000..06aed98 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityLavaFX.java @@ -0,0 +1,57 @@ +package net.minecraft.client.effect; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.level.World; + +public final class EntityLavaFX extends EntityFX { + private float lavaParticleScale; + + public EntityLavaFX(World var1, float var2, float var3, float var4) { + super(var1, var2, var3, var4, 0.0F, 0.0F, 0.0F); + this.motionX1 *= 0.8F; + this.motionY1 *= 0.8F; + this.motionZ1 *= 0.8F; + this.motionY1 = this.rand.nextFloat() * 0.4F + 0.05F; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.particleScale *= this.rand.nextFloat() * 2.0F + 0.2F; + this.lavaParticleScale = this.particleScale; + this.particleMaxAge = (int)(16.0D / (Math.random() * 0.8D + 0.2D)); + this.noClip = false; + this.particleTextureIndex = 49; + } + + public final float getEntityBrightness(float var1) { + return 1.0F; + } + + public final void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + float var8 = ((float)this.particleAge + var2) / (float)this.particleMaxAge; + this.particleScale = this.lavaParticleScale * (1.0F - var8 * var8); + super.renderParticle(var1, var2, var3, var4, var5, var6, var7); + } + + public final void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + if(this.particleAge++ >= this.particleMaxAge) { + this.setEntityDead(); + } + + float var1 = (float)this.particleAge / (float)this.particleMaxAge; + if(this.rand.nextFloat() > var1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY, this.posZ, this.motionX1, this.motionY1, this.motionZ1); + } + + this.motionY1 = (float)((double)this.motionY1 - 0.03D); + this.moveEntity(this.motionX1, this.motionY1, this.motionZ1); + this.motionX1 *= 0.999F; + this.motionY1 *= 0.999F; + this.motionZ1 *= 0.999F; + if(this.onGround) { + this.motionX1 *= 0.7F; + this.motionZ1 *= 0.7F; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityPickupFX.java b/src/teavm/java/net/minecraft/client/effect/EntityPickupFX.java new file mode 100644 index 0000000..69baa88 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityPickupFX.java @@ -0,0 +1,53 @@ +package net.minecraft.client.effect; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.client.render.entity.RenderManager; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.level.World; +import org.lwjgl.opengl.GL11; + +public final class EntityPickupFX extends EntityFX { + private Entity entityToPickUp; + private EntityLiving entityPickingUp; + private int age = 0; + private int maxAge = 0; + private float yOffs; + + public EntityPickupFX(World var1, Entity var2, EntityLiving var3, float var4) { + super(var1, var2.posX, var2.posY, var2.posZ, var2.motionX, var2.motionY, var2.motionZ); + this.entityToPickUp = var2; + this.entityPickingUp = var3; + this.maxAge = 3; + this.yOffs = -0.5F; + } + + public final void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + float var9 = ((float)this.age + var2) / (float)this.maxAge; + var9 *= var9; + var3 = this.entityToPickUp.posX; + var4 = this.entityToPickUp.posY; + var5 = this.entityToPickUp.posZ; + var6 = this.entityPickingUp.lastTickPosX + (this.entityPickingUp.posX - this.entityPickingUp.lastTickPosX) * var2; + var7 = this.entityPickingUp.lastTickPosY + (this.entityPickingUp.posY - this.entityPickingUp.lastTickPosY) * var2 + this.yOffs; + float var8 = this.entityPickingUp.lastTickPosZ + (this.entityPickingUp.posZ - this.entityPickingUp.lastTickPosZ) * var2; + var3 += (var6 - var3) * var9; + var4 += (var7 - var4) * var9; + var9 = var5 + (var8 - var5) * var9; + var5 = this.worldObj.getLightBrightness((int)var3, (int)var4, (int)var9); + GL11.glColor4f(var5, var5, var5, 1.0F); + RenderManager.instance.renderEntityWithPosYaw(this.entityToPickUp, var3, var4, var9, this.entityToPickUp.rotationYaw, var2); + } + + public final void onEntityUpdate() { + ++this.age; + if(this.age == this.maxAge) { + this.setEntityDead(); + } + + } + + public final int getFXLayer() { + return 2; + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntityRainFX.java b/src/teavm/java/net/minecraft/client/effect/EntityRainFX.java new file mode 100644 index 0000000..dcb392d --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntityRainFX.java @@ -0,0 +1,54 @@ +package net.minecraft.client.effect; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public class EntityRainFX extends EntityFX { + public EntityRainFX(World var1, float var2, float var3, float var4) { + super(var1, var2, var3, var4, 0.0F, 0.0F, 0.0F); + this.motionX1 *= 0.3F; + this.motionY1 = (float)Math.random() * 0.2F + 0.1F; + this.motionZ1 *= 0.3F; + this.particleRed = 1.0F; + this.particleGreen = 1.0F; + this.particleBlue = 1.0F; + this.particleTextureIndex = 16; + this.setSize(0.01F, 0.01F); + this.particleGravity = 0.06F; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + } + + public final void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + super.renderParticle(var1, var2, var3, var4, var5, var6, var7); + } + + public final void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY1 -= this.particleGravity; + this.moveEntity(this.motionX1, this.motionY1, this.motionZ1); + this.motionX1 *= 0.98F; + this.motionY1 *= 0.98F; + this.motionZ1 *= 0.98F; + if(this.particleMaxAge-- <= 0) { + this.setEntityDead(); + } + + if(this.onGround) { + if(Math.random() < 0.5D) { + this.setEntityDead(); + } + + this.motionX1 *= 0.7F; + this.motionZ1 *= 0.7F; + } + + Material var1 = this.worldObj.getBlockMaterial((int)this.posX, (int)this.posY, (int)this.posZ); + if(var1.getIsLiquid() || var1.isSolid()) { + this.setEntityDead(); + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntitySmokeFX.java b/src/teavm/java/net/minecraft/client/effect/EntitySmokeFX.java new file mode 100644 index 0000000..3555004 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntitySmokeFX.java @@ -0,0 +1,66 @@ +package net.minecraft.client.effect; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.level.World; + +public final class EntitySmokeFX extends EntityFX { + private float smokeParticleScale; + + public EntitySmokeFX(World var1, float var2, float var3, float var4) { + this(var1, var2, var3, var4, 1.0F); + } + + public EntitySmokeFX(World var1, float var2, float var3, float var4, float var5) { + super(var1, var2, var3, var4, 0.0F, 0.0F, 0.0F); + this.motionX1 *= 0.1F; + this.motionY1 *= 0.1F; + this.motionZ1 *= 0.1F; + this.particleRed = this.particleGreen = this.particleBlue = (float)(Math.random() * (double)0.3F); + this.particleScale *= 12.0F / 16.0F; + this.particleScale *= var5; + this.smokeParticleScale = this.particleScale; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * var5); + this.noClip = false; + } + + public final void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) { + float var8 = ((float)this.particleAge + var2) / (float)this.particleMaxAge * 32.0F; + if(var8 < 0.0F) { + var8 = 0.0F; + } + + if(var8 > 1.0F) { + var8 = 1.0F; + } + + this.particleScale = this.smokeParticleScale * var8; + super.renderParticle(var1, var2, var3, var4, var5, var6, var7); + } + + public final void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + if(this.particleAge++ >= this.particleMaxAge) { + this.setEntityDead(); + } + + this.particleTextureIndex = 7 - (this.particleAge << 3) / this.particleMaxAge; + this.motionY1 = (float)((double)this.motionY1 + 0.004D); + this.moveEntity(this.motionX1, this.motionY1, this.motionZ1); + if(this.posY == this.prevPosY) { + this.motionX1 = (float)((double)this.motionX1 * 1.1D); + this.motionZ1 = (float)((double)this.motionZ1 * 1.1D); + } + + this.motionX1 *= 0.96F; + this.motionY1 *= 0.96F; + this.motionZ1 *= 0.96F; + if(this.onGround) { + this.motionX1 *= 0.7F; + this.motionZ1 *= 0.7F; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/effect/EntitySplashFX.java b/src/teavm/java/net/minecraft/client/effect/EntitySplashFX.java new file mode 100644 index 0000000..dd4bbf1 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/effect/EntitySplashFX.java @@ -0,0 +1,11 @@ +package net.minecraft.client.effect; + +import net.minecraft.game.level.World; + +public final class EntitySplashFX extends EntityRainFX { + public EntitySplashFX(World var1, float var2, float var3, float var4) { + super(var1, var2, var3, var4); + this.particleGravity = 0.04F; + ++this.particleTextureIndex; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/FilenameFilterLevel.java b/src/teavm/java/net/minecraft/client/gui/FilenameFilterLevel.java new file mode 100644 index 0000000..f4b2822 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/FilenameFilterLevel.java @@ -0,0 +1,13 @@ +package net.minecraft.client.gui; + +import java.io.File; +import java.io.FilenameFilter; + +final class FilenameFilterLevel implements FilenameFilter { + FilenameFilterLevel(GuiLevelDialog var1) { + } + + public final boolean accept(File var1, String var2) { + return var2.toLowerCase().endsWith(".mclevel"); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/FontRenderer.java b/src/teavm/java/net/minecraft/client/gui/FontRenderer.java new file mode 100644 index 0000000..cde674c --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/FontRenderer.java @@ -0,0 +1,179 @@ +package net.minecraft.client.gui; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.nio.IntBuffer; +import javax.imageio.ImageIO; +import net.minecraft.client.GameSettings; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.client.render.Tessellator; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +public final class FontRenderer { + private int[] charWidth = new int[256]; + private int fontTextureName = 0; + private int fontDisplayLists; + private IntBuffer buffer = BufferUtils.createIntBuffer(1024); + + public FontRenderer(GameSettings var1, String var2, RenderEngine var3) { + BufferedImage var4; + try { + var4 = ImageIO.read(RenderEngine.class.getResourceAsStream(var2)); + } catch (IOException var15) { + throw new RuntimeException(var15); + } + + int var5 = var4.getWidth(); + int var6 = var4.getHeight(); + int[] var7 = new int[var5 * var6]; + var4.getRGB(0, 0, var5, var6, var7, 0, var5); + + int var8; + int var9; + int var11; + int var13; + int var14; + for(int var17 = 0; var17 < 128; ++var17) { + var6 = var17 % 16; + var8 = var17 / 16; + var9 = 0; + + for(boolean var10 = false; var9 < 8 && !var10; ++var9) { + var11 = (var6 << 3) + var9; + var10 = true; + + for(int var12 = 0; var12 < 8 && var10; ++var12) { + var13 = ((var8 << 3) + var12) * var5; + var14 = var7[var11 + var13] & 255; + if(var14 > 128) { + var10 = false; + } + } + } + + if(var17 == 32) { + var9 = 4; + } + + this.charWidth[var17] = var9; + } + + this.fontTextureName = var3.getTexture(var2); + this.fontDisplayLists = GL11.glGenLists(288); + Tessellator var18 = Tessellator.instance; + + for(var6 = 0; var6 < 256; ++var6) { + GL11.glNewList(this.fontDisplayLists + var6, GL11.GL_COMPILE); + var18.startDrawingQuads(); + var8 = var6 % 16 << 3; + var9 = var6 / 16 << 3; + var18.addVertexWithUV(0.0F, 7.99F, 0.0F, (float)var8 / 128.0F, ((float)var9 + 7.99F) / 128.0F); + var18.addVertexWithUV(7.99F, 7.99F, 0.0F, ((float)var8 + 7.99F) / 128.0F, ((float)var9 + 7.99F) / 128.0F); + var18.addVertexWithUV(7.99F, 0.0F, 0.0F, ((float)var8 + 7.99F) / 128.0F, (float)var9 / 128.0F); + var18.addVertexWithUV(0.0F, 0.0F, 0.0F, (float)var8 / 128.0F, (float)var9 / 128.0F); + var18.draw(); + GL11.glTranslatef((float)this.charWidth[var6], 0.0F, 0.0F); + GL11.glEndList(); + } + + for(var6 = 0; var6 < 32; ++var6) { + var8 = (var6 & 8) << 3; + var9 = (var6 & 1) * 191 + var8; + int var19 = ((var6 & 2) >> 1) * 191 + var8; + var11 = ((var6 & 4) >> 2) * 191 + var8; + boolean var20 = var6 >= 16; + if(var1.anaglyph) { + var13 = (var11 * 30 + var19 * 59 + var9 * 11) / 100; + var14 = (var11 * 30 + var19 * 70) / 100; + int var16 = (var11 * 30 + var9 * 70) / 100; + var11 = var13; + var19 = var14; + var9 = var16; + } + + var6 += 2; + if(var20) { + var11 /= 4; + var19 /= 4; + var9 /= 4; + } + + GL11.glColor4f((float)var11 / 255.0F, (float)var19 / 255.0F, (float)var9 / 255.0F, 1.0F); + } + + } + + public final void drawStringWithShadow(String var1, int var2, int var3, int var4) { + this.renderString(var1, var2 + 1, var3 + 1, var4, true); + this.drawString(var1, var2, var3, var4); + } + + public final void drawString(String var1, int var2, int var3, int var4) { + this.renderString(var1, var2, var3, var4, false); + } + + private void renderString(String var1, int var2, int var3, int var4, boolean var5) { + if(var1 != null) { + char[] var8 = var1.toCharArray(); + if(var5) { + var4 = (var4 & 16579836) >> 2; + } + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.fontTextureName); + float var6 = (float)(var4 >> 16 & 255) / 255.0F; + float var7 = (float)(var4 >> 8 & 255) / 255.0F; + float var9 = (float)(var4 & 255) / 255.0F; + GL11.glColor4f(var6, var7, var9, 1.0F); + this.buffer.clear(); + GL11.glPushMatrix(); + GL11.glTranslatef((float)var2, (float)var3, 0.0F); + + for(int var10 = 0; var10 < var8.length; ++var10) { + for(; var8[var10] == 38 && var8.length > var10 + 1; var10 += 2) { + int var11 = "0123456789abcdef".indexOf(var8[var10 + 1]); + if(var11 < 0 || var11 > 15) { + var11 = 15; + } + + this.buffer.put(this.fontDisplayLists + 256 + var11 + (var5 ? 16 : 0)); + if(this.buffer.remaining() == 0) { + this.buffer.flip(); + GL11.glCallLists(this.buffer); + this.buffer.clear(); + } + } + + this.buffer.put(this.fontDisplayLists + var8[var10]); + if(this.buffer.remaining() == 0) { + this.buffer.flip(); + GL11.glCallLists(this.buffer); + this.buffer.clear(); + } + } + + this.buffer.flip(); + GL11.glCallLists(this.buffer); + GL11.glPopMatrix(); + } + } + + public final int getStringWidth(String var1) { + if(var1 == null) { + return 0; + } else { + char[] var4 = var1.toCharArray(); + int var2 = 0; + + for(int var3 = 0; var3 < var4.length; ++var3) { + if(var4[var3] == 38) { + ++var3; + } else { + var2 += this.charWidth[var4[var3]]; + } + } + + return var2; + } + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/Gui.java b/src/teavm/java/net/minecraft/client/gui/Gui.java new file mode 100644 index 0000000..90ec7ed --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/Gui.java @@ -0,0 +1,73 @@ +package net.minecraft.client.gui; + +import net.minecraft.client.render.Tessellator; +import org.lwjgl.opengl.GL11; + +public class Gui { + protected float zLevel = 0.0F; + + protected static void drawRect(int var0, int var1, int var2, int var3, int var4) { + float var5 = (float)(var4 >>> 24) / 255.0F; + float var6 = (float)(var4 >> 16 & 255) / 255.0F; + float var7 = (float)(var4 >> 8 & 255) / 255.0F; + float var9 = (float)(var4 & 255) / 255.0F; + Tessellator var8 = Tessellator.instance; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(var6, var7, var9, var5); + var8.startDrawingQuads(); + var8.addVertex((float)var0, (float)var3, 0.0F); + var8.addVertex((float)var2, (float)var3, 0.0F); + var8.addVertex((float)var2, (float)var1, 0.0F); + var8.addVertex((float)var0, (float)var1, 0.0F); + var8.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + } + + protected static void drawGradientRect(int var0, int var1, int var2, int var3, int var4, int var5) { + float var6 = (float)(var4 >>> 24) / 255.0F; + float var7 = (float)(var4 >> 16 & 255) / 255.0F; + float var8 = (float)(var4 >> 8 & 255) / 255.0F; + float var13 = (float)(var4 & 255) / 255.0F; + float var9 = (float)(var5 >>> 24) / 255.0F; + float var10 = (float)(var5 >> 16 & 255) / 255.0F; + float var11 = (float)(var5 >> 8 & 255) / 255.0F; + float var14 = (float)(var5 & 255) / 255.0F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator var12 = Tessellator.instance; + var12.startDrawingQuads(); + var12.setColorRGBA_F(var7, var8, var13, var6); + var12.addVertex((float)var2, (float)var1, 0.0F); + var12.addVertex((float)var0, (float)var1, 0.0F); + var12.setColorRGBA_F(var10, var11, var14, var9); + var12.addVertex((float)var0, (float)var3, 0.0F); + var12.addVertex((float)var2, (float)var3, 0.0F); + var12.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public static void drawCenteredString(FontRenderer var0, String var1, int var2, int var3, int var4) { + var0.drawStringWithShadow(var1, var2 - var0.getStringWidth(var1) / 2, var3, var4); + } + + public static void drawString(FontRenderer var0, String var1, int var2, int var3, int var4) { + var0.drawStringWithShadow(var1, var2, var3, var4); + } + + public final void drawTexturedModalRect(int var1, int var2, int var3, int var4, int var5, int var6) { + Tessellator var7 = Tessellator.instance; + var7.startDrawingQuads(); + var7.addVertexWithUV((float)var1, (float)(var2 + var6), this.zLevel, (float)var3 * 0.00390625F, (float)(var4 + var6) * 0.00390625F); + var7.addVertexWithUV((float)(var1 + var5), (float)(var2 + var6), this.zLevel, (float)(var3 + var5) * 0.00390625F, (float)(var4 + var6) * 0.00390625F); + var7.addVertexWithUV((float)(var1 + var5), (float)var2, this.zLevel, (float)(var3 + var5) * 0.00390625F, (float)var4 * 0.00390625F); + var7.addVertexWithUV((float)var1, (float)var2, this.zLevel, (float)var3 * 0.00390625F, (float)var4 * 0.00390625F); + var7.draw(); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiButton.java b/src/teavm/java/net/minecraft/client/gui/GuiButton.java new file mode 100644 index 0000000..1a85271 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiButton.java @@ -0,0 +1,61 @@ +package net.minecraft.client.gui; + +import net.minecraft.client.Minecraft; +import org.lwjgl.opengl.GL11; + +public class GuiButton extends Gui { + private int width; + private int height; + private int xPosition; + private int yPosition; + public String displayString; + public int id; + public boolean enabled; + public boolean visible; + + public GuiButton(int var1, int var2, int var3, String var4) { + this(var1, var2, var3, 200, 20, var4); + } + + protected GuiButton(int var1, int var2, int var3, int var4, int var5, String var6) { + this.width = 200; + this.height = 20; + this.enabled = true; + this.visible = true; + this.id = var1; + this.xPosition = var2; + this.yPosition = var3; + this.width = var4; + this.height = 20; + this.displayString = var6; + } + + public final void drawButton(Minecraft var1, int var2, int var3) { + if(this.visible) { + FontRenderer var4 = var1.fontRenderer; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var1.renderEngine.getTexture("/gui/gui.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + byte var5 = 1; + boolean var6 = var2 >= this.xPosition && var3 >= this.yPosition && var2 < this.xPosition + this.width && var3 < this.yPosition + this.height; + if(!this.enabled) { + var5 = 0; + } else if(var6) { + var5 = 2; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + var5 * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + var5 * 20, this.width / 2, this.height); + if(!this.enabled) { + drawCenteredString(var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, -6250336); + } else if(var6) { + drawCenteredString(var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, 16777120); + } else { + drawCenteredString(var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, 14737632); + } + } + } + + public final boolean mousePressed(int var1, int var2) { + return this.enabled && var1 >= this.xPosition && var2 >= this.yPosition && var1 < this.xPosition + this.width && var2 < this.yPosition + this.height; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiControls.java b/src/teavm/java/net/minecraft/client/gui/GuiControls.java new file mode 100644 index 0000000..afeb250 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiControls.java @@ -0,0 +1,52 @@ +package net.minecraft.client.gui; + +import net.minecraft.client.GameSettings; + +public final class GuiControls extends GuiScreen { + private GuiScreen parentScreen; + private String screenTitle = "Controls"; + private GameSettings options; + private int buttonId = -1; + + public GuiControls(GuiScreen var1, GameSettings var2) { + this.parentScreen = var1; + this.options = var2; + } + + public final void initGui() { + for(int var1 = 0; var1 < this.options.keyBindings.length; ++var1) { + this.controlList.add(new GuiSmallButton(var1, this.width / 2 - 155 + var1 % 2 * 160, this.height / 6 + 24 * (var1 >> 1), this.options.setKeyBindingString(var1))); + } + + this.controlList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, "Done")); + } + + protected final void actionPerformed(GuiButton var1) { + for(int var2 = 0; var2 < this.options.keyBindings.length; ++var2) { + ((GuiButton)this.controlList.get(var2)).displayString = this.options.setKeyBindingString(var2); + } + + if(var1.id == 200) { + this.mc.displayGuiScreen(this.parentScreen); + } else { + this.buttonId = var1.id; + var1.displayString = "> " + this.options.setKeyBindingString(var1.id) + " <"; + } + } + + protected final void keyTyped(char var1, int var2) { + if(this.buttonId >= 0) { + this.options.setKeyBinding(this.buttonId, var2); + ((GuiButton)this.controlList.get(this.buttonId)).displayString = this.options.setKeyBindingString(this.buttonId); + this.buttonId = -1; + } else { + super.keyTyped(var1, var2); + } + } + + public final void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 20, 16777215); + super.drawScreen(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiErrorScreen.java b/src/teavm/java/net/minecraft/client/gui/GuiErrorScreen.java new file mode 100644 index 0000000..7ee9c96 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiErrorScreen.java @@ -0,0 +1,24 @@ +package net.minecraft.client.gui; + +public final class GuiErrorScreen extends GuiScreen { + private String title; + private String text; + + public GuiErrorScreen(String var1, String var2) { + this.title = var1; + this.text = var2; + } + + public final void initGui() { + } + + public final void drawScreen(int var1, int var2, float var3) { + drawGradientRect(0, 0, this.width, this.height, -12574688, -11530224); + drawCenteredString(this.fontRenderer, this.title, this.width / 2, 90, 16777215); + drawCenteredString(this.fontRenderer, this.text, this.width / 2, 110, 16777215); + super.drawScreen(var1, var2, var3); + } + + protected final void keyTyped(char var1, int var2) { + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiGameOver.java b/src/teavm/java/net/minecraft/client/gui/GuiGameOver.java new file mode 100644 index 0000000..76e4428 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiGameOver.java @@ -0,0 +1,51 @@ +package net.minecraft.client.gui; + +import net.minecraft.client.player.EntityPlayerSP; +import org.lwjgl.opengl.GL11; + +public final class GuiGameOver extends GuiScreen { + public final void initGui() { + this.controlList.clear(); + this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 72, "Generate new level...")); + this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 96, "Load level..")); + if(this.mc.session == null) { + ((GuiButton)this.controlList.get(1)).enabled = false; + } + + } + + protected final void keyTyped(char var1, int var2) { + } + + protected final void actionPerformed(GuiButton var1) { + if(var1.id == 0) { + this.mc.displayGuiScreen(new GuiOptions(this, this.mc.options)); + } + + if(var1.id == 1) { + this.mc.displayGuiScreen(new GuiNewLevel(this)); + } + + if(this.mc.session != null && var1.id == 2) { + this.mc.displayGuiScreen(new GuiLoadLevel(this)); + } + + } + + public final void drawScreen(int var1, int var2, float var3) { + drawGradientRect(0, 0, this.width, this.height, 1615855616, -1602211792); + GL11.glPushMatrix(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + drawCenteredString(this.fontRenderer, "Game over!", this.width / 2 / 2, 30, 16777215); + GL11.glPopMatrix(); + FontRenderer var10000 = this.fontRenderer; + StringBuilder var10001 = (new StringBuilder()).append("Score: &e"); + EntityPlayerSP var4 = this.mc.thePlayer; + drawCenteredString(var10000, var10001.append(var4.getScore).toString(), this.width / 2, 100, 16777215); + super.drawScreen(var1, var2, var3); + } + + public final boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiIngame.java b/src/teavm/java/net/minecraft/client/gui/GuiIngame.java new file mode 100644 index 0000000..3ec60ea --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiIngame.java @@ -0,0 +1,190 @@ +package net.minecraft.client.gui; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import net.minecraft.client.ChatLine; +import net.minecraft.client.Minecraft; +import net.minecraft.client.RenderHelper; +import net.minecraft.client.player.EntityPlayerSP; +import net.minecraft.client.render.entity.RenderItem; +import net.minecraft.game.entity.player.InventoryPlayer; +import net.minecraft.game.item.ItemStack; +import org.lwjgl.opengl.GL11; + +public final class GuiIngame extends Gui { + private static RenderItem itemRenderer = new RenderItem(); + private List chatMessageList = new ArrayList(); + private Random rand = new Random(); + private Minecraft mc; + private int updateCounter = 0; + + public GuiIngame(Minecraft var1) { + this.mc = var1; + } + + public final void renderGameOverlay(float var1) { + ScaledResolution var2 = new ScaledResolution(this.mc.displayWidth, this.mc.displayHeight); + int var3 = var2.getScaledWidth(); + int var19 = var2.getScaledHeight(); + FontRenderer var4 = this.mc.fontRenderer; + this.mc.entityRenderer.setupOverlayRendering(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/gui.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_BLEND); + InventoryPlayer var5 = this.mc.thePlayer.inventory; + this.zLevel = -90.0F; + this.drawTexturedModalRect(var3 / 2 - 91, var19 - 22, 0, 0, 182, 22); + this.drawTexturedModalRect(var3 / 2 - 91 - 1 + var5.currentItem * 20, var19 - 22 - 1, 0, 22, 24, 22); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/icons.png")); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR); + this.drawTexturedModalRect(var3 / 2 - 7, var19 / 2 - 7, 0, 0, 16, 16); + GL11.glDisable(GL11.GL_BLEND); + boolean var20 = this.mc.thePlayer.heartsLife / 3 % 2 == 1; + if(this.mc.thePlayer.heartsLife < 10) { + var20 = false; + } + + int var6 = this.mc.thePlayer.health; + int var7 = this.mc.thePlayer.prevHealth; + this.rand.setSeed((long)(this.updateCounter * 312871)); + int var10; + int var12; + if(this.mc.playerController.shouldDrawHUD()) { + EntityPlayerSP var8 = this.mc.thePlayer; + var10 = var8.inventory.getPlayerArmorValue(); + + int var11; + int var13; + for(var11 = 0; var11 < 10; ++var11) { + var12 = var19 - 32; + if(var10 > 0) { + var13 = var3 / 2 + 91 - (var11 << 3) - 9; + if((var11 << 1) + 1 < var10) { + this.drawTexturedModalRect(var13, var12, 34, 9, 9, 9); + } + + if((var11 << 1) + 1 == var10) { + this.drawTexturedModalRect(var13, var12, 25, 9, 9, 9); + } + + if((var11 << 1) + 1 > var10) { + this.drawTexturedModalRect(var13, var12, 16, 9, 9, 9); + } + } + + byte var26 = 0; + if(var20) { + var26 = 1; + } + + int var14 = var3 / 2 - 91 + (var11 << 3); + if(var6 <= 4) { + var12 += this.rand.nextInt(2); + } + + this.drawTexturedModalRect(var14, var12, 16 + var26 * 9, 0, 9, 9); + if(var20) { + if((var11 << 1) + 1 < var7) { + this.drawTexturedModalRect(var14, var12, 70, 0, 9, 9); + } + + if((var11 << 1) + 1 == var7) { + this.drawTexturedModalRect(var14, var12, 79, 0, 9, 9); + } + } + + if((var11 << 1) + 1 < var6) { + this.drawTexturedModalRect(var14, var12, 52, 0, 9, 9); + } + + if((var11 << 1) + 1 == var6) { + this.drawTexturedModalRect(var14, var12, 61, 0, 9, 9); + } + } + + if(this.mc.thePlayer.isInsideOfWater()) { + var11 = (int)Math.ceil((double)(this.mc.thePlayer.air - 2) * 10.0D / 300.0D); + var12 = (int)Math.ceil((double)this.mc.thePlayer.air * 10.0D / 300.0D) - var11; + + for(var13 = 0; var13 < var11 + var12; ++var13) { + if(var13 < var11) { + this.drawTexturedModalRect(var3 / 2 - 91 + (var13 << 3), var19 - 32 - 9, 16, 18, 9, 9); + } else { + this.drawTexturedModalRect(var3 / 2 - 91 + (var13 << 3), var19 - 32 - 9, 25, 18, 9, 9); + } + } + } + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_NORMALIZE); + GL11.glPushMatrix(); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + + for(var10 = 0; var10 < 9; ++var10) { + int var25 = var3 / 2 - 90 + var10 * 20 + 2; + int var21 = var19 - 16 - 3; + ItemStack var22 = this.mc.thePlayer.inventory.mainInventory[var10]; + if(var22 != null) { + float var9 = (float)var22.animationsToGo - var1; + if(var9 > 0.0F) { + GL11.glPushMatrix(); + float var26 = 1.0F + var9 / 5.0F; + GL11.glTranslatef((float)(var25 + 8), (float)(var21 + 12), 0.0F); + GL11.glScalef(1.0F / var26, (var26 + 1.0F) / 2.0F, 1.0F); + GL11.glTranslatef((float)(-(var25 + 8)), (float)(-(var21 + 12)), 0.0F); + } + + itemRenderer.renderItemIntoGUI(this.mc.renderEngine, var22, var25, var21); + if(var9 > 0.0F) { + GL11.glPopMatrix(); + } + + itemRenderer.renderItemOverlayIntoGUI(this.mc.fontRenderer, var22, var25, var21); + } + } + + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_NORMALIZE); + if(this.mc.options.showFPS) { + var4.drawStringWithShadow("Minecraft Indev (" + this.mc.debug + ")", 2, 2, 16777215); + Minecraft var23 = this.mc; + var4.drawStringWithShadow(var23.renderGlobal.getDebugInfoRenders(), 2, 12, 16777215); + var23 = this.mc; + var4.drawStringWithShadow(var23.renderGlobal.getDebugInfoEntities(), 2, 22, 16777215); + var23 = this.mc; + var4.drawStringWithShadow("P: " + var23.effectRenderer.getStatistics() + ". T: " + var23.theWorld.debugSkylightUpdates(), 2, 32, 16777215); + long var24 = Runtime.getRuntime().maxMemory(); + long var27 = Runtime.getRuntime().totalMemory(); + long var28 = Runtime.getRuntime().freeMemory(); + long var16 = var24 - var28; + String var18 = "Free memory: " + var16 * 100L / var24 + "% of " + var24 / 1024L / 1024L + "MB"; + drawString(var4, var18, var3 - var4.getStringWidth(var18) - 2, 2, 14737632); + var18 = "Allocated memory: " + var27 * 100L / var24 + "% (" + var27 / 1024L / 1024L + "MB)"; + drawString(var4, var18, var3 - var4.getStringWidth(var18) - 2, 12, 14737632); + } else { + var4.drawStringWithShadow("Minecraft Indev", 2, 2, 16777215); + } + + for(var12 = 0; var12 < this.chatMessageList.size() && var12 < 10; ++var12) { + if(((ChatLine)this.chatMessageList.get(var12)).updateCounter < 200) { + this.chatMessageList.get(var12); + var4.drawStringWithShadow((String)null, 2, var19 - 8 - var12 * 9 - 20, 16777215); + } + } + + } + + public final void addChatMessage() { + ++this.updateCounter; + + for(int var1 = 0; var1 < this.chatMessageList.size(); ++var1) { + ++((ChatLine)this.chatMessageList.get(var1)).updateCounter; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiIngameMenu.java b/src/teavm/java/net/minecraft/client/gui/GuiIngameMenu.java new file mode 100644 index 0000000..561ed33 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiIngameMenu.java @@ -0,0 +1,49 @@ +package net.minecraft.client.gui; + +public final class GuiIngameMenu extends GuiScreen { + public final void initGui() { + this.controlList.clear(); + this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4, "Options...")); + this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 24, "Generate new level...")); + this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 48, "Save level..")); + this.controlList.add(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 72, "Load level..")); + this.controlList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 120, "Back to game")); + if(this.mc.session == null) { + ((GuiButton)this.controlList.get(2)).enabled = false; + ((GuiButton)this.controlList.get(3)).enabled = false; + } + + } + + protected final void actionPerformed(GuiButton var1) { + if(var1.id == 0) { + this.mc.displayGuiScreen(new GuiOptions(this, this.mc.options)); + } + + if(var1.id == 1) { + this.mc.displayGuiScreen(new GuiNewLevel(this)); + } + + if(this.mc.session != null) { + if(var1.id == 2) { + this.mc.displayGuiScreen(new GuiSaveLevel(this)); + } + + if(var1.id == 3) { + this.mc.displayGuiScreen(new GuiLoadLevel(this)); + } + } + + if(var1.id == 4) { + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + } + + } + + public final void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + drawCenteredString(this.fontRenderer, "Game menu", this.width / 2, 40, 16777215); + super.drawScreen(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiLevelDialog.java b/src/teavm/java/net/minecraft/client/gui/GuiLevelDialog.java new file mode 100644 index 0000000..b413678 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiLevelDialog.java @@ -0,0 +1,41 @@ +package net.minecraft.client.gui; + +import java.awt.FileDialog; +import java.io.File; + +final class GuiLevelDialog extends Thread { + private GuiLoadLevel screen; + + GuiLevelDialog(GuiLoadLevel var1) { + this.screen = var1; + } + + public final void run() { + try { + FileDialog var1 = this.screen.saveFileDialog(); + File var2 = new File(this.screen.mc.mcDataDir, "saves"); + var2.mkdir(); + String var5 = var2.toString(); + if(!var5.endsWith(File.separator)) { + var5 = var5 + File.separator; + } + + var1.setDirectory(var5); + FilenameFilterLevel var6 = new FilenameFilterLevel(this); + var1.setFilenameFilter(var6); + var1.setLocationRelativeTo(this.screen.mc.mcCanvas); + var1.setVisible(true); + if(var1.getFile() != null) { + var5 = var1.getDirectory(); + if(!var5.endsWith(File.separator)) { + var5 = var5 + File.separator; + } + + GuiLoadLevel.a(this.screen, new File(var5 + var1.getFile())); + } + } finally { + GuiLoadLevel.unknown(this.screen, false); + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiLoadLevel.java b/src/teavm/java/net/minecraft/client/gui/GuiLoadLevel.java new file mode 100644 index 0000000..9cae6dc --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiLoadLevel.java @@ -0,0 +1,145 @@ +package net.minecraft.client.gui; + +import java.awt.Dialog; +import java.awt.FileDialog; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import net.minecraft.client.PlayerLoader; +import net.minecraft.game.level.World; + +public class GuiLoadLevel extends GuiScreen implements Runnable { + private GuiScreen parent; + private boolean finished = false; + private boolean loaded = false; + private String[] levels = null; + private String status = ""; + protected String title = "Load level"; + private boolean frozen = false; + private File selectedFile; + + public GuiLoadLevel(GuiScreen var1) { + this.parent = var1; + } + + public final void updateScreen() { + if(this.selectedFile != null) { + if(!this.selectedFile.getName().endsWith(".mclevel")) { + this.selectedFile = new File(this.selectedFile.getAbsolutePath() + ".mclevel"); + } + + this.openLevel(this.selectedFile); + this.selectedFile = null; + this.mc.displayGuiScreen((GuiScreen)null); + } + + } + + public void run() { + try { + this.status = "Getting level list.."; + URL var1 = new URL("http://" + this.mc.minecraftUri + "/listmaps.jsp?user=" + this.mc.session.username); + BufferedReader var3 = new BufferedReader(new InputStreamReader(var1.openConnection().getInputStream())); + this.levels = var3.readLine().split(";"); + if(this.levels.length >= 5) { + this.setLevels(this.levels); + this.loaded = true; + return; + } + + this.status = this.levels[0]; + this.finished = true; + } catch (Exception var2) { + var2.printStackTrace(); + this.status = "Failed to load levels"; + this.finished = true; + } + + } + + protected void setLevels(String[] var1) { + for(int var2 = 0; var2 < 5; ++var2) { + ((GuiButton)this.controlList.get(var2)).enabled = !var1[var2].equals("-"); + ((GuiButton)this.controlList.get(var2)).displayString = var1[var2]; + ((GuiButton)this.controlList.get(var2)).visible = true; + } + + ((GuiButton)this.controlList.get(5)).visible = true; + } + + public void initGui() { + (new Thread(this)).start(); + + for(int var1 = 0; var1 < 5; ++var1) { + this.controlList.add(new GuiButton(var1, this.width / 2 - 100, this.height / 6 + var1 * 24, "---")); + ((GuiButton)this.controlList.get(var1)).visible = false; + } + + this.controlList.add(new GuiButton(5, this.width / 2 - 100, this.height / 6 + 120 + 12, "Load file...")); + this.controlList.add(new GuiButton(6, this.width / 2 - 100, this.height / 6 + 168, "Cancel")); + ((GuiButton)this.controlList.get(5)).visible = false; + } + + protected final void actionPerformed(GuiButton var1) { + if(!this.frozen) { + if(var1.enabled) { + if(this.loaded && var1.id < 5) { + this.openLevel(var1.id); + } + + if(this.finished || this.loaded && var1.id == 5) { + this.frozen = true; + GuiLevelDialog var2 = new GuiLevelDialog(this); + var2.setDaemon(true); + var2.start(); + } + + if(this.finished || this.loaded && var1.id == 6) { + this.mc.displayGuiScreen(this.parent); + } + + } + } + } + + protected FileDialog saveFileDialog() { + return new FileDialog((Dialog)null, "Load level", 0); + } + + protected void openLevel(int var1) { + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + } + + public final void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215); + if(!this.loaded) { + drawCenteredString(this.fontRenderer, this.status, this.width / 2, this.height / 2 - 4, 16777215); + } + + super.drawScreen(var1, var2, var3); + } + + protected void openLevel(File var1) { + try { + FileInputStream var4 = new FileInputStream(var1); + World var2 = (new PlayerLoader(this.mc, this.mc.loadingScreen)).load(var4); + var4.close(); + this.mc.setLevel(var2); + } catch (IOException var3) { + var3.printStackTrace(); + } + } + + static File a(GuiLoadLevel var0, File var1) { + return var0.selectedFile = var1; + } + + static boolean unknown(GuiLoadLevel var0, boolean var1) { + return var0.frozen = false; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiNameLevel.java b/src/teavm/java/net/minecraft/client/gui/GuiNameLevel.java new file mode 100644 index 0000000..8c48927 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiNameLevel.java @@ -0,0 +1,75 @@ +package net.minecraft.client.gui; + +import org.lwjgl.opengl.GL11; + +public final class GuiNameLevel extends GuiScreen { + private GuiScreen parent; + private String title = "Enter level name:"; + private int id; + private String name; + private int counter = 0; + + public GuiNameLevel(GuiScreen var1, String var2, int var3) { + this.parent = var1; + this.id = var3; + this.name = var2; + if(this.name.equals("-")) { + this.name = ""; + } + + } + + public final void initGui() { + this.controlList.clear(); + GL11.enableRepeatEvents(true); + this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120, "Save")); + this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 144, "Cancel")); + ((GuiButton)this.controlList.get(0)).enabled = this.name.trim().length() > 1; + } + + public final void onGuiClosed() { + GL11.enableRepeatEvents(false); + } + + public final void updateScreen() { + ++this.counter; + } + + protected final void actionPerformed(GuiButton var1) { + if(var1.enabled) { + if(var1.id == 0 && this.name.trim().length() > 1) { + this.name.trim(); + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + } + + if(var1.id == 1) { + this.mc.displayGuiScreen(this.parent); + } + + } + } + + protected final void keyTyped(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; + } + + ((GuiButton)this.controlList.get(0)).enabled = this.name.trim().length() > 1; + } + + public final void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + drawCenteredString(this.fontRenderer, this.title, this.width / 2, 40, 16777215); + int var4 = this.width / 2 - 100; + int var5 = this.height / 2 - 10; + drawRect(var4 - 1, var5 - 1, var4 + 200 + 1, var5 + 20 + 1, -6250336); + drawRect(var4, var5, var4 + 200, var5 + 20, -16777216); + drawString(this.fontRenderer, this.name + (this.counter / 6 % 2 == 0 ? "_" : ""), var4 + 4, var5 + 6, 14737632); + super.drawScreen(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiNewLevel.java b/src/teavm/java/net/minecraft/client/gui/GuiNewLevel.java new file mode 100644 index 0000000..1dc2a11 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiNewLevel.java @@ -0,0 +1,60 @@ +package net.minecraft.client.gui; + +public final class GuiNewLevel extends GuiScreen { + private GuiScreen prevGui; + private String[] worldType = new String[]{"Inland", "Island", "Floating", "Flat"}; + private String[] worldShape = new String[]{"Square", "Long", "Deep"}; + private String[] worldSize = new String[]{"Small", "Normal", "Huge"}; + private String[] worldTheme = new String[]{"Normal", "Hell", "Paradise", "Woods"}; + private int selectedWorldType = 1; + private int selectedWorldShape = 0; + private int selectedWorldSize = 1; + private int selectedWorldTheme = 0; + + public GuiNewLevel(GuiScreen var1) { + this.prevGui = var1; + } + + public final void initGui() { + this.controlList.clear(); + this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4, "Type: ")); + this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 24, "Shape:")); + this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 48, "Size: ")); + this.controlList.add(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 72, "Theme: ")); + this.controlList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 96 + 12, "Create")); + this.controlList.add(new GuiButton(5, this.width / 2 - 100, this.height / 4 + 120 + 12, "Cancel")); + this.worldOptions(); + } + + private void worldOptions() { + ((GuiButton)this.controlList.get(0)).displayString = "Type: " + this.worldType[this.selectedWorldType]; + ((GuiButton)this.controlList.get(1)).displayString = "Shape: " + this.worldShape[this.selectedWorldShape]; + ((GuiButton)this.controlList.get(2)).displayString = "Size: " + this.worldSize[this.selectedWorldSize]; + ((GuiButton)this.controlList.get(3)).displayString = "Theme: " + this.worldTheme[this.selectedWorldTheme]; + } + + protected final void actionPerformed(GuiButton var1) { + if(var1.id == 5) { + this.mc.displayGuiScreen(this.prevGui); + } else if(var1.id == 4) { + this.mc.generateLevel(this.selectedWorldSize, this.selectedWorldShape, this.selectedWorldType, this.selectedWorldTheme); + this.mc.displayGuiScreen((GuiScreen)null); + } else if(var1.id == 0) { + this.selectedWorldType = (this.selectedWorldType + 1) % this.worldType.length; + } else if(var1.id == 1) { + this.selectedWorldShape = (this.selectedWorldShape + 1) % this.worldShape.length; + } else if(var1.id == 2) { + this.selectedWorldSize = (this.selectedWorldSize + 1) % this.worldSize.length; + } else if(var1.id == 3) { + this.selectedWorldTheme = (this.selectedWorldTheme + 1) % this.worldTheme.length; + } + + this.worldOptions(); + } + + public final void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + drawCenteredString(this.fontRenderer, "Generate new level", this.width / 2, 40, 16777215); + super.drawScreen(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiOptions.java b/src/teavm/java/net/minecraft/client/gui/GuiOptions.java new file mode 100644 index 0000000..7e44888 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiOptions.java @@ -0,0 +1,47 @@ +package net.minecraft.client.gui; + +import net.minecraft.client.GameSettings; + +public final class GuiOptions extends GuiScreen { + private GuiScreen parentScreen; + private String screenTitle = "Options"; + private GameSettings options; + + public GuiOptions(GuiScreen var1, GameSettings var2) { + this.parentScreen = var1; + this.options = var2; + } + + public final void initGui() { + for(int var1 = 0; var1 < this.options.numberOfOptions; ++var1) { + this.controlList.add(new GuiSmallButton(var1, this.width / 2 - 155 + var1 % 2 * 160, this.height / 6 + 24 * (var1 >> 1), this.options.setOptionString(var1))); + } + + this.controlList.add(new GuiButton(100, this.width / 2 - 100, this.height / 6 + 120 + 12, "Controls...")); + this.controlList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, "Done")); + } + + protected final void actionPerformed(GuiButton var1) { + if(var1.enabled) { + if(var1.id < 100) { + this.options.setOptionValue(var1.id, 1); + var1.displayString = this.options.setOptionString(var1.id); + } + + if(var1.id == 100) { + this.mc.displayGuiScreen(new GuiControls(this, this.options)); + } + + if(var1.id == 200) { + this.mc.displayGuiScreen(this.parentScreen); + } + + } + } + + public final void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 20, 16777215); + super.drawScreen(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiSaveLevel.java b/src/teavm/java/net/minecraft/client/gui/GuiSaveLevel.java new file mode 100644 index 0000000..5e2419a --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiSaveLevel.java @@ -0,0 +1,47 @@ +package net.minecraft.client.gui; + +import java.awt.Dialog; +import java.awt.FileDialog; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import net.minecraft.client.PlayerLoader; + +public final class GuiSaveLevel extends GuiLoadLevel { + public GuiSaveLevel(GuiScreen var1) { + super(var1); + this.title = "Save level"; + } + + protected final FileDialog saveFileDialog() { + return new FileDialog((Dialog)null, "Save level", 1); + } + + public final void initGui() { + super.initGui(); + ((GuiButton)this.controlList.get(5)).displayString = "Save file..."; + } + + protected final void setLevels(String[] var1) { + for(int var2 = 0; var2 < 5; ++var2) { + ((GuiButton)this.controlList.get(var2)).displayString = var1[var2]; + ((GuiButton)this.controlList.get(var2)).visible = true; + } + + ((GuiButton)this.controlList.get(5)).visible = true; + } + + protected final void openLevel(File var1) { + try { + FileOutputStream var3 = new FileOutputStream(var1); + (new PlayerLoader(this.mc, this.mc.loadingScreen)).save(this.mc.theWorld, var3); + var3.close(); + } catch (IOException var2) { + var2.printStackTrace(); + } + } + + protected final void openLevel(int var1) { + this.mc.displayGuiScreen(new GuiNameLevel(this, ((GuiButton)this.controlList.get(var1)).displayString, var1)); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiScreen.java b/src/teavm/java/net/minecraft/client/gui/GuiScreen.java new file mode 100644 index 0000000..ba1ecf5 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiScreen.java @@ -0,0 +1,107 @@ +package net.minecraft.client.gui; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.render.Tessellator; +import org.lwjgl.opengl.GL11; + +public class GuiScreen extends Gui { + protected Minecraft mc; + public int width; + public int height; + protected List controlList = new ArrayList(); + public boolean allowUserInput = false; + protected FontRenderer fontRenderer; + + public void drawScreen(int var1, int var2, float var3) { + for(int var5 = 0; var5 < this.controlList.size(); ++var5) { + GuiButton var4 = (GuiButton)this.controlList.get(var5); + var4.drawButton(this.mc, var1, var2); + } + + } + + protected void keyTyped(char var1, int var2) { + if(var2 == 1) { + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + } + + } + + protected void drawSlotInventory(int var1, int var2, int var3) { + if(var3 == 0) { + for(var3 = 0; var3 < this.controlList.size(); ++var3) { + GuiButton var4 = (GuiButton)this.controlList.get(var3); + if(var4.mousePressed(var1, var2)) { + this.actionPerformed(var4); + } + } + } + + } + + protected void actionPerformed(GuiButton var1) { + } + + public final void setWorldAndResolution(Minecraft var1, int var2, int var3) { + this.mc = var1; + this.fontRenderer = var1.fontRenderer; + this.width = var2; + this.height = var3; + this.initGui(); + } + + public void initGui() { + } + + public final void handleMouseInput() { + if(GL11.mouseGetEventButtonState()) { + int var1 = GL11.mouseGetEventX() * this.width / this.mc.displayWidth; + int var2 = this.height - GL11.mouseGetEventY() * this.height / this.mc.displayHeight - 1; + this.drawSlotInventory(var1, var2, GL11.mouseGetEventButton()); + } else { + GL11.mouseGetEventX(); + GL11.mouseGetEventY(); + GL11.mouseGetEventButton(); + } + } + + public final void handleKeyboardInput() { + if(GL11.getEventKeyState()) { + this.keyTyped(GL11.getEventChar(), GL11.getEventKey()); + } + + } + + public void updateScreen() { + } + + public void onGuiClosed() { + } + + public final void drawDefaultBackground() { + boolean var1 = false; + if(this.mc.theWorld != null) { + drawGradientRect(0, 0, this.width, this.height, 1610941696, -1607454624); + } else { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + Tessellator var2 = Tessellator.instance; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/dirt.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + var2.startDrawingQuads(); + var2.setColorOpaque_I(4210752); + var2.addVertexWithUV(0.0F, (float)this.height, 0.0F, 0.0F, (float)this.height / 32.0F); + var2.addVertexWithUV((float)this.width, (float)this.height, 0.0F, (float)this.width / 32.0F, (float)this.height / 32.0F); + var2.addVertexWithUV((float)this.width, 0.0F, 0.0F, (float)this.width / 32.0F, 0.0F); + var2.addVertexWithUV(0.0F, 0.0F, 0.0F, 0.0F, 0.0F); + var2.draw(); + } + } + + public boolean doesGuiPauseGame() { + return true; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/GuiSmallButton.java b/src/teavm/java/net/minecraft/client/gui/GuiSmallButton.java new file mode 100644 index 0000000..0363644 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/GuiSmallButton.java @@ -0,0 +1,7 @@ +package net.minecraft.client.gui; + +public final class GuiSmallButton extends GuiButton { + public GuiSmallButton(int var1, int var2, int var3, String var4) { + super(var1, var2, var3, 150, 20, var4); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/ScaledResolution.java b/src/teavm/java/net/minecraft/client/gui/ScaledResolution.java new file mode 100644 index 0000000..e8d40a2 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/ScaledResolution.java @@ -0,0 +1,25 @@ +package net.minecraft.client.gui; + +public final class ScaledResolution { + private int scaledWidth; + private int scaledHeight; + + public ScaledResolution(int var1, int var2) { + this.scaledWidth = var1; + this.scaledHeight = var2; + + for(var1 = 1; this.scaledWidth / (var1 + 1) >= 320 && this.scaledHeight / (var1 + 1) >= 240; ++var1) { + } + + this.scaledWidth /= var1; + this.scaledHeight /= var1; + } + + public final int getScaledWidth() { + return this.scaledWidth; + } + + public final int getScaledHeight() { + return this.scaledHeight; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/GuiChest.java b/src/teavm/java/net/minecraft/client/gui/container/GuiChest.java new file mode 100644 index 0000000..b094160 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/GuiChest.java @@ -0,0 +1,54 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.client.render.RenderEngine; +import net.minecraft.game.IInventory; +import org.lwjgl.opengl.GL11; + +public final class GuiChest extends GuiContainer { + private IInventory upperChestInventory; + private IInventory lowerChestInventory; + private int inventoryRows = 0; + + public GuiChest(IInventory var1, IInventory var2) { + this.upperChestInventory = var1; + this.lowerChestInventory = var2; + this.allowUserInput = false; + this.inventoryRows = var2.getSizeInventory() / 9; + this.ySize = 114 + this.inventoryRows * 18; + int var3 = (this.inventoryRows - 4) * 18; + + int var4; + int var5; + for(var4 = 0; var4 < this.inventoryRows; ++var4) { + for(var5 = 0; var5 < 9; ++var5) { + this.inventorySlots.add(new Slot(this, var2, var5 + var4 * 9, 8 + var5 * 18, 18 + var4 * 18)); + } + } + + for(var4 = 0; var4 < 3; ++var4) { + for(var5 = 0; var5 < 9; ++var5) { + this.inventorySlots.add(new Slot(this, var1, var5 + (var4 + 1) * 9, 8 + var5 * 18, 103 + var4 * 18 + var3)); + } + } + + for(var4 = 0; var4 < 9; ++var4) { + this.inventorySlots.add(new Slot(this, var1, var4, 8 + var4 * 18, var3 + 161)); + } + + } + + protected final void drawGuiContainerForegroundLayer() { + this.fontRenderer.drawString(this.lowerChestInventory.getInvName(), 8, 6, 4210752); + this.fontRenderer.drawString(this.upperChestInventory.getInvName(), 8, this.ySize - 96 + 2, 4210752); + } + + protected final void drawGuiContainerBackgroundLayer() { + int var1 = this.mc.renderEngine.getTexture("/gui/container.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderEngine.bindTexture(var1); + var1 = (this.width - this.xSize) / 2; + int var2 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(var1, var2, 0, 0, this.xSize, this.inventoryRows * 18 + 17); + this.drawTexturedModalRect(var1, var2 + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/GuiContainer.java b/src/teavm/java/net/minecraft/client/gui/container/GuiContainer.java new file mode 100644 index 0000000..5c8b127 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/GuiContainer.java @@ -0,0 +1,269 @@ +package net.minecraft.client.gui.container; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.RenderHelper; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.player.EntityPlayerSP; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.client.render.entity.RenderItem; +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemStack; +import org.lwjgl.opengl.GL11; + +public abstract class GuiContainer extends GuiScreen { + private static RenderItem itemRenderer = new RenderItem(); + private ItemStack itemStack = null; + protected int xSize = 176; + protected int ySize = 166; + protected List inventorySlots = new ArrayList(); + + public void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + int var13 = (this.width - this.xSize) / 2; + int var4 = (this.height - this.ySize) / 2; + this.drawGuiContainerBackgroundLayer(); + GL11.glPushMatrix(); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslatef((float)var13, (float)var4, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_NORMALIZE); + + for(int var5 = 0; var5 < this.inventorySlots.size(); ++var5) { + Slot var6; + label24: { + var6 = (Slot)this.inventorySlots.get(var5); + IInventory var9 = var6.inventory; + int var10 = var6.slotIndex; + int var11 = var6.xPos; + int var12 = var6.yPos; + ItemStack var15 = var9.getStackInSlot(var10); + if(var15 == null) { + int var8 = var6.getBackgroundIconIndex(); + if(var8 >= 0) { + GL11.glDisable(GL11.GL_LIGHTING); + RenderEngine.bindTexture(this.mc.renderEngine.getTexture("/gui/items.png")); + this.drawTexturedModalRect(var11, var12, var8 % 16 << 4, var8 / 16 << 4, 16, 16); + GL11.glEnable(GL11.GL_LIGHTING); + break label24; + } + } + + itemRenderer.renderItemIntoGUI(this.mc.renderEngine, var15, var11, var12); + itemRenderer.renderItemOverlayIntoGUI(this.fontRenderer, var15, var11, var12); + } + + if(var6.isAtCursorPos(var1, var2)) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int var7 = var6.xPos; + int var14 = var6.yPos; + drawGradientRect(var7, var14, var7 + 16, var14 + 16, -2130706433, -2130706433); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + } + + if(this.itemStack != null) { + GL11.glTranslatef(0.0F, 0.0F, 32.0F); + itemRenderer.renderItemIntoGUI(this.mc.renderEngine, this.itemStack, var1 - var13 - 8, var2 - var4 - 8); + itemRenderer.renderItemOverlayIntoGUI(this.fontRenderer, this.itemStack, var1 - var13 - 8, var2 - var4 - 8); + } + + GL11.glDisable(GL11.GL_NORMALIZE); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + this.drawGuiContainerForegroundLayer(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } + + protected void drawGuiContainerForegroundLayer() { + } + + protected abstract void drawGuiContainerBackgroundLayer(); + + protected final void drawSlotInventory(int var1, int var2, int var3) { + if(var3 == 0 || var3 == 1) { + int var6 = var2; + int var4 = var1; + GuiContainer var5 = this; + int var7 = 0; + + Slot var10000; + while(true) { + if(var7 >= var5.inventorySlots.size()) { + var10000 = null; + break; + } + + Slot var8 = (Slot)var5.inventorySlots.get(var7); + if(var8.isAtCursorPos(var4, var6)) { + var10000 = var8; + break; + } + + ++var7; + } + + Slot var11 = var10000; + if(var11 != null) { + ItemStack var12 = var11.inventory.getStackInSlot(var11.slotIndex); + if(var12 == null && this.itemStack == null) { + return; + } + + if(var12 != null && this.itemStack == null) { + var6 = var3 == 0 ? var12.stackSize : (var12.stackSize + 1) / 2; + this.itemStack = var11.inventory.decrStackSize(var11.slotIndex, var6); + if(var12.stackSize == 0) { + var11.putStack((ItemStack)null); + } + + var11.onPickupFromSlot(); + } else if(var12 == null && this.itemStack != null && var11.isItemValid(this.itemStack)) { + var6 = var3 == 0 ? this.itemStack.stackSize : 1; + if(var6 > var11.inventory.getInventoryStackLimit()) { + var6 = var11.inventory.getInventoryStackLimit(); + } + + var11.putStack(this.itemStack.splitStack(var6)); + if(this.itemStack.stackSize == 0) { + this.itemStack = null; + } + } else { + if(var12 == null || this.itemStack == null) { + return; + } + + ItemStack var9; + if(!var11.isItemValid(this.itemStack)) { + if(var12.itemID == this.itemStack.itemID) { + var9 = this.itemStack; + if(var9.getItem().getItemStackLimit() > 1) { + var6 = var12.stackSize; + if(var6 > 0) { + int var14 = var6 + this.itemStack.stackSize; + var9 = this.itemStack; + if(var14 <= var9.getItem().getItemStackLimit()) { + this.itemStack.stackSize += var6; + var12.splitStack(var6); + if(var12.stackSize == 0) { + var11.putStack((ItemStack)null); + } + + var11.onPickupFromSlot(); + return; + } + } + + return; + } + } + + return; + } + + if(var12.itemID != this.itemStack.itemID) { + if(this.itemStack.stackSize > var11.inventory.getInventoryStackLimit()) { + return; + } + + var11.putStack(this.itemStack); + this.itemStack = var12; + } else { + if(var12.itemID != this.itemStack.itemID) { + return; + } + + if(var3 == 0) { + var6 = this.itemStack.stackSize; + if(var6 > var11.inventory.getInventoryStackLimit() - var12.stackSize) { + var6 = var11.inventory.getInventoryStackLimit() - var12.stackSize; + } + + var9 = this.itemStack; + if(var6 > var9.getItem().getItemStackLimit() - var12.stackSize) { + var9 = this.itemStack; + var6 = var9.getItem().getItemStackLimit() - var12.stackSize; + } + + this.itemStack.splitStack(var6); + if(this.itemStack.stackSize == 0) { + this.itemStack = null; + } + + var12.stackSize += var6; + } else { + if(var3 != 1) { + return; + } + + var6 = 1; + if(1 > var11.inventory.getInventoryStackLimit() - var12.stackSize) { + var6 = var11.inventory.getInventoryStackLimit() - var12.stackSize; + } + + var9 = this.itemStack; + if(var6 > var9.getItem().getItemStackLimit() - var12.stackSize) { + var9 = this.itemStack; + var6 = var9.getItem().getItemStackLimit() - var12.stackSize; + } + + this.itemStack.splitStack(var6); + if(this.itemStack.stackSize == 0) { + this.itemStack = null; + } + + var12.stackSize += var6; + } + } + } + } else if(this.itemStack != null) { + int var13 = (this.width - this.xSize) / 2; + var6 = (this.height - this.ySize) / 2; + if(var1 < var13 || var2 < var6 || var1 >= var13 + this.xSize || var2 >= var6 + this.xSize) { + EntityPlayerSP var10 = this.mc.thePlayer; + if(var3 == 0) { + var10.dropPlayerItem(this.itemStack); + this.itemStack = null; + } + + if(var3 == 1) { + var10.dropPlayerItem(this.itemStack.splitStack(1)); + if(this.itemStack.stackSize == 0) { + this.itemStack = null; + } + } + } + } + } + + } + + protected final void keyTyped(char var1, int var2) { + if(var2 == 1 || var2 == this.mc.options.keyBindInventory.keyCode) { + this.mc.displayGuiScreen((GuiScreen)null); + } + + } + + public void onGuiClosed() { + if(this.itemStack != null) { + this.mc.thePlayer.dropPlayerItem(this.itemStack); + } + + } + + public void guiCraftingItemsCheck() { + } + + public final boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/GuiCrafting.java b/src/teavm/java/net/minecraft/client/gui/container/GuiCrafting.java new file mode 100644 index 0000000..3a55282 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/GuiCrafting.java @@ -0,0 +1,80 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.client.render.RenderEngine; +import net.minecraft.game.IInventory; +import net.minecraft.game.entity.player.InventoryPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.item.recipe.CraftingManager; +import org.lwjgl.opengl.GL11; + +public final class GuiCrafting extends GuiContainer { + private InventoryCrafting inventoryCrafting = new InventoryCrafting(this, 3, 3); + private IInventory iInventory = new InventoryCraftResult(); + + public GuiCrafting(InventoryPlayer var1) { + this.inventorySlots.add(new SlotCrafting(this, this.inventoryCrafting, this.iInventory, 0, 124, 35)); + + int var2; + int var3; + for(var2 = 0; var2 < 3; ++var2) { + for(var3 = 0; var3 < 3; ++var3) { + this.inventorySlots.add(new Slot(this, this.inventoryCrafting, var3 + var2 * 3, 30 + var3 * 18, 17 + var2 * 18)); + } + } + + for(var2 = 0; var2 < 3; ++var2) { + for(var3 = 0; var3 < 9; ++var3) { + this.inventorySlots.add(new Slot(this, var1, var3 + (var2 + 1) * 9, 8 + var3 * 18, 84 + var2 * 18)); + } + } + + for(var2 = 0; var2 < 9; ++var2) { + this.inventorySlots.add(new Slot(this, var1, var2, 8 + var2 * 18, 142)); + } + + } + + public final void onGuiClosed() { + super.onGuiClosed(); + + for(int var1 = 0; var1 < 9; ++var1) { + ItemStack var2 = this.inventoryCrafting.getStackInSlot(var1); + if(var2 != null) { + this.mc.thePlayer.dropPlayerItem(var2); + } + } + + } + + public final void guiCraftingItemsCheck() { + int[] var1 = new int[9]; + + for(int var2 = 0; var2 < 3; ++var2) { + for(int var3 = 0; var3 < 3; ++var3) { + int var4 = var2 + var3 * 3; + ItemStack var5 = this.inventoryCrafting.getStackInSlot(var4); + if(var5 == null) { + var1[var4] = -1; + } else { + var1[var4] = var5.itemID; + } + } + } + + this.iInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(var1)); + } + + protected final void drawGuiContainerForegroundLayer() { + this.fontRenderer.drawString("Crafting", 28, 6, 4210752); + this.fontRenderer.drawString("Inventory", 8, this.ySize - 96 + 2, 4210752); + } + + protected final void drawGuiContainerBackgroundLayer() { + int var1 = this.mc.renderEngine.getTexture("/gui/crafting.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderEngine.bindTexture(var1); + var1 = (this.width - this.xSize) / 2; + int var2 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(var1, var2, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/GuiFurnace.java b/src/teavm/java/net/minecraft/client/gui/container/GuiFurnace.java new file mode 100644 index 0000000..3b28e85 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/GuiFurnace.java @@ -0,0 +1,52 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.client.render.RenderEngine; +import net.minecraft.game.entity.player.InventoryPlayer; +import net.minecraft.game.level.block.tileentity.TileEntityFurnace; +import org.lwjgl.opengl.GL11; + +public final class GuiFurnace extends GuiContainer { + private TileEntityFurnace furnaceInventory; + + public GuiFurnace(InventoryPlayer var1, TileEntityFurnace var2) { + new InventoryCraftResult(); + this.furnaceInventory = var2; + this.inventorySlots.add(new Slot(this, var2, 0, 56, 17)); + this.inventorySlots.add(new Slot(this, var2, 1, 56, 53)); + this.inventorySlots.add(new Slot(this, var2, 2, 116, 35)); + + int var4; + for(var4 = 0; var4 < 3; ++var4) { + for(int var3 = 0; var3 < 9; ++var3) { + this.inventorySlots.add(new Slot(this, var1, var3 + (var4 + 1) * 9, 8 + var3 * 18, 84 + var4 * 18)); + } + } + + for(var4 = 0; var4 < 9; ++var4) { + this.inventorySlots.add(new Slot(this, var1, var4, 8 + var4 * 18, 142)); + } + + } + + protected final void drawGuiContainerForegroundLayer() { + this.fontRenderer.drawString("Furnace", 60, 6, 4210752); + this.fontRenderer.drawString("Inventory", 8, this.ySize - 96 + 2, 4210752); + } + + protected final void drawGuiContainerBackgroundLayer() { + int var1 = this.mc.renderEngine.getTexture("/gui/furnace.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderEngine.bindTexture(var1); + var1 = (this.width - this.xSize) / 2; + int var2 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(var1, var2, 0, 0, this.xSize, this.ySize); + int var3; + if(this.furnaceInventory.isBurning()) { + var3 = this.furnaceInventory.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(var1 + 56, var2 + 36 + 12 - var3, 176, 12 - var3, 14, var3 + 2); + } + + var3 = this.furnaceInventory.getCookProgressScaled(24); + this.drawTexturedModalRect(var1 + 79, var2 + 34, 176, 14, var3 + 1, 16); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/GuiInventory.java b/src/teavm/java/net/minecraft/client/gui/container/GuiInventory.java new file mode 100644 index 0000000..6489c75 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/GuiInventory.java @@ -0,0 +1,121 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.client.RenderHelper; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.client.render.entity.RenderManager; +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.item.recipe.CraftingManager; +import org.lwjgl.opengl.GL11; + +public final class GuiInventory extends GuiContainer { + private InventoryCrafting inventoryCrafting = new InventoryCrafting(this, 2, 2); + private IInventory iInventory = new InventoryCraftResult(); + private float xSize_lo; + private float ySize_lo; + + public GuiInventory(IInventory var1) { + this.allowUserInput = true; + this.inventorySlots.add(new SlotCrafting(this, this.inventoryCrafting, this.iInventory, 0, 144, 36)); + + int var2; + int var3; + for(var2 = 0; var2 < 2; ++var2) { + for(var3 = 0; var3 < 2; ++var3) { + this.inventorySlots.add(new Slot(this, this.inventoryCrafting, var3 + (var2 << 1), 88 + var3 * 18, 26 + var2 * 18)); + } + } + + for(var2 = 0; var2 < 4; ++var2) { + this.inventorySlots.add(new SlotArmor(this, this, var1, var1.getSizeInventory() - 1 - var2, 8, 8 + var2 * 18, var2)); + } + + for(var2 = 0; var2 < 3; ++var2) { + for(var3 = 0; var3 < 9; ++var3) { + this.inventorySlots.add(new Slot(this, var1, var3 + (var2 + 1) * 9, 8 + var3 * 18, 84 + var2 * 18)); + } + } + + for(var2 = 0; var2 < 9; ++var2) { + this.inventorySlots.add(new Slot(this, var1, var2, 8 + var2 * 18, 142)); + } + + } + + public final void onGuiClosed() { + super.onGuiClosed(); + + for(int var1 = 0; var1 < this.inventoryCrafting.getSizeInventory(); ++var1) { + ItemStack var2 = this.inventoryCrafting.getStackInSlot(var1); + if(var2 != null) { + this.mc.thePlayer.dropPlayerItem(var2); + } + } + + } + + public final void guiCraftingItemsCheck() { + int[] var1 = new int[9]; + + for(int var2 = 0; var2 < 3; ++var2) { + for(int var3 = 0; var3 < 3; ++var3) { + int var4 = -1; + if(var2 < 2 && var3 < 2) { + ItemStack var5 = this.inventoryCrafting.getStackInSlot(var2 + (var3 << 1)); + if(var5 != null) { + var4 = var5.itemID; + } + } + + var1[var2 + var3 * 3] = var4; + } + } + + this.iInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(var1)); + } + + protected final void drawGuiContainerForegroundLayer() { + this.fontRenderer.drawString("Crafting", 86, 16, 4210752); + } + + public final void drawScreen(int var1, int var2, float var3) { + super.drawScreen(var1, var2, var3); + this.xSize_lo = (float)var1; + this.ySize_lo = (float)var2; + } + + protected final void drawGuiContainerBackgroundLayer() { + int var1 = this.mc.renderEngine.getTexture("/gui/inventory.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderEngine.bindTexture(var1); + var1 = (this.width - this.xSize) / 2; + int var2 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(var1, var2, 0, 0, this.xSize, this.ySize); + GL11.glEnable(GL11.GL_NORMALIZE); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef((float)(var1 + 51), (float)(var2 + 75), 50.0F); + GL11.glScalef(-30.0F, 30.0F, 30.0F); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + float var3 = this.mc.thePlayer.renderYawOffset; + float var4 = this.mc.thePlayer.rotationYaw; + float var5 = this.mc.thePlayer.rotationPitch; + float var6 = (float)(var1 + 51) - this.xSize_lo; + float var7 = (float)(var2 + 75 - 50) - this.ySize_lo; + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-((float)Math.atan((double)(var7 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); + this.mc.thePlayer.renderYawOffset = (float)Math.atan((double)(var6 / 40.0F)) * 20.0F; + this.mc.thePlayer.rotationYaw = (float)Math.atan((double)(var6 / 40.0F)) * 40.0F; + this.mc.thePlayer.rotationPitch = -((float)Math.atan((double)(var7 / 40.0F))) * 20.0F; + GL11.glTranslatef(0.0F, this.mc.thePlayer.yOffset, 0.0F); + RenderManager.instance.renderEntityWithPosYaw(this.mc.thePlayer, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F); + this.mc.thePlayer.renderYawOffset = var3; + this.mc.thePlayer.rotationYaw = var4; + this.mc.thePlayer.rotationPitch = var5; + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_NORMALIZE); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/InventoryCraftResult.java b/src/teavm/java/net/minecraft/client/gui/container/InventoryCraftResult.java new file mode 100644 index 0000000..14928ae --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/InventoryCraftResult.java @@ -0,0 +1,38 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemStack; + +public final class InventoryCraftResult implements IInventory { + private ItemStack[] stackResult = new ItemStack[1]; + + public final int getSizeInventory() { + return 1; + } + + public final ItemStack getStackInSlot(int var1) { + return this.stackResult[var1]; + } + + public final String getInvName() { + return "Result"; + } + + public final ItemStack decrStackSize(int var1, int var2) { + if(this.stackResult[var1] != null) { + ItemStack var3 = this.stackResult[var1]; + this.stackResult[var1] = null; + return var3; + } else { + return null; + } + } + + public final void setInventorySlotContents(int var1, ItemStack var2) { + this.stackResult[var1] = var2; + } + + public final int getInventoryStackLimit() { + return 64; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/InventoryCrafting.java b/src/teavm/java/net/minecraft/client/gui/container/InventoryCrafting.java new file mode 100644 index 0000000..a978545 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/InventoryCrafting.java @@ -0,0 +1,59 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemStack; + +public final class InventoryCrafting implements IInventory { + private ItemStack[] stackList; + private int inventoryWidth; + private GuiContainer eventHandler; + + public InventoryCrafting(GuiContainer var1, int var2, int var3) { + this.inventoryWidth = var2 * var3; + this.stackList = new ItemStack[this.inventoryWidth]; + this.eventHandler = var1; + } + + public final int getSizeInventory() { + return this.inventoryWidth; + } + + public final ItemStack getStackInSlot(int var1) { + return this.stackList[var1]; + } + + public final String getInvName() { + return "Crafting"; + } + + public final ItemStack decrStackSize(int var1, int var2) { + if(this.stackList[var1] != null) { + ItemStack var3; + if(this.stackList[var1].stackSize <= var2) { + var3 = this.stackList[var1]; + this.stackList[var1] = null; + this.eventHandler.guiCraftingItemsCheck(); + return var3; + } else { + var3 = this.stackList[var1].splitStack(var2); + if(this.stackList[var1].stackSize == 0) { + this.stackList[var1] = null; + } + + this.eventHandler.guiCraftingItemsCheck(); + return var3; + } + } else { + return null; + } + } + + public final void setInventorySlotContents(int var1, ItemStack var2) { + this.stackList[var1] = var2; + this.eventHandler.guiCraftingItemsCheck(); + } + + public final int getInventoryStackLimit() { + return 64; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/Slot.java b/src/teavm/java/net/minecraft/client/gui/container/Slot.java new file mode 100644 index 0000000..b9eae83 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/Slot.java @@ -0,0 +1,43 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemStack; + +public class Slot { + public final int slotIndex; + public final int xPos; + public final int yPos; + public final IInventory inventory; + private final GuiContainer guiHandler; + + public Slot(GuiContainer var1, IInventory var2, int var3, int var4, int var5) { + this.guiHandler = var1; + this.inventory = var2; + this.slotIndex = var3; + this.xPos = var4; + this.yPos = var5; + } + + public final boolean isAtCursorPos(int var1, int var2) { + int var3 = (this.guiHandler.width - this.guiHandler.xSize) / 2; + int var4 = (this.guiHandler.height - this.guiHandler.ySize) / 2; + var1 -= var3; + var2 -= var4; + return var1 >= this.xPos - 1 && var1 < this.xPos + 16 + 1 && var2 >= this.yPos - 1 && var2 < this.yPos + 16 + 1; + } + + public void onPickupFromSlot() { + } + + public boolean isItemValid(ItemStack var1) { + return true; + } + + public final void putStack(ItemStack var1) { + this.inventory.setInventorySlotContents(this.slotIndex, var1); + } + + public int getBackgroundIconIndex() { + return -1; + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/SlotArmor.java b/src/teavm/java/net/minecraft/client/gui/container/SlotArmor.java new file mode 100644 index 0000000..c3d6347 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/SlotArmor.java @@ -0,0 +1,22 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemArmor; +import net.minecraft.game.item.ItemStack; + +final class SlotArmor extends Slot { + private int armorType; + + SlotArmor(GuiInventory var1, GuiContainer var2, IInventory var3, int var4, int var5, int var6, int var7) { + super(var2, var3, var4, 8, var6); + this.armorType = var7; + } + + public final boolean isItemValid(ItemStack var1) { + return var1.getItem() instanceof ItemArmor ? ((ItemArmor)var1.getItem()).armorType == this.armorType : false; + } + + public final int getBackgroundIconIndex() { + return 15 + (this.armorType << 4); + } +} diff --git a/src/teavm/java/net/minecraft/client/gui/container/SlotCrafting.java b/src/teavm/java/net/minecraft/client/gui/container/SlotCrafting.java new file mode 100644 index 0000000..893aa1b --- /dev/null +++ b/src/teavm/java/net/minecraft/client/gui/container/SlotCrafting.java @@ -0,0 +1,26 @@ +package net.minecraft.client.gui.container; + +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemStack; + +final class SlotCrafting extends Slot { + private final IInventory craftMatrix; + + public SlotCrafting(GuiContainer var1, IInventory var2, IInventory var3, int var4, int var5, int var6) { + super(var1, var3, 0, var5, var6); + this.craftMatrix = var2; + } + + public final boolean isItemValid(ItemStack var1) { + return false; + } + + public final void onPickupFromSlot() { + for(int var1 = 0; var1 < this.craftMatrix.getSizeInventory(); ++var1) { + if(this.craftMatrix.getStackInSlot(var1) != null) { + this.craftMatrix.decrStackSize(var1, 1); + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelBase.java b/src/teavm/java/net/minecraft/client/model/ModelBase.java new file mode 100644 index 0000000..1c76592 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelBase.java @@ -0,0 +1,9 @@ +package net.minecraft.client.model; + +public abstract class ModelBase { + public void render(float var1, float var2, float var3, float var4, float var5, float var6) { + } + + public void setRotationAngles(float var1, float var2, float var3, float var4, float var5, float var6) { + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelBiped.java b/src/teavm/java/net/minecraft/client/model/ModelBiped.java new file mode 100644 index 0000000..5d79b12 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelBiped.java @@ -0,0 +1,75 @@ +package net.minecraft.client.model; + +import net.PeytonPlayz585.math.MathHelper; + +public class ModelBiped extends ModelBase { + public ModelRenderer bipedHead; + public ModelRenderer bipedHeadwear; + public ModelRenderer bipedBody; + public ModelRenderer bipedRightArm; + public ModelRenderer bipedLeftArm; + public ModelRenderer bipedRightLeg; + public ModelRenderer bipedLeftLeg; + + public ModelBiped() { + this(0.0F); + } + + public ModelBiped(float var1) { + this(var1, 0.0F); + } + + private ModelBiped(float var1, float var2) { + this.bipedHead = new ModelRenderer(0, 0); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, var1); + this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedHeadwear = new ModelRenderer(32, 0); + this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, var1 + 0.5F); + this.bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedBody = new ModelRenderer(16, 16); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, var1); + this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedRightArm = new ModelRenderer(40, 16); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, var1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + this.bipedLeftArm = new ModelRenderer(40, 16); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, var1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); + this.bipedRightLeg = new ModelRenderer(0, 16); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, var1); + this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); + this.bipedLeftLeg = new ModelRenderer(0, 16); + this.bipedLeftLeg.mirror = true; + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, var1); + this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); + } + + public final void render(float var1, float var2, float var3, float var4, float var5, float var6) { + this.setRotationAngles(var1, var2, var3, var4, var5, 1.0F); + this.bipedHead.render(1.0F); + this.bipedBody.render(1.0F); + this.bipedRightArm.render(1.0F); + this.bipedLeftArm.render(1.0F); + this.bipedRightLeg.render(1.0F); + this.bipedLeftLeg.render(1.0F); + this.bipedHeadwear.render(1.0F); + } + + public void setRotationAngles(float var1, float var2, float var3, float var4, float var5, float var6) { + this.bipedHead.rotateAngleY = var4 / (180.0F / (float)Math.PI); + this.bipedHead.rotateAngleX = var5 / (180.0F / (float)Math.PI); + this.bipedHeadwear.rotateAngleY = this.bipedHead.rotateAngleY; + this.bipedHeadwear.rotateAngleX = this.bipedHead.rotateAngleX; + this.bipedRightArm.rotateAngleX = MathHelper.cos(var1 * 0.6662F + (float)Math.PI) * 2.0F * var2; + this.bipedRightArm.rotateAngleZ = (MathHelper.cos(var1 * 0.2312F) + 1.0F) * var2; + this.bipedLeftArm.rotateAngleX = MathHelper.cos(var1 * 0.6662F) * 2.0F * var2; + this.bipedLeftArm.rotateAngleZ = (MathHelper.cos(var1 * 0.2812F) - 1.0F) * var2; + this.bipedRightLeg.rotateAngleX = MathHelper.cos(var1 * 0.6662F) * 1.4F * var2; + this.bipedLeftLeg.rotateAngleX = MathHelper.cos(var1 * 0.6662F + (float)Math.PI) * 1.4F * var2; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(var3 * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(var3 * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(var3 * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(var3 * 0.067F) * 0.05F; + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelCreeper.java b/src/teavm/java/net/minecraft/client/model/ModelCreeper.java new file mode 100644 index 0000000..8829f6a --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelCreeper.java @@ -0,0 +1,55 @@ +package net.minecraft.client.model; + +import net.PeytonPlayz585.math.MathHelper; + +public final class ModelCreeper extends ModelBase { + private ModelRenderer head = new ModelRenderer(0, 0); + private ModelRenderer headwear; + private ModelRenderer body; + private ModelRenderer leg1; + private ModelRenderer leg2; + private ModelRenderer leg3; + private ModelRenderer leg4; + + public ModelCreeper() { + this.head.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); + this.head.setRotationPoint(0.0F, 4.0F, 0.0F); + this.headwear = new ModelRenderer(32, 0); + this.headwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.5F); + this.headwear.setRotationPoint(0.0F, 4.0F, 0.0F); + this.body = new ModelRenderer(16, 16); + this.body.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F); + this.body.setRotationPoint(0.0F, 4.0F, 0.0F); + this.leg1 = new ModelRenderer(0, 16); + this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F); + this.leg1.setRotationPoint(-2.0F, 16.0F, 4.0F); + this.leg2 = new ModelRenderer(0, 16); + this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F); + this.leg2.setRotationPoint(2.0F, 16.0F, 4.0F); + this.leg3 = new ModelRenderer(0, 16); + this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F); + this.leg3.setRotationPoint(-2.0F, 16.0F, -4.0F); + this.leg4 = new ModelRenderer(0, 16); + this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F); + this.leg4.setRotationPoint(2.0F, 16.0F, -4.0F); + } + + public final void render(float var1, float var2, float var3, float var4, float var5, float var6) { + this.setRotationAngles(var1, var2, var3, var4, var5, 1.0F); + this.head.render(1.0F); + this.body.render(1.0F); + this.leg1.render(1.0F); + this.leg2.render(1.0F); + this.leg3.render(1.0F); + this.leg4.render(1.0F); + } + + public final void setRotationAngles(float var1, float var2, float var3, float var4, float var5, float var6) { + this.head.rotateAngleY = var4 / (180.0F / (float)Math.PI); + this.head.rotateAngleX = var5 / (180.0F / (float)Math.PI); + this.leg1.rotateAngleX = MathHelper.cos(var1 * 0.6662F) * 1.4F * var2; + this.leg2.rotateAngleX = MathHelper.cos(var1 * 0.6662F + (float)Math.PI) * 1.4F * var2; + this.leg3.rotateAngleX = MathHelper.cos(var1 * 0.6662F + (float)Math.PI) * 1.4F * var2; + this.leg4.rotateAngleX = MathHelper.cos(var1 * 0.6662F) * 1.4F * var2; + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelPig.java b/src/teavm/java/net/minecraft/client/model/ModelPig.java new file mode 100644 index 0000000..35e9dc3 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelPig.java @@ -0,0 +1,7 @@ +package net.minecraft.client.model; + +public final class ModelPig extends ModelQuadruped { + public ModelPig() { + super(6, 0.0F); + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelQuadruped.java b/src/teavm/java/net/minecraft/client/model/ModelQuadruped.java new file mode 100644 index 0000000..31e3b36 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelQuadruped.java @@ -0,0 +1,52 @@ +package net.minecraft.client.model; + +import net.PeytonPlayz585.math.MathHelper; + +public class ModelQuadruped extends ModelBase { + public ModelRenderer head = new ModelRenderer(0, 0); + public ModelRenderer body; + public ModelRenderer leg1; + public ModelRenderer leg2; + public ModelRenderer leg3; + public ModelRenderer leg4; + + public ModelQuadruped(int var1, float var2) { + this.head.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, 0.0F); + this.head.setRotationPoint(0.0F, (float)(18 - var1), -6.0F); + this.body = new ModelRenderer(28, 8); + this.body.addBox(-5.0F, -10.0F, -7.0F, 10, 16, 8, 0.0F); + this.body.setRotationPoint(0.0F, (float)(17 - var1), 2.0F); + this.leg1 = new ModelRenderer(0, 16); + this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, var1, 4, 0.0F); + this.leg1.setRotationPoint(-3.0F, (float)(24 - var1), 7.0F); + this.leg2 = new ModelRenderer(0, 16); + this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, var1, 4, 0.0F); + this.leg2.setRotationPoint(3.0F, (float)(24 - var1), 7.0F); + this.leg3 = new ModelRenderer(0, 16); + this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, var1, 4, 0.0F); + this.leg3.setRotationPoint(-3.0F, (float)(24 - var1), -5.0F); + this.leg4 = new ModelRenderer(0, 16); + this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, var1, 4, 0.0F); + this.leg4.setRotationPoint(3.0F, (float)(24 - var1), -5.0F); + } + + public final void render(float var1, float var2, float var3, float var4, float var5, float var6) { + this.setRotationAngles(var1, var2, var3, var4, var5, 1.0F); + this.head.render(1.0F); + this.body.render(1.0F); + this.leg1.render(1.0F); + this.leg2.render(1.0F); + this.leg3.render(1.0F); + this.leg4.render(1.0F); + } + + public final void setRotationAngles(float var1, float var2, float var3, float var4, float var5, float var6) { + this.head.rotateAngleY = var4 / (180.0F / (float)Math.PI); + this.head.rotateAngleX = var5 / (180.0F / (float)Math.PI); + this.body.rotateAngleX = (float)Math.PI * 0.5F; + this.leg1.rotateAngleX = MathHelper.cos(var1 * 0.6662F) * 1.4F * var2; + this.leg2.rotateAngleX = MathHelper.cos(var1 * 0.6662F + (float)Math.PI) * 1.4F * var2; + this.leg3.rotateAngleX = MathHelper.cos(var1 * 0.6662F + (float)Math.PI) * 1.4F * var2; + this.leg4.rotateAngleX = MathHelper.cos(var1 * 0.6662F) * 1.4F * var2; + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelRenderer.java b/src/teavm/java/net/minecraft/client/model/ModelRenderer.java new file mode 100644 index 0000000..3320ae9 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelRenderer.java @@ -0,0 +1,150 @@ +package net.minecraft.client.model; + +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.physics.Vec3D; +import org.lwjgl.opengl.GL11; + +public final class ModelRenderer { + private PositionTextureVertex[] corners; + private TexturedQuad[] faces; + private int textureOffsetX; + private int textureOffsetY; + private float rotationPointX; + private float rotationPointY; + private float rotationPointZ; + public float rotateAngleX; + public float rotateAngleY; + public float rotateAngleZ; + private boolean compiled = false; + private int displayList = 0; + public boolean mirror = false; + public boolean showModel = true; + private boolean isHidden = false; + + public ModelRenderer(int var1, int var2) { + this.textureOffsetX = var1; + this.textureOffsetY = var2; + } + + public final void addBox(float var1, float var2, float var3, int var4, int var5, int var6, float var7) { + this.corners = new PositionTextureVertex[8]; + this.faces = new TexturedQuad[6]; + float var8 = var1 + (float)var4; + float var9 = var2 + (float)var5; + float var10 = var3 + (float)var6; + var1 -= var7; + var2 -= var7; + var3 -= var7; + var8 += var7; + var9 += var7; + var10 += var7; + if(this.mirror) { + var7 = var8; + var8 = var1; + var1 = var7; + } + + PositionTextureVertex var20 = new PositionTextureVertex(var1, var2, var3, 0.0F, 0.0F); + PositionTextureVertex var11 = new PositionTextureVertex(var8, var2, var3, 0.0F, 8.0F); + PositionTextureVertex var12 = new PositionTextureVertex(var8, var9, var3, 8.0F, 8.0F); + PositionTextureVertex var18 = new PositionTextureVertex(var1, var9, var3, 8.0F, 0.0F); + PositionTextureVertex var13 = new PositionTextureVertex(var1, var2, var10, 0.0F, 0.0F); + PositionTextureVertex var15 = new PositionTextureVertex(var8, var2, var10, 0.0F, 8.0F); + PositionTextureVertex var21 = new PositionTextureVertex(var8, var9, var10, 8.0F, 8.0F); + PositionTextureVertex var14 = new PositionTextureVertex(var1, var9, var10, 8.0F, 0.0F); + this.corners[0] = var20; + this.corners[1] = var11; + this.corners[2] = var12; + this.corners[3] = var18; + this.corners[4] = var13; + this.corners[5] = var15; + this.corners[6] = var21; + this.corners[7] = var14; + this.faces[0] = new TexturedQuad(new PositionTextureVertex[]{var15, var11, var12, var21}, this.textureOffsetX + var6 + var4, this.textureOffsetY + var6, this.textureOffsetX + var6 + var4 + var6, this.textureOffsetY + var6 + var5); + this.faces[1] = new TexturedQuad(new PositionTextureVertex[]{var20, var13, var14, var18}, this.textureOffsetX, this.textureOffsetY + var6, this.textureOffsetX + var6, this.textureOffsetY + var6 + var5); + this.faces[2] = new TexturedQuad(new PositionTextureVertex[]{var15, var13, var20, var11}, this.textureOffsetX + var6, this.textureOffsetY, this.textureOffsetX + var6 + var4, this.textureOffsetY + var6); + this.faces[3] = new TexturedQuad(new PositionTextureVertex[]{var12, var18, var14, var21}, this.textureOffsetX + var6 + var4, this.textureOffsetY, this.textureOffsetX + var6 + var4 + var4, this.textureOffsetY + var6); + this.faces[4] = new TexturedQuad(new PositionTextureVertex[]{var11, var20, var18, var12}, this.textureOffsetX + var6, this.textureOffsetY + var6, this.textureOffsetX + var6 + var4, this.textureOffsetY + var6 + var5); + this.faces[5] = new TexturedQuad(new PositionTextureVertex[]{var13, var15, var21, var14}, this.textureOffsetX + var6 + var4 + var6, this.textureOffsetY + var6, this.textureOffsetX + var6 + var4 + var6 + var4, this.textureOffsetY + var6 + var5); + if(this.mirror) { + for(int var16 = 0; var16 < this.faces.length; ++var16) { + TexturedQuad var17 = this.faces[var16]; + PositionTextureVertex[] var19 = new PositionTextureVertex[var17.vertexPositions.length]; + + for(var4 = 0; var4 < var17.vertexPositions.length; ++var4) { + var19[var4] = var17.vertexPositions[var17.vertexPositions.length - var4 - 1]; + } + + var17.vertexPositions = var19; + } + } + + } + + public final void setRotationPoint(float var1, float var2, float var3) { + this.rotationPointX = var1; + this.rotationPointY = var2; + this.rotationPointZ = var3; + } + + public final void render(float var1) { + if(this.showModel) { + if(!this.compiled) { + float var3 = var1; + ModelRenderer var2 = this; + this.displayList = GL11.glGenLists(1); + GL11.glNewList(this.displayList, GL11.GL_COMPILE); + Tessellator var4 = Tessellator.instance; + + for(int var5 = 0; var5 < var2.faces.length; ++var5) { + var4.startDrawingQuads(); + TexturedQuad var10000 = var2.faces[var5]; + float var8 = var3; + Tessellator var7 = var4; + TexturedQuad var6 = var10000; + Vec3D var9 = var6.vertexPositions[1].vector3D.subtract(var6.vertexPositions[0].vector3D).normalize(); + Vec3D var10 = var6.vertexPositions[1].vector3D.subtract(var6.vertexPositions[2].vector3D).normalize(); + var9 = (new Vec3D(var9.yCoord * var10.zCoord - var9.zCoord * var10.yCoord, var9.zCoord * var10.xCoord - var9.xCoord * var10.zCoord, var9.xCoord * var10.yCoord - var9.yCoord * var10.xCoord)).normalize(); + Tessellator.setNormal(-var9.xCoord, -var9.yCoord, -var9.zCoord); + + for(int var11 = 0; var11 < 4; ++var11) { + PositionTextureVertex var12 = var6.vertexPositions[var11]; + var7.addVertexWithUV(var12.vector3D.xCoord * var8, var12.vector3D.yCoord * var8, var12.vector3D.zCoord * var8, var12.texturePositionX, var12.texturePositionY); + } + + var4.draw(); + } + + GL11.glEndList(); + var2.compiled = true; + } + + if(this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) { + if(this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) { + GL11.glCallList(this.displayList); + } else { + GL11.glTranslatef(this.rotationPointX * var1, this.rotationPointY * var1, this.rotationPointZ * var1); + GL11.glCallList(this.displayList); + GL11.glTranslatef(-this.rotationPointX * var1, -this.rotationPointY * var1, -this.rotationPointZ * var1); + } + } else { + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * var1, this.rotationPointY * var1, this.rotationPointZ * var1); + if(this.rotateAngleZ != 0.0F) { + GL11.glRotatef(this.rotateAngleZ * (180.0F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + if(this.rotateAngleY != 0.0F) { + GL11.glRotatef(this.rotateAngleY * (180.0F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if(this.rotateAngleX != 0.0F) { + GL11.glRotatef(this.rotateAngleX * (180.0F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + + GL11.glCallList(this.displayList); + GL11.glPopMatrix(); + } + } + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelSheep.java b/src/teavm/java/net/minecraft/client/model/ModelSheep.java new file mode 100644 index 0000000..94aa937 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelSheep.java @@ -0,0 +1,13 @@ +package net.minecraft.client.model; + +public final class ModelSheep extends ModelQuadruped { + public ModelSheep() { + super(12, 0.0F); + this.head = new ModelRenderer(0, 0); + this.head.addBox(-3.0F, -4.0F, -6.0F, 6, 6, 8, 0.0F); + this.head.setRotationPoint(0.0F, 6.0F, -8.0F); + this.body = new ModelRenderer(28, 8); + this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, 0.0F); + this.body.setRotationPoint(0.0F, 5.0F, 2.0F); + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelSheepFur.java b/src/teavm/java/net/minecraft/client/model/ModelSheepFur.java new file mode 100644 index 0000000..5a3dc6f --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelSheepFur.java @@ -0,0 +1,25 @@ +package net.minecraft.client.model; + +public final class ModelSheepFur extends ModelQuadruped { + public ModelSheepFur() { + super(12, 0.0F); + this.head = new ModelRenderer(0, 0); + this.head.addBox(-3.0F, -4.0F, -4.0F, 6, 6, 6, 0.6F); + this.head.setRotationPoint(0.0F, 6.0F, -8.0F); + this.body = new ModelRenderer(28, 8); + this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, 1.75F); + this.body.setRotationPoint(0.0F, 5.0F, 2.0F); + this.leg1 = new ModelRenderer(0, 16); + this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); + this.leg1.setRotationPoint(-3.0F, 12.0F, 7.0F); + this.leg2 = new ModelRenderer(0, 16); + this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); + this.leg2.setRotationPoint(3.0F, 12.0F, 7.0F); + this.leg3 = new ModelRenderer(0, 16); + this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); + this.leg3.setRotationPoint(-3.0F, 12.0F, -5.0F); + this.leg4 = new ModelRenderer(0, 16); + this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); + this.leg4.setRotationPoint(3.0F, 12.0F, -5.0F); + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelSkeleton.java b/src/teavm/java/net/minecraft/client/model/ModelSkeleton.java new file mode 100644 index 0000000..1ac5028 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelSkeleton.java @@ -0,0 +1,20 @@ +package net.minecraft.client.model; + +public final class ModelSkeleton extends ModelZombie { + public ModelSkeleton() { + this.bipedRightArm = new ModelRenderer(40, 16); + this.bipedRightArm.addBox(-1.0F, -2.0F, -1.0F, 2, 12, 2, 0.0F); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + this.bipedLeftArm = new ModelRenderer(40, 16); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -1.0F, 2, 12, 2, 0.0F); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); + this.bipedRightLeg = new ModelRenderer(0, 16); + this.bipedRightLeg.addBox(-1.0F, 0.0F, -1.0F, 2, 12, 2, 0.0F); + this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); + this.bipedLeftLeg = new ModelRenderer(0, 16); + this.bipedLeftLeg.mirror = true; + this.bipedLeftLeg.addBox(-1.0F, 0.0F, -1.0F, 2, 12, 2, 0.0F); + this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelSpider.java b/src/teavm/java/net/minecraft/client/model/ModelSpider.java new file mode 100644 index 0000000..2207c53 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelSpider.java @@ -0,0 +1,112 @@ +package net.minecraft.client.model; + +import net.PeytonPlayz585.math.MathHelper; + +public final class ModelSpider extends ModelBase { + private ModelRenderer spiderHead = new ModelRenderer(32, 4); + private ModelRenderer spiderNeck; + private ModelRenderer spiderBody; + private ModelRenderer spiderLeg1; + private ModelRenderer spiderLeg2; + private ModelRenderer spiderLeg3; + private ModelRenderer spiderLeg4; + private ModelRenderer spiderLeg5; + private ModelRenderer spiderLeg6; + private ModelRenderer spiderLeg7; + private ModelRenderer spiderLeg8; + + public ModelSpider() { + this.spiderHead.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, 0.0F); + this.spiderHead.setRotationPoint(0.0F, 15.0F, -3.0F); + this.spiderNeck = new ModelRenderer(0, 0); + this.spiderNeck.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, 0.0F); + this.spiderNeck.setRotationPoint(0.0F, 15.0F, 0.0F); + this.spiderBody = new ModelRenderer(0, 12); + this.spiderBody.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, 0.0F); + this.spiderBody.setRotationPoint(0.0F, 15.0F, 9.0F); + this.spiderLeg1 = new ModelRenderer(18, 0); + this.spiderLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg1.setRotationPoint(-4.0F, 15.0F, 2.0F); + this.spiderLeg2 = new ModelRenderer(18, 0); + this.spiderLeg2.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg2.setRotationPoint(4.0F, 15.0F, 2.0F); + this.spiderLeg3 = new ModelRenderer(18, 0); + this.spiderLeg3.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg3.setRotationPoint(-4.0F, 15.0F, 1.0F); + this.spiderLeg4 = new ModelRenderer(18, 0); + this.spiderLeg4.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg4.setRotationPoint(4.0F, 15.0F, 1.0F); + this.spiderLeg5 = new ModelRenderer(18, 0); + this.spiderLeg5.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg5.setRotationPoint(-4.0F, 15.0F, 0.0F); + this.spiderLeg6 = new ModelRenderer(18, 0); + this.spiderLeg6.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg6.setRotationPoint(4.0F, 15.0F, 0.0F); + this.spiderLeg7 = new ModelRenderer(18, 0); + this.spiderLeg7.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg7.setRotationPoint(-4.0F, 15.0F, -1.0F); + this.spiderLeg8 = new ModelRenderer(18, 0); + this.spiderLeg8.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); + this.spiderLeg8.setRotationPoint(4.0F, 15.0F, -1.0F); + } + + public final void render(float var1, float var2, float var3, float var4, float var5, float var6) { + this.setRotationAngles(var1, var2, var3, var4, var5, 1.0F); + this.spiderHead.render(1.0F); + this.spiderNeck.render(1.0F); + this.spiderBody.render(1.0F); + this.spiderLeg1.render(1.0F); + this.spiderLeg2.render(1.0F); + this.spiderLeg3.render(1.0F); + this.spiderLeg4.render(1.0F); + this.spiderLeg5.render(1.0F); + this.spiderLeg6.render(1.0F); + this.spiderLeg7.render(1.0F); + this.spiderLeg8.render(1.0F); + } + + public final void setRotationAngles(float var1, float var2, float var3, float var4, float var5, float var6) { + this.spiderHead.rotateAngleY = var4 / (180.0F / (float)Math.PI); + this.spiderHead.rotateAngleX = var5 / (180.0F / (float)Math.PI); + this.spiderLeg1.rotateAngleZ = (float)Math.PI * -0.25F; + this.spiderLeg2.rotateAngleZ = (float)Math.PI * 0.25F; + this.spiderLeg3.rotateAngleZ = -((float)Math.PI * 0.185F); + this.spiderLeg4.rotateAngleZ = (float)Math.PI * 0.185F; + this.spiderLeg5.rotateAngleZ = -((float)Math.PI * 0.185F); + this.spiderLeg6.rotateAngleZ = (float)Math.PI * 0.185F; + this.spiderLeg7.rotateAngleZ = (float)Math.PI * -0.25F; + this.spiderLeg8.rotateAngleZ = (float)Math.PI * 0.25F; + this.spiderLeg1.rotateAngleY = (float)Math.PI * 0.25F; + this.spiderLeg2.rotateAngleY = (float)Math.PI * -0.25F; + this.spiderLeg3.rotateAngleY = (float)Math.PI * 0.125F; + this.spiderLeg4.rotateAngleY = (float)Math.PI * -0.125F; + this.spiderLeg5.rotateAngleY = (float)Math.PI * -0.125F; + this.spiderLeg6.rotateAngleY = (float)Math.PI * 0.125F; + this.spiderLeg7.rotateAngleY = (float)Math.PI * -0.25F; + this.spiderLeg8.rotateAngleY = (float)Math.PI * 0.25F; + var3 = -(MathHelper.cos(var1 * 0.6662F * 2.0F) * 0.4F) * var2; + var4 = -(MathHelper.cos(var1 * 0.6662F * 2.0F + (float)Math.PI) * 0.4F) * var2; + var5 = -(MathHelper.cos(var1 * 0.6662F * 2.0F + (float)Math.PI * 0.5F) * 0.4F) * var2; + var6 = -(MathHelper.cos(var1 * 0.6662F * 2.0F + (float)Math.PI * 3.0F / 2.0F) * 0.4F) * var2; + float var7 = Math.abs(MathHelper.sin(var1 * 0.6662F) * 0.4F) * var2; + float var8 = Math.abs(MathHelper.sin(var1 * 0.6662F + (float)Math.PI) * 0.4F) * var2; + float var9 = Math.abs(MathHelper.sin(var1 * 0.6662F + (float)Math.PI * 0.5F) * 0.4F) * var2; + var1 = Math.abs(MathHelper.sin(var1 * 0.6662F + (float)Math.PI * 3.0F / 2.0F) * 0.4F) * var2; + this.spiderLeg1.rotateAngleY += var3; + this.spiderLeg2.rotateAngleY -= var3; + this.spiderLeg3.rotateAngleY += var4; + this.spiderLeg4.rotateAngleY -= var4; + this.spiderLeg5.rotateAngleY += var5; + this.spiderLeg6.rotateAngleY -= var5; + this.spiderLeg7.rotateAngleY += var6; + this.spiderLeg8.rotateAngleY -= var6; + this.spiderLeg1.rotateAngleZ += var7; + this.spiderLeg2.rotateAngleZ -= var7; + this.spiderLeg3.rotateAngleZ += var8; + this.spiderLeg4.rotateAngleZ -= var8; + this.spiderLeg5.rotateAngleZ += var9; + this.spiderLeg6.rotateAngleZ -= var9; + this.spiderLeg7.rotateAngleZ += var1; + this.spiderLeg8.rotateAngleZ -= var1; + } +} diff --git a/src/teavm/java/net/minecraft/client/model/ModelZombie.java b/src/teavm/java/net/minecraft/client/model/ModelZombie.java new file mode 100644 index 0000000..60251a3 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/ModelZombie.java @@ -0,0 +1,23 @@ +package net.minecraft.client.model; + +import net.PeytonPlayz585.math.MathHelper; + +public class ModelZombie extends ModelBiped { + public final void setRotationAngles(float var1, float var2, float var3, float var4, float var5, float var6) { + super.setRotationAngles(var1, var2, var3, var4, var5, var6); + var1 = MathHelper.sin(0.0F); + var2 = MathHelper.sin(0.0F); + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -(0.1F - var1 * 0.6F); + this.bipedLeftArm.rotateAngleY = 0.1F - var1 * 0.6F; + this.bipedRightArm.rotateAngleX = (float)Math.PI * -0.5F; + this.bipedLeftArm.rotateAngleX = (float)Math.PI * -0.5F; + this.bipedRightArm.rotateAngleX -= var1 * 1.2F - var2 * 0.4F; + this.bipedLeftArm.rotateAngleX -= var1 * 1.2F - var2 * 0.4F; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(var3 * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(var3 * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(var3 * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(var3 * 0.067F) * 0.05F; + } +} diff --git a/src/teavm/java/net/minecraft/client/model/PositionTextureVertex.java b/src/teavm/java/net/minecraft/client/model/PositionTextureVertex.java new file mode 100644 index 0000000..5da95e8 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/PositionTextureVertex.java @@ -0,0 +1,29 @@ +package net.minecraft.client.model; + +import net.minecraft.game.physics.Vec3D; + +public final class PositionTextureVertex { + public Vec3D vector3D; + public float texturePositionX; + public float texturePositionY; + + public PositionTextureVertex(float var1, float var2, float var3, float var4, float var5) { + this(new Vec3D(var1, var2, var3), var4, var5); + } + + public final PositionTextureVertex setTexturePosition(float var1, float var2) { + return new PositionTextureVertex(this, var1, var2); + } + + private PositionTextureVertex(PositionTextureVertex var1, float var2, float var3) { + this.vector3D = var1.vector3D; + this.texturePositionX = var2; + this.texturePositionY = var3; + } + + private PositionTextureVertex(Vec3D var1, float var2, float var3) { + this.vector3D = var1; + this.texturePositionX = var2; + this.texturePositionY = var3; + } +} diff --git a/src/teavm/java/net/minecraft/client/model/TexturedQuad.java b/src/teavm/java/net/minecraft/client/model/TexturedQuad.java new file mode 100644 index 0000000..8ecf6e4 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/model/TexturedQuad.java @@ -0,0 +1,17 @@ +package net.minecraft.client.model; + +public final class TexturedQuad { + public PositionTextureVertex[] vertexPositions; + + private TexturedQuad(PositionTextureVertex[] var1) { + this.vertexPositions = var1; + } + + public TexturedQuad(PositionTextureVertex[] var1, int var2, int var3, int var4, int var5) { + this(var1); + var1[0] = var1[0].setTexturePosition((float)var4 / 64.0F - 0.0015625F, (float)var3 / 32.0F + 0.003125F); + var1[1] = var1[1].setTexturePosition((float)var2 / 64.0F + 0.0015625F, (float)var3 / 32.0F + 0.003125F); + var1[2] = var1[2].setTexturePosition((float)var2 / 64.0F + 0.0015625F, (float)var5 / 32.0F - 0.003125F); + var1[3] = var1[3].setTexturePosition((float)var4 / 64.0F - 0.0015625F, (float)var5 / 32.0F - 0.003125F); + } +} diff --git a/src/teavm/java/net/minecraft/client/player/EntityPlayerSP.java b/src/teavm/java/net/minecraft/client/player/EntityPlayerSP.java new file mode 100644 index 0000000..996a799 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/player/EntityPlayerSP.java @@ -0,0 +1,118 @@ +package net.minecraft.client.player; + +import net.PeytonPlayz585.nbt.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.Session; +import net.minecraft.client.effect.EntityPickupFX; +import net.minecraft.client.gui.container.GuiChest; +import net.minecraft.client.gui.container.GuiCrafting; +import net.minecraft.client.gui.container.GuiFurnace; +import net.minecraft.game.IInventory; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.entity.player.InventoryPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.tileentity.TileEntityFurnace; + +public class EntityPlayerSP extends EntityPlayer { + public MovementInput movementInput; + private Minecraft mc; + + public EntityPlayerSP(Minecraft var1, World var2, Session var3) { + super(var2); + this.mc = var1; + if(var3 != null) { + this.skinUrl = "http://www.minecraft.net/skin/" + var3.username + ".png"; + } + + } + + public final void updatePlayerActionState() { + this.moveStrafing = this.movementInput.moveStrafe; + this.moveForward = this.movementInput.moveForward; + this.isJumping = this.movementInput.jump; + } + + public final void onLivingUpdate() { + this.movementInput.updatePlayerMoveState(); + super.onLivingUpdate(); + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + var1.setInteger("Score", this.getScore); + InventoryPlayer var10002 = this.inventory; + NBTTagList var2 = new NBTTagList(); + InventoryPlayer var5 = var10002; + + int var3; + NBTTagCompound var4; + for(var3 = 0; var3 < var5.mainInventory.length; ++var3) { + if(var5.mainInventory[var3] != null) { + var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + var5.mainInventory[var3].writeToNBT(var4); + var2.setTag(var4); + } + } + + for(var3 = 0; var3 < var5.armorInventory.length; ++var3) { + if(var5.armorInventory[var3] != null) { + var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)(var3 + 100)); + var5.armorInventory[var3].writeToNBT(var4); + var2.setTag(var4); + } + } + + var1.setTag("Inventory", var2); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + this.getScore = var1.getInteger("Score"); + NBTTagList var6 = var1.getTagList("Inventory"); + NBTTagList var2 = var6; + InventoryPlayer var7 = this.inventory; + var7.mainInventory = new ItemStack[36]; + var7.armorInventory = new ItemStack[4]; + + for(int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + int var5 = var4.getByte("Slot") & 255; + if(var5 >= 0 && var5 < var7.mainInventory.length) { + var7.mainInventory[var5] = new ItemStack(var4); + } + + if(var5 >= 100 && var5 < var7.armorInventory.length + 100) { + var7.armorInventory[var5 - 100] = new ItemStack(var4); + } + } + + } + + protected final String getEntityString() { + return "LocalPlayer"; + } + + public final void displayGUIChest(IInventory var1) { + this.mc.displayGuiScreen(new GuiChest(this.inventory, var1)); + } + + public final void displayWorkbenchGUI() { + this.mc.displayGuiScreen(new GuiCrafting(this.inventory)); + } + + public final void displayGUIFurnace(TileEntityFurnace var1) { + this.mc.displayGuiScreen(new GuiFurnace(this.inventory, var1)); + } + + public final void destroyCurrentEquippedItem() { + this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack)null); + } + + public final void onItemPickup(Entity var1) { + this.mc.effectRenderer.addEffect(new EntityPickupFX(this.mc.theWorld, var1, this, -0.5F)); + } +} diff --git a/src/teavm/java/net/minecraft/client/player/MovementInput.java b/src/teavm/java/net/minecraft/client/player/MovementInput.java new file mode 100644 index 0000000..c39e792 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/player/MovementInput.java @@ -0,0 +1,16 @@ +package net.minecraft.client.player; + +public class MovementInput { + public float moveStrafe = 0.0F; + public float moveForward = 0.0F; + public boolean jump = false; + + public void updatePlayerMoveState() { + } + + public void resetKeyState() { + } + + public void checkKeyForMovementInput(int var1, boolean var2) { + } +} diff --git a/src/teavm/java/net/minecraft/client/player/MovementInputFromOptions.java b/src/teavm/java/net/minecraft/client/player/MovementInputFromOptions.java new file mode 100644 index 0000000..e271221 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/player/MovementInputFromOptions.java @@ -0,0 +1,69 @@ +package net.minecraft.client.player; + +import net.minecraft.client.GameSettings; + +public final class MovementInputFromOptions extends MovementInput { + private boolean[] movementKeyStates = new boolean[10]; + private GameSettings gameSettings; + + public MovementInputFromOptions(GameSettings var1) { + this.gameSettings = var1; + } + + public final void checkKeyForMovementInput(int var1, boolean var2) { + byte var3 = -1; + if(var1 == this.gameSettings.keyBindForward.keyCode) { + var3 = 0; + } + + if(var1 == this.gameSettings.keyBindBack.keyCode) { + var3 = 1; + } + + if(var1 == this.gameSettings.keyBindLeft.keyCode) { + var3 = 2; + } + + if(var1 == this.gameSettings.keyBindRight.keyCode) { + var3 = 3; + } + + if(var1 == this.gameSettings.keyBindJump.keyCode) { + var3 = 4; + } + + if(var3 >= 0) { + this.movementKeyStates[var3] = var2; + } + + } + + public final void resetKeyState() { + for(int var1 = 0; var1 < 10; ++var1) { + this.movementKeyStates[var1] = false; + } + + } + + public final void updatePlayerMoveState() { + this.moveStrafe = 0.0F; + this.moveForward = 0.0F; + if(this.movementKeyStates[0]) { + ++this.moveForward; + } + + if(this.movementKeyStates[1]) { + --this.moveForward; + } + + if(this.movementKeyStates[2]) { + ++this.moveStrafe; + } + + if(this.movementKeyStates[3]) { + --this.moveStrafe; + } + + this.jump = this.movementKeyStates[4]; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/EntityRenderer.java b/src/teavm/java/net/minecraft/client/render/EntityRenderer.java new file mode 100644 index 0000000..0196a74 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/EntityRenderer.java @@ -0,0 +1,542 @@ +package net.minecraft.client.render; + +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.ImageObserver; +import java.io.File; +import java.io.FileOutputStream; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.text.DecimalFormat; +import java.util.List; +import java.util.Random; +import javax.imageio.ImageIO; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.RenderHelper; +import net.minecraft.client.controller.PlayerControllerCreative; +import net.minecraft.client.effect.EffectRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.player.EntityPlayerSP; +import net.minecraft.client.render.camera.ClippingHelperImplementation; +import net.minecraft.client.render.camera.Frustrum; +import net.minecraft.client.render.camera.IsomCamera; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; +import net.minecraft.game.physics.MovingObjectPosition; +import net.minecraft.game.physics.Vec3D; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +public final class EntityRenderer { + private Minecraft mc; + private boolean anaglyphEnable = false; + private float farPlaneDistance = 0.0F; + public ItemRenderer itemRenderer; + private int rendererUpdateCount; + private Entity pointedEntity = null; + private int entityRendererInt1; + private int entityRendererInt2; + private DecimalFormat entityDecimalFormat = new DecimalFormat("0000"); + private ByteBuffer entityByteBuffer; + private FloatBuffer entityFloatBuffer = BufferUtils.createFloatBuffer(16); + private Random random = new Random(); + private volatile int unusedInt0 = 0; + private volatile int unusedInt1 = 0; + private FloatBuffer fogColorBuffer = BufferUtils.createFloatBuffer(16); + private float fogColorRed; + private float fogColorGreen; + private float fogColorBlue; + private float prevFogColor; + private float fogColor; + + public EntityRenderer(Minecraft var1) { + this.mc = var1; + this.itemRenderer = new ItemRenderer(var1); + } + + public final void updateRenderer() { + this.prevFogColor = this.fogColor; + float var1 = this.mc.theWorld.getLightBrightness((int)this.mc.thePlayer.posX, (int)this.mc.thePlayer.posY, (int)this.mc.thePlayer.posZ); + float var2 = (float)(3 - this.mc.options.renderDistance) / 3.0F; + var1 = var1 * (1.0F - var2) + var2; + this.fogColor += (var1 - this.fogColor) * 0.1F; + ++this.rendererUpdateCount; + this.itemRenderer.updateEquippedItem(); + } + + private Vec3D orientCamera(float var1) { + EntityPlayerSP var2 = this.mc.thePlayer; + float var3 = var2.prevPosX + (var2.posX - var2.prevPosX) * var1; + float var4 = var2.prevPosY + (var2.posY - var2.prevPosY) * var1; + var1 = var2.prevPosZ + (var2.posZ - var2.prevPosZ) * var1; + return new Vec3D(var3, var4, var1); + } + + private void hurtCameraEffect(float var1) { + EntityPlayerSP var2 = this.mc.thePlayer; + float var3 = (float)var2.hurtTime - var1; + if(var2.health <= 0) { + var1 += (float)var2.deathTime; + GL11.glRotatef(40.0F - 8000.0F / (var1 + 200.0F), 0.0F, 0.0F, 1.0F); + } + + if(var3 >= 0.0F) { + var3 /= (float)var2.maxHurtTime; + var3 = MathHelper.sin(var3 * var3 * var3 * var3 * (float)Math.PI); + var1 = var2.attackedAtYaw; + GL11.glRotatef(-var1, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-var3 * 14.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(var1, 0.0F, 1.0F, 0.0F); + } + } + + private void setupViewBobbing(float var1) { + if(!this.mc.options.thirdPersonView) { + EntityPlayerSP var2 = this.mc.thePlayer; + float var3 = var2.distanceWalkedModified - var2.prevDistanceWalkedModified; + var3 = var2.distanceWalkedModified + var3 * var1; + float var4 = var2.prevCameraYaw + (var2.cameraYaw - var2.prevCameraYaw) * var1; + var1 = var2.prevCameraPitch + (var2.cameraPitch - var2.prevCameraPitch) * var1; + GL11.glTranslatef(MathHelper.sin(var3 * (float)Math.PI) * var4 * 0.5F, -Math.abs(MathHelper.cos(var3 * (float)Math.PI) * var4), 0.0F); + GL11.glRotatef(MathHelper.sin(var3 * (float)Math.PI) * var4 * 3.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(Math.abs(MathHelper.cos(var3 * (float)Math.PI + 0.2F) * var4) * 5.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(var1, 1.0F, 0.0F, 0.0F); + } + } + + public final void updateCameraAndRender(float var1) { + if(this.anaglyphEnable && !GL11.isFocused()) { + this.mc.displayInGameMenu(); + } + + this.anaglyphEnable = GL11.isFocused(); + int var5; + int var6; + if(this.mc.inventoryScreen) { + GL11.mouseGetDX(); + byte var2 = 0; + GL11.mouseGetDY(); + byte var3 = 0; + this.mc.mouseHelper.ungrabMouse(); + byte var4 = 1; + if(this.mc.options.invertMouse) { + var4 = -1; + } + + var5 = var2 + this.mc.mouseHelper.deltaX; + var6 = var3 - this.mc.mouseHelper.deltaY; + if(var2 != 0 || this.entityRendererInt1 != 0) { + System.out.println("xxo: " + var2 + ", " + this.entityRendererInt1 + ": " + this.entityRendererInt1 + ", xo: " + var5); + } + + if(this.entityRendererInt1 != 0) { + this.entityRendererInt1 = 0; + } + + if(this.entityRendererInt2 != 0) { + this.entityRendererInt2 = 0; + } + + if(var2 != 0) { + this.entityRendererInt1 = var2; + } + + if(var3 != 0) { + this.entityRendererInt2 = var3; + } + + float var10001 = (float)var5; + float var11 = (float)(var6 * var4); + float var9 = var10001; + EntityPlayerSP var7 = this.mc.thePlayer; + float var13 = var7.rotationPitch; + float var14 = var7.rotationYaw; + var7.rotationYaw = (float)((double)var7.rotationYaw + (double)var9 * 0.15D); + var7.rotationPitch = (float)((double)var7.rotationPitch - (double)var11 * 0.15D); + if(var7.rotationPitch < -90.0F) { + var7.rotationPitch = -90.0F; + } + + if(var7.rotationPitch > 90.0F) { + var7.rotationPitch = 90.0F; + } + + var7.prevRotationPitch += var7.rotationPitch - var13; + var7.prevRotationYaw += var7.rotationYaw - var14; + } + + ScaledResolution var8 = new ScaledResolution(this.mc.displayWidth, this.mc.displayHeight); + int var10 = var8.getScaledWidth(); + int var12 = var8.getScaledHeight(); + var5 = GL11.mouseGetX() * var10 / this.mc.displayWidth; + var6 = var12 - GL11.mouseGetY() * var12 / this.mc.displayHeight - 1; + if(this.mc.theWorld != null) { + this.getMouseOver(var1); + this.mc.ingameGUI.renderGameOverlay(var1); + } else { + GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); + GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + this.setupOverlayRendering(); + } + + if(this.mc.currentScreen != null) { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + this.mc.currentScreen.drawScreen(var5, var6, var1); + } + + Thread.yield(); + GL11.updateDisplay(); + } + + private void getMouseOver(float var1) { + EntityRenderer var7 = this; + EntityPlayerSP var9 = this.mc.thePlayer; + float var2 = var9.prevRotationPitch + (var9.rotationPitch - var9.prevRotationPitch) * var1; + float var10 = var9.prevRotationYaw + (var9.rotationYaw - var9.prevRotationYaw) * var1; + Vec3D var11 = this.orientCamera(var1); + float var12 = MathHelper.cos(-var10 * ((float)Math.PI / 180.0F) - (float)Math.PI); + float var13 = MathHelper.sin(-var10 * ((float)Math.PI / 180.0F) - (float)Math.PI); + float var14 = -MathHelper.cos(-var2 * ((float)Math.PI / 180.0F)); + float var15 = MathHelper.sin(-var2 * ((float)Math.PI / 180.0F)); + float var16 = var13 * var14; + float var17 = var12 * var14; + float var18 = this.mc.playerController.getBlockReachDistance(); + Vec3D var19 = var11.addVector(var16 * var18, var15 * var18, var17 * var18); + this.mc.objectMouseOver = this.mc.theWorld.rayTraceBlocks(var11, var19); + float var20 = var18; + var11 = this.orientCamera(var1); + if(this.mc.objectMouseOver != null) { + var20 = this.mc.objectMouseOver.hitVec.distance(var11); + } + + if(this.mc.playerController instanceof PlayerControllerCreative) { + var18 = 32.0F; + } else { + if(var20 > 3.0F) { + var20 = 3.0F; + } + + var18 = var20; + } + + var19 = var11.addVector(var16 * var18, var15 * var18, var17 * var18); + this.pointedEntity = null; + List var8 = this.mc.theWorld.entityMap.getEntitiesWithinAABB(var9, var9.boundingBox.addCoord(var16 * var18, var15 * var18, var17 * var18)); + float var28 = 0.0F; + + for(int var41 = 0; var41 < var8.size(); ++var41) { + Entity var21 = (Entity)var8.get(var41); + if(var21.canBeCollidedWith()) { + AxisAlignedBB var22 = var21.boundingBox.expand(0.1F, 0.1F, 0.1F); + MovingObjectPosition var23 = var22.calculateIntercept(var11, var19); + if(var23 != null) { + var2 = var11.distance(var23.hitVec); + if(var2 < var28 || var28 == 0.0F) { + var7.pointedEntity = var21; + var28 = var2; + } + } + } + } + + if(var7.pointedEntity != null && !(var7.mc.playerController instanceof PlayerControllerCreative)) { + var7.mc.objectMouseOver = new MovingObjectPosition(var7.pointedEntity); + } + + for(int var24 = 0; var24 < 2; ++var24) { + if(this.mc.options.anaglyph) { + if(var24 == 0) { + GL11.glColorMask(false, true, true, false); + } else { + GL11.glColorMask(true, false, false, false); + } + } + + EntityPlayerSP var3 = this.mc.thePlayer; + World var4 = this.mc.theWorld; + RenderGlobal var5 = this.mc.renderGlobal; + EffectRenderer var6 = this.mc.effectRenderer; + GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); + this.updateFogColor(var1); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + float var27 = var1; + this.farPlaneDistance = (float)(512 >> (this.mc.options.renderDistance << 1)); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + if(this.mc.options.anaglyph) { + GL11.glTranslatef((float)(-((var24 << 1) - 1)) * 0.07F, 0.0F, 0.0F); + } + + EntityPlayerSP var34 = this.mc.thePlayer; + var13 = 70.0F; + if(var34.isInsideOfWater()) { + var13 = 60.0F; + } + + if(var34.health <= 0) { + var14 = (float)var34.deathTime + var1; + var13 /= (1.0F - 500.0F / (var14 + 500.0F)) * 2.0F + 1.0F; + } + + GL11.gluPerspective(var13, (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + if(this.mc.options.anaglyph) { + GL11.glTranslatef((float)((var24 << 1) - 1) * 0.1F, 0.0F, 0.0F); + } + + this.hurtCameraEffect(var1); + if(this.mc.options.fancyGraphics) { + this.setupViewBobbing(var1); + } + + EntityRenderer var30 = this; + var34 = this.mc.thePlayer; + var13 = var34.prevPosX + (var34.posX - var34.prevPosX) * var1; + var14 = var34.prevPosY + (var34.posY - var34.prevPosY) * var1; + var15 = var34.prevPosZ + (var34.posZ - var34.prevPosZ) * var1; + if(!this.mc.options.thirdPersonView) { + GL11.glTranslatef(0.0F, 0.0F, -0.1F); + } else { + var16 = 4.0F; + float var25 = -MathHelper.sin(var34.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(var34.rotationPitch / 180.0F * (float)Math.PI) * 4.0F; + var17 = MathHelper.cos(var34.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(var34.rotationPitch / 180.0F * (float)Math.PI) * 4.0F; + var18 = -MathHelper.sin(var34.rotationPitch / 180.0F * (float)Math.PI) * 4.0F; + + for(int var39 = 0; var39 < 8; ++var39) { + var20 = (float)(((var39 & 1) << 1) - 1); + var27 = (float)(((var39 >> 1 & 1) << 1) - 1); + var28 = (float)(((var39 >> 2 & 1) << 1) - 1); + var20 *= 0.1F; + var27 *= 0.1F; + var28 *= 0.1F; + MovingObjectPosition var42 = var30.mc.theWorld.rayTraceBlocks(new Vec3D(var13 + var20, var14 + var27, var15 + var28), new Vec3D(var13 - var25 + var20 + var28, var14 - var18 + var27, var15 - var17 + var28)); + if(var42 != null) { + float var40 = var42.hitVec.distance(new Vec3D(var13, var14, var15)); + if(var40 < var16) { + var16 = var40; + } + } + } + + GL11.glTranslatef(0.0F, 0.0F, -var16); + } + + GL11.glRotatef(var34.prevRotationPitch + (var34.rotationPitch - var34.prevRotationPitch) * var27, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(var34.prevRotationYaw + (var34.rotationYaw - var34.prevRotationYaw) * var27 + 180.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-var13, -var14, -var15); + ClippingHelperImplementation.init(); + this.setupFog(); + GL11.glEnable(GL11.GL_FOG); + var5.renderSky(var1); + this.setupFog(); + Frustrum var26 = new Frustrum(); + this.mc.renderGlobal.clipRenderersByFrustrum(var26); + this.mc.renderGlobal.updateRenderers(var3); + this.setupFog(); + GL11.glEnable(GL11.GL_FOG); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png")); + RenderHelper.disableStandardItemLighting(); + var5.sortAndRender(var3, 0); + int var29; + if(var4.isSolid(var3.posX, var3.posY, var3.posZ, 0.1F)) { + var29 = (int)var3.posX; + int var31 = (int)var3.posY; + int var32 = (int)var3.posZ; + RenderBlocks var33 = new RenderBlocks(var4); + + for(int var35 = var29 - 1; var35 <= var29 + 1; ++var35) { + for(int var37 = var31 - 1; var37 <= var31 + 1; ++var37) { + for(int var36 = var32 - 1; var36 <= var32 + 1; ++var36) { + int var38 = var4.getBlockId(var35, var37, var36); + if(var38 > 0) { + var33.renderBlockAllFaces(Block.blocksList[var38], var35, var37, var36); + } + } + } + } + } + + RenderHelper.enableStandardItemLighting(); + var5.renderEntities(this.orientCamera(var1), var26, var1); + var6.renderLitParticles(var1); + RenderHelper.disableStandardItemLighting(); + this.setupFog(); + var6.renderParticles(var3, var1); + var5.oobGroundRenderer(); + if(this.mc.objectMouseOver != null && var3.isInsideOfWater()) { + GL11.glDisable(GL11.GL_ALPHA_TEST); + var5.drawBlockBreaking(this.mc.objectMouseOver, 0, var3.inventory.getCurrentItem()); + var5.drawSelectionBox(this.mc.objectMouseOver, 0); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.setupFog(); + var5.oobWaterRenderer(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glColorMask(false, false, false, false); + var29 = var5.sortAndRender(var3, 1); + GL11.glColorMask(true, true, true, true); + if(this.mc.options.anaglyph) { + if(var24 == 0) { + GL11.glColorMask(false, true, true, false); + } else { + GL11.glColorMask(true, false, false, false); + } + } + + if(var29 > 0) { + var5.renderAllRenderLists(); + } + + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + if(this.mc.objectMouseOver != null && !var3.isInsideOfWater()) { + GL11.glDisable(GL11.GL_ALPHA_TEST); + var5.drawBlockBreaking(this.mc.objectMouseOver, 0, var3.inventory.getCurrentItem()); + var5.drawSelectionBox(this.mc.objectMouseOver, 0); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glDisable(GL11.GL_FOG); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glLoadIdentity(); + if(this.mc.options.anaglyph) { + GL11.glTranslatef((float)((var24 << 1) - 1) * 0.1F, 0.0F, 0.0F); + } + + GL11.glPushMatrix(); + this.hurtCameraEffect(var1); + if(this.mc.options.fancyGraphics) { + this.setupViewBobbing(var1); + } + + if(!this.mc.options.thirdPersonView) { + this.itemRenderer.renderItemInFirstPerson(var1); + } + + GL11.glPopMatrix(); + if(!this.mc.options.thirdPersonView) { + this.itemRenderer.renderOverlays(var1); + this.hurtCameraEffect(var1); + } + + if(this.mc.options.fancyGraphics) { + this.setupViewBobbing(var1); + } + + if(!this.mc.options.anaglyph) { + return; + } + } + + GL11.glColorMask(true, true, true, false); + } + + public final void setupOverlayRendering() { + ScaledResolution var1 = new ScaledResolution(this.mc.displayWidth, this.mc.displayHeight); + int var2 = var1.getScaledWidth(); + int var3 = var1.getScaledHeight(); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, (double)var2, (double)var3, 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + } + + private void updateFogColor(float var1) { + World var2 = this.mc.theWorld; + EntityPlayerSP var3 = this.mc.thePlayer; + float var4 = 1.0F / (float)(4 - this.mc.options.renderDistance); + var4 = 1.0F - (float)Math.pow((double)var4, 0.25D); + Vec3D var5 = var2.getSkyColor(var1); + float var6 = var5.xCoord; + float var7 = var5.yCoord; + float var13 = var5.zCoord; + Vec3D var8 = var2.getFogColor(var1); + this.fogColorRed = var8.xCoord; + this.fogColorGreen = var8.yCoord; + this.fogColorBlue = var8.zCoord; + this.fogColorRed += (var6 - this.fogColorRed) * var4; + this.fogColorGreen += (var7 - this.fogColorGreen) * var4; + this.fogColorBlue += (var13 - this.fogColorBlue) * var4; + Block var9 = Block.blocksList[var2.getBlockId((int)var3.posX, (int)(var3.posY + 0.12F), (int)var3.posZ)]; + if(var9 != null && var9.material != Material.air) { + Material var10 = var9.material; + if(var10 == Material.water) { + this.fogColorRed = 0.02F; + this.fogColorGreen = 0.02F; + this.fogColorBlue = 0.2F; + } else if(var10 == Material.lava) { + this.fogColorRed = 0.6F; + this.fogColorGreen = 0.1F; + this.fogColorBlue = 0.0F; + } + } + + float var11 = this.prevFogColor + (this.fogColor - this.prevFogColor) * var1; + this.fogColorRed *= var11; + this.fogColorGreen *= var11; + this.fogColorBlue *= var11; + if(this.mc.options.anaglyph) { + var1 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F; + var11 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F; + float var12 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F; + this.fogColorRed = var1; + this.fogColorGreen = var11; + this.fogColorBlue = var12; + } + + GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F); + } + + private void setupFog() { + World var1 = this.mc.theWorld; + EntityPlayerSP var2 = this.mc.thePlayer; + int var10000 = GL11.GL_FOG_COLOR; + float var3 = 1.0F; + float var6 = this.fogColorBlue; + float var5 = this.fogColorGreen; + float var4 = this.fogColorRed; + this.fogColorBuffer.clear(); + this.fogColorBuffer.put(var4).put(var5).put(var6).put(1.0F); + this.fogColorBuffer.flip(); + GL11.glFog(var10000, this.fogColorBuffer); + GL11.glNormal3f(0.0F, -1.0F, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Block var7 = Block.blocksList[var1.getBlockId((int)var2.posX, (int)(var2.posY + 0.12F), (int)var2.posZ)]; + if(var7 != null && var7.material.getIsLiquid()) { + Material var8 = var7.material; + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); + if(var8 == Material.water) { + GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F); + } else if(var8 == Material.lava) { + GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F); + } + } else { + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); + GL11.glFogf(GL11.GL_FOG_START, this.farPlaneDistance / 4.0F); + GL11.glFogf(GL11.GL_FOG_END, this.farPlaneDistance); + } + + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/EntitySorter.java b/src/teavm/java/net/minecraft/client/render/EntitySorter.java new file mode 100644 index 0000000..ff36c3d --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/EntitySorter.java @@ -0,0 +1,19 @@ +package net.minecraft.client.render; + +import java.util.Comparator; +import net.minecraft.game.entity.player.EntityPlayer; + +public final class EntitySorter implements Comparator { + private EntityPlayer player; + + public EntitySorter(EntityPlayer var1) { + this.player = var1; + } + + public final int compare(Object var1, Object var2) { + WorldRenderer var10001 = (WorldRenderer)var1; + WorldRenderer var3 = (WorldRenderer)var2; + WorldRenderer var4 = var10001; + return var4.distanceToEntitySquared(this.player) < var3.distanceToEntitySquared(this.player) ? -1 : 1; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/ImageBufferDownload.java b/src/teavm/java/net/minecraft/client/render/ImageBufferDownload.java new file mode 100644 index 0000000..50edcca --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/ImageBufferDownload.java @@ -0,0 +1,72 @@ +package net.minecraft.client.render; + +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.ImageObserver; + +public class ImageBufferDownload { + private int[] imageData; + private int imageWidth; + private int imageHeight; + + public BufferedImage parseUserSkin(BufferedImage var1) { + this.imageWidth = 64; + this.imageHeight = 32; + BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2); + Graphics var3 = var2.getGraphics(); + var3.drawImage(var1, 0, 0, (ImageObserver)null); + var3.dispose(); + this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData(); + this.setAreaOpaque(0, 0, 32, 16); + this.setAreaTransparent(32, 0, 64, 32); + this.setAreaOpaque(0, 16, 64, 32); + return var2; + } + + private void setAreaTransparent(int var1, int var2, int var3, int var4) { + byte var5 = 32; + byte var11 = 64; + byte var10 = 0; + byte var9 = 32; + ImageBufferDownload var8 = this; + var2 = var9; + + boolean var10000; + label43: + while(true) { + if(var2 >= var11) { + var10000 = false; + break; + } + + for(int var6 = var10; var6 < var5; ++var6) { + int var7 = var8.imageData[var2 + var6 * var8.imageWidth]; + if(var7 >>> 24 < 128) { + var10000 = true; + break label43; + } + } + + ++var2; + } + + if(!var10000) { + for(var1 = 32; var1 < 64; ++var1) { + for(var2 = 0; var2 < 32; ++var2) { + this.imageData[var1 + var2 * this.imageWidth] &= 16777215; + } + } + + } + } + + private void setAreaOpaque(int var1, int var2, int var3, int var4) { + for(var1 = 0; var1 < var3; ++var1) { + for(int var5 = var2; var5 < var4; ++var5) { + this.imageData[var1 + var5 * this.imageWidth] |= -16777216; + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/render/ItemRenderer.java b/src/teavm/java/net/minecraft/client/render/ItemRenderer.java new file mode 100644 index 0000000..497d7b1 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/ItemRenderer.java @@ -0,0 +1,304 @@ +package net.minecraft.client.render; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.RenderHelper; +import net.minecraft.client.player.EntityPlayerSP; +import net.minecraft.client.render.entity.Render; +import net.minecraft.client.render.entity.RenderManager; +import net.minecraft.client.render.entity.RenderPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.block.Block; +import org.lwjgl.opengl.GL11; + +public final class ItemRenderer { + private Minecraft mc; + private ItemStack itemToRender = null; + private float equippedProgress = 0.0F; + private float prevEquippedProgress = 0.0F; + private int swingProgress = 0; + private boolean itemSwingState = false; + private RenderBlocks renderBlocksInstance = new RenderBlocks(); + + public ItemRenderer(Minecraft var1) { + this.mc = var1; + } + + public final void renderItemInFirstPerson(float var1) { + float var2 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * var1; + EntityPlayerSP var3 = this.mc.thePlayer; + GL11.glPushMatrix(); + GL11.glRotatef(var3.prevRotationPitch + (var3.rotationPitch - var3.prevRotationPitch) * var1, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(var3.prevRotationYaw + (var3.rotationYaw - var3.prevRotationYaw) * var1, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + float var9 = this.mc.theWorld.getLightBrightness((int)var3.posX, (int)var3.posY, (int)var3.posZ); + GL11.glColor4f(var9, var9, var9, 1.0F); + float var4; + float var5; + if(this.itemToRender != null) { + GL11.glPushMatrix(); + if(this.itemSwingState) { + var9 = ((float)this.swingProgress + var1) / 8.0F; + var4 = MathHelper.sin(var9 * (float)Math.PI); + var5 = MathHelper.sin(MathHelper.sqrt_float(var9) * (float)Math.PI); + GL11.glTranslatef(-var5 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(var9) * (float)Math.PI * 2.0F) * 0.2F, -var4 * 0.2F); + } + + GL11.glTranslatef(0.56F, -0.52F - (1.0F - var2) * 0.6F, -0.71999997F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL11.GL_NORMALIZE); + if(this.itemSwingState) { + var9 = ((float)this.swingProgress + var1) / 8.0F; + var4 = MathHelper.sin(var9 * var9 * (float)Math.PI); + var5 = MathHelper.sin(MathHelper.sqrt_float(var9) * (float)Math.PI); + GL11.glRotatef(-var4 * 20.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-var5 * 20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-var5 * 80.0F, 1.0F, 0.0F, 0.0F); + } + + GL11.glScalef(0.4F, 0.4F, 0.4F); + if(this.itemToRender.itemID < 256 && Block.blocksList[this.itemToRender.itemID].getRenderType() == 0) { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png")); + this.renderBlocksInstance.renderBlockOnInventory(Block.blocksList[this.itemToRender.itemID]); + } else { + if(this.itemToRender.itemID < 256) { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png")); + } else { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/items.png")); + } + + Tessellator var11 = Tessellator.instance; + ItemStack var10 = this.itemToRender; + var5 = (float)(var10.getItem().getIconIndex() % 16 << 4) / 256.0F; + var10 = this.itemToRender; + var1 = (float)((var10.getItem().getIconIndex() % 16 << 4) + 16) / 256.0F; + var10 = this.itemToRender; + var2 = (float)(var10.getItem().getIconIndex() / 16 << 4) / 256.0F; + var10 = this.itemToRender; + var9 = (float)((var10.getItem().getIconIndex() / 16 << 4) + 16) / 256.0F; + GL11.glEnable(GL11.GL_NORMALIZE); + GL11.glTranslatef(0.0F, -0.3F, 0.0F); + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-(15.0F / 16.0F), -(1.0F / 16.0F), 0.0F); + Tessellator.setNormal(0.0F, 0.0F, 1.0F); + var11.startDrawingQuads(); + var11.addVertexWithUV(0.0F, 0.0F, 0.0F, var1, var9); + var11.addVertexWithUV(1.0F, 0.0F, 0.0F, var5, var9); + var11.addVertexWithUV(1.0F, 1.0F, 0.0F, var5, var2); + var11.addVertexWithUV(0.0F, 1.0F, 0.0F, var1, var2); + var11.draw(); + Tessellator.setNormal(0.0F, 0.0F, -1.0F); + var11.startDrawingQuads(); + var11.addVertexWithUV(0.0F, 1.0F, -(1.0F / 16.0F), var1, var2); + var11.addVertexWithUV(1.0F, 1.0F, -(1.0F / 16.0F), var5, var2); + var11.addVertexWithUV(1.0F, 0.0F, -(1.0F / 16.0F), var5, var9); + var11.addVertexWithUV(0.0F, 0.0F, -(1.0F / 16.0F), var1, var9); + var11.draw(); + Tessellator.setNormal(-1.0F, 0.0F, 0.0F); + var11.startDrawingQuads(); + + int var6; + float var7; + float var8; + for(var6 = 0; var6 < 16; ++var6) { + var7 = (float)var6 / 16.0F; + var8 = var1 + (var5 - var1) * var7 - 0.001953125F; + var7 *= 1.0F; + var11.addVertexWithUV(var7, 0.0F, -(1.0F / 16.0F), var8, var9); + var11.addVertexWithUV(var7, 0.0F, 0.0F, var8, var9); + var11.addVertexWithUV(var7, 1.0F, 0.0F, var8, var2); + var11.addVertexWithUV(var7, 1.0F, -(1.0F / 16.0F), var8, var2); + } + + var11.draw(); + Tessellator.setNormal(1.0F, 0.0F, 0.0F); + var11.startDrawingQuads(); + + for(var6 = 0; var6 < 16; ++var6) { + var7 = (float)var6 / 16.0F; + var8 = var1 + (var5 - var1) * var7 - 0.001953125F; + var7 = var7 * 1.0F + 1.0F / 16.0F; + var11.addVertexWithUV(var7, 1.0F, -(1.0F / 16.0F), var8, var2); + var11.addVertexWithUV(var7, 1.0F, 0.0F, var8, var2); + var11.addVertexWithUV(var7, 0.0F, 0.0F, var8, var9); + var11.addVertexWithUV(var7, 0.0F, -(1.0F / 16.0F), var8, var9); + } + + var11.draw(); + Tessellator.setNormal(0.0F, 1.0F, 0.0F); + var11.startDrawingQuads(); + + for(var6 = 0; var6 < 16; ++var6) { + var7 = (float)var6 / 16.0F; + var8 = var9 + (var2 - var9) * var7 - 0.001953125F; + var7 = var7 * 1.0F + 1.0F / 16.0F; + var11.addVertexWithUV(0.0F, var7, 0.0F, var1, var8); + var11.addVertexWithUV(1.0F, var7, 0.0F, var5, var8); + var11.addVertexWithUV(1.0F, var7, -(1.0F / 16.0F), var5, var8); + var11.addVertexWithUV(0.0F, var7, -(1.0F / 16.0F), var1, var8); + } + + var11.draw(); + Tessellator.setNormal(0.0F, -1.0F, 0.0F); + var11.startDrawingQuads(); + + for(var6 = 0; var6 < 16; ++var6) { + var7 = (float)var6 / 16.0F; + var8 = var9 + (var2 - var9) * var7 - 0.001953125F; + var7 *= 1.0F; + var11.addVertexWithUV(1.0F, var7, 0.0F, var5, var8); + var11.addVertexWithUV(0.0F, var7, 0.0F, var1, var8); + var11.addVertexWithUV(0.0F, var7, -(1.0F / 16.0F), var1, var8); + var11.addVertexWithUV(1.0F, var7, -(1.0F / 16.0F), var5, var8); + } + + var11.draw(); + GL11.glDisable(GL11.GL_NORMALIZE); + } + + GL11.glPopMatrix(); + } else { + GL11.glPushMatrix(); + if(this.itemSwingState) { + var9 = ((float)this.swingProgress + var1) / 8.0F; + var4 = MathHelper.sin(var9 * (float)Math.PI); + var5 = MathHelper.sin(MathHelper.sqrt_float(var9) * (float)Math.PI); + GL11.glTranslatef(-var5 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(var9) * (float)Math.PI * 2.0F) * 0.4F, -var4 * 0.4F); + } + + GL11.glTranslatef(0.64000005F, -0.6F - (1.0F - var2) * 0.6F, -0.71999997F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL11.GL_NORMALIZE); + if(this.itemSwingState) { + var9 = ((float)this.swingProgress + var1) / 8.0F; + var4 = MathHelper.sin(var9 * var9 * (float)Math.PI); + var5 = MathHelper.sin(MathHelper.sqrt_float(var9) * (float)Math.PI); + GL11.glRotatef(var5 * 70.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-var4 * 20.0F, 0.0F, 0.0F, 1.0F); + } + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTextureForDownloadableImage(this.mc.thePlayer.skinUrl, this.mc.thePlayer.getTexture())); + GL11.glTranslatef(-0.2F, -0.3F, 0.1F); + GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(1.0F / 16.0F, 1.0F / 16.0F, 1.0F / 16.0F); + GL11.glTranslatef(6.0F, 0.0F, 0.0F); + Render var13 = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); + RenderPlayer var12 = (RenderPlayer)var13; + var12.drawFirstPersonHand(); + GL11.glPopMatrix(); + } + + GL11.glDisable(GL11.GL_NORMALIZE); + RenderHelper.disableStandardItemLighting(); + } + + public final void renderOverlays(float var1) { + GL11.glDisable(GL11.GL_ALPHA_TEST); + int var2; + Tessellator var3; + float var7; + float var9; + if(this.mc.thePlayer.fire > 0) { + var2 = this.mc.renderEngine.getTexture("/terrain.png"); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2); + var3 = Tessellator.instance; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + for(var2 = 0; var2 < 2; ++var2) { + GL11.glPushMatrix(); + int var4 = Block.fire.blockIndexInTexture + (var2 << 4); + int var5 = (var4 & 15) << 4; + var4 &= 240; + float var6 = (float)var5 / 256.0F; + float var10 = ((float)var5 + 15.99F) / 256.0F; + var7 = (float)var4 / 256.0F; + var9 = ((float)var4 + 15.99F) / 256.0F; + GL11.glTranslatef((float)(-((var2 << 1) - 1)) * 0.24F, -0.3F, 0.0F); + GL11.glRotatef((float)((var2 << 1) - 1) * 10.0F, 0.0F, 1.0F, 0.0F); + var3.startDrawingQuads(); + var3.addVertexWithUV(-0.5F, -0.5F, -0.5F, var10, var9); + var3.addVertexWithUV(0.5F, -0.5F, -0.5F, var6, var9); + var3.addVertexWithUV(0.5F, 0.5F, -0.5F, var6, var7); + var3.addVertexWithUV(-0.5F, 0.5F, -0.5F, var10, var7); + var3.draw(); + GL11.glPopMatrix(); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + } + + if(this.mc.thePlayer.isInsideOfWater()) { + var2 = this.mc.renderEngine.getTexture("/water.png"); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2); + var3 = Tessellator.instance; + float var8 = this.mc.thePlayer.getEntityBrightness(var1); + GL11.glColor4f(var8, var8, var8, 0.5F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glPushMatrix(); + var7 = -this.mc.thePlayer.rotationYaw / 64.0F; + var9 = this.mc.thePlayer.rotationPitch / 64.0F; + var3.startDrawingQuads(); + var3.addVertexWithUV(-1.0F, -1.0F, -0.5F, var7 + 4.0F, var9 + 4.0F); + var3.addVertexWithUV(1.0F, -1.0F, -0.5F, var7 + 0.0F, var9 + 4.0F); + var3.addVertexWithUV(1.0F, 1.0F, -0.5F, var7 + 0.0F, var9 + 0.0F); + var3.addVertexWithUV(-1.0F, 1.0F, -0.5F, var7 + 4.0F, var9 + 0.0F); + var3.draw(); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + public final void updateEquippedItem() { + this.prevEquippedProgress = this.equippedProgress; + if(this.itemSwingState) { + ++this.swingProgress; + if(this.swingProgress == 8) { + this.swingProgress = 0; + this.itemSwingState = false; + } + } + + EntityPlayerSP var1 = this.mc.thePlayer; + ItemStack var3 = var1.inventory.getCurrentItem(); + float var2 = var3 == this.itemToRender ? 1.0F : 0.0F; + var2 -= this.equippedProgress; + if(var2 < -0.4F) { + var2 = -0.4F; + } + + if(var2 > 0.4F) { + var2 = 0.4F; + } + + this.equippedProgress += var2; + if(this.equippedProgress < 0.1F) { + this.itemToRender = var3; + } + + } + + public final void equipAnimationSpeed() { + this.equippedProgress = 0.0F; + } + + public final void equippedItemRender() { + this.swingProgress = -1; + this.itemSwingState = true; + } + + public final void resetEquippedProgress() { + this.equippedProgress = 0.0F; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/RenderBlocks.java b/src/teavm/java/net/minecraft/client/render/RenderBlocks.java new file mode 100644 index 0000000..4471547 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/RenderBlocks.java @@ -0,0 +1,808 @@ +package net.minecraft.client.render; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.material.Material; +import org.lwjgl.opengl.GL11; + +public final class RenderBlocks { + private World blockAccess; + private int overrideBlockTexture = -1; + private boolean renderAllFaces = false; + + public RenderBlocks(World var1) { + this.blockAccess = var1; + } + + public RenderBlocks() { + } + + public final void renderBlockUsingTexture(Block var1, int var2, int var3, int var4, int var5) { + this.overrideBlockTexture = var5; + this.renderBlockByRenderType(var1, var2, var3, var4); + this.overrideBlockTexture = -1; + } + + public final void renderBlockAllFaces(Block var1, int var2, int var3, int var4) { + this.renderAllFaces = true; + this.renderBlockByRenderType(var1, var2, var3, var4); + this.renderAllFaces = false; + } + + public final boolean renderBlockByRenderType(Block var1, int var2, int var3, int var4) { + int var5 = var1.getRenderType(); + Tessellator var6; + float var10; + boolean var26; + if(var5 == 0) { + var6 = Tessellator.instance; + var26 = false; + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2, var3 - 1, var4, 0)) { + var10 = var1.getBlockBrightness(this.blockAccess, var2, var3 - 1, var4); + if(Block.lightValue[var1.blockID] > 0) { + var10 = 1.0F; + } + + var6.setColorOpaque_F(0.5F * var10, 0.5F * var10, 0.5F * var10); + this.renderBlockBottom(var1, (float)var2, (float)var3, (float)var4, var1.getBlockTexture(this.blockAccess, var2, var3, var4, 0)); + var26 = true; + } + + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2, var3 + 1, var4, 1)) { + var10 = var1.getBlockBrightness(this.blockAccess, var2, var3 + 1, var4); + if(Block.lightValue[var1.blockID] > 0) { + var10 = 1.0F; + } + + var6.setColorOpaque_F(var10 * 1.0F, var10 * 1.0F, var10 * 1.0F); + this.renderBlockTop(var1, (float)var2, (float)var3, (float)var4, var1.getBlockTexture(this.blockAccess, var2, var3, var4, 1)); + var26 = true; + } + + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2, var3, var4 - 1, 2)) { + var10 = var1.getBlockBrightness(this.blockAccess, var2, var3, var4 - 1); + if(Block.lightValue[var1.blockID] > 0) { + var10 = 1.0F; + } + + var6.setColorOpaque_F(0.8F * var10, 0.8F * var10, 0.8F * var10); + this.renderBlockNorth(var1, var2, var3, var4, var1.getBlockTexture(this.blockAccess, var2, var3, var4, 2)); + var26 = true; + } + + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2, var3, var4 + 1, 3)) { + var10 = var1.getBlockBrightness(this.blockAccess, var2, var3, var4 + 1); + if(Block.lightValue[var1.blockID] > 0) { + var10 = 1.0F; + } + + var6.setColorOpaque_F(0.8F * var10, 0.8F * var10, 0.8F * var10); + this.renderBlockSouth(var1, var2, var3, var4, var1.getBlockTexture(this.blockAccess, var2, var3, var4, 3)); + var26 = true; + } + + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2 - 1, var3, var4, 4)) { + var10 = var1.getBlockBrightness(this.blockAccess, var2 - 1, var3, var4); + if(Block.lightValue[var1.blockID] > 0) { + var10 = 1.0F; + } + + var6.setColorOpaque_F(0.6F * var10, 0.6F * var10, 0.6F * var10); + this.renderBlockWest(var1, var2, var3, var4, var1.getBlockTexture(this.blockAccess, var2, var3, var4, 4)); + var26 = true; + } + + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2 + 1, var3, var4, 5)) { + var10 = var1.getBlockBrightness(this.blockAccess, var2 + 1, var3, var4); + if(Block.lightValue[var1.blockID] > 0) { + var10 = 1.0F; + } + + var6.setColorOpaque_F(0.6F * var10, 0.6F * var10, 0.6F * var10); + this.renderBlockEast(var1, var2, var3, var4, var1.getBlockTexture(this.blockAccess, var2, var3, var4, 5)); + var26 = true; + } + + return var26; + } else { + float var11; + float var22; + if(var5 == 4) { + var6 = Tessellator.instance; + var26 = false; + var10 = var1.minY; + var11 = var1.maxY; + var1.maxY = var11 - this.materialNotWater(var2, var3, var4); + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2, var3 - 1, var4, 0)) { + var22 = var1.getBlockBrightness(this.blockAccess, var2, var3 - 1, var4); + var6.setColorOpaque_F(0.5F * var22, 0.5F * var22, 0.5F * var22); + this.renderBlockBottom(var1, (float)var2, (float)var3, (float)var4, var1.getBlockTextureFromSide(0)); + var26 = true; + } + + if(this.renderAllFaces || var1.shouldSideBeRendered(this.blockAccess, var2, var3 + 1, var4, 1)) { + var22 = var1.getBlockBrightness(this.blockAccess, var2, var3 + 1, var4); + var6.setColorOpaque_F(var22 * 1.0F, var22 * 1.0F, var22 * 1.0F); + this.renderBlockTop(var1, (float)var2, (float)var3, (float)var4, var1.getBlockTextureFromSide(1)); + var26 = true; + } + + var1.minY = var11 - this.materialNotWater(var2, var3, var4 - 1); + if(this.renderAllFaces || var1.maxY > var1.minY || var1.shouldSideBeRendered(this.blockAccess, var2, var3, var4 - 1, 2)) { + var22 = var1.getBlockBrightness(this.blockAccess, var2, var3, var4 - 1); + var6.setColorOpaque_F(0.8F * var22, 0.8F * var22, 0.8F * var22); + this.renderBlockNorth(var1, var2, var3, var4, var1.getBlockTextureFromSide(2)); + var26 = true; + } + + var1.minY = var11 - this.materialNotWater(var2, var3, var4 + 1); + if(this.renderAllFaces || var1.maxY > var1.minY || var1.shouldSideBeRendered(this.blockAccess, var2, var3, var4 + 1, 3)) { + var22 = var1.getBlockBrightness(this.blockAccess, var2, var3, var4 + 1); + var6.setColorOpaque_F(0.8F * var22, 0.8F * var22, 0.8F * var22); + this.renderBlockSouth(var1, var2, var3, var4, var1.getBlockTextureFromSide(3)); + var26 = true; + } + + var1.minY = var11 - this.materialNotWater(var2 - 1, var3, var4); + if(this.renderAllFaces || var1.maxY > var1.minY || var1.shouldSideBeRendered(this.blockAccess, var2 - 1, var3, var4, 4)) { + var22 = var1.getBlockBrightness(this.blockAccess, var2 - 1, var3, var4); + var6.setColorOpaque_F(0.6F * var22, 0.6F * var22, 0.6F * var22); + this.renderBlockWest(var1, var2, var3, var4, var1.getBlockTextureFromSide(4)); + var26 = true; + } + + var1.minY = var11 - this.materialNotWater(var2 + 1, var3, var4); + if(this.renderAllFaces || var1.maxY > var1.minY || var1.shouldSideBeRendered(this.blockAccess, var2 + 1, var3, var4, 5)) { + var22 = var1.getBlockBrightness(this.blockAccess, var2 + 1, var3, var4); + var6.setColorOpaque_F(0.6F * var22, 0.6F * var22, 0.6F * var22); + this.renderBlockEast(var1, var2, var3, var4, var1.getBlockTextureFromSide(5)); + var26 = true; + } + + var1.minY = var10; + var1.maxY = var11; + return var26; + } else if(var5 == 1) { + var6 = Tessellator.instance; + var22 = var1.getBlockBrightness(this.blockAccess, var2, var3, var4); + var6.setColorOpaque_F(var22, var22, var22); + this.renderBlockPlant(var1, this.blockAccess.getBlockMetadata(var2, var3, var4), (float)var2, (float)var3, (float)var4); + return true; + } else if(var5 == 6) { + var6 = Tessellator.instance; + var22 = var1.getBlockBrightness(this.blockAccess, var2, var3, var4); + var6.setColorOpaque_F(var22, var22, var22); + this.renderBlockCrops(var1, this.blockAccess.getBlockMetadata(var2, var3, var4), (float)var2, (float)var3 - 1.0F / 16.0F, (float)var4); + return true; + } else { + float var8; + if(var5 == 2) { + byte var21 = this.blockAccess.getBlockMetadata(var2, var3, var4); + Tessellator var25 = Tessellator.instance; + var8 = var1.getBlockBrightness(this.blockAccess, var2, var3, var4); + if(Block.lightValue[var1.blockID] > 0) { + var8 = 1.0F; + } + + var25.setColorOpaque_F(var8, var8, var8); + if(var21 == 1) { + this.renderBlockTorch(var1, (float)var2 - 10.0F * 0.01F, (float)var3 + 0.2F, (float)var4, -0.4F, 0.0F); + } else if(var21 == 2) { + this.renderBlockTorch(var1, (float)var2 + 10.0F * 0.01F, (float)var3 + 0.2F, (float)var4, 0.4F, 0.0F); + } else if(var21 == 3) { + this.renderBlockTorch(var1, (float)var2, (float)var3 + 0.2F, (float)var4 - 10.0F * 0.01F, 0.0F, -0.4F); + } else if(var21 == 4) { + this.renderBlockTorch(var1, (float)var2, (float)var3 + 0.2F, (float)var4 + 10.0F * 0.01F, 0.0F, 0.4F); + } else { + this.renderBlockTorch(var1, (float)var2, (float)var3, (float)var4, 0.0F, 0.0F); + } + + return true; + } else { + int var7; + float var12; + float var13; + float var14; + float var15; + int var23; + if(var5 == 3) { + var5 = var4; + var4 = var3; + var3 = var2; + var6 = Tessellator.instance; + var7 = var1.getBlockTextureFromSide(0); + if(this.overrideBlockTexture >= 0) { + var7 = this.overrideBlockTexture; + } + + var8 = var1.getBlockBrightness(this.blockAccess, var2, var4, var5); + var6.setColorOpaque_F(var8, var8, var8); + var2 = (var7 & 15) << 4; + var23 = var7 & 240; + float var24 = (float)var2 / 256.0F; + var10 = ((float)var2 + 15.99F) / 256.0F; + var11 = (float)var23 / 256.0F; + var22 = ((float)var23 + 15.99F) / 256.0F; + float var16; + float var19; + if(!this.blockAccess.isBlockNormalCube(var3, var4 - 1, var5) && !Block.fire.canBlockCatchFire(this.blockAccess, var3, var4 - 1, var5)) { + if((var3 + var4 + var5 & 1) == 1) { + var24 = (float)var2 / 256.0F; + var10 = ((float)var2 + 15.99F) / 256.0F; + var11 = (float)(var23 + 16) / 256.0F; + var22 = ((float)var23 + 15.99F + 16.0F) / 256.0F; + } + + if((var3 / 2 + var4 / 2 + var5 / 2 & 1) == 1) { + var14 = var10; + var10 = var24; + var24 = var14; + } + + if(Block.fire.canBlockCatchFire(this.blockAccess, var3 - 1, var4, var5)) { + var6.addVertexWithUV((float)var3 + 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1), var10, var11); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)var5, var24, var22); + var6.addVertexWithUV((float)var3 + 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5, var24, var11); + var6.addVertexWithUV((float)var3 + 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5, var24, var11); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)var5, var24, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV((float)var3 + 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1), var10, var11); + } + + if(Block.fire.canBlockCatchFire(this.blockAccess, var3 + 1, var4, var5)) { + var6.addVertexWithUV((float)(var3 + 1) - 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5, var24, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)var5, var24, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV((float)(var3 + 1) - 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1), var10, var11); + var6.addVertexWithUV((float)(var3 + 1) - 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1), var10, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)var5, var24, var22); + var6.addVertexWithUV((float)(var3 + 1) - 0.2F, (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5, var24, var11); + } + + if(Block.fire.canBlockCatchFire(this.blockAccess, var3, var4, var5 - 1)) { + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5 + 0.2F, var10, var11); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)var5, var10, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)var5, var24, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5 + 0.2F, var24, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5 + 0.2F, var24, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)var5, var24, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)var5, var10, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F + 1.0F / 16.0F, (float)var5 + 0.2F, var10, var11); + } + + if(Block.fire.canBlockCatchFire(this.blockAccess, var3, var4, var5 + 1)) { + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1) - 0.2F, var24, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var24, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1) - 0.2F, var10, var11); + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1) - 0.2F, var10, var11); + var6.addVertexWithUV((float)var3, (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.0F / 16.0F, (float)(var5 + 1), var24, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F + 1.0F / 16.0F, (float)(var5 + 1) - 0.2F, var24, var11); + } + + if(Block.fire.canBlockCatchFire(this.blockAccess, var3, var4 + 1, var5)) { + var14 = (float)var3 + 0.5F + 0.5F; + var15 = (float)var3 + 0.5F - 0.5F; + var19 = (float)var5 + 0.5F + 0.5F; + var16 = (float)var5 + 0.5F - 0.5F; + var24 = (float)var2 / 256.0F; + var10 = ((float)var2 + 15.99F) / 256.0F; + var11 = (float)var23 / 256.0F; + var22 = ((float)var23 + 15.99F) / 256.0F; + ++var4; + if((var3 + var4 + var5 & 1) == 0) { + var6.addVertexWithUV(var15, (float)var4 + -0.2F, (float)var5, var10, var11); + var6.addVertexWithUV(var14, (float)var4, (float)var5, var10, var22); + var6.addVertexWithUV(var14, (float)var4, (float)(var5 + 1), var24, var22); + var6.addVertexWithUV(var15, (float)var4 + -0.2F, (float)(var5 + 1), var24, var11); + var24 = (float)var2 / 256.0F; + var10 = ((float)var2 + 15.99F) / 256.0F; + var11 = (float)(var23 + 16) / 256.0F; + var22 = ((float)var23 + 15.99F + 16.0F) / 256.0F; + var6.addVertexWithUV(var14, (float)var4 + -0.2F, (float)(var5 + 1), var10, var11); + var6.addVertexWithUV(var15, (float)var4, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV(var15, (float)var4, (float)var5, var24, var22); + var6.addVertexWithUV(var14, (float)var4 + -0.2F, (float)var5, var24, var11); + } else { + var6.addVertexWithUV((float)var3, (float)var4 + -0.2F, var19, var10, var11); + var6.addVertexWithUV((float)var3, (float)var4, var16, var10, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4, var16, var24, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + -0.2F, var19, var24, var11); + var24 = (float)var2 / 256.0F; + var10 = ((float)var2 + 15.99F) / 256.0F; + var11 = (float)(var23 + 16) / 256.0F; + var22 = ((float)var23 + 15.99F + 16.0F) / 256.0F; + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + -0.2F, var16, var10, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4, var19, var10, var22); + var6.addVertexWithUV((float)var3, (float)var4, var19, var24, var22); + var6.addVertexWithUV((float)var3, (float)var4 + -0.2F, var16, var24, var11); + } + } + } else { + var12 = (float)var3 + 0.5F + 0.2F; + var13 = (float)var3 + 0.5F - 0.2F; + var14 = (float)var5 + 0.5F + 0.2F; + var15 = (float)var5 + 0.5F - 0.2F; + var19 = (float)var3 + 0.5F - 0.3F; + var16 = (float)var3 + 0.5F + 0.3F; + float var17 = (float)var5 + 0.5F - 0.3F; + float var18 = (float)var5 + 0.5F + 0.3F; + var6.addVertexWithUV(var19, (float)var4 + 1.4F, (float)(var5 + 1), var10, var11); + var6.addVertexWithUV(var12, (float)var4, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV(var12, (float)var4, (float)var5, var24, var22); + var6.addVertexWithUV(var19, (float)var4 + 1.4F, (float)var5, var24, var11); + var6.addVertexWithUV(var16, (float)var4 + 1.4F, (float)var5, var10, var11); + var6.addVertexWithUV(var13, (float)var4, (float)var5, var10, var22); + var6.addVertexWithUV(var13, (float)var4, (float)(var5 + 1), var24, var22); + var6.addVertexWithUV(var16, (float)var4 + 1.4F, (float)(var5 + 1), var24, var11); + var24 = (float)var2 / 256.0F; + var10 = ((float)var2 + 15.99F) / 256.0F; + var11 = (float)(var23 + 16) / 256.0F; + var22 = ((float)var23 + 15.99F + 16.0F) / 256.0F; + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F, var18, var10, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4, var15, var10, var22); + var6.addVertexWithUV((float)var3, (float)var4, var15, var24, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F, var18, var24, var11); + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F, var17, var10, var11); + var6.addVertexWithUV((float)var3, (float)var4, var14, var10, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4, var14, var24, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F, var17, var24, var11); + var12 = (float)var3 + 0.5F - 0.5F; + var13 = (float)var3 + 0.5F + 0.5F; + var14 = (float)var5 + 0.5F - 0.5F; + var15 = (float)var5 + 0.5F + 0.5F; + var19 = (float)var3 + 0.5F - 0.4F; + var16 = (float)var3 + 0.5F + 0.4F; + var17 = (float)var5 + 0.5F - 0.4F; + var18 = (float)var5 + 0.5F + 0.4F; + var6.addVertexWithUV(var19, (float)var4 + 1.4F, (float)var5, var24, var11); + var6.addVertexWithUV(var12, (float)var4, (float)var5, var24, var22); + var6.addVertexWithUV(var12, (float)var4, (float)(var5 + 1), var10, var22); + var6.addVertexWithUV(var19, (float)var4 + 1.4F, (float)(var5 + 1), var10, var11); + var6.addVertexWithUV(var16, (float)var4 + 1.4F, (float)(var5 + 1), var24, var11); + var6.addVertexWithUV(var13, (float)var4, (float)(var5 + 1), var24, var22); + var6.addVertexWithUV(var13, (float)var4, (float)var5, var10, var22); + var6.addVertexWithUV(var16, (float)var4 + 1.4F, (float)var5, var10, var11); + var24 = (float)var2 / 256.0F; + var10 = ((float)var2 + 15.99F) / 256.0F; + var11 = (float)var23 / 256.0F; + var22 = ((float)var23 + 15.99F) / 256.0F; + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F, var18, var24, var11); + var6.addVertexWithUV((float)var3, (float)var4, var15, var24, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4, var15, var10, var22); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F, var18, var10, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4 + 1.4F, var17, var24, var11); + var6.addVertexWithUV((float)(var3 + 1), (float)var4, var14, var24, var22); + var6.addVertexWithUV((float)var3, (float)var4, var14, var10, var22); + var6.addVertexWithUV((float)var3, (float)var4 + 1.4F, var17, var10, var11); + } + + return true; + } else if(var5 == 5) { + var5 = var4; + var4 = var3; + var3 = var2; + var6 = Tessellator.instance; + var7 = var1.getBlockTextureFromSide(0); + if(this.overrideBlockTexture >= 0) { + var7 = this.overrideBlockTexture; + } + + var8 = var1.getBlockBrightness(this.blockAccess, var2, var4, var5); + var6.setColorOpaque_F(var8, var8, var8); + var2 = ((var7 & 15) << 4) + 16; + var23 = (var7 & 15) << 4; + int var9 = var7 & 240; + if((var3 + var4 + var5 & 1) == 1) { + var2 = (var7 & 15) << 4; + var23 = ((var7 & 15) << 4) + 16; + } + + var10 = (float)var2 / 256.0F; + var11 = ((float)var2 + 15.99F) / 256.0F; + var22 = (float)var9 / 256.0F; + float var20 = ((float)var9 + 15.99F) / 256.0F; + var12 = (float)var23 / 256.0F; + var13 = ((float)var23 + 15.99F) / 256.0F; + var14 = (float)var9 / 256.0F; + var15 = ((float)var9 + 15.99F) / 256.0F; + if(this.blockAccess.isBlockNormalCube(var3 - 1, var4, var5)) { + var6.addVertexWithUV((float)var3 + 0.05F, (float)(var4 + 1) + 2.0F / 16.0F, (float)(var5 + 1) + 2.0F / 16.0F, var10, var22); + var6.addVertexWithUV((float)var3 + 0.05F, (float)var4 - 2.0F / 16.0F, (float)(var5 + 1) + 2.0F / 16.0F, var10, var20); + var6.addVertexWithUV((float)var3 + 0.05F, (float)var4 - 2.0F / 16.0F, (float)var5 - 2.0F / 16.0F, var11, var20); + var6.addVertexWithUV((float)var3 + 0.05F, (float)(var4 + 1) + 2.0F / 16.0F, (float)var5 - 2.0F / 16.0F, var11, var22); + } + + if(this.blockAccess.isBlockNormalCube(var3 + 1, var4, var5)) { + var6.addVertexWithUV((float)(var3 + 1) - 0.05F, (float)var4 - 2.0F / 16.0F, (float)(var5 + 1) + 2.0F / 16.0F, var11, var20); + var6.addVertexWithUV((float)(var3 + 1) - 0.05F, (float)(var4 + 1) + 2.0F / 16.0F, (float)(var5 + 1) + 2.0F / 16.0F, var11, var22); + var6.addVertexWithUV((float)(var3 + 1) - 0.05F, (float)(var4 + 1) + 2.0F / 16.0F, (float)var5 - 2.0F / 16.0F, var10, var22); + var6.addVertexWithUV((float)(var3 + 1) - 0.05F, (float)var4 - 2.0F / 16.0F, (float)var5 - 2.0F / 16.0F, var10, var20); + } + + if(this.blockAccess.isBlockNormalCube(var3, var4, var5 - 1)) { + var6.addVertexWithUV((float)(var3 + 1) + 2.0F / 16.0F, (float)var4 - 2.0F / 16.0F, (float)var5 + 0.05F, var13, var15); + var6.addVertexWithUV((float)(var3 + 1) + 2.0F / 16.0F, (float)(var4 + 1) + 2.0F / 16.0F, (float)var5 + 0.05F, var13, var14); + var6.addVertexWithUV((float)var3 - 2.0F / 16.0F, (float)(var4 + 1) + 2.0F / 16.0F, (float)var5 + 0.05F, var12, var14); + var6.addVertexWithUV((float)var3 - 2.0F / 16.0F, (float)var4 - 2.0F / 16.0F, (float)var5 + 0.05F, var12, var15); + } + + if(this.blockAccess.isBlockNormalCube(var3, var4, var5 + 1)) { + var6.addVertexWithUV((float)(var3 + 1) + 2.0F / 16.0F, (float)(var4 + 1) + 2.0F / 16.0F, (float)(var5 + 1) - 0.05F, var12, var14); + var6.addVertexWithUV((float)(var3 + 1) + 2.0F / 16.0F, (float)var4 - 2.0F / 16.0F, (float)(var5 + 1) - 0.05F, var12, var15); + var6.addVertexWithUV((float)var3 - 2.0F / 16.0F, (float)var4 - 2.0F / 16.0F, (float)(var5 + 1) - 0.05F, var13, var15); + var6.addVertexWithUV((float)var3 - 2.0F / 16.0F, (float)(var4 + 1) + 2.0F / 16.0F, (float)(var5 + 1) - 0.05F, var13, var14); + } + + return true; + } else { + return false; + } + } + } + } + } + + private void renderBlockTorch(Block var1, float var2, float var3, float var4, float var5, float var6) { + Tessellator var7 = Tessellator.instance; + int var19 = var1.getBlockTextureFromSide(0); + if(this.overrideBlockTexture >= 0) { + var19 = this.overrideBlockTexture; + } + + int var8 = (var19 & 15) << 4; + var19 &= 240; + float var9 = (float)var8 / 256.0F; + float var21 = ((float)var8 + 15.99F) / 256.0F; + float var10 = (float)var19 / 256.0F; + float var20 = ((float)var19 + 15.99F) / 256.0F; + float var11 = var9 + 0.02734375F; + float var12 = var10 + 0.0234375F; + float var13 = var9 + 0.03515625F; + float var14 = var10 + 0.03125F; + var2 += 0.5F; + var4 += 0.5F; + float var15 = var2 - 0.5F; + float var16 = var2 + 0.5F; + float var17 = var4 - 0.5F; + float var18 = var4 + 0.5F; + var7.addVertexWithUV(var2 + var5 * (6.0F / 16.0F) - 1.0F / 16.0F, var3 + 10.0F / 16.0F, var4 + var6 * (6.0F / 16.0F) - 1.0F / 16.0F, var11, var12); + var7.addVertexWithUV(var2 + var5 * (6.0F / 16.0F) - 1.0F / 16.0F, var3 + 10.0F / 16.0F, var4 + var6 * (6.0F / 16.0F) + 1.0F / 16.0F, var11, var14); + var7.addVertexWithUV(var2 + var5 * (6.0F / 16.0F) + 1.0F / 16.0F, var3 + 10.0F / 16.0F, var4 + var6 * (6.0F / 16.0F) + 1.0F / 16.0F, var13, var14); + var7.addVertexWithUV(var2 + var5 * (6.0F / 16.0F) + 1.0F / 16.0F, var3 + 10.0F / 16.0F, var4 + var6 * (6.0F / 16.0F) - 1.0F / 16.0F, var13, var12); + var7.addVertexWithUV(var2 - 1.0F / 16.0F, var3 + 1.0F, var17, var9, var10); + var7.addVertexWithUV(var2 - 1.0F / 16.0F + var5, var3, var17 + var6, var9, var20); + var7.addVertexWithUV(var2 - 1.0F / 16.0F + var5, var3, var18 + var6, var21, var20); + var7.addVertexWithUV(var2 - 1.0F / 16.0F, var3 + 1.0F, var18, var21, var10); + var7.addVertexWithUV(var2 + 1.0F / 16.0F, var3 + 1.0F, var18, var9, var10); + var7.addVertexWithUV(var2 + var5 + 1.0F / 16.0F, var3, var18 + var6, var9, var20); + var7.addVertexWithUV(var2 + var5 + 1.0F / 16.0F, var3, var17 + var6, var21, var20); + var7.addVertexWithUV(var2 + 1.0F / 16.0F, var3 + 1.0F, var17, var21, var10); + var7.addVertexWithUV(var15, var3 + 1.0F, var4 + 1.0F / 16.0F, var9, var10); + var7.addVertexWithUV(var15 + var5, var3, var4 + 1.0F / 16.0F + var6, var9, var20); + var7.addVertexWithUV(var16 + var5, var3, var4 + 1.0F / 16.0F + var6, var21, var20); + var7.addVertexWithUV(var16, var3 + 1.0F, var4 + 1.0F / 16.0F, var21, var10); + var7.addVertexWithUV(var16, var3 + 1.0F, var4 - 1.0F / 16.0F, var9, var10); + var7.addVertexWithUV(var16 + var5, var3, var4 - 1.0F / 16.0F + var6, var9, var20); + var7.addVertexWithUV(var15 + var5, var3, var4 - 1.0F / 16.0F + var6, var21, var20); + var7.addVertexWithUV(var15, var3 + 1.0F, var4 - 1.0F / 16.0F, var21, var10); + } + + private void renderBlockPlant(Block var1, int var2, float var3, float var4, float var5) { + Tessellator var6 = Tessellator.instance; + int var11 = var1.getBlockTextureFromSideAndMetadata(0, var2); + if(this.overrideBlockTexture >= 0) { + var11 = this.overrideBlockTexture; + } + + var2 = (var11 & 15) << 4; + var11 &= 240; + float var7 = (float)var2 / 256.0F; + float var12 = ((float)var2 + 15.99F) / 256.0F; + float var8 = (float)var11 / 256.0F; + float var13 = ((float)var11 + 15.99F) / 256.0F; + float var9 = var3 + 0.5F - 0.45F; + var3 = var3 + 0.5F + 0.45F; + float var10 = var5 + 0.5F - 0.45F; + var5 = var5 + 0.5F + 0.45F; + var6.addVertexWithUV(var9, var4 + 1.0F, var10, var7, var8); + var6.addVertexWithUV(var9, var4, var10, var7, var13); + var6.addVertexWithUV(var3, var4, var5, var12, var13); + var6.addVertexWithUV(var3, var4 + 1.0F, var5, var12, var8); + var6.addVertexWithUV(var3, var4 + 1.0F, var5, var7, var8); + var6.addVertexWithUV(var3, var4, var5, var7, var13); + var6.addVertexWithUV(var9, var4, var10, var12, var13); + var6.addVertexWithUV(var9, var4 + 1.0F, var10, var12, var8); + var6.addVertexWithUV(var9, var4 + 1.0F, var5, var7, var8); + var6.addVertexWithUV(var9, var4, var5, var7, var13); + var6.addVertexWithUV(var3, var4, var10, var12, var13); + var6.addVertexWithUV(var3, var4 + 1.0F, var10, var12, var8); + var6.addVertexWithUV(var3, var4 + 1.0F, var10, var7, var8); + var6.addVertexWithUV(var3, var4, var10, var7, var13); + var6.addVertexWithUV(var9, var4, var5, var12, var13); + var6.addVertexWithUV(var9, var4 + 1.0F, var5, var12, var8); + } + + private void renderBlockCrops(Block var1, int var2, float var3, float var4, float var5) { + Tessellator var6 = Tessellator.instance; + int var13 = var1.getBlockTextureFromSideAndMetadata(0, var2); + if(this.overrideBlockTexture >= 0) { + var13 = this.overrideBlockTexture; + } + + var2 = (var13 & 15) << 4; + var13 &= 240; + float var7 = (float)var2 / 256.0F; + float var14 = ((float)var2 + 15.99F) / 256.0F; + float var8 = (float)var13 / 256.0F; + float var15 = ((float)var13 + 15.99F) / 256.0F; + float var9 = var3 + 0.5F - 0.25F; + float var10 = var3 + 0.5F + 0.25F; + float var11 = var5 + 0.5F - 0.5F; + float var12 = var5 + 0.5F + 0.5F; + var6.addVertexWithUV(var9, var4 + 1.0F, var11, var7, var8); + var6.addVertexWithUV(var9, var4, var11, var7, var15); + var6.addVertexWithUV(var9, var4, var12, var14, var15); + var6.addVertexWithUV(var9, var4 + 1.0F, var12, var14, var8); + var6.addVertexWithUV(var9, var4 + 1.0F, var12, var7, var8); + var6.addVertexWithUV(var9, var4, var12, var7, var15); + var6.addVertexWithUV(var9, var4, var11, var14, var15); + var6.addVertexWithUV(var9, var4 + 1.0F, var11, var14, var8); + var6.addVertexWithUV(var10, var4 + 1.0F, var12, var7, var8); + var6.addVertexWithUV(var10, var4, var12, var7, var15); + var6.addVertexWithUV(var10, var4, var11, var14, var15); + var6.addVertexWithUV(var10, var4 + 1.0F, var11, var14, var8); + var6.addVertexWithUV(var10, var4 + 1.0F, var11, var7, var8); + var6.addVertexWithUV(var10, var4, var11, var7, var15); + var6.addVertexWithUV(var10, var4, var12, var14, var15); + var6.addVertexWithUV(var10, var4 + 1.0F, var12, var14, var8); + var9 = var3 + 0.5F - 0.5F; + var10 = var3 + 0.5F + 0.5F; + var11 = var5 + 0.5F - 0.25F; + var12 = var5 + 0.5F + 0.25F; + var6.addVertexWithUV(var9, var4 + 1.0F, var11, var7, var8); + var6.addVertexWithUV(var9, var4, var11, var7, var15); + var6.addVertexWithUV(var10, var4, var11, var14, var15); + var6.addVertexWithUV(var10, var4 + 1.0F, var11, var14, var8); + var6.addVertexWithUV(var10, var4 + 1.0F, var11, var7, var8); + var6.addVertexWithUV(var10, var4, var11, var7, var15); + var6.addVertexWithUV(var9, var4, var11, var14, var15); + var6.addVertexWithUV(var9, var4 + 1.0F, var11, var14, var8); + var6.addVertexWithUV(var10, var4 + 1.0F, var12, var7, var8); + var6.addVertexWithUV(var10, var4, var12, var7, var15); + var6.addVertexWithUV(var9, var4, var12, var14, var15); + var6.addVertexWithUV(var9, var4 + 1.0F, var12, var14, var8); + var6.addVertexWithUV(var9, var4 + 1.0F, var12, var7, var8); + var6.addVertexWithUV(var9, var4, var12, var7, var15); + var6.addVertexWithUV(var10, var4, var12, var14, var15); + var6.addVertexWithUV(var10, var4 + 1.0F, var12, var14, var8); + } + + private float materialNotWater(int var1, int var2, int var3) { + return this.blockAccess.getBlockMaterial(var1, var2, var3) != Material.water ? 1.0F : (float)this.blockAccess.getBlockMetadata(var1, var2, var3) / 9.0F; + } + + private void renderBlockBottom(Block var1, float var2, float var3, float var4, int var5) { + Tessellator var6 = Tessellator.instance; + if(this.overrideBlockTexture >= 0) { + var5 = this.overrideBlockTexture; + } + + int var7 = (var5 & 15) << 4; + var5 &= 240; + float var8 = (float)var7 / 256.0F; + float var14 = ((float)var7 + 15.99F) / 256.0F; + float var9 = (float)var5 / 256.0F; + float var13 = ((float)var5 + 15.99F) / 256.0F; + float var10 = var2 + var1.minX; + var2 += var1.maxX; + var3 += var1.minY; + float var11 = var4 + var1.minZ; + float var12 = var4 + var1.maxZ; + var6.addVertexWithUV(var10, var3, var12, var8, var13); + var6.addVertexWithUV(var10, var3, var11, var8, var9); + var6.addVertexWithUV(var2, var3, var11, var14, var9); + var6.addVertexWithUV(var2, var3, var12, var14, var13); + } + + private void renderBlockTop(Block var1, float var2, float var3, float var4, int var5) { + Tessellator var6 = Tessellator.instance; + if(this.overrideBlockTexture >= 0) { + var5 = this.overrideBlockTexture; + } + + int var7 = (var5 & 15) << 4; + var5 &= 240; + float var8 = (float)var7 / 256.0F; + float var14 = ((float)var7 + 15.99F) / 256.0F; + float var9 = (float)var5 / 256.0F; + float var13 = ((float)var5 + 15.99F) / 256.0F; + float var10 = var2 + var1.minX; + var2 += var1.maxX; + var3 += var1.maxY; + float var11 = var4 + var1.minZ; + float var12 = var4 + var1.maxZ; + var6.addVertexWithUV(var2, var3, var12, var14, var13); + var6.addVertexWithUV(var2, var3, var11, var14, var9); + var6.addVertexWithUV(var10, var3, var11, var8, var9); + var6.addVertexWithUV(var10, var3, var12, var8, var13); + } + + private void renderBlockNorth(Block var1, int var2, int var3, int var4, int var5) { + Tessellator var6 = Tessellator.instance; + if(this.overrideBlockTexture >= 0) { + var5 = this.overrideBlockTexture; + } + + int var7 = (var5 & 15) << 4; + var5 &= 240; + float var8 = (float)var7 / 256.0F; + float var16 = ((float)var7 + 15.99F) / 256.0F; + float var9; + float var15; + if(var1.minY >= 0.0F && var1.maxY <= 1.0F) { + var9 = ((float)var5 + var1.minY * 15.99F) / 256.0F; + var15 = ((float)var5 + var1.maxY * 15.99F) / 256.0F; + } else { + var9 = (float)var5 / 256.0F; + var15 = ((float)var5 + 15.99F) / 256.0F; + } + + float var10 = (float)var2 + var1.minX; + float var13 = (float)var2 + var1.maxX; + float var11 = (float)var3 + var1.minY; + float var14 = (float)var3 + var1.maxY; + float var12 = (float)var4 + var1.minZ; + var6.addVertexWithUV(var10, var14, var12, var16, var9); + var6.addVertexWithUV(var13, var14, var12, var8, var9); + var6.addVertexWithUV(var13, var11, var12, var8, var15); + var6.addVertexWithUV(var10, var11, var12, var16, var15); + } + + private void renderBlockSouth(Block var1, int var2, int var3, int var4, int var5) { + Tessellator var6 = Tessellator.instance; + if(this.overrideBlockTexture >= 0) { + var5 = this.overrideBlockTexture; + } + + int var7 = (var5 & 15) << 4; + var5 &= 240; + float var8 = (float)var7 / 256.0F; + float var16 = ((float)var7 + 15.99F) / 256.0F; + float var9; + float var15; + if(var1.minY >= 0.0F && var1.maxY <= 1.0F) { + var9 = ((float)var5 + var1.minY * 15.99F) / 256.0F; + var15 = ((float)var5 + var1.maxY * 15.99F) / 256.0F; + } else { + var9 = (float)var5 / 256.0F; + var15 = ((float)var5 + 15.99F) / 256.0F; + } + + float var10 = (float)var2 + var1.minX; + float var13 = (float)var2 + var1.maxX; + float var11 = (float)var3 + var1.minY; + float var14 = (float)var3 + var1.maxY; + float var12 = (float)var4 + var1.maxZ; + var6.addVertexWithUV(var10, var14, var12, var8, var9); + var6.addVertexWithUV(var10, var11, var12, var8, var15); + var6.addVertexWithUV(var13, var11, var12, var16, var15); + var6.addVertexWithUV(var13, var14, var12, var16, var9); + } + + private void renderBlockWest(Block var1, int var2, int var3, int var4, int var5) { + Tessellator var6 = Tessellator.instance; + if(this.overrideBlockTexture >= 0) { + var5 = this.overrideBlockTexture; + } + + int var7 = (var5 & 15) << 4; + var5 &= 240; + float var8 = (float)var7 / 256.0F; + float var16 = ((float)var7 + 15.99F) / 256.0F; + float var9; + float var15; + if(var1.minY >= 0.0F && var1.maxY <= 1.0F) { + var9 = ((float)var5 + var1.minY * 15.99F) / 256.0F; + var15 = ((float)var5 + var1.maxY * 15.99F) / 256.0F; + } else { + var9 = (float)var5 / 256.0F; + var15 = ((float)var5 + 15.99F) / 256.0F; + } + + float var13 = (float)var2 + var1.minX; + float var10 = (float)var3 + var1.minY; + float var14 = (float)var3 + var1.maxY; + float var11 = (float)var4 + var1.minZ; + float var12 = (float)var4 + var1.maxZ; + var6.addVertexWithUV(var13, var14, var12, var16, var9); + var6.addVertexWithUV(var13, var14, var11, var8, var9); + var6.addVertexWithUV(var13, var10, var11, var8, var15); + var6.addVertexWithUV(var13, var10, var12, var16, var15); + } + + private void renderBlockEast(Block var1, int var2, int var3, int var4, int var5) { + Tessellator var6 = Tessellator.instance; + if(this.overrideBlockTexture >= 0) { + var5 = this.overrideBlockTexture; + } + + int var7 = (var5 & 15) << 4; + var5 &= 240; + float var8 = (float)var7 / 256.0F; + float var16 = ((float)var7 + 15.99F) / 256.0F; + float var9; + float var15; + if(var1.minY >= 0.0F && var1.maxY <= 1.0F) { + var9 = ((float)var5 + var1.minY * 15.99F) / 256.0F; + var15 = ((float)var5 + var1.maxY * 15.99F) / 256.0F; + } else { + var9 = (float)var5 / 256.0F; + var15 = ((float)var5 + 15.99F) / 256.0F; + } + + float var13 = (float)var2 + var1.maxX; + float var10 = (float)var3 + var1.minY; + float var14 = (float)var3 + var1.maxY; + float var11 = (float)var4 + var1.minZ; + float var12 = (float)var4 + var1.maxZ; + var6.addVertexWithUV(var13, var10, var12, var8, var15); + var6.addVertexWithUV(var13, var10, var11, var16, var15); + var6.addVertexWithUV(var13, var14, var11, var16, var9); + var6.addVertexWithUV(var13, var14, var12, var8, var9); + } + + public final void renderBlockOnInventory(Block var1) { + Tessellator var2 = Tessellator.instance; + int var3 = var1.getRenderType(); + if(var3 == 0) { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + var2.startDrawingQuads(); + Tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderBlockBottom(var1, 0.0F, 0.0F, 0.0F, var1.getBlockTextureFromSide(0)); + var2.draw(); + var2.startDrawingQuads(); + Tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderBlockTop(var1, 0.0F, 0.0F, 0.0F, var1.getBlockTextureFromSide(1)); + var2.draw(); + var2.startDrawingQuads(); + Tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderBlockNorth(var1, 0, 0, 0, var1.getBlockTextureFromSide(2)); + var2.draw(); + var2.startDrawingQuads(); + Tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderBlockSouth(var1, 0, 0, 0, var1.getBlockTextureFromSide(3)); + var2.draw(); + var2.startDrawingQuads(); + Tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderBlockWest(var1, 0, 0, 0, var1.getBlockTextureFromSide(4)); + var2.draw(); + var2.startDrawingQuads(); + Tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderBlockEast(var1, 0, 0, 0, var1.getBlockTextureFromSide(5)); + var2.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } else if(var3 == 1) { + var2.startDrawingQuads(); + Tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderBlockPlant(var1, -1, -0.5F, -0.5F, -0.5F); + var2.draw(); + } else if(var3 == 6) { + var2.startDrawingQuads(); + Tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderBlockCrops(var1, -1, -0.5F, -0.5F, -0.5F); + var2.draw(); + } else { + if(var3 == 2) { + var2.startDrawingQuads(); + Tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderBlockTorch(var1, -0.5F, -0.5F, -0.5F, 0.0F, 0.0F); + var2.draw(); + } + + } + } +} diff --git a/src/teavm/java/net/minecraft/client/render/RenderEngine.java b/src/teavm/java/net/minecraft/client/render/RenderEngine.java new file mode 100644 index 0000000..4d8ae39 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/RenderEngine.java @@ -0,0 +1,247 @@ +package net.minecraft.client.render; + +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.Iterator; +import java.util.List; +import java.util.Map; +import javax.imageio.ImageIO; +import net.minecraft.client.GameSettings; +import net.minecraft.client.render.texture.TextureFX; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +public class RenderEngine { + private HashMap textureMap = new HashMap(); + private HashMap textureContentsMap = new HashMap(); + private IntBuffer singleIntBuffer = BufferUtils.createIntBuffer(1); + private ByteBuffer imageData = BufferUtils.createByteBuffer(262144); + private List textureList = new ArrayList(); + private Map urlToImageDataMap = new HashMap(); + private GameSettings options; + private boolean clampTexture = false; + + public RenderEngine(GameSettings var1) { + this.options = var1; + } + + public final int getTexture(String var1) { + Integer var2 = (Integer)this.textureMap.get(var1); + if(var2 != null) { + return var2.intValue(); + } else { + try { + this.singleIntBuffer.clear(); + GL11.glGenTextures(this.singleIntBuffer); + int var4 = this.singleIntBuffer.get(0); + if(var1.startsWith("##")) { + this.setupTexture(unwrapImageByColumns(ImageIO.read(RenderEngine.class.getResourceAsStream(var1.substring(2)))), var4); + } else if(var1.startsWith("%%")) { + this.clampTexture = true; + this.setupTexture(ImageIO.read(RenderEngine.class.getResourceAsStream(var1.substring(2))), var4); + this.clampTexture = false; + } else { + this.setupTexture(ImageIO.read(RenderEngine.class.getResourceAsStream(var1)), var4); + } + + this.textureMap.put(var1, Integer.valueOf(var4)); + return var4; + } catch (IOException var3) { + throw new RuntimeException("!!"); + } + } + } + + private static BufferedImage unwrapImageByColumns(BufferedImage var0) { + int var1 = var0.getWidth() / 16; + BufferedImage var2 = new BufferedImage(16, var0.getHeight() * var1, 2); + Graphics var3 = var2.getGraphics(); + + for(int var4 = 0; var4 < var1; ++var4) { + var3.drawImage(var0, -var4 << 4, var4 * var0.getHeight(), (ImageObserver)null); + } + + var3.dispose(); + return var2; + } + + private void setupTexture(BufferedImage var1, int var2) { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + if(this.clampTexture) { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); + } else { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + } + + 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.options != null && this.options.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.imageData.clear(); + this.imageData.put(var5); + this.imageData.position(0).limit(var5.length); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, var2, var3, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)this.imageData); + } + + public final int getTextureForDownloadableImage(String var1, String var2) { + ThreadDownloadImageData var6 = (ThreadDownloadImageData)this.urlToImageDataMap.get(var1); + if(var6 != null && var6.image != null && !var6.textureSetupComplete) { + if(var6.textureName < 0) { + BufferedImage var4 = var6.image; + this.singleIntBuffer.clear(); + GL11.glGenTextures(this.singleIntBuffer); + int var5 = this.singleIntBuffer.get(0); + this.setupTexture(var4, var5); + this.textureContentsMap.put(Integer.valueOf(var5), var4); + var6.textureName = var5; + } else { + this.setupTexture(var6.image, var6.textureName); + } + + var6.textureSetupComplete = true; + } + + return var6 != null && var6.textureName >= 0 ? var6.textureName : this.getTexture(var2); + } + + public final ThreadDownloadImageData obtainImageData(String var1, ImageBufferDownload var2) { + ThreadDownloadImageData var3 = (ThreadDownloadImageData)this.urlToImageDataMap.get(var1); + if(var3 == null) { + this.urlToImageDataMap.put(var1, new ThreadDownloadImageData(var1, var2)); + } else { + ++var3.referenceCount; + } + + return var3; + } + + public final void releaseImageData(String var1) { + ThreadDownloadImageData var2 = (ThreadDownloadImageData)this.urlToImageDataMap.get(var1); + if(var2 != null) { + --var2.referenceCount; + if(var2.referenceCount == 0) { + if(var2.textureName >= 0) { + int var3 = var2.textureName; + this.textureContentsMap.remove(Integer.valueOf(var3)); + this.singleIntBuffer.clear(); + this.singleIntBuffer.put(var3); + this.singleIntBuffer.flip(); + GL11.glDeleteTextures(this.singleIntBuffer); + } + + this.urlToImageDataMap.remove(var1); + } + } + + } + + public final void registerTextureFX(TextureFX var1) { + this.textureList.add(var1); + var1.onTick(); + } + + public final void updateDynamicTextures() { + int var1; + TextureFX var2; + for(var1 = 0; var1 < this.textureList.size(); ++var1) { + var2 = (TextureFX)this.textureList.get(var1); + var2.anaglyphEnabled = this.options.anaglyph; + var2.onTick(); + this.imageData.clear(); + this.imageData.put(var2.imageData); + this.imageData.position(0).limit(var2.imageData.length); + GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, var2.iconIndex % 16 << 4, var2.iconIndex / 16 << 4, 16, 16, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)this.imageData); + } + + for(var1 = 0; var1 < this.textureList.size(); ++var1) { + var2 = (TextureFX)this.textureList.get(var1); + if(var2.textureId > 0) { + this.imageData.clear(); + this.imageData.put(var2.imageData); + this.imageData.position(0).limit(var2.imageData.length); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2.textureId); + GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)this.imageData); + } + } + + } + + public final void refreshTextures() { + Iterator var1 = this.textureContentsMap.keySet().iterator(); + + int var2; + BufferedImage var3; + while(var1.hasNext()) { + var2 = ((Integer)var1.next()).intValue(); + var3 = (BufferedImage)this.textureContentsMap.get(Integer.valueOf(var2)); + this.setupTexture(var3, var2); + } + + ThreadDownloadImageData var5; + for(var1 = this.urlToImageDataMap.values().iterator(); var1.hasNext(); var5.textureSetupComplete = false) { + var5 = (ThreadDownloadImageData)var1.next(); + } + + var1 = this.textureMap.keySet().iterator(); + + while(var1.hasNext()) { + String var6 = (String)var1.next(); + + try { + if(var6.startsWith("##")) { + var3 = unwrapImageByColumns(ImageIO.read(RenderEngine.class.getResourceAsStream(var6.substring(2)))); + } else if(var6.startsWith("%%")) { + this.clampTexture = true; + var3 = ImageIO.read(RenderEngine.class.getResourceAsStream(var6.substring(2))); + this.clampTexture = false; + } else { + var3 = ImageIO.read(RenderEngine.class.getResourceAsStream(var6)); + } + + var2 = ((Integer)this.textureMap.get(var6)).intValue(); + this.setupTexture(var3, var2); + } catch (IOException var4) { + var4.printStackTrace(); + } + } + + } + + public static void bindTexture(int var0) { + if(var0 >= 0) { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var0); + } + } +} diff --git a/src/teavm/java/net/minecraft/client/render/RenderGlobal.java b/src/teavm/java/net/minecraft/client/render/RenderGlobal.java new file mode 100644 index 0000000..31c7bfa --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/RenderGlobal.java @@ -0,0 +1,762 @@ +package net.minecraft.client.render; + +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.effect.EntityBubbleFX; +import net.minecraft.client.effect.EntityExplodeFX; +import net.minecraft.client.effect.EntityFlameFX; +import net.minecraft.client.effect.EntityLavaFX; +import net.minecraft.client.effect.EntitySmokeFX; +import net.minecraft.client.effect.EntitySplashFX; +import net.minecraft.client.render.camera.ICamera; +import net.minecraft.client.render.entity.RenderManager; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.EntityMap; +import net.minecraft.game.level.IWorldAccess; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.physics.AxisAlignedBB; +import net.minecraft.game.physics.MovingObjectPosition; +import net.minecraft.game.physics.Vec3D; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +public final class RenderGlobal implements IWorldAccess { + private World worldObj; + private RenderEngine renderEngine; + private int glGenList; + private IntBuffer renderIntBuffer = BufferUtils.createIntBuffer(65536); + private List worldRenderersToUpdate = new ArrayList(); + private WorldRenderer[] sortedWorldRenderers; + private WorldRenderer[] worldRenderers; + private int renderChunksWide; + private int renderChunksTall; + private int renderChunksDeep; + private int glRenderListBase; + private Minecraft mc; + private RenderBlocks globalRenderBlocks; + private IntBuffer glOcclusionQueryBase; + private boolean occlusionEnabled = false; + private int cloudOffsetX = 0; + private int glSkyList; + private int countEntitiesTotal; + private int countEntitiesRendered; + private int countEntitiesHidden; + private int[] dummyBuf50k = new int['\uc350']; + private IntBuffer occlusionResult = BufferUtils.createIntBuffer(64); + private int renderersLoaded; + private int renderersBeingClipped; + private int renderersBeingOccluded; + private int renderersBeingRendered; + private float prevSortX = -9999.0F; + private float prevSortY = -9999.0F; + private float prevSortZ = -9999.0F; + public float damagePartialTime; + + public RenderGlobal(Minecraft var1, RenderEngine var2) { + this.mc = var1; + this.renderEngine = var2; + this.glGenList = GL11.glGenLists(2); + this.glRenderListBase = GL11.glGenLists(786432); + this.occlusionEnabled = true; + if(this.occlusionEnabled) { + this.occlusionResult.clear(); + if(this.occlusionResult.get(0) == 0) { + this.occlusionEnabled = false; + } else { + this.glOcclusionQueryBase = BufferUtils.createIntBuffer(262144); + this.glOcclusionQueryBase.clear(); + this.glOcclusionQueryBase.position(0); + this.glOcclusionQueryBase.limit(262144); + } + } + + this.glSkyList = GL11.glGenLists(1); + GL11.glNewList(this.glSkyList, GL11.GL_COMPILE); + Random var5 = new Random(10842L); + + for(int var6 = 0; var6 < 500; ++var6) { + GL11.glRotatef(var5.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(var5.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(var5.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F); + Tessellator var3 = Tessellator.instance; + float var4 = 0.25F + var5.nextFloat() * 0.25F; + var3.startDrawingQuads(); + var3.addVertexWithUV(-var4, -100.0F, var4, 1.0F, 1.0F); + var3.addVertexWithUV(var4, -100.0F, var4, 0.0F, 1.0F); + var3.addVertexWithUV(var4, -100.0F, -var4, 0.0F, 0.0F); + var3.addVertexWithUV(-var4, -100.0F, -var4, 1.0F, 0.0F); + var3.draw(); + } + + GL11.glEndList(); + } + + public final void changeWorld(World var1) { + if(this.worldObj != null) { + this.worldObj.removeWorldAccess(this); + } + + this.prevSortX = -9999.0F; + this.prevSortY = -9999.0F; + this.prevSortZ = -9999.0F; + RenderManager.instance.set(var1); + this.worldObj = var1; + this.globalRenderBlocks = new RenderBlocks(var1); + if(var1 != null) { + var1.addWorldAccess(this); + this.loadRenderers(); + } + + } + + public final void loadRenderers() { + int var1; + if(this.worldRenderers != null) { + for(var1 = 0; var1 < this.worldRenderers.length; ++var1) { + this.worldRenderers[var1].stopRendering(); + } + } + + this.renderChunksWide = this.worldObj.width / 16; + this.renderChunksTall = this.worldObj.height / 16; + this.renderChunksDeep = this.worldObj.length / 16; + this.worldRenderers = new WorldRenderer[this.renderChunksWide * this.renderChunksTall * this.renderChunksDeep]; + this.sortedWorldRenderers = new WorldRenderer[this.renderChunksWide * this.renderChunksTall * this.renderChunksDeep]; + var1 = 0; + int var2 = 0; + + int var3; + for(var3 = 0; var3 < this.renderChunksWide; ++var3) { + for(int var4 = 0; var4 < this.renderChunksTall; ++var4) { + for(int var5 = 0; var5 < this.renderChunksDeep; ++var5) { + this.worldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3] = new WorldRenderer(this.worldObj, var3 << 4, var4 << 4, var5 << 4, 16, this.glRenderListBase + var1); + if(this.occlusionEnabled) { + this.worldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3].glOcclusionQuery = this.glOcclusionQueryBase.get(var2); + } + + ++var2; + this.sortedWorldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3] = this.worldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3]; + var1 += 3; + } + } + } + + for(var3 = 0; var3 < this.worldRenderersToUpdate.size(); ++var3) { + ((WorldRenderer)this.worldRenderersToUpdate.get(var3)).needsUpdate = false; + } + + this.worldRenderersToUpdate.clear(); + GL11.glNewList(this.glGenList, GL11.GL_COMPILE); + this.oobGroundRenderHeight(); + GL11.glEndList(); + GL11.glNewList(this.glGenList + 1, GL11.GL_COMPILE); + this.oobWaterRenderHeight(); + GL11.glEndList(); + this.markBlocksForUpdate(0, 0, 0, this.worldObj.width, this.worldObj.height, this.worldObj.length); + } + + public final void renderEntities(Vec3D var1, ICamera var2, float var3) { + EntityMap var4 = this.worldObj.entityMap; + RenderManager.instance.cacheActiveRenderInfo(this.worldObj, this.renderEngine, this.mc.thePlayer, var3); + this.countEntitiesTotal = 0; + this.countEntitiesRendered = 0; + this.countEntitiesHidden = 0; + + for(int var5 = 0; var5 < var4.width; ++var5) { + for(int var6 = 0; var6 < var4.depth; ++var6) { + for(int var7 = 0; var7 < var4.height; ++var7) { + List var8 = var4.entityGrid[(var7 * var4.depth + var6) * var4.width + var5]; + if(var8.size() != 0) { + int var9 = (var5 << 3) + 4; + int var10 = (var6 << 3) + 4; + int var11 = (var7 << 3) + 4; + this.countEntitiesTotal += var8.size(); + float var10001 = (float)var9; + float var10002 = (float)var10; + float var14 = (float)var11; + float var13 = var10002; + float var12 = var10001; + boolean var10000; + if(var12 >= 0.0F && var13 >= 0.0F && var14 >= 0.0F && var12 < (float)this.worldObj.width && var13 < (float)this.worldObj.height && var14 < (float)this.worldObj.length) { + int var17 = (int)(var12 / 16.0F); + int var19 = (int)(var13 / 16.0F); + int var20 = (int)(var14 / 16.0F); + var10000 = this.worldRenderers[(var20 * this.renderChunksTall + var19) * this.renderChunksWide + var17].isInFrustrum && this.worldRenderers[(var20 * this.renderChunksTall + var19) * this.renderChunksWide + var17].isVisible; + } else { + var10000 = true; + } + + if(!var10000) { + this.countEntitiesHidden += var8.size(); + } else { + for(var9 = 0; var9 < var8.size(); ++var9) { + Entity var15 = (Entity)var8.get(var9); + var13 = var15.posX - var1.xCoord; + var14 = var15.posY - var1.yCoord; + var12 = var15.posZ - var1.zCoord; + var13 = var13 * var13 + var14 * var14 + var12 * var12; + float var16 = var13; + AxisAlignedBB var18 = var15.boundingBox; + var13 = var18.maxX - var18.minX; + var14 = var18.maxY - var18.minY; + var12 = var18.maxZ - var18.minZ; + var12 = (var13 + var14 + var12) / 3.0F; + var12 *= 64.0F; + if(var16 < var12 * var12 && var2.isBoundingBoxInFrustrum(var15.boundingBox) && (var15 != this.worldObj.playerEntity || this.mc.options.thirdPersonView)) { + ++this.countEntitiesRendered; + RenderManager.instance.renderEntity(var15, var3); + } + } + } + } + } + } + } + + } + + public final String getDebugInfoRenders() { + return "C: " + this.renderersBeingRendered + "/" + this.renderersLoaded + ". F: " + this.renderersBeingClipped + ", O: " + this.renderersBeingOccluded; + } + + public final String getDebugInfoEntities() { + return "E: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal + ". B: " + this.countEntitiesHidden + ", I: " + (this.countEntitiesTotal - this.countEntitiesHidden - this.countEntitiesRendered); + } + + public final int sortAndRender(EntityPlayer var1, int var2) { + if(var2 == 0) { + this.renderersLoaded = 0; + this.renderersBeingClipped = 0; + this.renderersBeingOccluded = 0; + this.renderersBeingRendered = 0; + } + + float var3 = var1.posX - this.prevSortX; + float var4 = var1.posY - this.prevSortY; + float var5 = var1.posZ - this.prevSortZ; + if(var3 * var3 + var4 * var4 + var5 * var5 > 16.0F) { + this.prevSortX = var1.posX; + this.prevSortY = var1.posY; + this.prevSortZ = var1.posZ; + Arrays.sort(this.sortedWorldRenderers, new EntitySorter(var1)); + } + + int var8; + if(this.occlusionEnabled && var2 == 0) { + int var10 = 8; + this.checkOcclusionQueryResult(0, 8); + + int var6; + for(var6 = 0; var6 < 8; ++var6) { + this.sortedWorldRenderers[var6].isVisible = true; + } + + var8 = 0 + this.renderSortedRenderers(0, 8, var2); + + do { + int var9 = var10; + var10 <<= 1; + if(var10 > this.sortedWorldRenderers.length) { + var10 = this.sortedWorldRenderers.length; + } + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glColorMask(false, false, false, false); + GL11.glDepthMask(false); + this.checkOcclusionQueryResult(var9, var10); + + for(var6 = var9; var6 < var10; ++var6) { + if(!this.sortedWorldRenderers[var6].isInFrustrum) { + this.sortedWorldRenderers[var6].isVisible = true; + } + + if(this.sortedWorldRenderers[var6].isInFrustrum && !this.sortedWorldRenderers[var6].isWaitingOnOcclusionQuery) { + float var7 = MathHelper.sqrt_float(this.sortedWorldRenderers[var6].distanceToEntitySquared(var1)); + int var11 = (int)(1.0F + var7 / 64.0F); + if(this.cloudOffsetX % var11 == var6 % var11) { + this.sortedWorldRenderers[var6].callOcclusionQueryList(); + this.sortedWorldRenderers[var6].isWaitingOnOcclusionQuery = true; + } + } + } + + GL11.glColorMask(true, true, true, true); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + var8 += this.renderSortedRenderers(var9, var10, var2); + } while(var10 < this.sortedWorldRenderers.length); + } else { + var8 = 0 + this.renderSortedRenderers(0, this.sortedWorldRenderers.length, var2); + } + + return var8; + } + + private void checkOcclusionQueryResult(int var1, int var2) { + for(var1 = var1; var1 < var2; ++var1) { + if(this.sortedWorldRenderers[var1].isWaitingOnOcclusionQuery) { + this.occlusionResult.clear(); + if(this.occlusionResult.get(0) != 0) { + this.sortedWorldRenderers[var1].isWaitingOnOcclusionQuery = false; + this.occlusionResult.clear(); + this.sortedWorldRenderers[var1].isVisible = this.occlusionResult.get(0) != 0; + } + } + } + + } + + private int renderSortedRenderers(int var1, int var2, int var3) { + int var4 = 0; + + for(var1 = var1; var1 < var2; ++var1) { + if(var3 == 0) { + ++this.renderersLoaded; + if(!this.sortedWorldRenderers[var1].isInFrustrum) { + ++this.renderersBeingClipped; + } + + if(this.sortedWorldRenderers[var1].isInFrustrum && !this.sortedWorldRenderers[var1].isVisible) { + ++this.renderersBeingOccluded; + } + + if(this.sortedWorldRenderers[var1].isInFrustrum && this.sortedWorldRenderers[var1].isVisible) { + ++this.renderersBeingRendered; + } + } + + if(this.sortedWorldRenderers[var1].isInFrustrum && this.sortedWorldRenderers[var1].isVisible) { + var4 = this.sortedWorldRenderers[var1].getGLCallListForPass(this.dummyBuf50k, var4, var3); + } + } + + this.renderIntBuffer.clear(); + this.renderIntBuffer.put(this.dummyBuf50k, 0, var4); + this.renderIntBuffer.flip(); + if(this.renderIntBuffer.remaining() > 0) { + GL11.glCallLists(this.renderIntBuffer); + } + + return this.renderIntBuffer.remaining(); + } + + public final void renderAllRenderLists() { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain.png")); + GL11.glCallLists(this.renderIntBuffer); + } + + public final void updateClouds() { + ++this.cloudOffsetX; + } + + public final void renderSky(float var1) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + Vec3D var2 = this.worldObj.getSkyColor(var1); + float var3 = var2.xCoord; + float var4 = var2.yCoord; + float var9 = var2.zCoord; + if(this.mc.options.anaglyph) { + float var5 = (var3 * 30.0F + var4 * 59.0F + var9 * 11.0F) / 100.0F; + var4 = (var3 * 30.0F + var4 * 70.0F) / 100.0F; + var9 = (var3 * 30.0F + var9 * 70.0F) / 100.0F; + var3 = var5; + var4 = var4; + var9 = var9; + } + + GL11.glDepthMask(false); + Tessellator var12 = Tessellator.instance; + var12.startDrawingQuads(); + var12.setColorOpaque_F(var3, var4, var9); + var9 = (float)(this.worldObj.height + 10); + + int var10; + for(var10 = -2048; var10 < this.worldObj.width + 2048; var10 += 512) { + for(int var13 = -2048; var13 < this.worldObj.length + 2048; var13 += 512) { + var12.addVertex((float)var10, var9, (float)var13); + var12.addVertex((float)(var10 + 512), var9, (float)var13); + var12.addVertex((float)(var10 + 512), var9, (float)(var13 + 512)); + var12.addVertex((float)var10, var9, (float)(var13 + 512)); + } + } + + var12.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glPushMatrix(); + var3 = this.worldObj.playerEntity.lastTickPosX + (this.worldObj.playerEntity.posX - this.worldObj.playerEntity.lastTickPosX) * var1; + var4 = this.worldObj.playerEntity.lastTickPosY + (this.worldObj.playerEntity.posY - this.worldObj.playerEntity.lastTickPosY) * var1; + float var6 = this.worldObj.playerEntity.lastTickPosZ + (this.worldObj.playerEntity.posZ - this.worldObj.playerEntity.lastTickPosZ) * var1; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslatef(var3, var4, var6); + GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(this.worldObj.getCelestialAngle(var1) * 360.0F, 1.0F, 0.0F, 0.0F); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain/sun.png")); + var12.startDrawingQuads(); + var12.addVertexWithUV(-30.0F, 100.0F, -30.0F, 0.0F, 0.0F); + var12.addVertexWithUV(30.0F, 100.0F, -30.0F, 1.0F, 0.0F); + var12.addVertexWithUV(30.0F, 100.0F, 30.0F, 1.0F, 1.0F); + var12.addVertexWithUV(-30.0F, 100.0F, 30.0F, 0.0F, 1.0F); + var12.draw(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain/moon.png")); + var12.startDrawingQuads(); + var12.addVertexWithUV(-20.0F, -100.0F, 20.0F, 1.0F, 1.0F); + var12.addVertexWithUV(20.0F, -100.0F, 20.0F, 0.0F, 1.0F); + var12.addVertexWithUV(20.0F, -100.0F, -20.0F, 0.0F, 0.0F); + var12.addVertexWithUV(-20.0F, -100.0F, -20.0F, 1.0F, 0.0F); + var12.draw(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + var9 = this.worldObj.getStarBrightness(var1); + GL11.glColor4f(var9, var9, var9, var9); + GL11.glCallList(this.glSkyList); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_FOG); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/clouds.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Vec3D var11 = this.worldObj.getCloudColor(var1); + var4 = var11.xCoord; + var6 = var11.yCoord; + var3 = var11.zCoord; + float var7; + if(this.mc.options.anaglyph) { + var9 = (var4 * 30.0F + var6 * 59.0F + var3 * 11.0F) / 100.0F; + var7 = (var4 * 30.0F + var6 * 70.0F) / 100.0F; + var3 = (var4 * 30.0F + var3 * 70.0F) / 100.0F; + var4 = var9; + var6 = var7; + var3 = var3; + } + + var9 = (float)this.worldObj.cloudHeight; + var7 = ((float)this.cloudOffsetX + var1) * (0.5F / 1024.0F) * 0.03F; + var12.startDrawingQuads(); + var12.setColorOpaque_F(var4, var6, var3); + + for(int var8 = -2048; var8 < this.worldObj.width + 2048; var8 += 512) { + for(var10 = -2048; var10 < this.worldObj.length + 2048; var10 += 512) { + var12.addVertexWithUV((float)var8, var9, (float)(var10 + 512), (float)var8 * (0.5F / 1024.0F) + var7, (float)(var10 + 512) * (0.5F / 1024.0F)); + var12.addVertexWithUV((float)(var8 + 512), var9, (float)(var10 + 512), (float)(var8 + 512) * (0.5F / 1024.0F) + var7, (float)(var10 + 512) * (0.5F / 1024.0F)); + var12.addVertexWithUV((float)(var8 + 512), var9, (float)var10, (float)(var8 + 512) * (0.5F / 1024.0F) + var7, (float)var10 * (0.5F / 1024.0F)); + var12.addVertexWithUV((float)var8, var9, (float)var10, (float)var8 * (0.5F / 1024.0F) + var7, (float)var10 * (0.5F / 1024.0F)); + var12.addVertexWithUV((float)var8, var9, (float)var10, (float)var8 * (0.5F / 1024.0F) + var7, (float)var10 * (0.5F / 1024.0F)); + var12.addVertexWithUV((float)(var8 + 512), var9, (float)var10, (float)(var8 + 512) * (0.5F / 1024.0F) + var7, (float)var10 * (0.5F / 1024.0F)); + var12.addVertexWithUV((float)(var8 + 512), var9, (float)(var10 + 512), (float)(var8 + 512) * (0.5F / 1024.0F) + var7, (float)(var10 + 512) * (0.5F / 1024.0F)); + var12.addVertexWithUV((float)var8, var9, (float)(var10 + 512), (float)var8 * (0.5F / 1024.0F) + var7, (float)(var10 + 512) * (0.5F / 1024.0F)); + } + } + + var12.draw(); + } + + public final void oobGroundRenderer() { + float var1 = this.worldObj.getLightBrightness(0, this.worldObj.getGroundLevel(), 0); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/dirt.png")); + if(this.worldObj.getGroundLevel() > this.worldObj.getWaterLevel() && this.worldObj.defaultFluid == Block.waterMoving.blockID) { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/grass.png")); + } + + GL11.glColor4f(var1, var1, var1, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glCallList(this.glGenList); + } + + private void oobGroundRenderHeight() { + Tessellator var1 = Tessellator.instance; + float var2 = (float)this.worldObj.getGroundLevel(); + int var3 = 128; + if(128 > this.worldObj.width) { + var3 = this.worldObj.width; + } + + if(var3 > this.worldObj.length) { + var3 = this.worldObj.length; + } + + int var4 = 2048 / var3; + var1.startDrawingQuads(); + + for(int var5 = -var3 * var4; var5 < this.worldObj.width + var3 * var4; var5 += var3) { + for(int var6 = -var3 * var4; var6 < this.worldObj.length + var3 * var4; var6 += var3) { + if(var2 < 0.0F || var5 < 0 || var6 < 0 || var5 >= this.worldObj.width || var6 >= this.worldObj.length) { + var1.addVertexWithUV((float)var5, var2, (float)(var6 + var3), 0.0F, (float)var3); + var1.addVertexWithUV((float)(var5 + var3), var2, (float)(var6 + var3), (float)var3, (float)var3); + var1.addVertexWithUV((float)(var5 + var3), var2, (float)var6, (float)var3, 0.0F); + var1.addVertexWithUV((float)var5, var2, (float)var6, 0.0F, 0.0F); + } + } + } + + var1.draw(); + } + + public final void oobWaterRenderer() { + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/water.png")); + float var1 = this.worldObj.getLightBrightness(0, this.worldObj.getWaterLevel(), 0); + GL11.glColor4f(var1, var1, var1, 1.0F); + GL11.glCallList(this.glGenList + 1); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + } + + private void oobWaterRenderHeight() { + float var1 = (float)this.worldObj.getWaterLevel(); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator var2 = Tessellator.instance; + int var3 = 128; + if(128 > this.worldObj.width) { + var3 = this.worldObj.width; + } + + if(var3 > this.worldObj.length) { + var3 = this.worldObj.length; + } + + int var4 = 2048 / var3; + var2.startDrawingQuads(); + float var5 = Block.waterMoving.minX; + float var6 = Block.waterMoving.minZ; + + for(int var7 = -var3 * var4; var7 < this.worldObj.width + var3 * var4; var7 += var3) { + for(int var8 = -var3 * var4; var8 < this.worldObj.length + var3 * var4; var8 += var3) { + float var9 = var1 + Block.waterMoving.minY; + if(var1 < 0.0F || var7 < 0 || var8 < 0 || var7 >= this.worldObj.width || var8 >= this.worldObj.length) { + var2.addVertexWithUV((float)var7 + var5, var9, (float)(var8 + var3) + var6, 0.0F, (float)var3); + var2.addVertexWithUV((float)(var7 + var3) + var5, var9, (float)(var8 + var3) + var6, (float)var3, (float)var3); + var2.addVertexWithUV((float)(var7 + var3) + var5, var9, (float)var8 + var6, (float)var3, 0.0F); + var2.addVertexWithUV((float)var7 + var5, var9, (float)var8 + var6, 0.0F, 0.0F); + var2.addVertexWithUV((float)var7 + var5, var9, (float)var8 + var6, 0.0F, 0.0F); + var2.addVertexWithUV((float)(var7 + var3) + var5, var9, (float)var8 + var6, (float)var3, 0.0F); + var2.addVertexWithUV((float)(var7 + var3) + var5, var9, (float)(var8 + var3) + var6, (float)var3, (float)var3); + var2.addVertexWithUV((float)var7 + var5, var9, (float)(var8 + var3) + var6, 0.0F, (float)var3); + } + } + } + + var2.draw(); + GL11.glDisable(GL11.GL_BLEND); + } + + public final void updateRenderers(EntityPlayer var1) { + Collections.sort(this.worldRenderersToUpdate, new RenderSorter(var1)); + int var2 = this.worldRenderersToUpdate.size() - 1; + int var3 = this.worldRenderersToUpdate.size(); + + for(int var4 = 0; var4 < var3; ++var4) { + WorldRenderer var5 = (WorldRenderer)this.worldRenderersToUpdate.get(var2 - var4); + if(var5.distanceToEntitySquared(var1) > 2500.0F && var4 > 4) { + return; + } + + this.worldRenderersToUpdate.remove(var5); + var5.updateRenderer(); + var5.needsUpdate = false; + } + + } + + public final void drawBlockBreaking(MovingObjectPosition var1, int var2, ItemStack var3) { + Tessellator var4 = Tessellator.instance; + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GL11.glColor4f(1.0F, 1.0F, 1.0F, (MathHelper.sin((float)System.currentTimeMillis() / 100.0F) * 0.2F + 0.4F) * 0.5F); + if(this.damagePartialTime > 0.0F) { + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR); + int var5 = this.renderEngine.getTexture("/terrain.png"); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GL11.glPushMatrix(); + var5 = this.worldObj.getBlockId(var1.blockX, var1.blockY, var1.blockZ); + Block var6 = var5 > 0 ? Block.blocksList[var5] : null; + GL11.glDisable(GL11.GL_ALPHA_TEST); + var4.startDrawingQuads(); + var4.disableColor(); + if(var6 == null) { + var6 = Block.stone; + } + + this.globalRenderBlocks.renderBlockUsingTexture(var6, var1.blockX, var1.blockY, var1.blockZ, 240 + (int)(this.damagePartialTime * 10.0F)); + var4.draw(); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + } + + public final void drawSelectionBox(MovingObjectPosition var1, int var2) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F); + GL11.glLineWidth(2.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(false); + var2 = this.worldObj.getBlockId(var1.blockX, var1.blockY, var1.blockZ); + if(var2 > 0) { + AxisAlignedBB var3 = Block.blocksList[var2].getSelectedBoundingBoxFromPool(var1.blockX, var1.blockY, var1.blockZ).expand(0.002F, 0.002F, 0.002F); + Tessellator var4 = Tessellator.instance; + var4.startDrawing(3); + var4.addVertex(var3.minX, var3.minY, var3.minZ); + var4.addVertex(var3.maxX, var3.minY, var3.minZ); + var4.addVertex(var3.maxX, var3.minY, var3.maxZ); + var4.addVertex(var3.minX, var3.minY, var3.maxZ); + var4.addVertex(var3.minX, var3.minY, var3.minZ); + var4.draw(); + var4.startDrawing(3); + var4.addVertex(var3.minX, var3.maxY, var3.minZ); + var4.addVertex(var3.maxX, var3.maxY, var3.minZ); + var4.addVertex(var3.maxX, var3.maxY, var3.maxZ); + var4.addVertex(var3.minX, var3.maxY, var3.maxZ); + var4.addVertex(var3.minX, var3.maxY, var3.minZ); + var4.draw(); + var4.startDrawing(1); + var4.addVertex(var3.minX, var3.minY, var3.minZ); + var4.addVertex(var3.minX, var3.maxY, var3.minZ); + var4.addVertex(var3.maxX, var3.minY, var3.minZ); + var4.addVertex(var3.maxX, var3.maxY, var3.minZ); + var4.addVertex(var3.maxX, var3.minY, var3.maxZ); + var4.addVertex(var3.maxX, var3.maxY, var3.maxZ); + var4.addVertex(var3.minX, var3.minY, var3.maxZ); + var4.addVertex(var3.minX, var3.maxY, var3.maxZ); + var4.draw(); + } + + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + } + + private void markBlocksForUpdate(int var1, int var2, int var3, int var4, int var5, int var6) { + var1 /= 16; + var2 /= 16; + var3 /= 16; + var4 /= 16; + var5 /= 16; + var6 /= 16; + if(var1 < 0) { + var1 = 0; + } + + if(var2 < 0) { + var2 = 0; + } + + if(var3 < 0) { + var3 = 0; + } + + if(var4 > this.renderChunksWide - 1) { + var4 = this.renderChunksWide - 1; + } + + if(var5 > this.renderChunksTall - 1) { + var5 = this.renderChunksTall - 1; + } + + if(var6 > this.renderChunksDeep - 1) { + var6 = this.renderChunksDeep - 1; + } + + for(var1 = var1; var1 <= var4; ++var1) { + for(int var7 = var2; var7 <= var5; ++var7) { + for(int var8 = var3; var8 <= var6; ++var8) { + WorldRenderer var9 = this.worldRenderers[(var8 * this.renderChunksTall + var7) * this.renderChunksWide + var1]; + if(!var9.needsUpdate) { + var9.needsUpdate = true; + this.worldRenderersToUpdate.add(this.worldRenderers[(var8 * this.renderChunksTall + var7) * this.renderChunksWide + var1]); + } + } + } + } + + } + + public final void markBlockAndNeighborsNeedsUpdate(int var1, int var2, int var3) { + this.markBlocksForUpdate(var1 - 1, var2 - 1, var3 - 1, var1 + 1, var2 + 1, var3 + 1); + } + + public final void markBlockRangeNeedsUpdate(int var1, int var2, int var3, int var4, int var5, int var6) { + this.markBlocksForUpdate(var1 - 1, var2 - 1, var3 - 1, var4 + 1, var5 + 1, var6 + 1); + } + + public final void clipRenderersByFrustrum(ICamera var1) { + for(int var2 = 0; var2 < this.worldRenderers.length; ++var2) { + this.worldRenderers[var2].updateInFrustrum(var1); + } + + } + + public final void spawnParticle(String var1, float var2, float var3, float var4, float var5, float var6, float var7) { + float var8 = this.worldObj.playerEntity.posX - var2; + float var9 = this.worldObj.playerEntity.posY - var3; + float var10 = this.worldObj.playerEntity.posZ - var4; + if(var8 * var8 + var9 * var9 + var10 * var10 <= 256.0F) { + if(var1 == "bubble") { + this.mc.effectRenderer.addEffect(new EntityBubbleFX(this.worldObj, var2, var3, var4, var5, var6, var7)); + } else if(var1 == "smoke") { + this.mc.effectRenderer.addEffect(new EntitySmokeFX(this.worldObj, var2, var3, var4)); + } else if(var1 == "explode") { + this.mc.effectRenderer.addEffect(new EntityExplodeFX(this.worldObj, var2, var3, var4, var5, var6, var7)); + } else if(var1 == "flame") { + this.mc.effectRenderer.addEffect(new EntityFlameFX(this.worldObj, var2, var3, var4)); + } else if(var1 == "lava") { + this.mc.effectRenderer.addEffect(new EntityLavaFX(this.worldObj, var2, var3, var4)); + } else if(var1 == "splash") { + this.mc.effectRenderer.addEffect(new EntitySplashFX(this.worldObj, var2, var3, var4)); + } else { + if(var1 == "largesmoke") { + this.mc.effectRenderer.addEffect(new EntitySmokeFX(this.worldObj, var2, var3, var4, 2.5F)); + } + + } + } + } + + public final void obtainEntitySkin(Entity var1) { + if(var1.skinUrl != null) { + this.renderEngine.obtainImageData(var1.skinUrl, new ImageBufferDownload()); + } + + } + + public final void releaseEntitySkin(Entity var1) { + if(var1.skinUrl != null) { + this.renderEngine.releaseImageData(var1.skinUrl); + } + + } + + public final void updateAllRenderers() { + GL11.glNewList(this.glGenList, GL11.GL_COMPILE); + this.oobGroundRenderHeight(); + GL11.glEndList(); + GL11.glNewList(this.glGenList + 1, GL11.GL_COMPILE); + this.oobWaterRenderHeight(); + GL11.glEndList(); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/RenderSorter.java b/src/teavm/java/net/minecraft/client/render/RenderSorter.java new file mode 100644 index 0000000..0b89bb8 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/RenderSorter.java @@ -0,0 +1,21 @@ +package net.minecraft.client.render; + +import java.util.Comparator; +import net.minecraft.game.entity.player.EntityPlayer; + +public final class RenderSorter implements Comparator { + private EntityPlayer baseEntity; + + public RenderSorter(EntityPlayer var1) { + this.baseEntity = var1; + } + + public final int compare(Object var1, Object var2) { + WorldRenderer var10001 = (WorldRenderer)var1; + WorldRenderer var3 = (WorldRenderer)var2; + WorldRenderer var6 = var10001; + boolean var4 = var6.isInFrustrum; + boolean var5 = var3.isInFrustrum; + return var4 && !var5 ? 1 : ((!var5 || var4) && var6.distanceToEntitySquared(this.baseEntity) < var3.distanceToEntitySquared(this.baseEntity) ? 1 : -1); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/Tessellator.java b/src/teavm/java/net/minecraft/client/render/Tessellator.java new file mode 100644 index 0000000..8428905 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/Tessellator.java @@ -0,0 +1,223 @@ +package net.minecraft.client.render; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.ARBVertexBufferObject; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL15; + +public final class Tessellator { + private static boolean convertQuadsToTriangles = false; + private static boolean tryVBO = false; + private ByteBuffer byteBuffer = BufferUtils.createByteBuffer(8388608); + private int[] rawBuffer = new int[2097152]; + private int vertexCount = 0; + private float textureU; + private float textureV; + private int color; + private boolean hasColor = false; + private boolean hasTexture = false; + private int rawBufferIndex = 0; + private int addedVertices = 0; + private boolean isColorDisabled = false; + private int drawMode; + public static Tessellator instance = new Tessellator(); + private boolean isDrawing = false; + private boolean useVBO = false; + private IntBuffer vertexBuffers; + private int vboIndex = 0; + private int vboCount = 10; + + private Tessellator() { + this.useVBO = false; + if(this.useVBO) { + this.vertexBuffers = BufferUtils.createIntBuffer(this.vboCount); + ARBVertexBufferObject.glGenBuffersARB(this.vertexBuffers); + } + + } + + public final void draw() { + if(!this.isDrawing) { + throw new IllegalStateException("Not tesselating!"); + } else { + this.isDrawing = false; + if(this.vertexCount > 0) { + IntBuffer var1 = this.byteBuffer.asIntBuffer(); + FloatBuffer var2 = this.byteBuffer.asFloatBuffer(); + var1.clear(); + var1.put(this.rawBuffer, 0, this.rawBufferIndex); + this.byteBuffer.position(0); + this.byteBuffer.limit(this.rawBufferIndex << 2); + if(this.useVBO) { + this.vboIndex = (this.vboIndex + 1) % this.vboCount; + ARBVertexBufferObject.glBindBufferARB(GL15.GL_ARRAY_BUFFER, this.vertexBuffers.get(this.vboIndex)); + ARBVertexBufferObject.glBufferDataARB(GL15.GL_ARRAY_BUFFER, this.byteBuffer, GL15.GL_STREAM_DRAW); + } + + if(this.hasTexture) { + if(this.useVBO) { + GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 32, 12L); + } else { + var2.position(3); + GL11.glTexCoordPointer(2, 32, (FloatBuffer)var2); + } + + GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + } + + if(this.hasColor) { + if(this.useVBO) { + GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 32, 20L); + } else { + this.byteBuffer.position(20); + GL11.glColorPointer(4, true, 32, this.byteBuffer); + } + + GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); + } + + if(this.useVBO) { + GL11.glVertexPointer(3, GL11.GL_FLOAT, 32, 0L); + } else { + var2.position(0); + GL11.glVertexPointer(3, 32, (FloatBuffer)var2); + } + + GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + GL11.glDrawArrays(this.drawMode, GL11.GL_POINTS, this.vertexCount); + GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); + if(this.hasTexture) { + GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + } + + if(this.hasColor) { + GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); + } + } + + this.reset(); + } + } + + private void reset() { + this.vertexCount = 0; + this.byteBuffer.clear(); + this.rawBufferIndex = 0; + this.addedVertices = 0; + } + + public final void startDrawingQuads() { + this.startDrawing(7); + } + + public final void startDrawing(int var1) { + if(this.isDrawing) { + throw new IllegalStateException("Already tesselating!"); + } else { + this.isDrawing = true; + this.reset(); + this.drawMode = var1; + this.hasColor = false; + this.hasTexture = false; + this.isColorDisabled = false; + } + } + + public final void setColorOpaque_F(float var1, float var2, float var3) { + this.setColorOpaque((int)(var1 * 255.0F), (int)(var2 * 255.0F), (int)(var3 * 255.0F)); + } + + public final void setColorRGBA_F(float var1, float var2, float var3, float var4) { + this.setColorRGBA((int)(var1 * 255.0F), (int)(var2 * 255.0F), (int)(var3 * 255.0F), (int)(var4 * 255.0F)); + } + + private void setColorOpaque(int var1, int var2, int var3) { + this.setColorRGBA(var1, var2, var3, 255); + } + + private void setColorRGBA(int var1, int var2, int var3, int var4) { + if(!this.isColorDisabled) { + if(var1 > 255) { + var1 = 255; + } + + if(var2 > 255) { + var2 = 255; + } + + if(var3 > 255) { + var3 = 255; + } + + if(var4 > 255) { + var4 = 255; + } + + if(var1 < 0) { + var1 = 0; + } + + if(var2 < 0) { + var2 = 0; + } + + if(var3 < 0) { + var3 = 0; + } + + if(var4 < 0) { + var4 = 0; + } + + this.hasColor = true; + this.color = var4 << 24 | var3 << 16 | var2 << 8 | var1; + } + } + + public final void addVertexWithUV(float var1, float var2, float var3, float var4, float var5) { + this.hasTexture = true; + this.textureU = var4; + this.textureV = var5; + this.addVertex(var1, var2, var3); + } + + public final void addVertex(float var1, float var2, float var3) { + ++this.addedVertices; + if(this.hasTexture) { + this.rawBuffer[this.rawBufferIndex + 3] = Float.floatToRawIntBits(this.textureU); + this.rawBuffer[this.rawBufferIndex + 4] = Float.floatToRawIntBits(this.textureV); + } + + if(this.hasColor) { + this.rawBuffer[this.rawBufferIndex + 5] = this.color; + } + + this.rawBuffer[this.rawBufferIndex] = Float.floatToRawIntBits(var1); + this.rawBuffer[this.rawBufferIndex + 1] = Float.floatToRawIntBits(var2); + this.rawBuffer[this.rawBufferIndex + 2] = Float.floatToRawIntBits(var3); + this.rawBufferIndex += 8; + ++this.vertexCount; + if(this.vertexCount % 4 == 0 && this.rawBufferIndex >= 2097120) { + this.draw(); + } + + } + + public final void setColorOpaque_I(int var1) { + int var2 = var1 >> 16 & 255; + int var3 = var1 >> 8 & 255; + var1 &= 255; + this.setColorOpaque(var2, var3, var1); + } + + public final void disableColor() { + this.isColorDisabled = true; + } + + public static void setNormal(float var0, float var1, float var2) { + GL11.glNormal3f(var0, var1, var2); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/ThreadDownloadImage.java b/src/teavm/java/net/minecraft/client/render/ThreadDownloadImage.java new file mode 100644 index 0000000..be11868 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/ThreadDownloadImage.java @@ -0,0 +1,45 @@ +package net.minecraft.client.render; + +import java.net.HttpURLConnection; +import java.net.URL; +import javax.imageio.ImageIO; + +final class ThreadDownloadImage extends Thread { + private String location; + private ImageBufferDownload buffer; + private ThreadDownloadImageData imageData; + + ThreadDownloadImage(ThreadDownloadImageData var1, String var2, ImageBufferDownload var3) { + this.imageData = var1; + this.location = var2; + this.buffer = var3; + } + + public final void run() { + HttpURLConnection var1 = null; + + try { + URL var2 = new URL(this.location); + var1 = (HttpURLConnection)var2.openConnection(); + var1.setDoInput(true); + var1.setDoOutput(false); + var1.connect(); + if(var1.getResponseCode() == 404) { + return; + } + + if(this.buffer == null) { + this.imageData.image = ImageIO.read(var1.getInputStream()); + } else { + this.imageData.image = this.buffer.parseUserSkin(ImageIO.read(var1.getInputStream())); + } + + return; + } catch (Exception var5) { + var5.printStackTrace(); + } finally { + var1.disconnect(); + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/render/ThreadDownloadImageData.java b/src/teavm/java/net/minecraft/client/render/ThreadDownloadImageData.java new file mode 100644 index 0000000..0607dcd --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/ThreadDownloadImageData.java @@ -0,0 +1,14 @@ +package net.minecraft.client.render; + +import java.awt.image.BufferedImage; + +public final class ThreadDownloadImageData { + public BufferedImage image; + public int referenceCount = 1; + public int textureName = -1; + public boolean textureSetupComplete = false; + + public ThreadDownloadImageData(String var1, ImageBufferDownload var2) { + (new ThreadDownloadImage(this, var1, var2)).start(); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/WorldRenderer.java b/src/teavm/java/net/minecraft/client/render/WorldRenderer.java new file mode 100644 index 0000000..4cc9510 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/WorldRenderer.java @@ -0,0 +1,147 @@ +package net.minecraft.client.render; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.render.camera.ICamera; +import net.minecraft.client.render.entity.RenderItem; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.physics.AxisAlignedBB; +import org.lwjgl.opengl.GL11; + +public final class WorldRenderer { + private World worldObj; + private int glRenderList = -1; + private static Tessellator tessellator = Tessellator.instance; + public static int chunksUpdated = 0; + private int posX; + private int posY; + private int posZ; + private int sizeWidth; + private int sizeHeight; + private int sizeDepth; + public boolean isInFrustrum = false; + private boolean[] skipRenderPass = new boolean[2]; + private int posXPlus; + private int posYPlus; + private int posZPlus; + public boolean needsUpdate; + private AxisAlignedBB rendererBoundingBox; + private RenderBlocks renderBlocks; + public boolean isVisible = true; + public boolean isWaitingOnOcclusionQuery; + public int glOcclusionQuery; + + public WorldRenderer(World var1, int var2, int var3, int var4, int var5, int var6) { + this.renderBlocks = new RenderBlocks(var1); + this.worldObj = var1; + this.posX = var2; + this.posY = var3; + this.posZ = var4; + this.sizeWidth = this.sizeHeight = this.sizeDepth = 16; + this.posXPlus = var2 + this.sizeWidth / 2; + this.posYPlus = var3 + this.sizeHeight / 2; + this.posZPlus = var4 + this.sizeDepth / 2; + MathHelper.sqrt_float((float)(this.sizeWidth * this.sizeWidth + this.sizeHeight * this.sizeHeight + this.sizeDepth * this.sizeDepth)); + this.rendererBoundingBox = (new AxisAlignedBB((float)var2, (float)var3, (float)var4, (float)(var2 + this.sizeWidth), (float)(var3 + this.sizeHeight), (float)(var4 + this.sizeDepth))).expand(2.0F, 2.0F, 2.0F); + this.glRenderList = var6; + this.setDontDraw(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glNewList(var6 + 2, GL11.GL_COMPILE); + RenderItem.renderOffsetAABB(this.rendererBoundingBox); + GL11.glEndList(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public final void updateRenderer() { + if(this.needsUpdate) { + ++chunksUpdated; + int var1 = this.posX; + int var2 = this.posY; + int var3 = this.posZ; + int var4 = this.posX + this.sizeWidth; + int var5 = this.posY + this.sizeHeight; + int var6 = this.posZ + this.sizeDepth; + + int var7; + for(var7 = 0; var7 < 2; ++var7) { + this.skipRenderPass[var7] = true; + } + + for(var7 = 0; var7 < 2; ++var7) { + boolean var8 = false; + boolean var9 = false; + tessellator.startDrawingQuads(); + GL11.glNewList(this.glRenderList + var7, GL11.GL_COMPILE); + + for(int var10 = var2; var10 < var5; ++var10) { + for(int var11 = var3; var11 < var6; ++var11) { + int var12 = (var10 * this.worldObj.length + var11) * this.worldObj.width + var1; + + for(int var13 = var1; var13 < var4; ++var13) { + int var14 = this.worldObj.blocks[var12++] & 255; + if(var14 > 0) { + Block var15 = Block.blocksList[var14]; + if(var15.getRenderBlockPass() != var7) { + var8 = true; + } else { + var9 |= this.renderBlocks.renderBlockByRenderType(var15, var13, var10, var11); + } + } + } + } + } + + tessellator.draw(); + GL11.glEndList(); + if(var9) { + this.skipRenderPass[var7] = false; + } + + if(!var8) { + break; + } + } + + } + } + + public final float distanceToEntitySquared(EntityLiving var1) { + float var2 = var1.posX - (float)this.posXPlus; + float var3 = var1.posY - (float)this.posYPlus; + float var4 = var1.posZ - (float)this.posZPlus; + return var2 * var2 + var3 * var3 + var4 * var4; + } + + private void setDontDraw() { + for(int var1 = 0; var1 < 2; ++var1) { + this.skipRenderPass[var1] = true; + } + + } + + public final void stopRendering() { + this.setDontDraw(); + this.worldObj = null; + } + + public final int getGLCallListForPass(int[] var1, int var2, int var3) { + if(!this.isInFrustrum) { + return var2; + } else { + if(!this.skipRenderPass[var3]) { + var1[var2++] = this.glRenderList + var3; + } + + return var2; + } + } + + public final void updateInFrustrum(ICamera var1) { + this.isInFrustrum = var1.isBoundingBoxInFrustrum(this.rendererBoundingBox); + } + + public final void callOcclusionQueryList() { + GL11.glCallList(this.glRenderList + 2); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/camera/ClippingHelper.java b/src/teavm/java/net/minecraft/client/render/camera/ClippingHelper.java new file mode 100644 index 0000000..ed7b530 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/camera/ClippingHelper.java @@ -0,0 +1,8 @@ +package net.minecraft.client.render.camera; + +public class ClippingHelper { + public float[][] frustrum = new float[16][16]; + public float[] projectionMatrix = new float[16]; + public float[] modelviewMatrix = new float[16]; + public float[] clippingMatrix = new float[16]; +} diff --git a/src/teavm/java/net/minecraft/client/render/camera/ClippingHelperImplementation.java b/src/teavm/java/net/minecraft/client/render/camera/ClippingHelperImplementation.java new file mode 100644 index 0000000..613f125 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/camera/ClippingHelperImplementation.java @@ -0,0 +1,82 @@ +package net.minecraft.client.render.camera; + +import java.nio.FloatBuffer; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +import net.PeytonPlayz585.math.MathHelper; + +public final class ClippingHelperImplementation extends ClippingHelper { + private static ClippingHelperImplementation instance = new ClippingHelperImplementation(); + private FloatBuffer projectionMatrixBuffer = BufferUtils.createFloatBuffer(16); + private FloatBuffer modelviewMatrixBuffer = BufferUtils.createFloatBuffer(16); + private FloatBuffer ICamera = BufferUtils.createFloatBuffer(16); + + public static ClippingHelper init() { + ClippingHelperImplementation var0 = instance; + var0.projectionMatrixBuffer.clear(); + var0.modelviewMatrixBuffer.clear(); + var0.ICamera.clear(); + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, var0.projectionMatrixBuffer); + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, var0.modelviewMatrixBuffer); + var0.projectionMatrixBuffer.flip().limit(16); + var0.projectionMatrixBuffer.get(var0.projectionMatrix); + var0.modelviewMatrixBuffer.flip().limit(16); + var0.modelviewMatrixBuffer.get(var0.modelviewMatrix); + var0.clippingMatrix[0] = var0.modelviewMatrix[0] * var0.projectionMatrix[0] + var0.modelviewMatrix[1] * var0.projectionMatrix[4] + var0.modelviewMatrix[2] * var0.projectionMatrix[8] + var0.modelviewMatrix[3] * var0.projectionMatrix[12]; + var0.clippingMatrix[1] = var0.modelviewMatrix[0] * var0.projectionMatrix[1] + var0.modelviewMatrix[1] * var0.projectionMatrix[5] + var0.modelviewMatrix[2] * var0.projectionMatrix[9] + var0.modelviewMatrix[3] * var0.projectionMatrix[13]; + var0.clippingMatrix[2] = var0.modelviewMatrix[0] * var0.projectionMatrix[2] + var0.modelviewMatrix[1] * var0.projectionMatrix[6] + var0.modelviewMatrix[2] * var0.projectionMatrix[10] + var0.modelviewMatrix[3] * var0.projectionMatrix[14]; + var0.clippingMatrix[3] = var0.modelviewMatrix[0] * var0.projectionMatrix[3] + var0.modelviewMatrix[1] * var0.projectionMatrix[7] + var0.modelviewMatrix[2] * var0.projectionMatrix[11] + var0.modelviewMatrix[3] * var0.projectionMatrix[15]; + var0.clippingMatrix[4] = var0.modelviewMatrix[4] * var0.projectionMatrix[0] + var0.modelviewMatrix[5] * var0.projectionMatrix[4] + var0.modelviewMatrix[6] * var0.projectionMatrix[8] + var0.modelviewMatrix[7] * var0.projectionMatrix[12]; + var0.clippingMatrix[5] = var0.modelviewMatrix[4] * var0.projectionMatrix[1] + var0.modelviewMatrix[5] * var0.projectionMatrix[5] + var0.modelviewMatrix[6] * var0.projectionMatrix[9] + var0.modelviewMatrix[7] * var0.projectionMatrix[13]; + var0.clippingMatrix[6] = var0.modelviewMatrix[4] * var0.projectionMatrix[2] + var0.modelviewMatrix[5] * var0.projectionMatrix[6] + var0.modelviewMatrix[6] * var0.projectionMatrix[10] + var0.modelviewMatrix[7] * var0.projectionMatrix[14]; + var0.clippingMatrix[7] = var0.modelviewMatrix[4] * var0.projectionMatrix[3] + var0.modelviewMatrix[5] * var0.projectionMatrix[7] + var0.modelviewMatrix[6] * var0.projectionMatrix[11] + var0.modelviewMatrix[7] * var0.projectionMatrix[15]; + var0.clippingMatrix[8] = var0.modelviewMatrix[8] * var0.projectionMatrix[0] + var0.modelviewMatrix[9] * var0.projectionMatrix[4] + var0.modelviewMatrix[10] * var0.projectionMatrix[8] + var0.modelviewMatrix[11] * var0.projectionMatrix[12]; + var0.clippingMatrix[9] = var0.modelviewMatrix[8] * var0.projectionMatrix[1] + var0.modelviewMatrix[9] * var0.projectionMatrix[5] + var0.modelviewMatrix[10] * var0.projectionMatrix[9] + var0.modelviewMatrix[11] * var0.projectionMatrix[13]; + var0.clippingMatrix[10] = var0.modelviewMatrix[8] * var0.projectionMatrix[2] + var0.modelviewMatrix[9] * var0.projectionMatrix[6] + var0.modelviewMatrix[10] * var0.projectionMatrix[10] + var0.modelviewMatrix[11] * var0.projectionMatrix[14]; + var0.clippingMatrix[11] = var0.modelviewMatrix[8] * var0.projectionMatrix[3] + var0.modelviewMatrix[9] * var0.projectionMatrix[7] + var0.modelviewMatrix[10] * var0.projectionMatrix[11] + var0.modelviewMatrix[11] * var0.projectionMatrix[15]; + var0.clippingMatrix[12] = var0.modelviewMatrix[12] * var0.projectionMatrix[0] + var0.modelviewMatrix[13] * var0.projectionMatrix[4] + var0.modelviewMatrix[14] * var0.projectionMatrix[8] + var0.modelviewMatrix[15] * var0.projectionMatrix[12]; + var0.clippingMatrix[13] = var0.modelviewMatrix[12] * var0.projectionMatrix[1] + var0.modelviewMatrix[13] * var0.projectionMatrix[5] + var0.modelviewMatrix[14] * var0.projectionMatrix[9] + var0.modelviewMatrix[15] * var0.projectionMatrix[13]; + var0.clippingMatrix[14] = var0.modelviewMatrix[12] * var0.projectionMatrix[2] + var0.modelviewMatrix[13] * var0.projectionMatrix[6] + var0.modelviewMatrix[14] * var0.projectionMatrix[10] + var0.modelviewMatrix[15] * var0.projectionMatrix[14]; + var0.clippingMatrix[15] = var0.modelviewMatrix[12] * var0.projectionMatrix[3] + var0.modelviewMatrix[13] * var0.projectionMatrix[7] + var0.modelviewMatrix[14] * var0.projectionMatrix[11] + var0.modelviewMatrix[15] * var0.projectionMatrix[15]; + var0.frustrum[0][0] = var0.clippingMatrix[3] - var0.clippingMatrix[0]; + var0.frustrum[0][1] = var0.clippingMatrix[7] - var0.clippingMatrix[4]; + var0.frustrum[0][2] = var0.clippingMatrix[11] - var0.clippingMatrix[8]; + var0.frustrum[0][3] = var0.clippingMatrix[15] - var0.clippingMatrix[12]; + normalize(var0.frustrum, 0); + var0.frustrum[1][0] = var0.clippingMatrix[3] + var0.clippingMatrix[0]; + var0.frustrum[1][1] = var0.clippingMatrix[7] + var0.clippingMatrix[4]; + var0.frustrum[1][2] = var0.clippingMatrix[11] + var0.clippingMatrix[8]; + var0.frustrum[1][3] = var0.clippingMatrix[15] + var0.clippingMatrix[12]; + normalize(var0.frustrum, 1); + var0.frustrum[2][0] = var0.clippingMatrix[3] + var0.clippingMatrix[1]; + var0.frustrum[2][1] = var0.clippingMatrix[7] + var0.clippingMatrix[5]; + var0.frustrum[2][2] = var0.clippingMatrix[11] + var0.clippingMatrix[9]; + var0.frustrum[2][3] = var0.clippingMatrix[15] + var0.clippingMatrix[13]; + normalize(var0.frustrum, 2); + var0.frustrum[3][0] = var0.clippingMatrix[3] - var0.clippingMatrix[1]; + var0.frustrum[3][1] = var0.clippingMatrix[7] - var0.clippingMatrix[5]; + var0.frustrum[3][2] = var0.clippingMatrix[11] - var0.clippingMatrix[9]; + var0.frustrum[3][3] = var0.clippingMatrix[15] - var0.clippingMatrix[13]; + normalize(var0.frustrum, 3); + var0.frustrum[4][0] = var0.clippingMatrix[3] - var0.clippingMatrix[2]; + var0.frustrum[4][1] = var0.clippingMatrix[7] - var0.clippingMatrix[6]; + var0.frustrum[4][2] = var0.clippingMatrix[11] - var0.clippingMatrix[10]; + var0.frustrum[4][3] = var0.clippingMatrix[15] - var0.clippingMatrix[14]; + normalize(var0.frustrum, 4); + var0.frustrum[5][0] = var0.clippingMatrix[3] + var0.clippingMatrix[2]; + var0.frustrum[5][1] = var0.clippingMatrix[7] + var0.clippingMatrix[6]; + var0.frustrum[5][2] = var0.clippingMatrix[11] + var0.clippingMatrix[10]; + var0.frustrum[5][3] = var0.clippingMatrix[15] + var0.clippingMatrix[14]; + normalize(var0.frustrum, 5); + return instance; + } + + private static void normalize(float[][] var0, int var1) { + float var2 = MathHelper.sqrt_float(var0[var1][0] * var0[var1][0] + var0[var1][1] * var0[var1][1] + var0[var1][2] * var0[var1][2]); + var0[var1][0] /= var2; + var0[var1][1] /= var2; + var0[var1][2] /= var2; + var0[var1][3] /= var2; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/camera/Frustrum.java b/src/teavm/java/net/minecraft/client/render/camera/Frustrum.java new file mode 100644 index 0000000..e02ff32 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/camera/Frustrum.java @@ -0,0 +1,26 @@ +package net.minecraft.client.render.camera; + +import net.minecraft.game.physics.AxisAlignedBB; + +public final class Frustrum implements ICamera { + private ClippingHelper clippingHelper = ClippingHelperImplementation.init(); + + public final boolean isBoundingBoxInFrustrum(AxisAlignedBB var1) { + ClippingHelper var9 = this.clippingHelper; + float var7 = var1.maxZ; + float var6 = var1.maxY; + float var5 = var1.maxX; + float var4 = var1.minZ; + float var3 = var1.minY; + float var10 = var1.minX; + var9 = var9; + + for(int var8 = 0; var8 < 6; ++var8) { + if(var9.frustrum[var8][0] * var10 + var9.frustrum[var8][1] * var3 + var9.frustrum[var8][2] * var4 + var9.frustrum[var8][3] <= 0.0F && var9.frustrum[var8][0] * var5 + var9.frustrum[var8][1] * var3 + var9.frustrum[var8][2] * var4 + var9.frustrum[var8][3] <= 0.0F && var9.frustrum[var8][0] * var10 + var9.frustrum[var8][1] * var6 + var9.frustrum[var8][2] * var4 + var9.frustrum[var8][3] <= 0.0F && var9.frustrum[var8][0] * var5 + var9.frustrum[var8][1] * var6 + var9.frustrum[var8][2] * var4 + var9.frustrum[var8][3] <= 0.0F && var9.frustrum[var8][0] * var10 + var9.frustrum[var8][1] * var3 + var9.frustrum[var8][2] * var7 + var9.frustrum[var8][3] <= 0.0F && var9.frustrum[var8][0] * var5 + var9.frustrum[var8][1] * var3 + var9.frustrum[var8][2] * var7 + var9.frustrum[var8][3] <= 0.0F && var9.frustrum[var8][0] * var10 + var9.frustrum[var8][1] * var6 + var9.frustrum[var8][2] * var7 + var9.frustrum[var8][3] <= 0.0F && var9.frustrum[var8][0] * var5 + var9.frustrum[var8][1] * var6 + var9.frustrum[var8][2] * var7 + var9.frustrum[var8][3] <= 0.0F) { + return false; + } + } + + return true; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/camera/ICamera.java b/src/teavm/java/net/minecraft/client/render/camera/ICamera.java new file mode 100644 index 0000000..bf9d2bf --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/camera/ICamera.java @@ -0,0 +1,7 @@ +package net.minecraft.client.render.camera; + +import net.minecraft.game.physics.AxisAlignedBB; + +public interface ICamera { + boolean isBoundingBoxInFrustrum(AxisAlignedBB var1); +} diff --git a/src/teavm/java/net/minecraft/client/render/camera/IsomCamera.java b/src/teavm/java/net/minecraft/client/render/camera/IsomCamera.java new file mode 100644 index 0000000..8c228c0 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/camera/IsomCamera.java @@ -0,0 +1,9 @@ +package net.minecraft.client.render.camera; + +import net.minecraft.game.physics.AxisAlignedBB; + +public final class IsomCamera implements ICamera { + public final boolean isBoundingBoxInFrustrum(AxisAlignedBB var1) { + return true; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/Render.java b/src/teavm/java/net/minecraft/client/render/entity/Render.java new file mode 100644 index 0000000..12856c4 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/Render.java @@ -0,0 +1,180 @@ +package net.minecraft.client.render.entity; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.render.RenderBlocks; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.physics.AxisAlignedBB; +import org.lwjgl.opengl.GL11; + +public abstract class Render { + protected RenderManager renderManager; + protected float shadowSize; + protected float shadowOpaque; + + public Render() { + new ModelBiped(); + new RenderBlocks(); + this.shadowSize = 0.0F; + this.shadowOpaque = 1.0F; + } + + public abstract void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6); + + protected final void loadTexture(String var1) { + RenderEngine var2 = this.renderManager.renderEngine; + RenderEngine.bindTexture(var2.getTexture(var1)); + } + + protected final void loadDownloadableImageTexture(String var1, String var2) { + RenderEngine var3 = this.renderManager.renderEngine; + RenderEngine.bindTexture(var3.getTextureForDownloadableImage(var1, var2)); + } + + public static void renderOffsetAABB(AxisAlignedBB var0) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator var1 = Tessellator.instance; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + var1.startDrawingQuads(); + Tessellator.setNormal(0.0F, 0.0F, -1.0F); + var1.addVertex(var0.minX, var0.maxY, var0.minZ); + var1.addVertex(var0.maxX, var0.maxY, var0.minZ); + var1.addVertex(var0.maxX, var0.minY, var0.minZ); + var1.addVertex(var0.minX, var0.minY, var0.minZ); + Tessellator.setNormal(0.0F, 0.0F, 1.0F); + var1.addVertex(var0.minX, var0.minY, var0.maxZ); + var1.addVertex(var0.maxX, var0.minY, var0.maxZ); + var1.addVertex(var0.maxX, var0.maxY, var0.maxZ); + var1.addVertex(var0.minX, var0.maxY, var0.maxZ); + Tessellator.setNormal(0.0F, -1.0F, 0.0F); + var1.addVertex(var0.minX, var0.minY, var0.minZ); + var1.addVertex(var0.maxX, var0.minY, var0.minZ); + var1.addVertex(var0.maxX, var0.minY, var0.maxZ); + var1.addVertex(var0.minX, var0.minY, var0.maxZ); + Tessellator.setNormal(0.0F, 1.0F, 0.0F); + var1.addVertex(var0.minX, var0.maxY, var0.maxZ); + var1.addVertex(var0.maxX, var0.maxY, var0.maxZ); + var1.addVertex(var0.maxX, var0.maxY, var0.minZ); + var1.addVertex(var0.minX, var0.maxY, var0.minZ); + Tessellator.setNormal(-1.0F, 0.0F, 0.0F); + var1.addVertex(var0.minX, var0.minY, var0.maxZ); + var1.addVertex(var0.minX, var0.maxY, var0.maxZ); + var1.addVertex(var0.minX, var0.maxY, var0.minZ); + var1.addVertex(var0.minX, var0.minY, var0.minZ); + Tessellator.setNormal(1.0F, 0.0F, 0.0F); + var1.addVertex(var0.maxX, var0.minY, var0.minZ); + var1.addVertex(var0.maxX, var0.maxY, var0.minZ); + var1.addVertex(var0.maxX, var0.maxY, var0.maxZ); + var1.addVertex(var0.maxX, var0.minY, var0.maxZ); + var1.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public final void setRenderManager(RenderManager var1) { + this.renderManager = var1; + } + + public final void renderShadow(Entity var1, float var2, float var3, float var4, float var5) { + float var12; + float var18; + float var19; + int var29; + float var34; + float var36; + if(this.shadowSize > 0.0F) { + var5 = this.renderManager.getDistanceToCamera(var2, var3, var4); + var5 = (1.0F - var5 / 256.0F) * this.shadowOpaque; + if(var5 > 0.0F) { + float var9 = var5; + float var8 = var4; + float var7 = var3; + float var6 = var2; + Render var27 = this; + GL11.glEnable(GL11.GL_BLEND); + RenderEngine var10 = this.renderManager.renderEngine; + RenderEngine.bindTexture(var10.getTexture("%%/shadow.png")); + World var11 = this.renderManager.worldObj; + GL11.glDepthMask(false); + var12 = this.shadowSize; + + for(var29 = (int)(var2 - var12); var29 <= (int)(var6 + var12); ++var29) { + for(int var13 = (int)(var7 - 2.0F); var13 <= (int)var7; ++var13) { + for(int var14 = (int)(var8 - var12); var14 <= (int)(var8 + var12); ++var14) { + int var15 = var11.getBlockId(var29, var13 - 1, var14); + if(var15 > 0 && var11.getBlockLightValue(var29, var13, var14) > 3) { + Block var16 = Block.blocksList[var15]; + Tessellator var25 = Tessellator.instance; + var34 = (var9 - (var7 - (float)var13) / 2.0F) * 0.5F * var27.renderManager.worldObj.getLightBrightness(var29, var13, var14); + if(var34 >= 0.0F) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, var34); + var25.startDrawingQuads(); + var34 = (float)var29 + var16.minX; + var18 = (float)var29 + var16.maxX; + float var20 = (float)var13 + var16.minY; + float var21 = (float)var14 + var16.minZ; + var36 = (float)var14 + var16.maxZ; + float var22 = (var6 - var34) / 2.0F / var12 + 0.5F; + float var17 = (var6 - var18) / 2.0F / var12 + 0.5F; + float var23 = (var8 - var21) / 2.0F / var12 + 0.5F; + var19 = (var8 - var36) / 2.0F / var12 + 0.5F; + var25.addVertexWithUV(var34, var20, var21, var22, var23); + var25.addVertexWithUV(var34, var20, var36, var22, var19); + var25.addVertexWithUV(var18, var20, var36, var17, var19); + var25.addVertexWithUV(var18, var20, var21, var17, var23); + var25.draw(); + } + } + } + } + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + } + } + + if(var1.fire > 0) { + GL11.glDisable(GL11.GL_LIGHTING); + int var26 = Block.fire.blockIndexInTexture; + var29 = (var26 & 15) << 4; + int var30 = var26 & 240; + var12 = (float)var29 / 256.0F; + float var31 = ((float)var29 + 15.99F) / 256.0F; + float var32 = (float)var30 / 256.0F; + float var33 = ((float)var30 + 15.99F) / 256.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(var2, var3, var4); + var34 = var1.width * 1.4F; + GL11.glScalef(var34, var34, var34); + this.loadTexture("/terrain.png"); + Tessellator var35 = Tessellator.instance; + var36 = 1.0F; + var18 = 0.0F; + var19 = var1.height / var1.width; + GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, 0.4F + (float)((int)var19) * 0.02F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + var35.startDrawingQuads(); + + while(var19 > 0.0F) { + var35.addVertexWithUV(var36 - 0.5F, 0.0F - var18, 0.0F, var31, var33); + var35.addVertexWithUV(-0.5F, 0.0F - var18, 0.0F, var12, var33); + var35.addVertexWithUV(-0.5F, 1.4F - var18, 0.0F, var12, var32); + var35.addVertexWithUV(var36 - 0.5F, 1.4F - var18, 0.0F, var31, var32); + --var19; + --var18; + var36 *= 0.9F; + GL11.glTranslatef(0.0F, 0.0F, -0.04F); + } + + var35.draw(); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderArrow.java b/src/teavm/java/net/minecraft/client/render/entity/RenderArrow.java new file mode 100644 index 0000000..64b5617 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderArrow.java @@ -0,0 +1,57 @@ +package net.minecraft.client.render.entity; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.projectile.EntityArrow; +import org.lwjgl.opengl.GL11; + +public final class RenderArrow extends Render { + public final void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) { + EntityArrow var8 = (EntityArrow)var1; + this.loadTexture("/item/arrows.png"); + GL11.glPushMatrix(); + GL11.glTranslatef(var2, var3, var4); + GL11.glRotatef(var8.prevRotationYaw + (var8.rotationYaw - var8.prevRotationYaw) * var6 - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(var8.prevRotationPitch + (var8.rotationPitch - var8.prevRotationPitch) * var6, 0.0F, 0.0F, 1.0F); + Tessellator var7 = Tessellator.instance; + GL11.glEnable(GL11.GL_NORMALIZE); + var2 = (float)var8.arrowShake - var6; + if(var2 > 0.0F) { + var2 = -MathHelper.sin(var2 * 3.0F) * var2; + GL11.glRotatef(var2, 0.0F, 0.0F, 1.0F); + } + + GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); + GL11.glScalef(0.05625F, 0.05625F, 0.05625F); + GL11.glTranslatef(-4.0F, 0.0F, 0.0F); + GL11.glNormal3f(0.05625F, 0.0F, 0.0F); + var7.startDrawingQuads(); + var7.addVertexWithUV(-7.0F, -2.0F, -2.0F, 0.0F, 0.15625F); + var7.addVertexWithUV(-7.0F, -2.0F, 2.0F, 0.15625F, 0.15625F); + var7.addVertexWithUV(-7.0F, 2.0F, 2.0F, 0.15625F, 5.0F / 16.0F); + var7.addVertexWithUV(-7.0F, 2.0F, -2.0F, 0.0F, 5.0F / 16.0F); + var7.draw(); + GL11.glNormal3f(-0.05625F, 0.0F, 0.0F); + var7.startDrawingQuads(); + var7.addVertexWithUV(-7.0F, 2.0F, -2.0F, 0.0F, 0.15625F); + var7.addVertexWithUV(-7.0F, 2.0F, 2.0F, 0.15625F, 0.15625F); + var7.addVertexWithUV(-7.0F, -2.0F, 2.0F, 0.15625F, 5.0F / 16.0F); + var7.addVertexWithUV(-7.0F, -2.0F, -2.0F, 0.0F, 5.0F / 16.0F); + var7.draw(); + + for(int var9 = 0; var9 < 4; ++var9) { + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glNormal3f(0.0F, 0.0F, 0.05625F); + var7.startDrawingQuads(); + var7.addVertexWithUV(-8.0F, -2.0F, 0.0F, 0.0F, 0.0F); + var7.addVertexWithUV(8.0F, -2.0F, 0.0F, 0.5F, 0.0F); + var7.addVertexWithUV(8.0F, 2.0F, 0.0F, 0.5F, 0.15625F); + var7.addVertexWithUV(-8.0F, 2.0F, 0.0F, 0.0F, 0.15625F); + var7.draw(); + } + + GL11.glDisable(GL11.GL_NORMALIZE); + GL11.glPopMatrix(); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderCreeper.java b/src/teavm/java/net/minecraft/client/render/entity/RenderCreeper.java new file mode 100644 index 0000000..7f0b284 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderCreeper.java @@ -0,0 +1,51 @@ +package net.minecraft.client.render.entity; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.model.ModelCreeper; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.monster.EntityCreeper; +import org.lwjgl.opengl.GL11; + +public final class RenderCreeper extends RenderLiving { + public RenderCreeper() { + super(new ModelCreeper(), 0.5F); + } + + protected final void preRenderCallback(EntityLiving var1, float var2) { + EntityCreeper var4 = (EntityCreeper)var1; + float var5 = var4.c(var2); + var2 = 1.0F + MathHelper.sin(var5 * 100.0F) * var5 * 0.01F; + if(var5 < 0.0F) { + var5 = 0.0F; + } + + if(var5 > 1.0F) { + var5 = 1.0F; + } + + var5 *= var5; + var5 *= var5; + float var3 = (1.0F + var5 * 0.4F) * var2; + var5 = (1.0F + var5 * 0.1F) / var2; + GL11.glScalef(var3, var5, var3); + } + + protected final int getColorMultiplier(EntityLiving var1, float var2, float var3) { + EntityCreeper var4 = (EntityCreeper)var1; + float var5 = var4.c(var3); + if((int)(var5 * 10.0F) % 2 == 0) { + return 0; + } else { + int var6 = (int)(var5 * 0.2F * 255.0F); + if(var6 < 0) { + var6 = 0; + } + + if(var6 > 255) { + var6 = 255; + } + + return var6 << 24 | 16711680 | '\uff00' | 255; + } + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderEntity.java b/src/teavm/java/net/minecraft/client/render/entity/RenderEntity.java new file mode 100644 index 0000000..3382a39 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderEntity.java @@ -0,0 +1,13 @@ +package net.minecraft.client.render.entity; + +import net.minecraft.game.entity.Entity; +import org.lwjgl.opengl.GL11; + +public final class RenderEntity extends Render { + public final void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) { + GL11.glPushMatrix(); + GL11.glTranslatef(var2 - var1.lastTickPosX, var3 - var1.lastTickPosY, var4 - var1.lastTickPosZ); + renderOffsetAABB(var1.boundingBox); + GL11.glPopMatrix(); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderGiantZombie.java b/src/teavm/java/net/minecraft/client/render/entity/RenderGiantZombie.java new file mode 100644 index 0000000..5ffc3a7 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderGiantZombie.java @@ -0,0 +1,17 @@ +package net.minecraft.client.render.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.game.entity.EntityLiving; +import org.lwjgl.opengl.GL11; + +public final class RenderGiantZombie extends RenderLiving { + private float scale = 6.0F; + + public RenderGiantZombie(ModelBase var1, float var2, float var3) { + super(var1, 3.0F); + } + + protected final void preRenderCallback(EntityLiving var1, float var2) { + GL11.glScalef(this.scale, this.scale, this.scale); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderItem.java b/src/teavm/java/net/minecraft/client/render/entity/RenderItem.java new file mode 100644 index 0000000..3266676 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderItem.java @@ -0,0 +1,200 @@ +package net.minecraft.client.render.entity; + +import java.util.Random; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.render.RenderBlocks; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.block.Block; +import org.lwjgl.opengl.GL11; + +public final class RenderItem extends Render { + private RenderBlocks renderBlocks = new RenderBlocks(); + private Random random = new Random(); + + public RenderItem() { + this.shadowSize = 0.15F; + this.shadowOpaque = 12.0F / 16.0F; + } + + public final void renderItemIntoGUI(RenderEngine var1, ItemStack var2, int var3, int var4) { + if(var2 != null) { + int var9; + if(var2.itemID < 256 && Block.blocksList[var2.itemID].getRenderType() == 0) { + var9 = var2.itemID; + RenderEngine.bindTexture(var1.getTexture("/terrain.png")); + Block var8 = Block.blocksList[var9]; + GL11.glPushMatrix(); + GL11.glTranslatef((float)(var3 - 2), (float)(var4 + 3), 0.0F); + GL11.glScalef(10.0F, 10.0F, 10.0F); + GL11.glTranslatef(1.0F, 0.5F, 8.0F); + GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.renderBlocks.renderBlockOnInventory(var8); + GL11.glPopMatrix(); + } else { + if(var2.getItem().getIconIndex() >= 0) { + GL11.glDisable(GL11.GL_LIGHTING); + if(var2.itemID < 256) { + RenderEngine.bindTexture(var1.getTexture("/terrain.png")); + } else { + RenderEngine.bindTexture(var1.getTexture("/gui/items.png")); + } + + int var10000 = var3; + int var10001 = var4; + int var10002 = var2.getItem().getIconIndex() % 16 << 4; + int var10003 = var2.getItem().getIconIndex() / 16 << 4; + boolean var6 = true; + var6 = true; + var4 = var10003; + var3 = var10002; + var9 = var10001; + int var7 = var10000; + Tessellator var5 = Tessellator.instance; + var5.startDrawingQuads(); + var5.addVertexWithUV((float)var7, (float)(var9 + 16), 0.0F, (float)var3 * 0.00390625F, (float)(var4 + 16) * 0.00390625F); + var5.addVertexWithUV((float)(var7 + 16), (float)(var9 + 16), 0.0F, (float)(var3 + 16) * 0.00390625F, (float)(var4 + 16) * 0.00390625F); + var5.addVertexWithUV((float)(var7 + 16), (float)var9, 0.0F, (float)(var3 + 16) * 0.00390625F, (float)var4 * 0.00390625F); + var5.addVertexWithUV((float)var7, (float)var9, 0.0F, (float)var3 * 0.00390625F, (float)var4 * 0.00390625F); + var5.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + } + + } + } + } + + public final void renderItemOverlayIntoGUI(FontRenderer var1, ItemStack var2, int var3, int var4) { + if(var2 != null) { + if(var2.stackSize > 1) { + String var5 = "" + var2.stackSize; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + var1.drawStringWithShadow(var5, var3 + 19 - 2 - var1.getStringWidth(var5), var4 + 6 + 3, 16777215); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + if(var2.itemDamage > 0) { + int var9 = 13 - var2.itemDamage * 13 / var2.isItemStackDamageable(); + int var7 = 255 - var2.itemDamage * 255 / var2.isItemStackDamageable(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator var8 = Tessellator.instance; + int var6 = 255 - var7 << 16 | var7 << 8; + var7 = (255 - var7) / 4 << 16 | 16128; + renderQuad(var8, var3 + 2, var4 + 13, 13, 2, 0); + renderQuad(var8, var3 + 2, var4 + 13, 12, 1, var7); + renderQuad(var8, var3 + 2, var4 + 13, var9, 1, var6); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + } + } + + private static void renderQuad(Tessellator var0, int var1, int var2, int var3, int var4, int var5) { + var0.startDrawingQuads(); + var0.setColorOpaque_I(var5); + var0.addVertex((float)var1, (float)var2, 0.0F); + var0.addVertex((float)var1, (float)(var2 + var4), 0.0F); + var0.addVertex((float)(var1 + var3), (float)(var2 + var4), 0.0F); + var0.addVertex((float)(var1 + var3), (float)var2, 0.0F); + var0.draw(); + } + + public final void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) { + EntityItem var13 = (EntityItem)var1; + RenderItem var12 = this; + this.random.setSeed(187L); + ItemStack var7 = var13.item; + GL11.glPushMatrix(); + float var8 = MathHelper.sin(((float)var13.age + var6) / 10.0F + var13.hoverStart) * 0.1F + 0.1F; + var6 = (((float)var13.age + var6) / 20.0F + var13.hoverStart) * (180.0F / (float)Math.PI); + byte var9 = 1; + if(var13.item.stackSize > 1) { + var9 = 2; + } + + if(var13.item.stackSize > 5) { + var9 = 3; + } + + if(var13.item.stackSize > 20) { + var9 = 4; + } + + GL11.glTranslatef(var2, var3 + var8, var4); + GL11.glEnable(GL11.GL_NORMALIZE); + if(var7.itemID < 256 && Block.blocksList[var7.itemID].getRenderType() == 0) { + GL11.glRotatef(var6, 0.0F, 1.0F, 0.0F); + this.loadTexture("/terrain.png"); + var2 = 0.25F; + if(!Block.blocksList[var7.itemID].renderAsNormalBlock() && var7.itemID != Block.stairSingle.blockID) { + var2 = 0.5F; + } + + GL11.glScalef(var2, var2, var2); + + for(int var16 = 0; var16 < var9; ++var16) { + GL11.glPushMatrix(); + if(var16 > 0) { + var4 = (var12.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var2; + var5 = (var12.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var2; + var6 = (var12.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var2; + GL11.glTranslatef(var4, var5, var6); + } + + var12.renderBlocks.renderBlockOnInventory(Block.blocksList[var7.itemID]); + GL11.glPopMatrix(); + } + } else { + GL11.glScalef(0.5F, 0.5F, 0.5F); + int var14 = var7.getItem().getIconIndex(); + if(var7.itemID < 256) { + this.loadTexture("/terrain.png"); + } else { + this.loadTexture("/gui/items.png"); + } + + Tessellator var15 = Tessellator.instance; + var4 = (float)(var14 % 16 << 4) / 256.0F; + var5 = (float)((var14 % 16 << 4) + 16) / 256.0F; + var6 = (float)(var14 / 16 << 4) / 256.0F; + var2 = (float)((var14 / 16 << 4) + 16) / 256.0F; + + for(int var17 = 0; var17 < var9; ++var17) { + GL11.glPushMatrix(); + if(var17 > 0) { + var8 = (var12.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float var10 = (var12.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float var11 = (var12.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(var8, var10, var11); + } + + GL11.glRotatef(180.0F - var12.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + var15.startDrawingQuads(); + Tessellator.setNormal(0.0F, 1.0F, 0.0F); + var15.addVertexWithUV(-0.5F, -0.25F, 0.0F, var4, var2); + var15.addVertexWithUV(0.5F, -0.25F, 0.0F, var5, var2); + var15.addVertexWithUV(0.5F, 12.0F / 16.0F, 0.0F, var5, var6); + var15.addVertexWithUV(-0.5F, 12.0F / 16.0F, 0.0F, var4, var6); + var15.draw(); + GL11.glPopMatrix(); + } + } + + GL11.glDisable(GL11.GL_NORMALIZE); + GL11.glPopMatrix(); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderLiving.java b/src/teavm/java/net/minecraft/client/render/entity/RenderLiving.java new file mode 100644 index 0000000..5d2168d --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderLiving.java @@ -0,0 +1,134 @@ +package net.minecraft.client.render.entity; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.client.model.ModelBase; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import org.lwjgl.opengl.GL11; + +public class RenderLiving extends Render { + protected ModelBase mainModel; + private ModelBase renderPassModel; + + public RenderLiving(ModelBase var1, float var2) { + this.mainModel = var1; + this.shadowSize = var2; + } + + public final void setRenderPassModel(ModelBase var1) { + this.renderPassModel = var1; + } + + public void a(EntityLiving var1, float var2, float var3, float var4, float var5, float var6) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + + try { + var5 = var1.prevRenderYawOffset + (var1.renderYawOffset - var1.prevRenderYawOffset) * var6; + float var7 = var1.prevRotationYaw + (var1.rotationYaw - var1.prevRotationYaw) * var6; + float var8 = var1.prevRotationPitch + (var1.rotationPitch - var1.prevRotationPitch) * var6; + GL11.glTranslatef(var2, var3, var4); + var2 = (float)var1.ticksExisted + var6; + GL11.glRotatef(180.0F - var5, 0.0F, 1.0F, 0.0F); + if(var1.deathTime > 0) { + var3 = ((float)var1.deathTime + var6 - 1.0F) / 20.0F * 1.6F; + var3 = MathHelper.sqrt_float(var3); + if(var3 > 1.0F) { + var3 = 1.0F; + } + + GL11.glRotatef(var3 * this.getDeathMaxRotation(var1), 0.0F, 0.0F, 1.0F); + } + + GL11.glScalef(-(1.0F / 16.0F), -(1.0F / 16.0F), 1.0F / 16.0F); + this.preRenderCallback(var1, var6); + GL11.glTranslatef(0.0F, -24.0F, 0.0F); + GL11.glEnable(GL11.GL_NORMALIZE); + var3 = var1.prevLimbYaw + (var1.limbYaw - var1.prevLimbYaw) * var6; + var4 = var1.limbSwing - var1.limbYaw * (1.0F - var6); + if(var3 > 1.0F) { + var3 = 1.0F; + } + + this.loadDownloadableImageTexture(var1.skinUrl, var1.getTexture()); + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.mainModel.render(var4, var3, var2, var7 - var5, var8, 1.0F); + + for(int var9 = 0; var9 < 4; ++var9) { + if(this.shouldRenderPass(var1, var9)) { + this.renderPassModel.render(var4, var3, var2, var7 - var5, var8, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + float var15 = var1.getEntityBrightness(var6); + int var14 = this.getColorMultiplier(var1, var15, var6); + if(var14 >>> 24 > 0 || var1.hurtTime > 0 || var1.deathTime > 0) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); + if(var1.hurtTime > 0 || var1.deathTime > 0) { + GL11.glColor4f(var15, 0.0F, 0.0F, 0.4F); + this.mainModel.render(var4, var3, var2, var7 - var5, var8, 1.0F); + + for(int var10 = 0; var10 < 4; ++var10) { + if(this.shouldRenderPass(var1, var10)) { + GL11.glColor4f(var15, 0.0F, 0.0F, 0.4F); + this.renderPassModel.render(var4, var3, var2, var7 - var5, var8, 1.0F); + } + } + } + + if(var14 >>> 24 > 0) { + float var16 = (float)(var14 >> 16 & 255) / 255.0F; + var15 = (float)(var14 >> 8 & 255) / 255.0F; + float var11 = (float)(var14 & 255) / 255.0F; + var6 = (float)(var14 >>> 24) / 255.0F; + GL11.glColor4f(var16, var15, var11, var6); + this.mainModel.render(var4, var3, var2, var7 - var5, var8, 1.0F); + + for(int var12 = 0; var12 < 4; ++var12) { + if(this.shouldRenderPass(var1, var12)) { + GL11.glColor4f(var16, var15, var11, var6); + this.renderPassModel.render(var4, var3, var2, var7 - var5, var8, 1.0F); + } + } + } + + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glDisable(GL11.GL_NORMALIZE); + } catch (Exception var13) { + var13.printStackTrace(); + } + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } + + protected boolean shouldRenderPass(EntityLiving var1, int var2) { + return false; + } + + protected float getDeathMaxRotation(EntityLiving var1) { + return 90.0F; + } + + protected int getColorMultiplier(EntityLiving var1, float var2, float var3) { + return 0; + } + + protected void preRenderCallback(EntityLiving var1, float var2) { + } + + public void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) { + this.a((EntityLiving)var1, var2, var3, var4, var5, var6); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderManager.java b/src/teavm/java/net/minecraft/client/render/entity/RenderManager.java new file mode 100644 index 0000000..903cc7e --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderManager.java @@ -0,0 +1,113 @@ +package net.minecraft.client.render.entity; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelPig; +import net.minecraft.client.model.ModelSheep; +import net.minecraft.client.model.ModelSheepFur; +import net.minecraft.client.model.ModelSkeleton; +import net.minecraft.client.model.ModelZombie; +import net.minecraft.client.render.RenderEngine; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.EntityPainting; +import net.minecraft.game.entity.animal.EntityPig; +import net.minecraft.game.entity.animal.EntitySheep; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.entity.misc.EntityTNTPrimed; +import net.minecraft.game.entity.monster.EntityCreeper; +import net.minecraft.game.entity.monster.EntityGiantZombie; +import net.minecraft.game.entity.monster.EntitySkeleton; +import net.minecraft.game.entity.monster.EntitySpider; +import net.minecraft.game.entity.monster.EntityZombie; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.entity.projectile.EntityArrow; +import net.minecraft.game.level.World; +import org.lwjgl.opengl.GL11; + +public final class RenderManager { + private Map entityRenderMap = new HashMap(); + public static RenderManager instance = new RenderManager(); + public RenderEngine renderEngine; + public World worldObj; + public float playerViewY; + private float viewerPosX; + private float viewerPosY; + private float viewerPosZ; + + private RenderManager() { + this.entityRenderMap.put(EntitySpider.class, new RenderSpider()); + this.entityRenderMap.put(EntityPig.class, new RenderLiving(new ModelPig(), 0.7F)); + this.entityRenderMap.put(EntitySheep.class, new RenderSheep(new ModelSheep(), new ModelSheepFur(), 0.7F)); + this.entityRenderMap.put(EntityCreeper.class, new RenderCreeper()); + this.entityRenderMap.put(EntitySkeleton.class, new RenderLiving(new ModelSkeleton(), 0.5F)); + this.entityRenderMap.put(EntityZombie.class, new RenderLiving(new ModelZombie(), 0.5F)); + this.entityRenderMap.put(EntityPlayer.class, new RenderPlayer()); + this.entityRenderMap.put(EntityGiantZombie.class, new RenderGiantZombie(new ModelZombie(), 0.5F, 6.0F)); + this.entityRenderMap.put(EntityLiving.class, new RenderLiving(new ModelBiped(), 0.5F)); + this.entityRenderMap.put(Entity.class, new RenderEntity()); + this.entityRenderMap.put(EntityPainting.class, new RenderPainting()); + this.entityRenderMap.put(EntityArrow.class, new RenderArrow()); + this.entityRenderMap.put(EntityItem.class, new RenderItem()); + this.entityRenderMap.put(EntityTNTPrimed.class, new RenderTNTPrimed()); + Iterator var1 = this.entityRenderMap.values().iterator(); + + while(var1.hasNext()) { + Render var2 = (Render)var1.next(); + var2.setRenderManager(this); + } + + } + + public final Render getEntityRenderObject(Entity var1) { + Class var2 = var1.getClass(); + Render var3 = (Render)this.entityRenderMap.get(var2); + if(var3 == null && var2 != Entity.class) { + var3 = (Render)this.entityRenderMap.get(var2.getSuperclass()); + this.entityRenderMap.put(var2, var3); + } + + return var3; + } + + public final void cacheActiveRenderInfo(World var1, RenderEngine var2, EntityPlayer var3, float var4) { + this.worldObj = var1; + this.renderEngine = var2; + this.playerViewY = var3.prevRotationYaw + (var3.rotationYaw - var3.prevRotationYaw) * var4; + this.viewerPosX = var3.lastTickPosX + (var3.posX - var3.lastTickPosX) * var4; + this.viewerPosY = var3.lastTickPosY + (var3.posY - var3.lastTickPosY) * var4; + this.viewerPosZ = var3.lastTickPosZ + (var3.posZ - var3.lastTickPosZ) * var4; + } + + public final void renderEntity(Entity var1, float var2) { + float var3 = var1.lastTickPosX + (var1.posX - var1.lastTickPosX) * var2; + float var4 = var1.lastTickPosY + (var1.posY - var1.lastTickPosY) * var2; + float var5 = var1.lastTickPosZ + (var1.posZ - var1.lastTickPosZ) * var2; + float var6 = var1.prevRotationYaw + (var1.rotationYaw - var1.prevRotationYaw) * var2; + float var7 = this.worldObj.getLightBrightness((int)var3, (int)(var4 + var1.getShadowSize()), (int)var5); + GL11.glColor3f(var7, var7, var7); + this.renderEntityWithPosYaw(var1, var3, var4, var5, var6, var2); + } + + public final void renderEntityWithPosYaw(Entity var1, float var2, float var3, float var4, float var5, float var6) { + Render var7 = this.getEntityRenderObject(var1); + if(var7 != null) { + var7.doRender(var1, var2, var3, var4, var5, var6); + var7.renderShadow(var1, var2, var3, var4, var6); + } + + } + + public final void set(World var1) { + this.worldObj = var1; + } + + public final float getDistanceToCamera(float var1, float var2, float var3) { + var1 -= this.viewerPosX; + var2 -= this.viewerPosY; + var3 -= this.viewerPosZ; + return var1 * var1 + var2 * var2 + var3 * var3; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderPainting.java b/src/teavm/java/net/minecraft/client/render/entity/RenderPainting.java new file mode 100644 index 0000000..729f9a6 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderPainting.java @@ -0,0 +1,105 @@ +package net.minecraft.client.render.entity; + +import java.util.Random; +import net.minecraft.client.render.Tessellator; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityPainting; +import net.minecraft.game.entity.EnumArt; +import org.lwjgl.opengl.GL11; + +public final class RenderPainting extends Render { + private Random rand = new Random(); + + public final void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) { + EntityPainting var22 = (EntityPainting)var1; + this.rand.setSeed(187L); + GL11.glPushMatrix(); + GL11.glTranslatef(var2, var3, var4); + GL11.glRotatef(var5, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL11.GL_NORMALIZE); + this.loadTexture("/art/kz.png"); + EnumArt var23 = var22.art; + GL11.glScalef(1.0F / 16.0F, 1.0F / 16.0F, 1.0F / 16.0F); + int var27 = var23.offsetY; + int var26 = var23.offsetX; + int var25 = var23.sizeY; + int var24 = var23.sizeX; + var22 = var22; + RenderPainting var21 = this; + float var7 = (float)(-var24) / 2.0F; + float var8 = (float)(-var25) / 2.0F; + + for(int var9 = 0; var9 < var24 / 16; ++var9) { + for(int var10 = 0; var10 < var25 / 16; ++var10) { + float var11 = var7 + (float)(var9 + 1 << 4); + float var12 = var7 + (float)(var9 << 4); + float var13 = var8 + (float)(var10 + 1 << 4); + float var14 = var8 + (float)(var10 << 4); + float var10002 = (var11 + var12) / 2.0F; + float var18 = (var13 + var14) / 2.0F; + float var17 = var10002; + int var19 = (int)var22.posX; + int var28 = (int)(var22.posY + var18 / 16.0F); + int var20 = (int)var22.posZ; + if(var22.direction == 0) { + var19 = (int)(var22.posX + var17 / 16.0F); + } + + if(var22.direction == 1) { + var20 = (int)(var22.posZ - var17 / 16.0F); + } + + if(var22.direction == 2) { + var19 = (int)(var22.posX - var17 / 16.0F); + } + + if(var22.direction == 3) { + var20 = (int)(var22.posZ + var17 / 16.0F); + } + + float var15 = var21.renderManager.worldObj.getLightBrightness(var19, var28, var20); + GL11.glColor3f(var15, var15, var15); + var15 = (float)(var26 + var24 - (var9 << 4)) / 256.0F; + float var16 = (float)(var26 + var24 - (var9 + 1 << 4)) / 256.0F; + var17 = (float)(var27 + var25 - (var10 << 4)) / 256.0F; + var18 = (float)(var27 + var25 - (var10 + 1 << 4)) / 256.0F; + Tessellator var29 = Tessellator.instance; + var29.startDrawingQuads(); + Tessellator.setNormal(0.0F, 0.0F, -1.0F); + var29.addVertexWithUV(var11, var14, -0.5F, var16, var17); + var29.addVertexWithUV(var12, var14, -0.5F, var15, var17); + var29.addVertexWithUV(var12, var13, -0.5F, var15, var18); + var29.addVertexWithUV(var11, var13, -0.5F, var16, var18); + Tessellator.setNormal(0.0F, 0.0F, 1.0F); + var29.addVertexWithUV(var11, var13, 0.5F, 12.0F / 16.0F, 0.0F); + var29.addVertexWithUV(var12, var13, 0.5F, 13.0F / 16.0F, 0.0F); + var29.addVertexWithUV(var12, var14, 0.5F, 13.0F / 16.0F, 1.0F / 16.0F); + var29.addVertexWithUV(var11, var14, 0.5F, 12.0F / 16.0F, 1.0F / 16.0F); + Tessellator.setNormal(0.0F, -1.0F, 0.0F); + var29.addVertexWithUV(var11, var13, -0.5F, 12.0F / 16.0F, 0.001953125F); + var29.addVertexWithUV(var12, var13, -0.5F, 13.0F / 16.0F, 0.001953125F); + var29.addVertexWithUV(var12, var13, 0.5F, 13.0F / 16.0F, 0.001953125F); + var29.addVertexWithUV(var11, var13, 0.5F, 12.0F / 16.0F, 0.001953125F); + Tessellator.setNormal(0.0F, 1.0F, 0.0F); + var29.addVertexWithUV(var11, var14, 0.5F, 12.0F / 16.0F, 0.001953125F); + var29.addVertexWithUV(var12, var14, 0.5F, 13.0F / 16.0F, 0.001953125F); + var29.addVertexWithUV(var12, var14, -0.5F, 13.0F / 16.0F, 0.001953125F); + var29.addVertexWithUV(var11, var14, -0.5F, 12.0F / 16.0F, 0.001953125F); + Tessellator.setNormal(-1.0F, 0.0F, 0.0F); + var29.addVertexWithUV(var11, var13, 0.5F, 385.0F / 512.0F, 0.0F); + var29.addVertexWithUV(var11, var14, 0.5F, 385.0F / 512.0F, 1.0F / 16.0F); + var29.addVertexWithUV(var11, var14, -0.5F, 385.0F / 512.0F, 1.0F / 16.0F); + var29.addVertexWithUV(var11, var13, -0.5F, 385.0F / 512.0F, 0.0F); + Tessellator.setNormal(1.0F, 0.0F, 0.0F); + var29.addVertexWithUV(var12, var13, -0.5F, 385.0F / 512.0F, 0.0F); + var29.addVertexWithUV(var12, var14, -0.5F, 385.0F / 512.0F, 1.0F / 16.0F); + var29.addVertexWithUV(var12, var14, 0.5F, 385.0F / 512.0F, 1.0F / 16.0F); + var29.addVertexWithUV(var12, var13, 0.5F, 385.0F / 512.0F, 0.0F); + var29.draw(); + } + } + + GL11.glDisable(GL11.GL_NORMALIZE); + GL11.glPopMatrix(); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderPlayer.java b/src/teavm/java/net/minecraft/client/render/entity/RenderPlayer.java new file mode 100644 index 0000000..c9aa417 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderPlayer.java @@ -0,0 +1,65 @@ +package net.minecraft.client.render.entity; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.entity.player.InventoryPlayer; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemArmor; +import net.minecraft.game.item.ItemStack; + +public final class RenderPlayer extends RenderLiving { + private ModelBiped modelBipedMain = (ModelBiped)this.mainModel; + private ModelBiped modelArmorChestplate = new ModelBiped(1.0F); + private ModelBiped modelArmor = new ModelBiped(0.5F); + private static final String[] armorFilenamePrefix = new String[]{"cloth", "chain", "iron", "diamond", "gold"}; + + public RenderPlayer() { + super(new ModelBiped(0.0F), 0.5F); + } + + private void renderPlayer(EntityPlayer var1, float var2, float var3, float var4, float var5, float var6) { + super.a(var1, var2, var3 - var1.yOffset, var4, var5, var6); + } + + public final void drawFirstPersonHand() { + this.modelBipedMain.bipedRightArm.render(1.0F); + } + + protected final boolean shouldRenderPass(EntityLiving var1, int var2) { + EntityPlayer var10001 = (EntityPlayer)var1; + int var3 = var2; + EntityPlayer var5 = var10001; + int var4 = 3 - var3; + InventoryPlayer var6 = var5.inventory; + ItemStack var7 = var6.armorInventory[var4]; + if(var7 != null) { + Item var8 = var7.getItem(); + if(var8 instanceof ItemArmor) { + ItemArmor var9 = (ItemArmor)var8; + this.loadTexture("/armor/" + armorFilenamePrefix[var9.renderIndex] + "_" + (var3 == 2 ? 2 : 1) + ".png"); + ModelBiped var10 = var3 == 2 ? this.modelArmor : this.modelArmorChestplate; + var10.bipedHead.showModel = var3 == 0; + var10.bipedHeadwear.showModel = var3 == 0; + var10.bipedBody.showModel = var3 == 1 || var3 == 2; + var10.bipedRightArm.showModel = var3 == 1; + var10.bipedLeftArm.showModel = var3 == 1; + var10.bipedRightLeg.showModel = var3 == 2 || var3 == 3; + var10.bipedLeftLeg.showModel = var3 == 2 || var3 == 3; + this.setRenderPassModel(var10); + return true; + } + } + + return false; + } + + public final void a(EntityLiving var1, float var2, float var3, float var4, float var5, float var6) { + this.renderPlayer((EntityPlayer)var1, var2, var3, var4, var5, var6); + } + + public final void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) { + this.renderPlayer((EntityPlayer)var1, var2, var3, var4, var5, var6); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderSheep.java b/src/teavm/java/net/minecraft/client/render/entity/RenderSheep.java new file mode 100644 index 0000000..83d28ec --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderSheep.java @@ -0,0 +1,20 @@ +package net.minecraft.client.render.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.animal.EntitySheep; + +public final class RenderSheep extends RenderLiving { + public RenderSheep(ModelBase var1, ModelBase var2, float var3) { + super(var1, 0.7F); + this.setRenderPassModel(var2); + } + + protected final boolean shouldRenderPass(EntityLiving var1, int var2) { + EntitySheep var10001 = (EntitySheep)var1; + int var3 = var2; + EntitySheep var4 = var10001; + this.loadTexture("/mob/sheep_fur.png"); + return var3 == 0 && !var4.sheared; + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderSpider.java b/src/teavm/java/net/minecraft/client/render/entity/RenderSpider.java new file mode 100644 index 0000000..8d56504 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderSpider.java @@ -0,0 +1,36 @@ +package net.minecraft.client.render.entity; + +import net.minecraft.client.model.ModelSpider; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.monster.EntitySpider; +import org.lwjgl.opengl.GL11; + +public final class RenderSpider extends RenderLiving { + public RenderSpider() { + super(new ModelSpider(), 1.0F); + this.setRenderPassModel(new ModelSpider()); + } + + protected final float getDeathMaxRotation(EntityLiving var1) { + return 180.0F; + } + + protected final boolean shouldRenderPass(EntityLiving var1, int var2) { + EntitySpider var10001 = (EntitySpider)var1; + int var3 = var2; + EntitySpider var5 = var10001; + if(var3 != 0) { + return false; + } else if(var3 != 0) { + return false; + } else { + this.loadTexture("/mob/spider_eyes.png"); + float var4 = (1.0F - var5.getEntityBrightness(1.0F)) * 0.5F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, var4); + return true; + } + } +} diff --git a/src/teavm/java/net/minecraft/client/render/entity/RenderTNTPrimed.java b/src/teavm/java/net/minecraft/client/render/entity/RenderTNTPrimed.java new file mode 100644 index 0000000..568bb40 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/entity/RenderTNTPrimed.java @@ -0,0 +1,58 @@ +package net.minecraft.client.render.entity; + +import net.minecraft.client.render.RenderBlocks; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.misc.EntityTNTPrimed; +import net.minecraft.game.level.block.Block; +import org.lwjgl.opengl.GL11; + +public final class RenderTNTPrimed extends Render { + private RenderBlocks blockRenderer = new RenderBlocks(); + + public RenderTNTPrimed() { + this.shadowSize = 0.5F; + } + + public final void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) { + EntityTNTPrimed var10001 = (EntityTNTPrimed)var1; + var5 = var4; + var4 = var3; + var3 = var2; + EntityTNTPrimed var7 = var10001; + GL11.glPushMatrix(); + GL11.glTranslatef(var3, var4, var5); + if((float)var7.fuse - var6 + 1.0F < 10.0F) { + var3 = 1.0F - ((float)var7.fuse - var6 + 1.0F) / 10.0F; + if(var3 < 0.0F) { + var3 = 0.0F; + } + + if(var3 > 1.0F) { + var3 = 1.0F; + } + + var3 *= var3; + var3 *= var3; + var3 = 1.0F + var3 * 0.3F; + GL11.glScalef(var3, var3, var3); + } + + var3 = (1.0F - ((float)var7.fuse - var6 + 1.0F) / 100.0F) * 0.8F; + this.loadTexture("/terrain.png"); + this.blockRenderer.renderBlockOnInventory(Block.tnt); + if(var7.fuse / 5 % 2 == 0) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, var3); + this.blockRenderer.renderBlockOnInventory(Block.tnt); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glPopMatrix(); + } +} diff --git a/src/teavm/java/net/minecraft/client/render/texture/TextureFX.java b/src/teavm/java/net/minecraft/client/render/texture/TextureFX.java new file mode 100644 index 0000000..2ef62a8 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/texture/TextureFX.java @@ -0,0 +1,15 @@ +package net.minecraft.client.render.texture; + +public class TextureFX { + public byte[] imageData = new byte[1024]; + public int iconIndex; + public boolean anaglyphEnabled = false; + public int textureId = 0; + + public TextureFX(int var1) { + this.iconIndex = var1; + } + + public void onTick() { + } +} diff --git a/src/teavm/java/net/minecraft/client/render/texture/TextureFlamesFX.java b/src/teavm/java/net/minecraft/client/render/texture/TextureFlamesFX.java new file mode 100644 index 0000000..6e9f072 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/texture/TextureFlamesFX.java @@ -0,0 +1,79 @@ +package net.minecraft.client.render.texture; + +import net.minecraft.game.level.block.Block; + +public final class TextureFlamesFX extends TextureFX { + private float[] currentFireFrame = new float[320]; + private float[] lastFireFrame = new float[320]; + + public TextureFlamesFX(int var1) { + super(Block.fire.blockIndexInTexture + (var1 << 4)); + } + + public final void onTick() { + int var1; + int var2; + int var3; + int var5; + int var6; + for(var1 = 0; var1 < 16; ++var1) { + for(var2 = 0; var2 < 20; ++var2) { + var3 = 18; + float var4 = this.currentFireFrame[var1 + ((var2 + 1) % 20 << 4)] * 18.0F; + + for(var5 = var1 - 1; var5 <= var1 + 1; ++var5) { + for(var6 = var2; var6 <= var2 + 1; ++var6) { + if(var5 >= 0 && var6 >= 0 && var5 < 16 && var6 < 20) { + var4 += this.currentFireFrame[var5 + (var6 << 4)]; + } + + ++var3; + } + } + + this.lastFireFrame[var1 + (var2 << 4)] = var4 / ((float)var3 * 1.06F); + if(var2 >= 19) { + this.lastFireFrame[var1 + (var2 << 4)] = (float)(Math.random() * Math.random() * Math.random() * 4.0D + Math.random() * (double)0.1F + (double)0.2F); + } + } + } + + float[] var9 = this.lastFireFrame; + this.lastFireFrame = this.currentFireFrame; + this.currentFireFrame = var9; + + for(var2 = 0; var2 < 256; ++var2) { + float var10 = this.currentFireFrame[var2] * 1.8F; + if(var10 > 1.0F) { + var10 = 1.0F; + } + + if(var10 < 0.0F) { + var10 = 0.0F; + } + + var5 = (int)(var10 * 155.0F + 100.0F); + var6 = (int)(var10 * var10 * 255.0F); + int var7 = (int)(var10 * var10 * var10 * var10 * var10 * var10 * var10 * var10 * var10 * var10 * 255.0F); + short var8 = 255; + if(var10 < 0.5F) { + var8 = 0; + } + + if(this.anaglyphEnabled) { + var1 = (var5 * 30 + var6 * 59 + var7 * 11) / 100; + var3 = (var5 * 30 + var6 * 70) / 100; + int var11 = (var5 * 30 + var7 * 70) / 100; + var5 = var1; + var6 = var3; + var7 = var11; + } + + this.imageData[var2 << 2] = (byte)var5; + this.imageData[(var2 << 2) + 1] = (byte)var6; + this.imageData[(var2 << 2) + 2] = (byte)var7; + this.imageData[(var2 << 2) + 3] = (byte)var8; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/render/texture/TextureGearsFX.java b/src/teavm/java/net/minecraft/client/render/texture/TextureGearsFX.java new file mode 100644 index 0000000..5e61d21 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/texture/TextureGearsFX.java @@ -0,0 +1,66 @@ +package net.minecraft.client.render.texture; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import javax.imageio.ImageIO; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.game.level.block.Block; + +public class TextureGearsFX extends TextureFX { + private int gearRotation = 0; + private int[] gearColor = new int[1024]; + private int[] gearMiddleColor = new int[1024]; + private int gearRotationDir; + + public TextureGearsFX(int var1) { + super(Block.cog.blockIndexInTexture + var1); + this.gearRotationDir = (var1 << 1) - 1; + this.gearRotation = 2; + + try { + BufferedImage var3 = ImageIO.read(TextureGearsFX.class.getResource("/misc/gear.png")); + var3.getRGB(0, 0, 32, 32, this.gearColor, 0, 32); + var3 = ImageIO.read(TextureGearsFX.class.getResource("/misc/gearmiddle.png")); + var3.getRGB(0, 0, 16, 16, this.gearMiddleColor, 0, 16); + } catch (IOException var2) { + var2.printStackTrace(); + } + } + + public final void onTick() { + this.gearRotation = this.gearRotation + this.gearRotationDir & 63; + float var1 = MathHelper.sin((float)this.gearRotation / 64.0F * (float)Math.PI * 2.0F); + float var2 = MathHelper.cos((float)this.gearRotation / 64.0F * (float)Math.PI * 2.0F); + + for(int var3 = 0; var3 < 16; ++var3) { + for(int var4 = 0; var4 < 16; ++var4) { + float var5 = ((float)var3 / 15.0F - 0.5F) * 31.0F; + float var6 = ((float)var4 / 15.0F - 0.5F) * 31.0F; + float var7 = var2 * var5 - var1 * var6; + var5 = var2 * var6 + var1 * var5; + int var11 = (int)(var7 + 16.0F); + int var10 = (int)(var5 + 16.0F); + int var12 = 0; + if(var11 >= 0 && var10 >= 0 && var11 < 32 && var10 < 32) { + var12 = this.gearColor[var11 + (var10 << 5)]; + var10 = this.gearMiddleColor[var3 + (var4 << 4)]; + if(var10 >>> 24 > 128) { + var12 = var10; + } + } + + var10 = var12 >> 16 & 255; + var11 = var12 >> 8 & 255; + int var8 = var12 & 255; + var12 = var12 >>> 24 > 128 ? 255 : 0; + int var9 = var3 + (var4 << 4); + this.imageData[var9 << 2] = (byte)var10; + this.imageData[(var9 << 2) + 1] = (byte)var11; + this.imageData[(var9 << 2) + 2] = (byte)var8; + this.imageData[(var9 << 2) + 3] = (byte)var12; + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/render/texture/TextureLavaFX.java b/src/teavm/java/net/minecraft/client/render/texture/TextureLavaFX.java new file mode 100644 index 0000000..614a841 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/texture/TextureLavaFX.java @@ -0,0 +1,85 @@ +package net.minecraft.client.render.texture; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.game.level.block.Block; + +public final class TextureLavaFX extends TextureFX { + private float[] red = new float[256]; + private float[] green = new float[256]; + private float[] blue = new float[256]; + private float[] alpha = new float[256]; + + public TextureLavaFX() { + super(Block.lavaMoving.blockIndexInTexture); + } + + public final void onTick() { + int var1; + int var2; + float var3; + int var5; + int var6; + int var7; + int var8; + int var9; + for(var1 = 0; var1 < 16; ++var1) { + for(var2 = 0; var2 < 16; ++var2) { + var3 = 0.0F; + int var4 = (int)(MathHelper.sin((float)var2 * (float)Math.PI * 2.0F / 16.0F) * 1.2F); + var5 = (int)(MathHelper.sin((float)var1 * (float)Math.PI * 2.0F / 16.0F) * 1.2F); + + for(var6 = var1 - 1; var6 <= var1 + 1; ++var6) { + for(var7 = var2 - 1; var7 <= var2 + 1; ++var7) { + var8 = var6 + var4 & 15; + var9 = var7 + var5 & 15; + var3 += this.red[var8 + (var9 << 4)]; + } + } + + this.green[var1 + (var2 << 4)] = var3 / 10.0F + (this.blue[(var1 & 15) + ((var2 & 15) << 4)] + this.blue[(var1 + 1 & 15) + ((var2 & 15) << 4)] + this.blue[(var1 + 1 & 15) + ((var2 + 1 & 15) << 4)] + this.blue[(var1 & 15) + ((var2 + 1 & 15) << 4)]) / 4.0F * 0.8F; + this.blue[var1 + (var2 << 4)] += this.alpha[var1 + (var2 << 4)] * 0.01F; + if(this.blue[var1 + (var2 << 4)] < 0.0F) { + this.blue[var1 + (var2 << 4)] = 0.0F; + } + + this.alpha[var1 + (var2 << 4)] -= 0.06F; + if(Math.random() < 0.005D) { + this.alpha[var1 + (var2 << 4)] = 1.5F; + } + } + } + + float[] var10 = this.green; + this.green = this.red; + this.red = var10; + + for(var2 = 0; var2 < 256; ++var2) { + var3 = this.red[var2] * 2.0F; + if(var3 > 1.0F) { + var3 = 1.0F; + } + + if(var3 < 0.0F) { + var3 = 0.0F; + } + + var5 = (int)(var3 * 100.0F + 155.0F); + var6 = (int)(var3 * var3 * 255.0F); + var7 = (int)(var3 * var3 * var3 * var3 * 128.0F); + if(this.anaglyphEnabled) { + var8 = (var5 * 30 + var6 * 59 + var7 * 11) / 100; + var9 = (var5 * 30 + var6 * 70) / 100; + var1 = (var5 * 30 + var7 * 70) / 100; + var5 = var8; + var6 = var9; + var7 = var1; + } + + this.imageData[var2 << 2] = (byte)var5; + this.imageData[(var2 << 2) + 1] = (byte)var6; + this.imageData[(var2 << 2) + 2] = (byte)var7; + this.imageData[(var2 << 2) + 3] = -1; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/render/texture/TextureWaterFX.java b/src/teavm/java/net/minecraft/client/render/texture/TextureWaterFX.java new file mode 100644 index 0000000..52658b8 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/texture/TextureWaterFX.java @@ -0,0 +1,88 @@ +package net.minecraft.client.render.texture; + +import net.minecraft.game.level.block.Block; + +public final class TextureWaterFX extends TextureFX { + private float[] red = new float[256]; + private float[] green = new float[256]; + private float[] blue = new float[256]; + private float[] alpha = new float[256]; + private int tickCounter = 0; + + public TextureWaterFX() { + super(Block.waterMoving.blockIndexInTexture); + } + + public final void onTick() { + ++this.tickCounter; + + int var1; + int var2; + float var3; + int var4; + int var5; + int var6; + for(var1 = 0; var1 < 16; ++var1) { + for(var2 = 0; var2 < 16; ++var2) { + var3 = 0.0F; + + for(var4 = var1 - 1; var4 <= var1 + 1; ++var4) { + var5 = var4 & 15; + var6 = var2 & 15; + var3 += this.red[var5 + (var6 << 4)]; + } + + this.green[var1 + (var2 << 4)] = var3 / 3.3F + this.blue[var1 + (var2 << 4)] * 0.8F; + } + } + + for(var1 = 0; var1 < 16; ++var1) { + for(var2 = 0; var2 < 16; ++var2) { + this.blue[var1 + (var2 << 4)] += this.alpha[var1 + (var2 << 4)] * 0.05F; + if(this.blue[var1 + (var2 << 4)] < 0.0F) { + this.blue[var1 + (var2 << 4)] = 0.0F; + } + + this.alpha[var1 + (var2 << 4)] -= 0.1F; + if(Math.random() < 0.05D) { + this.alpha[var1 + (var2 << 4)] = 0.5F; + } + } + } + + float[] var8 = this.green; + this.green = this.red; + this.red = var8; + + for(var2 = 0; var2 < 256; ++var2) { + var3 = this.red[var2]; + if(var3 > 1.0F) { + var3 = 1.0F; + } + + if(var3 < 0.0F) { + var3 = 0.0F; + } + + float var9 = var3 * var3; + var5 = (int)(32.0F + var9 * 32.0F); + var6 = (int)(50.0F + var9 * 64.0F); + var1 = 255; + int var10 = (int)(146.0F + var9 * 50.0F); + if(this.anaglyphEnabled) { + var1 = (var5 * 30 + var6 * 59 + 2805) / 100; + var4 = (var5 * 30 + var6 * 70) / 100; + int var7 = (var5 * 30 + 17850) / 100; + var5 = var1; + var6 = var4; + var1 = var7; + } + + this.imageData[var2 << 2] = (byte)var5; + this.imageData[(var2 << 2) + 1] = (byte)var6; + this.imageData[(var2 << 2) + 2] = (byte)var1; + this.imageData[(var2 << 2) + 3] = (byte)var10; + } + + } +} diff --git a/src/teavm/java/net/minecraft/client/render/texture/TextureWaterFlowFX.java b/src/teavm/java/net/minecraft/client/render/texture/TextureWaterFlowFX.java new file mode 100644 index 0000000..4214b43 --- /dev/null +++ b/src/teavm/java/net/minecraft/client/render/texture/TextureWaterFlowFX.java @@ -0,0 +1,88 @@ +package net.minecraft.client.render.texture; + +import net.minecraft.game.level.block.Block; + +public final class TextureWaterFlowFX extends TextureFX { + private float[] red = new float[256]; + private float[] green = new float[256]; + private float[] blue = new float[256]; + private float[] alpha = new float[256]; + private int tickCounter = 0; + + public TextureWaterFlowFX() { + super(Block.waterMoving.blockIndexInTexture + 32); + } + + public final void onTick() { + ++this.tickCounter; + + int var1; + int var2; + float var3; + int var4; + int var5; + int var6; + for(var1 = 0; var1 < 16; ++var1) { + for(var2 = 0; var2 < 16; ++var2) { + var3 = 0.0F; + + for(var4 = var2 - 2; var4 <= var2; ++var4) { + var5 = var1 & 15; + var6 = var4 & 15; + var3 += this.red[var5 + (var6 << 4)]; + } + + this.green[var1 + (var2 << 4)] = var3 / 3.2F + this.blue[var1 + (var2 << 4)] * 0.8F; + } + } + + for(var1 = 0; var1 < 16; ++var1) { + for(var2 = 0; var2 < 16; ++var2) { + this.blue[var1 + (var2 << 4)] += this.alpha[var1 + (var2 << 4)] * 0.05F; + if(this.blue[var1 + (var2 << 4)] < 0.0F) { + this.blue[var1 + (var2 << 4)] = 0.0F; + } + + this.alpha[var1 + (var2 << 4)] -= 0.3F; + if(Math.random() < 0.2D) { + this.alpha[var1 + (var2 << 4)] = 0.5F; + } + } + } + + float[] var8 = this.green; + this.green = this.red; + this.red = var8; + + for(var2 = 0; var2 < 256; ++var2) { + var3 = this.red[var2]; + if(var3 > 1.0F) { + var3 = 1.0F; + } + + if(var3 < 0.0F) { + var3 = 0.0F; + } + + float var9 = var3 * var3; + var5 = (int)(32.0F + var9 * 32.0F); + var6 = (int)(50.0F + var9 * 64.0F); + var1 = 255; + int var10 = (int)(146.0F + var9 * 50.0F); + if(this.anaglyphEnabled) { + var1 = (var5 * 30 + var6 * 59 + 2805) / 100; + var4 = (var5 * 30 + var6 * 70) / 100; + int var7 = (var5 * 30 + 17850) / 100; + var5 = var1; + var6 = var4; + var1 = var7; + } + + this.imageData[var2 << 2] = (byte)var5; + this.imageData[(var2 << 2) + 1] = (byte)var6; + this.imageData[(var2 << 2) + 2] = (byte)var1; + this.imageData[(var2 << 2) + 3] = (byte)var10; + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/IInventory.java b/src/teavm/java/net/minecraft/game/IInventory.java new file mode 100644 index 0000000..cc61424 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/IInventory.java @@ -0,0 +1,17 @@ +package net.minecraft.game; + +import net.minecraft.game.item.ItemStack; + +public interface IInventory { + int getSizeInventory(); + + ItemStack getStackInSlot(int var1); + + ItemStack decrStackSize(int var1, int var2); + + void setInventorySlotContents(int var1, ItemStack var2); + + String getInvName(); + + int getInventoryStackLimit(); +} diff --git a/src/teavm/java/net/minecraft/game/InventoryLargeChest.java b/src/teavm/java/net/minecraft/game/InventoryLargeChest.java new file mode 100644 index 0000000..07eaaa2 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/InventoryLargeChest.java @@ -0,0 +1,43 @@ +package net.minecraft.game; + +import net.minecraft.game.item.ItemStack; + +public final class InventoryLargeChest implements IInventory { + private String name; + private IInventory upperChest; + private IInventory lowerChest; + + public InventoryLargeChest(String var1, IInventory var2, IInventory var3) { + this.name = var1; + this.upperChest = var2; + this.lowerChest = var3; + } + + public final int getSizeInventory() { + return this.upperChest.getSizeInventory() + this.lowerChest.getSizeInventory(); + } + + public final String getInvName() { + return this.name; + } + + public final ItemStack getStackInSlot(int var1) { + return var1 >= this.upperChest.getSizeInventory() ? this.lowerChest.getStackInSlot(var1 - this.upperChest.getSizeInventory()) : this.upperChest.getStackInSlot(var1); + } + + public final ItemStack decrStackSize(int var1, int var2) { + return var1 >= this.upperChest.getSizeInventory() ? this.lowerChest.decrStackSize(var1 - this.upperChest.getSizeInventory(), var2) : this.upperChest.decrStackSize(var1, var2); + } + + public final void setInventorySlotContents(int var1, ItemStack var2) { + if(var1 >= this.upperChest.getSizeInventory()) { + this.lowerChest.setInventorySlotContents(var1 - this.upperChest.getSizeInventory(), var2); + } else { + this.upperChest.setInventorySlotContents(var1, var2); + } + } + + public final int getInventoryStackLimit() { + return this.upperChest.getInventoryStackLimit(); + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/Entity.java b/src/teavm/java/net/minecraft/game/entity/Entity.java new file mode 100644 index 0000000..d036898 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/Entity.java @@ -0,0 +1,545 @@ +package net.minecraft.game.entity; + +import java.util.ArrayList; +import java.util.Random; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.PeytonPlayz585.nbt.NBTTagFloat; +import net.PeytonPlayz585.nbt.NBTTagList; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.StepSound; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public abstract class Entity { + public boolean preventEntitySpawning = false; + protected World worldObj; + public float prevPosX; + public float prevPosY; + public float prevPosZ; + public float posX; + public float posY; + public float posZ; + public float motionX; + public float motionY; + public float motionZ; + public float rotationYaw; + public float rotationPitch; + public float prevRotationYaw; + public float prevRotationPitch; + public AxisAlignedBB boundingBox; + public boolean onGround = false; + public boolean isCollidedHorizontally = false; + private boolean surfaceCollision = true; + public boolean isDead = false; + public float yOffset = 0.0F; + public float width = 0.6F; + public float height = 1.8F; + public float prevDistanceWalkedModified = 0.0F; + public float distanceWalkedModified = 0.0F; + protected boolean canTriggerWalking = true; + private float fallDistance = 0.0F; + private int nextStepDistance = 1; + public float lastTickPosX; + public float lastTickPosY; + public float lastTickPosZ; + private float ySize = 0.0F; + public float stepHeight = 0.0F; + public boolean noClip = false; + private float entityCollisionReduction = 0.0F; + protected Random rand = new Random(); + public int ticksExisted = 0; + public int fireResistance = 1; + public int fire = 0; + protected int maxAir = 300; + private boolean inWater = false; + public int heartsLife = 0; + public int air = 300; + private boolean isFirstUpdate = true; + public String skinUrl; + + public Entity(World var1) { + this.worldObj = var1; + this.setPosition(0.0F, 0.0F, 0.0F); + } + + protected void preparePlayerToSpawn() { + if(this.worldObj != null) { + float var1 = (float)this.worldObj.xSpawn + 0.5F; + float var2 = (float)this.worldObj.ySpawn; + + for(float var3 = (float)this.worldObj.zSpawn + 0.5F; var2 > 0.0F; ++var2) { + this.setPosition(var1, var2, var3); + if(this.worldObj.getCollidingBoundingBoxes(this.boundingBox).size() == 0) { + break; + } + } + + this.motionX = this.motionY = this.motionZ = 0.0F; + this.rotationYaw = this.worldObj.rotSpawn; + this.rotationPitch = 0.0F; + } + } + + public void setEntityDead() { + this.isDead = true; + } + + protected void setSize(float var1, float var2) { + this.width = var1; + this.height = var2; + } + + protected final void setPosition(float var1, float var2, float var3) { + this.posX = var1; + this.posY = var2; + this.posZ = var3; + float var4 = this.width / 2.0F; + float var5 = this.height / 2.0F; + this.boundingBox = new AxisAlignedBB(var1 - var4, var2 - var5, var3 - var4, var1 + var4, var2 + var5, var3 + var4); + } + + public void onEntityUpdate() { + ++this.ticksExisted; + this.prevDistanceWalkedModified = this.distanceWalkedModified; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + if(this.handleWaterMovement()) { + if(!this.inWater && !this.isFirstUpdate) { + float var1 = MathHelper.sqrt_float(this.motionX * this.motionX * 0.2F + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.2F) * 0.2F; + if(var1 > 1.0F) { + var1 = 1.0F; + } + + var1 = (float)((int)this.boundingBox.minY); + + int var2; + float var3; + float var4; + for(var2 = 0; (float)var2 < 1.0F + this.width * 20.0F; ++var2) { + var3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + var4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle("bubble", this.posX + var3, var1 + 1.0F, this.posZ + var4, this.motionX, this.motionY - this.rand.nextFloat() * 0.2F, this.motionZ); + } + + for(var2 = 0; (float)var2 < 1.0F + this.width * 20.0F; ++var2) { + var3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + var4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle("splash", this.posX + var3, var1 + 1.0F, this.posZ + var4, this.motionX, this.motionY, this.motionZ); + } + } + + this.fallDistance = 0.0F; + this.inWater = true; + this.fire = 0; + } else { + this.inWater = false; + } + + if(this.fire > 0) { + if(this.fire % 20 == 0) { + this.attackEntityFrom((Entity)null, 1); + } + + --this.fire; + } + + if(this.handleLavaMovement()) { + this.attackEntityFrom((Entity)null, 10); + this.fire = 600; + } + + float var5; + if(this.posX < -8.0F) { + var5 = -(this.posX + 8.0F); + this.motionX += var5 * 0.001F; + } + + if(this.posZ < -8.0F) { + var5 = -(this.posZ + 8.0F); + this.motionZ += var5 * 0.001F; + } + + if(this.posX > (float)this.worldObj.width + 8.0F) { + var5 = this.posX - (float)this.worldObj.width + 8.0F; + this.motionX -= var5 * 0.001F; + } + + if(this.posZ > (float)this.worldObj.length + 8.0F) { + var5 = this.posZ - (float)this.worldObj.length + 8.0F; + this.motionZ -= var5 * 0.001F; + } + + this.isFirstUpdate = false; + } + + public final boolean isOffsetPositionInLiquid(float var1, float var2, float var3) { + float var4 = var3; + var3 = var2; + var2 = var1; + AxisAlignedBB var5 = this.boundingBox; + var5 = new AxisAlignedBB(var5.minX + var4, var5.minY + var3, var5.minZ + var4, var5.maxX + var2, var5.maxY + var3, var5.maxZ + var4); + ArrayList var6 = this.worldObj.getCollidingBoundingBoxes(var5); + return var6.size() > 0 ? false : !this.worldObj.getIsAnyLiquid(var5); + } + + public final void moveEntity(float var1, float var2, float var3) { + if(this.noClip) { + this.boundingBox.offset(var1, var2, var3); + this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0F; + this.posY = this.boundingBox.minY + this.yOffset - this.ySize; + this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0F; + } else { + float var4 = this.posX; + float var5 = this.posZ; + float var6 = var1; + float var7 = var2; + float var8 = var3; + AxisAlignedBB var9 = this.boundingBox.copy(); + ArrayList var10 = this.worldObj.getCollidingBoundingBoxes(this.boundingBox.addCoord(var1, var2, var3)); + + for(int var11 = 0; var11 < var10.size(); ++var11) { + var2 = ((AxisAlignedBB)var10.get(var11)).calculateYOffset(this.boundingBox, var2); + } + + this.boundingBox.offset(0.0F, var2, 0.0F); + if(!this.surfaceCollision && var7 != var2) { + var3 = 0.0F; + var2 = var3; + var1 = var3; + } + + boolean var18 = this.onGround || var7 != var2 && var7 < 0.0F; + + int var12; + for(var12 = 0; var12 < var10.size(); ++var12) { + var1 = ((AxisAlignedBB)var10.get(var12)).calculateXOffset(this.boundingBox, var1); + } + + this.boundingBox.offset(var1, 0.0F, 0.0F); + if(!this.surfaceCollision && var6 != var1) { + var3 = 0.0F; + var2 = var3; + var1 = var3; + } + + for(var12 = 0; var12 < var10.size(); ++var12) { + var3 = ((AxisAlignedBB)var10.get(var12)).calculateZOffset(this.boundingBox, var3); + } + + this.boundingBox.offset(0.0F, 0.0F, var3); + if(!this.surfaceCollision && var8 != var3) { + var3 = 0.0F; + var2 = var3; + var1 = var3; + } + + int var17; + float var19; + float var20; + if(this.stepHeight > 0.0F && var18 && this.ySize < 0.05F && (var6 != var1 || var8 != var3)) { + var20 = var1; + var19 = var2; + float var13 = var3; + var1 = var6; + var2 = this.stepHeight; + var3 = var8; + AxisAlignedBB var14 = this.boundingBox.copy(); + this.boundingBox = var9.copy(); + var10 = this.worldObj.getCollidingBoundingBoxes(this.boundingBox.addCoord(var6, var2, var8)); + + for(var17 = 0; var17 < var10.size(); ++var17) { + var2 = ((AxisAlignedBB)var10.get(var17)).calculateYOffset(this.boundingBox, var2); + } + + this.boundingBox.offset(0.0F, var2, 0.0F); + if(!this.surfaceCollision && var7 != var2) { + var3 = 0.0F; + var2 = var3; + var1 = var3; + } + + for(var17 = 0; var17 < var10.size(); ++var17) { + var1 = ((AxisAlignedBB)var10.get(var17)).calculateXOffset(this.boundingBox, var1); + } + + this.boundingBox.offset(var1, 0.0F, 0.0F); + if(!this.surfaceCollision && var6 != var1) { + var3 = 0.0F; + var2 = var3; + var1 = var3; + } + + for(var17 = 0; var17 < var10.size(); ++var17) { + var3 = ((AxisAlignedBB)var10.get(var17)).calculateZOffset(this.boundingBox, var3); + } + + this.boundingBox.offset(0.0F, 0.0F, var3); + if(!this.surfaceCollision && var8 != var3) { + var3 = 0.0F; + var2 = var3; + var1 = var3; + } + + if(var20 * var20 + var13 * var13 >= var1 * var1 + var3 * var3) { + var1 = var20; + var2 = var19; + var3 = var13; + this.boundingBox = var14.copy(); + } else { + this.ySize = (float)((double)this.ySize + 0.5D); + } + } + + this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0F; + this.posY = this.boundingBox.minY + this.yOffset - this.ySize; + this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0F; + this.isCollidedHorizontally = var6 != var1 || var8 != var3; + this.onGround = var7 != var2 && var7 < 0.0F; + if(this.onGround) { + if(this.fallDistance > 0.0F) { + this.fall(this.fallDistance); + this.fallDistance = 0.0F; + } + } else if(var2 < 0.0F) { + this.fallDistance -= var2; + } + + if(var6 != var1) { + this.motionX = 0.0F; + } + + if(var7 != var2) { + this.motionY = 0.0F; + } + + if(var8 != var3) { + this.motionZ = 0.0F; + } + + var20 = this.posX - var4; + var19 = this.posZ - var5; + this.distanceWalkedModified = (float)((double)this.distanceWalkedModified + (double)MathHelper.sqrt_float(var20 * var20 + var19 * var19) * 0.6D); + if(this.canTriggerWalking) { + int var21 = (int)this.posX; + int var23 = (int)(this.posY - 0.2F - this.yOffset); + var17 = (int)this.posZ; + int var16 = this.worldObj.getBlockId(var21, var23, var17); + if(this.distanceWalkedModified > (float)this.nextStepDistance && var16 > 0) { + ++this.nextStepDistance; + StepSound var15 = Block.blocksList[var16].stepSound; + Block.blocksList[var16].onEntityWalking(this.worldObj, var21, var23, var17); + } + } + + this.ySize *= 0.4F; + boolean var22 = this.handleWaterMovement(); + if(this.worldObj.isBoundingBoxBurning(this.boundingBox)) { + this.dealFireDamage(1); + if(!var22) { + ++this.fire; + if(this.fire == 0) { + this.fire = 300; + } + } + } else if(this.fire <= 0) { + this.fire = -this.fireResistance; + } + + if(var22 && this.fire > 0) { + this.fire = -this.fireResistance; + } + + } + } + + protected void dealFireDamage(int var1) { + this.attackEntityFrom((Entity)null, 1); + } + + protected void fall(float var1) { + } + + public final boolean handleWaterMovement() { + return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0F, -0.4F, 0.0F), Material.water); + } + + public final boolean isInsideOfWater() { + int var1 = this.worldObj.getBlockId((int)this.posX, (int)(this.posY + this.getEyeHeight()), (int)this.posZ); + return var1 != 0 ? Block.blocksList[var1].material == Material.water : false; + } + + protected float getEyeHeight() { + return 0.0F; + } + + public final boolean handleLavaMovement() { + return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0F, -0.4F, 0.0F), Material.lava); + } + + public final void moveFlying(float var1, float var2, float var3) { + float var4 = MathHelper.sqrt_float(var1 * var1 + var2 * var2); + if(var4 >= 0.01F) { + if(var4 < 1.0F) { + var4 = 1.0F; + } + + var4 = var3 / var4; + var1 *= var4; + var2 *= var4; + var3 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F); + var4 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F); + this.motionX += var1 * var4 - var2 * var3; + this.motionZ += var2 * var4 + var1 * var3; + } + } + + public float getEntityBrightness(float var1) { + int var4 = (int)this.posX; + int var2 = (int)(this.posY + this.yOffset / 2.0F); + int var3 = (int)this.posZ; + return this.worldObj.getLightBrightness(var4, var2, var3); + } + + public final void setWorld(World var1) { + this.worldObj = var1; + } + + public final void setPositionAndRotation(float var1, float var2, float var3, float var4, float var5) { + this.prevPosX = this.posX = var1; + this.prevPosY = this.posY = var2 + this.yOffset; + this.prevPosZ = this.posZ = var3; + this.rotationYaw = var4; + this.rotationPitch = var5; + this.setPosition(this.posX, this.posY, this.posZ); + } + + public final float getDistanceSqToEntity(Entity var1) { + float var2 = this.posX - var1.posX; + float var3 = this.posY - var1.posY; + float var4 = this.posZ - var1.posZ; + return var2 * var2 + var3 * var3 + var4 * var4; + } + + public void onCollideWithPlayer(EntityPlayer var1) { + } + + public final void applyEntityCollision(Entity var1) { + float var2 = var1.posX - this.posX; + float var3 = var1.posZ - this.posZ; + float var4 = var2 * var2 + var3 * var3; + if(var4 >= 0.01F) { + var4 = MathHelper.sqrt_float(var4); + var2 /= var4; + var3 /= var4; + var2 /= var4; + var3 /= var4; + var2 *= 0.05F; + var3 *= 0.05F; + this.addVelocity(-var2, 0.0F, -var3); + var1.addVelocity(var2, 0.0F, var3); + } + + } + + private void addVelocity(float var1, float var2, float var3) { + this.motionX += var1; + this.motionY = this.motionY; + this.motionZ += var3; + } + + public boolean attackEntityFrom(Entity var1, int var2) { + return false; + } + + public boolean canBeCollidedWith() { + return false; + } + + public boolean canBePushed() { + return false; + } + + public String getTexture() { + return null; + } + + public final void writeToNBT(NBTTagCompound var1) { + String var2 = this.getEntityString(); + if(!this.isDead && var2 != null) { + var1.setString("id", var2); + var1.setTag("Pos", newDoubleNBTList(new float[]{this.posX, this.posY, this.posZ})); + var1.setTag("Motion", newDoubleNBTList(new float[]{this.motionX, this.motionY, this.motionZ})); + var1.setTag("Rotation", newDoubleNBTList(new float[]{this.rotationYaw, this.rotationPitch})); + var1.setFloat("FallDistance", this.fallDistance); + var1.setShort("Fire", (short)this.fire); + var1.setShort("Air", (short)this.air); + this.writeEntityToNBT(var1); + } + } + + public final void readFromNBT(NBTTagCompound var1) { + NBTTagList var2 = var1.getTagList("Pos"); + NBTTagList var3 = var1.getTagList("Motion"); + NBTTagList var4 = var1.getTagList("Rotation"); + this.posX = ((NBTTagFloat)var2.tagAt(0)).floatValue; + this.posY = ((NBTTagFloat)var2.tagAt(1)).floatValue; + this.posZ = ((NBTTagFloat)var2.tagAt(2)).floatValue; + this.motionX = ((NBTTagFloat)var3.tagAt(0)).floatValue; + this.motionY = ((NBTTagFloat)var3.tagAt(1)).floatValue; + this.motionZ = ((NBTTagFloat)var3.tagAt(2)).floatValue; + this.rotationYaw = ((NBTTagFloat)var4.tagAt(0)).floatValue; + this.rotationPitch = ((NBTTagFloat)var4.tagAt(1)).floatValue; + this.fallDistance = var1.getFloat("FallDistance"); + this.fire = var1.getShort("Fire"); + this.air = var1.getShort("Air"); + this.setPositionAndRotation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.readEntityFromNBT(var1); + } + + protected abstract String getEntityString(); + + protected abstract void readEntityFromNBT(NBTTagCompound var1); + + protected abstract void writeEntityToNBT(NBTTagCompound var1); + + private static NBTTagList newDoubleNBTList(float... var0) { + NBTTagList var1 = new NBTTagList(); + var0 = var0; + int var2 = var0.length; + + for(int var3 = 0; var3 < var2; ++var3) { + float var4 = var0[var3]; + var1.setTag(new NBTTagFloat(var4)); + } + + return var1; + } + + public float getShadowSize() { + return this.height / 2.0F; + } + + public final EntityItem dropItemWithOffset(int var1, int var2) { + return this.entityDropItem(var1, 1, 0.0F); + } + + public final EntityItem entityDropItem(int var1, int var2, float var3) { + EntityItem var4 = new EntityItem(this.worldObj, this.posX, this.posY + var3, this.posZ, new ItemStack(var1, var2)); + var4.delayBeforeCanPickup = 10; + this.worldObj.spawnEntityInWorld(var4); + return var4; + } + + public boolean isEntityAlive() { + return !this.isDead; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/EntityCreature.java b/src/teavm/java/net/minecraft/game/entity/EntityCreature.java new file mode 100644 index 0000000..7df8f58 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/EntityCreature.java @@ -0,0 +1,138 @@ +package net.minecraft.game.entity; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.game.level.World; +import net.minecraft.game.level.path.PathEntity; +import net.minecraft.game.physics.Vec3D; + +public class EntityCreature extends EntityLiving { + private PathEntity pathToEntity; + protected Entity playerToAttack; + protected boolean hasAttacked = false; + + public EntityCreature(World var1) { + super(var1); + } + + protected void updatePlayerActionState() { + this.hasAttacked = false; + float var6; + float var7; + float var8; + if(this.playerToAttack == null) { + this.playerToAttack = this.findPlayerToAttack(); + if(this.playerToAttack != null) { + this.pathToEntity = this.worldObj.pathFinder.createEntityPathTo(this, this.playerToAttack, 16.0F); + } + } else if(!this.playerToAttack.isEntityAlive()) { + this.playerToAttack = null; + } else { + Entity var5 = this.playerToAttack; + var7 = var5.posX - super.posX; + var8 = var5.posY - super.posY; + var6 = var5.posZ - super.posZ; + float var1 = MathHelper.sqrt_float(var7 * var7 + var8 * var8 + var6 * var6); + if(this.worldObj.rayTraceBlocks(new Vec3D(this.posX, this.posY + this.getEyeHeight(), this.posZ), new Vec3D(this.playerToAttack.posX, this.playerToAttack.posY + this.playerToAttack.getEyeHeight(), this.playerToAttack.posZ)) == null) { + this.attackEntity(this.playerToAttack, var1); + } + } + + if(this.hasAttacked) { + this.moveStrafing = 0.0F; + this.moveForward = 0.0F; + this.isJumping = false; + } else { + float var4; + if(this.playerToAttack == null || this.pathToEntity != null && this.rand.nextInt(20) != 0) { + if(this.pathToEntity == null || this.rand.nextInt(100) == 0) { + int var10 = -1; + int var2 = -1; + int var3 = -1; + var4 = -99999.0F; + + for(int var14 = 0; var14 < 200; ++var14) { + int var16 = (int)(this.posX + (float)this.rand.nextInt(21) - 10.0F); + int var17 = (int)(this.posY + (float)this.rand.nextInt(9) - 4.0F); + int var18 = (int)(this.posZ + (float)this.rand.nextInt(21) - 10.0F); + float var9 = this.getBlockPathWeight(var16, var17, var18); + if(var9 > var4) { + var4 = var9; + var10 = var16; + var2 = var17; + var3 = var18; + } + } + + if(var10 > 0) { + this.pathToEntity = this.worldObj.pathFinder.createEntityPathTo(this, var10, var2, var3, 16.0F); + } + } + } else { + this.pathToEntity = this.worldObj.pathFinder.createEntityPathTo(this, this.playerToAttack, 16.0F); + } + + boolean var11 = this.handleWaterMovement(); + boolean var12 = this.handleLavaMovement(); + if(this.pathToEntity != null && this.rand.nextInt(100) != 0) { + Vec3D var13 = this.pathToEntity.getPosition(this); + var4 = this.width * 2.0F; + + float var15; + while(var13 != null) { + var8 = this.posZ; + var7 = this.posY; + var6 = this.posX; + var6 -= var13.xCoord; + var7 -= var13.yCoord; + var15 = var8 - var13.zCoord; + if(var6 * var6 + var7 * var7 + var15 * var15 >= var4 * var4 || var13.yCoord > this.posY) { + break; + } + + this.pathToEntity.incrementPathIndex(); + if(this.pathToEntity.isFinished()) { + var13 = null; + this.pathToEntity = null; + } else { + var13 = this.pathToEntity.getPosition(this); + } + } + + this.isJumping = false; + if(var13 != null) { + var15 = var13.xCoord - this.posX; + var6 = var13.zCoord - this.posZ; + var7 = var13.yCoord - this.posY; + this.rotationYaw = (float)(Math.atan2((double)var6, (double)var15) * 180.0D / (double)((float)Math.PI)) - 90.0F; + this.moveForward = this.moveSpeed; + if(var7 > 0.0F) { + this.isJumping = true; + } + } + + if(this.rand.nextFloat() < 0.8F && (var11 || var12)) { + this.isJumping = true; + } + + } else { + super.updatePlayerActionState(); + this.pathToEntity = null; + } + } + } + + protected void attackEntity(Entity var1, float var2) { + } + + protected float getBlockPathWeight(int var1, int var2, int var3) { + return 0.0F; + } + + protected Entity findPlayerToAttack() { + return null; + } + + public boolean getCanSpawnHere(float var1, float var2, float var3) { + return super.getCanSpawnHere(var1, var2, var3) && this.getBlockPathWeight((int)var1, (int)var2, (int)var3) >= 0.0F; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/EntityLiving.java b/src/teavm/java/net/minecraft/game/entity/EntityLiving.java new file mode 100644 index 0000000..de2c417 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/EntityLiving.java @@ -0,0 +1,457 @@ +package net.minecraft.game.entity; + +import java.util.List; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.StepSound; + +public class EntityLiving extends Entity { + public int heartsHalvesLife = 20; + public float renderYawOffset = 0.0F; + public float prevRenderYawOffset = 0.0F; + private float rotationYawHead; + private float prevRotationYawHead; + protected String texture = "/char.png"; + private int scoreValue = 0; + public int health; + public int prevHealth; + private int livingSoundTime; + public int hurtTime; + public int maxHurtTime; + public float attackedAtYaw = 0.0F; + public int deathTime = 0; + public int attackTime = 0; + public float prevCameraPitch; + public float cameraPitch; + public float prevLimbYaw; + public float limbYaw; + public float limbSwing; + protected int entityAge; + protected float moveStrafing; + protected float moveForward; + private float randomYawVelocity; + protected boolean isJumping; + private float defaultPitch; + protected float moveSpeed; + + public EntityLiving(World var1) { + super(var1); + Math.random(); + this.entityAge = 0; + this.isJumping = false; + this.defaultPitch = 0.0F; + this.moveSpeed = 0.7F; + this.health = 10; + this.preventEntitySpawning = true; + Math.random(); + this.setPosition(this.posX, this.posY, this.posZ); + Math.random(); + this.rotationYaw = (float)(Math.random() * (double)((float)Math.PI) * 2.0D); + this.stepHeight = 0.5F; + } + + public final String getTexture() { + return this.texture; + } + + public final boolean canBeCollidedWith() { + return !this.isDead; + } + + public final boolean canBePushed() { + return !this.isDead; + } + + protected float getEyeHeight() { + return this.height * 0.85F; + } + + public void onEntityUpdate() { + super.onEntityUpdate(); + if(this.rand.nextInt(1000) < this.livingSoundTime++) { + this.livingSoundTime = -80; + } + + float var2; + float var3; + float var4; + if(this.isInsideOfWater()) { + --this.air; + if(this.air == -20) { + this.air = 0; + + for(int var7 = 0; var7 < 8; ++var7) { + var2 = this.rand.nextFloat() - this.rand.nextFloat(); + var3 = this.rand.nextFloat() - this.rand.nextFloat(); + var4 = this.rand.nextFloat() - this.rand.nextFloat(); + this.worldObj.spawnParticle("bubble", this.posX + var2, this.posY + var3, this.posZ + var4, this.motionX, this.motionY, this.motionZ); + } + + this.attackEntityFrom((Entity)null, 2); + } + + this.fire = 0; + } else { + this.air = this.maxAir; + } + + this.prevCameraPitch = this.cameraPitch; + if(this.attackTime > 0) { + --this.attackTime; + } + + if(this.hurtTime > 0) { + --this.hurtTime; + } + + if(this.heartsLife > 0) { + --this.heartsLife; + } + + if(this.health <= 0) { + ++this.deathTime; + if(this.deathTime > 20) { + this.setEntityDead(); + } + } + + this.prevRenderYawOffset = this.renderYawOffset; + this.prevRotationYaw = this.rotationYaw; + this.prevRotationPitch = this.rotationPitch; + this.onLivingUpdate(); + float var8 = this.posX - this.prevPosX; + var2 = this.posZ - this.prevPosZ; + var3 = MathHelper.sqrt_float(var8 * var8 + var2 * var2); + var4 = this.renderYawOffset; + float var5 = 0.0F; + float var6 = 0.0F; + if(var3 > 0.05F) { + var6 = 1.0F; + var5 = var3 * 3.0F; + var4 = (float)Math.atan2((double)var2, (double)var8) * 180.0F / (float)Math.PI - 90.0F; + } + + if(!this.onGround) { + var6 = 0.0F; + } + + this.rotationYawHead += (var6 - this.rotationYawHead) * 0.3F; + + for(var8 = var4 - this.renderYawOffset; var8 < -180.0F; var8 += 360.0F) { + } + + while(var8 >= 180.0F) { + var8 -= 360.0F; + } + + this.renderYawOffset += var8 * 0.1F; + + for(var8 = this.rotationYaw - this.renderYawOffset; var8 < -180.0F; var8 += 360.0F) { + } + + while(var8 >= 180.0F) { + var8 -= 360.0F; + } + + boolean var9 = var8 < -90.0F || var8 >= 90.0F; + if(var8 < -75.0F) { + var8 = -75.0F; + } + + if(var8 >= 75.0F) { + var8 = 75.0F; + } + + this.renderYawOffset = this.rotationYaw - var8; + this.renderYawOffset += var8 * 0.1F; + if(var9) { + var5 = -var5; + } + + while(this.rotationYaw - this.prevRotationYaw < -180.0F) { + this.prevRotationYaw -= 360.0F; + } + + while(this.rotationYaw - this.prevRotationYaw >= 180.0F) { + this.prevRotationYaw += 360.0F; + } + + while(this.renderYawOffset - this.prevRenderYawOffset < -180.0F) { + this.prevRenderYawOffset -= 360.0F; + } + + while(this.renderYawOffset - this.prevRenderYawOffset >= 180.0F) { + this.prevRenderYawOffset += 360.0F; + } + + while(this.rotationPitch - this.prevRotationPitch < -180.0F) { + this.prevRotationPitch -= 360.0F; + } + + while(this.rotationPitch - this.prevRotationPitch >= 180.0F) { + this.prevRotationPitch += 360.0F; + } + + this.prevRotationYawHead += var5; + } + + protected final void setSize(float var1, float var2) { + super.setSize(var1, var2); + } + + public final void heal(int var1) { + if(this.health > 0) { + this.health += var1; + if(this.health > 20) { + this.health = 20; + } + + this.heartsLife = this.heartsHalvesLife / 2; + } + } + + public boolean attackEntityFrom(Entity var1, int var2) { + if(!this.worldObj.survivalWorld) { + return false; + } else { + this.entityAge = 0; + if(this.health <= 0) { + return false; + } else { + this.limbYaw = 1.5F; + if((float)this.heartsLife > (float)this.heartsHalvesLife / 2.0F) { + if(this.prevHealth - var2 >= this.health) { + return false; + } + + this.health = this.prevHealth - var2; + } else { + this.prevHealth = this.health; + this.heartsLife = this.heartsHalvesLife; + this.health -= var2; + this.hurtTime = this.maxHurtTime = 10; + } + + this.attackedAtYaw = 0.0F; + if(var1 != null) { + float var6 = var1.posX - this.posX; + float var3 = var1.posZ - this.posZ; + this.attackedAtYaw = (float)(Math.atan2((double)var3, (double)var6) * 180.0D / (double)((float)Math.PI)) - this.rotationYaw; + float var5 = MathHelper.sqrt_float(var6 * var6 + var3 * var3); + this.motionX /= 2.0F; + this.motionY /= 2.0F; + this.motionZ /= 2.0F; + this.motionX -= var6 / var5 * 0.4F; + this.motionY += 0.4F; + this.motionZ -= var3 / var5 * 0.4F; + if(this.motionY > 0.4F) { + this.motionY = 0.4F; + } + } else { + this.attackedAtYaw = (float)((int)(Math.random() * 2.0D) * 180); + } + + if(this.health <= 0) { + this.onDeath(var1); + } + + return true; + } + } + } + + protected String getLivingSound() { + return null; + } + + protected String getHurtSound() { + return "random.hurt"; + } + + protected String getDeathSound() { + return "random.hurt"; + } + + public void onDeath(Entity var1) { + int var4 = this.scoreValue(); + if(var4 > 0) { + int var2 = this.rand.nextInt(3); + + for(int var3 = 0; var3 < var2; ++var3) { + this.dropItemWithOffset(var4, 1); + } + } + + } + + protected int scoreValue() { + return 0; + } + + protected final void fall(float var1) { + int var3 = (int)Math.ceil((double)(var1 - 3.0F)); + if(var3 > 0) { + this.attackEntityFrom((Entity)null, var3); + var3 = this.worldObj.getBlockId((int)this.posX, (int)(this.posY - 0.2F - this.yOffset), (int)this.posZ); + } + + } + + protected void writeEntityToNBT(NBTTagCompound var1) { + var1.setShort("Health", (short)this.health); + var1.setShort("HurtTime", (short)this.hurtTime); + var1.setShort("DeathTime", (short)this.deathTime); + var1.setShort("AttackTime", (short)this.attackTime); + } + + protected void readEntityFromNBT(NBTTagCompound var1) { + this.health = var1.getShort("Health"); + if(!var1.hasKey("Health")) { + this.health = 10; + } + + this.hurtTime = var1.getShort("HurtTime"); + this.deathTime = var1.getShort("DeathTime"); + this.attackTime = var1.getShort("AttackTime"); + } + + protected String getEntityString() { + return "Mob"; + } + + public final boolean isEntityAlive() { + return !this.isDead && this.health > 0; + } + + public void onLivingUpdate() { + ++this.entityAge; + float var2; + float var3; + if(this.entityAge > 600 && this.rand.nextInt(800) == 0) { + Entity var1 = this.worldObj.getPlayerEntity(); + if(var1 != null) { + var2 = var1.posX - this.posX; + var3 = var1.posY - this.posY; + float var5 = var1.posZ - this.posZ; + var2 = var2 * var2 + var3 * var3 + var5 * var5; + if(var2 < 1024.0F) { + this.entityAge = 0; + } else { + this.setEntityDead(); + } + } + } + + if(this.health <= 0) { + this.isJumping = false; + this.moveStrafing = 0.0F; + this.moveForward = 0.0F; + this.randomYawVelocity = 0.0F; + } else { + this.updatePlayerActionState(); + } + + boolean var6 = this.handleWaterMovement(); + boolean var8 = this.handleLavaMovement(); + if(this.isJumping) { + if(var6) { + this.motionY += 0.04F; + } else if(var8) { + this.motionY += 0.04F; + } else if(this.onGround) { + this.motionY = 0.42F; + } + } + + this.moveStrafing *= 0.98F; + this.moveForward *= 0.98F; + this.randomYawVelocity *= 0.9F; + var3 = this.moveForward; + var2 = this.moveStrafing; + float var4; + if(this.handleWaterMovement()) { + var4 = this.posY; + this.moveFlying(var2, var3, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.8F; + this.motionY *= 0.8F; + this.motionZ *= 0.8F; + this.motionY = (float)((double)this.motionY - 0.02D); + if(this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6F - this.posY + var4, this.motionZ)) { + this.motionY = 0.3F; + } + } else if(this.handleLavaMovement()) { + var4 = this.posY; + this.moveFlying(var2, var3, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5F; + this.motionY *= 0.5F; + this.motionZ *= 0.5F; + this.motionY = (float)((double)this.motionY - 0.02D); + if(this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6F - this.posY + var4, this.motionZ)) { + this.motionY = 0.3F; + } + } else { + this.moveFlying(var2, var3, this.onGround ? 0.1F : 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.91F; + this.motionY *= 0.98F; + this.motionZ *= 0.91F; + this.motionY = (float)((double)this.motionY - 0.08D); + if(this.onGround) { + this.motionX *= 0.6F; + this.motionZ *= 0.6F; + } + } + + this.prevLimbYaw = this.limbYaw; + var4 = this.posX - this.prevPosX; + var2 = this.posZ - this.prevPosZ; + var2 = MathHelper.sqrt_float(var4 * var4 + var2 * var2) * 4.0F; + if(var2 > 1.0F) { + var2 = 1.0F; + } + + this.limbYaw += (var2 - this.limbYaw) * 0.4F; + this.limbSwing += this.limbYaw; + List var9 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.2F, 0.0F, 0.2F)); + if(var9 != null && var9.size() > 0) { + for(int var7 = 0; var7 < var9.size(); ++var7) { + Entity var10 = (Entity)var9.get(var7); + if(var10.canBePushed()) { + var10.applyEntityCollision(this); + } + } + } + + } + + protected void updatePlayerActionState() { + if(this.rand.nextFloat() < 0.07F) { + this.moveStrafing = (this.rand.nextFloat() - 0.5F) * this.moveSpeed; + this.moveForward = this.rand.nextFloat() * this.moveSpeed; + } + + this.isJumping = this.rand.nextFloat() < 0.01F; + if(this.rand.nextFloat() < 0.04F) { + this.randomYawVelocity = (this.rand.nextFloat() - 0.5F) * 60.0F; + } + + this.rotationYaw += this.randomYawVelocity; + this.rotationPitch = 0.0F; + boolean var1 = this.handleWaterMovement(); + boolean var2 = this.handleLavaMovement(); + if(var1 || var2) { + this.isJumping = this.rand.nextFloat() < 0.8F; + } + + } + + public boolean getCanSpawnHere(float var1, float var2, float var3) { + this.setPosition(var1, var2 + this.height / 2.0F, var3); + return this.worldObj.checkIfAABBIsClear1(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this.boundingBox).size() == 0 && !this.worldObj.getIsAnyLiquid(this.boundingBox); + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/EntityPainting.java b/src/teavm/java/net/minecraft/game/entity/EntityPainting.java new file mode 100644 index 0000000..16e937d --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/EntityPainting.java @@ -0,0 +1,233 @@ +package net.minecraft.game.entity; + +import java.util.ArrayList; +import java.util.List; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public class EntityPainting extends Entity { + private int tickCounter1; + public int direction; + private int xPosition; + private int yPosition; + private int zPosition; + public EnumArt art; + + public EntityPainting(World var1) { + super(var1); + this.tickCounter1 = 0; + this.direction = 0; + this.yOffset = 0.0F; + this.setSize(0.5F, 0.5F); + } + + public EntityPainting(World var1, int var2, int var3, int var4, int var5) { + this(var1); + this.xPosition = var2; + this.yPosition = var3; + this.zPosition = var4; + ArrayList var7 = new ArrayList(); + EnumArt[] var8 = EnumArt.values(); + var3 = var8.length; + + for(var4 = 0; var4 < var3; ++var4) { + EnumArt var6 = var8[var4]; + this.art = var6; + this.setDirection(var5); + if(this.onValidSurface()) { + var7.add(var6); + } + } + + if(var7.size() > 0) { + this.art = (EnumArt)var7.get(this.rand.nextInt(var7.size())); + } + + this.setDirection(var5); + } + + private void setDirection(int var1) { + this.direction = var1; + this.prevRotationYaw = this.rotationYaw = (float)(var1 * 90); + float var2 = (float)this.art.sizeX; + float var3 = (float)this.art.sizeY; + float var4 = (float)this.art.sizeX; + if(var1 != 0 && var1 != 2) { + var2 = 0.5F; + } else { + var4 = 0.5F; + } + + var2 /= 32.0F; + var3 /= 32.0F; + var4 /= 32.0F; + float var5 = (float)this.xPosition + 0.5F; + float var6 = (float)this.yPosition + 0.5F; + float var7 = (float)this.zPosition + 0.5F; + if(var1 == 0) { + var7 -= 9.0F / 16.0F; + } + + if(var1 == 1) { + var5 -= 9.0F / 16.0F; + } + + if(var1 == 2) { + var7 += 9.0F / 16.0F; + } + + if(var1 == 3) { + var5 += 9.0F / 16.0F; + } + + if(var1 == 0) { + var5 -= getArtSize(this.art.sizeX); + } + + if(var1 == 1) { + var7 += getArtSize(this.art.sizeX); + } + + if(var1 == 2) { + var5 += getArtSize(this.art.sizeX); + } + + if(var1 == 3) { + var7 -= getArtSize(this.art.sizeX); + } + + var6 += getArtSize(this.art.sizeY); + this.setPosition(var5, var6, var7); + this.boundingBox = new AxisAlignedBB(var5 - var2, var6 - var3, var7 - var4, var5 + var2, var6 + var3, var7 + var4); + float var8 = 0.1F / 16.0F; + AxisAlignedBB var9 = this.boundingBox; + var2 = var9.minX; + var3 = var9.minY; + var4 = var9.minZ; + var5 = var9.maxX; + var6 = var9.maxY; + var8 = var9.maxZ; + var5 -= 0.1F / 16.0F; + var6 -= 0.1F / 16.0F; + var8 -= 0.1F / 16.0F; + this.boundingBox = new AxisAlignedBB(var2, var3, var4, var5, var6, var8); + } + + private static float getArtSize(int var0) { + return var0 == 32 ? 0.5F : (var0 == 64 ? 0.5F : 0.0F); + } + + public final void onEntityUpdate() { + if(this.tickCounter1++ == 100 && !this.onValidSurface()) { + this.tickCounter1 = 0; + this.setEntityDead(); + this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Item.painting))); + } + + } + + public final boolean onValidSurface() { + if(this.worldObj.getCollidingBoundingBoxes(this.boundingBox).size() > 0) { + return false; + } else { + int var1 = this.art.sizeX / 16; + int var2 = this.art.sizeY / 16; + int var3 = this.xPosition; + int var5 = this.zPosition; + if(this.direction == 0) { + var3 = (int)(this.posX - (float)this.art.sizeX / 32.0F); + } + + if(this.direction == 1) { + var5 = (int)(this.posZ - (float)this.art.sizeX / 32.0F); + } + + if(this.direction == 2) { + var3 = (int)(this.posX - (float)this.art.sizeX / 32.0F); + } + + if(this.direction == 3) { + var5 = (int)(this.posZ - (float)this.art.sizeX / 32.0F); + } + + int var4 = (int)(this.posY - (float)this.art.sizeY / 32.0F); + + int var7; + for(int var6 = 0; var6 < var1; ++var6) { + for(var7 = 0; var7 < var2; ++var7) { + Material var8; + if(this.direction != 0 && this.direction != 2) { + var8 = this.worldObj.getBlockMaterial(this.xPosition, var4 + var7, var5 + var6); + } else { + var8 = this.worldObj.getBlockMaterial(var3 + var6, var4 + var7, this.zPosition); + } + + if(!var8.isSolid()) { + return false; + } + } + } + + List var9 = this.worldObj.entityMap.getEntitiesWithinAABB(this, this.boundingBox); + + for(var7 = 0; var7 < var9.size(); ++var7) { + if(var9.get(var7) instanceof EntityPainting) { + return false; + } + } + + return true; + } + } + + public final boolean canBeCollidedWith() { + return true; + } + + public final boolean attackEntityFrom(Entity var1, int var2) { + this.setEntityDead(); + this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Item.painting))); + return true; + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + var1.setByte("Dir", (byte)this.direction); + var1.setString("Motive", this.art.title); + var1.setInteger("TileX", this.xPosition); + var1.setInteger("TileY", this.yPosition); + var1.setInteger("TileZ", this.zPosition); + } + + protected final String getEntityString() { + return "Painting"; + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + this.direction = var1.getByte("Dir"); + this.xPosition = var1.getInteger("TileX"); + this.yPosition = var1.getInteger("TileY"); + this.zPosition = var1.getInteger("TileZ"); + String var6 = var1.getString("Motive"); + EnumArt[] var2 = EnumArt.values(); + int var3 = var2.length; + + for(int var4 = 0; var4 < var3; ++var4) { + EnumArt var5 = var2[var4]; + if(var5.title.equals(var6)) { + this.art = var5; + } + } + + if(this.art == null) { + this.art = EnumArt.Kebab; + } + + this.setDirection(this.direction); + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/EnumArt.java b/src/teavm/java/net/minecraft/game/entity/EnumArt.java new file mode 100644 index 0000000..b4aec62 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/EnumArt.java @@ -0,0 +1,37 @@ +package net.minecraft.game.entity; + +public enum EnumArt { + Kebab("Kebab", 16, 16, 0, 0), + Aztec("Aztec", 16, 16, 16, 0), + Alban("Alban", 16, 16, 32, 0), + Aztec2("Aztec2", 16, 16, 48, 0), + Bomb("Bomb", 16, 16, 64, 0), + Plant("Plant", 16, 16, 80, 0), + Wasteland("Wasteland", 16, 16, 96, 0), + Pool("Pool", 32, 16, 0, 32), + Courbet("Courbet", 32, 16, 32, 32), + Sea("Sea", 32, 16, 64, 32), + Sunset("Sunset", 32, 16, 96, 32), + Wanderer("Wanderer", 16, 32, 0, 64), + Match("Match", 32, 32, 0, 128), + Bust("Bust", 32, 32, 32, 128), + Stage("Stage", 32, 32, 64, 128), + Void("Void", 32, 32, 96, 128), + SkullAndRoses("SkullAndRoses", 32, 32, 128, 128), + Fighters("Fighters", 64, 32, 0, 96), + Pointer("Pointer", 64, 64, 0, 192); + + public final String title; + public final int sizeX; + public final int sizeY; + public final int offsetX; + public final int offsetY; + + private EnumArt(String var3, int var4, int var5, int var6, int var7) { + this.title = var3; + this.sizeX = var4; + this.sizeY = var5; + this.offsetX = var6; + this.offsetY = var7; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/animal/EntityAnimal.java b/src/teavm/java/net/minecraft/game/entity/animal/EntityAnimal.java new file mode 100644 index 0000000..fd1ec88 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/animal/EntityAnimal.java @@ -0,0 +1,28 @@ +package net.minecraft.game.entity.animal; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.EntityCreature; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public abstract class EntityAnimal extends EntityCreature { + public EntityAnimal(World var1) { + super(var1); + } + + protected final float getBlockPathWeight(int var1, int var2, int var3) { + return this.worldObj.getBlockId(var1, var2 - 1, var3) == Block.grass.blockID ? 10.0F : this.worldObj.getLightBrightness(var1, var2, var3) - 0.5F; + } + + protected void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + } + + protected void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + } + + public final boolean getCanSpawnHere(float var1, float var2, float var3) { + return this.worldObj.getBlockLightValue((int)var1, (int)var2, (int)var3) > 8 && super.getCanSpawnHere(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/animal/EntityPig.java b/src/teavm/java/net/minecraft/game/entity/animal/EntityPig.java new file mode 100644 index 0000000..970ba7f --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/animal/EntityPig.java @@ -0,0 +1,41 @@ +package net.minecraft.game.entity.animal; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.item.Item; +import net.minecraft.game.level.World; + +public class EntityPig extends EntityAnimal { + public EntityPig(World var1) { + super(var1); + this.texture = "/mob/pig.png"; + this.setSize(0.9F, 0.9F); + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + } + + protected final String getEntityString() { + return "Pig"; + } + + protected final String getLivingSound() { + return "mob.pig"; + } + + protected final String getHurtSound() { + return "mob.pig"; + } + + protected final String getDeathSound() { + return "mob.pigdeath"; + } + + protected final int scoreValue() { + return Item.porkRaw.shiftedIndex; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/animal/EntitySheep.java b/src/teavm/java/net/minecraft/game/entity/animal/EntitySheep.java new file mode 100644 index 0000000..6de1319 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/animal/EntitySheep.java @@ -0,0 +1,60 @@ +package net.minecraft.game.entity.animal; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public class EntitySheep extends EntityAnimal { + public boolean sheared = false; + + public EntitySheep(World var1) { + super(var1); + this.texture = "/mob/sheep.png"; + this.setSize(0.9F, 1.3F); + } + + public final boolean attackEntityFrom(Entity var1, int var2) { + if(!this.sheared && var1 instanceof EntityLiving) { + this.sheared = true; + int var3 = 1 + this.rand.nextInt(3); + + for(int var4 = 0; var4 < var3; ++var4) { + EntityItem var5 = this.entityDropItem(Block.clothGray.blockID, 1, 1.0F); + var5.motionY += this.rand.nextFloat() * 0.05F; + var5.motionX += (this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F; + var5.motionZ += (this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F; + } + } + + return super.attackEntityFrom(var1, var2); + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + var1.setBoolean("Sheared", this.sheared); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + this.sheared = var1.getBoolean("Sheared"); + } + + protected final String getEntityString() { + return "Sheep"; + } + + protected final String getLivingSound() { + return "mob.sheep"; + } + + protected final String getHurtSound() { + return "mob.sheep"; + } + + protected final String getDeathSound() { + return "mob.sheep"; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/misc/EntityItem.java b/src/teavm/java/net/minecraft/game/entity/misc/EntityItem.java new file mode 100644 index 0000000..d323b44 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/misc/EntityItem.java @@ -0,0 +1,181 @@ +package net.minecraft.game.entity.misc; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.material.Material; + +public class EntityItem extends Entity { + public ItemStack item; + private int unknownEntityItemInt; + public int age = 0; + public int delayBeforeCanPickup; + private int health = 5; + public float hoverStart = (float)(Math.random() * Math.PI * 2.0D); + + public EntityItem(World var1, float var2, float var3, float var4, ItemStack var5) { + super(var1); + this.setSize(0.25F, 0.25F); + this.yOffset = this.height / 2.0F; + this.setPosition(var2, var3, var4); + this.item = var5; + this.rotationYaw = (float)(Math.random() * 360.0D); + this.motionX = (float)(Math.random() * (double)0.2F - (double)0.1F); + this.motionY = 0.2F; + this.motionZ = (float)(Math.random() * (double)0.2F - (double)0.1F); + this.canTriggerWalking = false; + } + + public EntityItem(World var1) { + super(var1); + } + + public final void onEntityUpdate() { + super.onEntityUpdate(); + if(this.delayBeforeCanPickup > 0) { + --this.delayBeforeCanPickup; + } + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.04F; + if(this.worldObj.getBlockMaterial((int)this.posX, (int)this.posY, (int)this.posZ) == Material.lava) { + this.motionY = 0.2F; + this.motionX = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F; + this.motionZ = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F; + } + + float var4 = this.posZ; + float var3 = this.posY; + float var2 = this.posX; + int var5 = (int)var2; + int var6 = (int)var3; + int var7 = (int)var4; + var2 -= (float)var5; + var3 -= (float)var6; + var4 -= (float)var7; + if(Block.opaqueCubeLookup[this.worldObj.getBlockId(var5, var6, var7)]) { + boolean var8 = !Block.opaqueCubeLookup[this.worldObj.getBlockId(var5 - 1, var6, var7)]; + boolean var9 = !Block.opaqueCubeLookup[this.worldObj.getBlockId(var5 + 1, var6, var7)]; + boolean var10 = !Block.opaqueCubeLookup[this.worldObj.getBlockId(var5, var6 - 1, var7)]; + boolean var11 = !Block.opaqueCubeLookup[this.worldObj.getBlockId(var5, var6 + 1, var7)]; + boolean var12 = !Block.opaqueCubeLookup[this.worldObj.getBlockId(var5, var6, var7 - 1)]; + boolean var13 = !Block.opaqueCubeLookup[this.worldObj.getBlockId(var5, var6, var7 + 1)]; + byte var14 = -1; + float var15 = 9999.0F; + if(var8 && var2 < 9999.0F) { + var15 = var2; + var14 = 0; + } + + if(var9 && 1.0F - var2 < var15) { + var15 = 1.0F - var2; + var14 = 1; + } + + if(var10 && var3 < var15) { + var15 = var3; + var14 = 2; + } + + if(var11 && 1.0F - var3 < var15) { + var15 = 1.0F - var3; + var14 = 3; + } + + if(var12 && var4 < var15) { + var15 = var4; + var14 = 4; + } + + if(var13 && 1.0F - var4 < var15) { + var14 = 5; + } + + var2 = this.rand.nextFloat() * 0.2F + 0.1F; + if(var14 == 0) { + this.motionX = -var2; + } + + if(var14 == 1) { + this.motionX = var2; + } + + if(var14 == 2) { + this.motionY = -var2; + } + + if(var14 == 3) { + this.motionY = var2; + } + + if(var14 == 4) { + this.motionZ = -var2; + } + + if(var14 == 5) { + this.motionZ = var2; + } + } + + boolean var10000 = false; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.98F; + this.motionY *= 0.98F; + this.motionZ *= 0.98F; + if(this.onGround) { + this.motionX *= 0.7F; + this.motionZ *= 0.7F; + this.motionY *= -0.5F; + } + + ++this.unknownEntityItemInt; + ++this.age; + if(this.age >= 6000) { + this.setEntityDead(); + } + + } + + protected final void dealFireDamage(int var1) { + this.attackEntityFrom((Entity)null, 1); + } + + public final boolean attackEntityFrom(Entity var1, int var2) { + this.health -= var2; + if(this.health <= 0) { + this.setEntityDead(); + } + + return false; + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + var1.setShort("Health", (byte)this.health); + var1.setShort("Age", (short)this.age); + var1.setCompoundTag("Item", this.item.writeToNBT(new NBTTagCompound())); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + this.health = var1.getShort("Health") & 255; + this.age = var1.getShort("Age"); + var1 = var1.getCompoundTag("Item"); + this.item = new ItemStack(var1); + } + + protected final String getEntityString() { + return "Item"; + } + + public final void onCollideWithPlayer(EntityPlayer var1) { + if(this.delayBeforeCanPickup == 0 && var1.inventory.storePartialItemStack(this.item)) { + var1.onItemPickup(this); + this.setEntityDead(); + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/misc/EntityTNTPrimed.java b/src/teavm/java/net/minecraft/game/entity/misc/EntityTNTPrimed.java new file mode 100644 index 0000000..e7d9860 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/misc/EntityTNTPrimed.java @@ -0,0 +1,70 @@ +package net.minecraft.game.entity.misc; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.level.World; + +public class EntityTNTPrimed extends Entity { + public int fuse = 0; + + public EntityTNTPrimed(World var1, float var2, float var3, float var4) { + super(var1); + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.98F); + this.yOffset = this.height / 2.0F; + this.setPosition(var2, var3, var4); + float var5 = (float)(Math.random() * (double)((float)Math.PI) * 2.0D); + this.motionX = -MathHelper.sin(var5 * (float)Math.PI / 180.0F) * 0.02F; + this.motionY = 0.2F; + this.motionZ = -MathHelper.cos(var5 * (float)Math.PI / 180.0F) * 0.02F; + this.canTriggerWalking = false; + this.fuse = 80; + this.prevPosX = var2; + this.prevPosY = var3; + this.prevPosZ = var4; + } + + public final boolean canBeCollidedWith() { + return !this.isDead; + } + + public final void onEntityUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.04F; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.98F; + this.motionY *= 0.98F; + this.motionZ *= 0.98F; + if(this.onGround) { + this.motionX *= 0.7F; + this.motionZ *= 0.7F; + this.motionY *= -0.5F; + } + + if(this.fuse-- <= 0) { + this.setEntityDead(); + this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 4.0F); + } else { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5F, this.posZ, 0.0F, 0.0F, 0.0F); + } + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + var1.setByte("Fuse", (byte)this.fuse); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + this.fuse = var1.getByte("Fuse"); + } + + protected final String getEntityString() { + return "PrimedTnt"; + } + + public final float getShadowSize() { + return 0.0F; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/monster/EntityCreeper.java b/src/teavm/java/net/minecraft/game/entity/monster/EntityCreeper.java new file mode 100644 index 0000000..b166770 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/monster/EntityCreeper.java @@ -0,0 +1,69 @@ +package net.minecraft.game.entity.monster; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.item.Item; +import net.minecraft.game.level.World; + +public class EntityCreeper extends EntityMob { + private int timeSinceIgnited; + private int lastActiveTime; + private int fuseTime = 30; + private int creeperState = -1; + + public EntityCreeper(World var1) { + super(var1); + this.texture = "/mob/creeper.png"; + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + } + + protected final String getEntityString() { + return "Creeper"; + } + + protected final void updatePlayerActionState() { + this.lastActiveTime = this.timeSinceIgnited; + if(this.timeSinceIgnited > 0 && this.creeperState < 0) { + --this.timeSinceIgnited; + } + + if(this.creeperState >= 0) { + this.creeperState = 2; + } + + super.updatePlayerActionState(); + if(this.creeperState != 1) { + this.creeperState = -1; + } + + } + + protected final void attackEntity(Entity var1, float var2) { + if(this.creeperState <= 0 && var2 < 3.0F || this.creeperState > 0 && var2 < 7.0F) { + this.creeperState = 1; + ++this.timeSinceIgnited; + if(this.timeSinceIgnited == this.fuseTime) { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0F); + this.setEntityDead(); + } + + this.hasAttacked = true; + } + + } + + public final float c(float var1) { + return ((float)this.lastActiveTime + (float)(this.timeSinceIgnited - this.lastActiveTime) * var1) / (float)(this.fuseTime - 2); + } + + protected final int scoreValue() { + return Item.gunpowder.shiftedIndex; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/monster/EntityGiantZombie.java b/src/teavm/java/net/minecraft/game/entity/monster/EntityGiantZombie.java new file mode 100644 index 0000000..da8b06e --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/monster/EntityGiantZombie.java @@ -0,0 +1,23 @@ +package net.minecraft.game.entity.monster; + +import net.minecraft.game.level.World; + +public class EntityGiantZombie extends EntityMob { + public EntityGiantZombie(World var1) { + super(var1); + this.texture = "/mob/zombie.png"; + this.moveSpeed = 0.5F; + this.attackStrength = 50; + this.health *= 10; + this.yOffset *= 6.0F; + this.setSize(this.width * 6.0F, this.height * 6.0F); + } + + protected final float getBlockPathWeight(int var1, int var2, int var3) { + return this.worldObj.getLightBrightness(var1, var2, var3) - 0.5F; + } + + protected final String getEntityString() { + return "Giant"; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/monster/EntityMob.java b/src/teavm/java/net/minecraft/game/entity/monster/EntityMob.java new file mode 100644 index 0000000..ac7c534 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/monster/EntityMob.java @@ -0,0 +1,78 @@ +package net.minecraft.game.entity.monster; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityCreature; +import net.minecraft.game.level.World; + +public class EntityMob extends EntityCreature { + protected int attackStrength = 2; + + public EntityMob(World var1) { + super(var1); + this.health = 20; + } + + public void onLivingUpdate() { + float var1 = this.getEntityBrightness(1.0F); + if(var1 > 0.5F) { + this.entityAge += 2; + } + + super.onLivingUpdate(); + } + + public final void onEntityUpdate() { + super.onEntityUpdate(); + if(this.worldObj.difficultySetting == 0) { + this.setEntityDead(); + } + + } + + protected Entity findPlayerToAttack() { + float var1 = this.worldObj.playerEntity.getDistanceSqToEntity(this); + return var1 < 256.0F ? this.worldObj.playerEntity : null; + } + + public final boolean attackEntityFrom(Entity var1, int var2) { + if(super.attackEntityFrom(var1, var2)) { + if(var1 != this) { + this.playerToAttack = var1; + } + + return true; + } else { + return false; + } + } + + protected void attackEntity(Entity var1, float var2) { + if((double)var2 < 2.5D && var1.boundingBox.maxY > this.boundingBox.minY && var1.boundingBox.minY < this.boundingBox.maxY) { + this.attackTime = 20; + var1.attackEntityFrom(this, this.attackStrength); + } + + } + + protected float getBlockPathWeight(int var1, int var2, int var3) { + return 0.5F - this.worldObj.getLightBrightness(var1, var2, var3); + } + + protected void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + } + + protected void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + } + + protected String getEntityString() { + return "Monster"; + } + + public final boolean getCanSpawnHere(float var1, float var2, float var3) { + byte var4 = this.worldObj.getBlockLightValue((int)var1, (int)var2, (int)var3); + return var4 <= this.rand.nextInt(8) && super.getCanSpawnHere(var1, var2, var3); + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/monster/EntitySkeleton.java b/src/teavm/java/net/minecraft/game/entity/monster/EntitySkeleton.java new file mode 100644 index 0000000..48479a6 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/monster/EntitySkeleton.java @@ -0,0 +1,62 @@ +package net.minecraft.game.entity.monster; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.projectile.EntityArrow; +import net.minecraft.game.item.Item; +import net.minecraft.game.level.World; + +public class EntitySkeleton extends EntityMob { + public EntitySkeleton(World var1) { + super(var1); + this.texture = "/mob/skeleton.png"; + } + + public final void onLivingUpdate() { + if(this.worldObj.skylightSubtracted > 7) { + float var1 = this.getEntityBrightness(1.0F); + if(var1 > 0.5F && this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ) && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F) { + this.fire = 300; + } + } + + super.onLivingUpdate(); + } + + protected final void attackEntity(Entity var1, float var2) { + if(var2 < 10.0F) { + var2 = var1.posX - this.posX; + float var3 = var1.posZ - this.posZ; + if(this.attackTime == 0) { + EntityArrow var4 = new EntityArrow(this.worldObj, this); + ++var4.posY; + float var6 = var1.posY - 0.2F - var4.posY; + float var5 = MathHelper.sqrt_float(var2 * var2 + var3 * var3) * 0.2F; + this.worldObj.spawnEntityInWorld(var4); + var4.setArrowHeading(var2, var6 + var5, var3, 0.6F, 12.0F); + this.attackTime = 30; + } + + this.rotationYaw = (float)(Math.atan2((double)var3, (double)var2) * 180.0D / (double)((float)Math.PI)) - 90.0F; + this.hasAttacked = true; + } + + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + } + + protected final String getEntityString() { + return "Skeleton"; + } + + protected final int scoreValue() { + return Item.arrow.shiftedIndex; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/monster/EntitySpider.java b/src/teavm/java/net/minecraft/game/entity/monster/EntitySpider.java new file mode 100644 index 0000000..d256240 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/monster/EntitySpider.java @@ -0,0 +1,66 @@ +package net.minecraft.game.entity.monster; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.item.Item; +import net.minecraft.game.level.World; + +public class EntitySpider extends EntityMob { + public EntitySpider(World var1) { + super(var1); + this.texture = "/mob/spider.png"; + this.setSize(1.4F, 0.9F); + this.moveSpeed = 0.8F; + } + + protected final Entity findPlayerToAttack() { + float var1 = this.getEntityBrightness(1.0F); + if(var1 < 0.5F) { + var1 = this.worldObj.playerEntity.getDistanceSqToEntity(this); + if(var1 < 256.0F) { + return this.worldObj.playerEntity; + } + } + + return null; + } + + protected final void attackEntity(Entity var1, float var2) { + float var3 = this.getEntityBrightness(1.0F); + if(var3 > 0.5F && this.rand.nextInt(100) == 0) { + this.playerToAttack = null; + } else { + if(var2 > 2.0F && var2 < 6.0F && this.rand.nextInt(10) == 0) { + if(this.onGround) { + var2 = var1.posX - this.posX; + float var4 = var1.posZ - this.posZ; + var3 = MathHelper.sqrt_float(var2 * var2 + var4 * var4); + this.motionX = var2 / var3 * 0.5F * 0.8F + this.motionX * 0.2F; + this.motionZ = var4 / var3 * 0.5F * 0.8F + this.motionZ * 0.2F; + this.motionY = 0.4F; + return; + } + } else { + super.attackEntity(var1, var2); + } + + } + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + } + + protected final String getEntityString() { + return "Spider"; + } + + protected final int scoreValue() { + return Item.silk.shiftedIndex; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/monster/EntityZombie.java b/src/teavm/java/net/minecraft/game/entity/monster/EntityZombie.java new file mode 100644 index 0000000..c6e5f15 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/monster/EntityZombie.java @@ -0,0 +1,32 @@ +package net.minecraft.game.entity.monster; + +import net.minecraft.game.item.Item; +import net.minecraft.game.level.World; + +public class EntityZombie extends EntityMob { + public EntityZombie(World var1) { + super(var1); + this.texture = "/mob/zombie.png"; + this.moveSpeed = 0.5F; + this.attackStrength = 5; + } + + public final void onLivingUpdate() { + if(this.worldObj.skylightSubtracted > 7) { + float var1 = this.getEntityBrightness(1.0F); + if(var1 > 0.5F && this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ) && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F) { + this.fire = 300; + } + } + + super.onLivingUpdate(); + } + + protected final String getEntityString() { + return "Zombie"; + } + + protected final int scoreValue() { + return Item.feather.shiftedIndex; + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/player/EntityPlayer.java b/src/teavm/java/net/minecraft/game/entity/player/EntityPlayer.java new file mode 100644 index 0000000..aa4f0f7 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/player/EntityPlayer.java @@ -0,0 +1,222 @@ +package net.minecraft.game.entity.player; + +import java.util.List; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.IInventory; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.entity.monster.EntityMob; +import net.minecraft.game.entity.projectile.EntityArrow; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemArmor; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.tileentity.TileEntityFurnace; +import net.minecraft.game.level.material.Material; + +public class EntityPlayer extends EntityLiving { + public InventoryPlayer inventory = new InventoryPlayer(this); + public byte unusedByte = 0; + public int getScore = 0; + public float prevCameraYaw; + public float cameraYaw; + private int damageRemainder = 0; + + public EntityPlayer(World var1) { + super(var1); + if(var1 != null) { + var1.playerEntity = this; + var1.releaseEntitySkin(this); + } + + this.setPositionAndRotation((float)var1.xSpawn, (float)var1.ySpawn, (float)var1.zSpawn, 0.0F, 0.0F); + this.yOffset = 1.62F; + this.health = 20; + this.fireResistance = 20; + this.texture = "/char.png"; + } + + public final void preparePlayerToSpawn() { + this.yOffset = 1.62F; + this.setSize(0.6F, 1.8F); + super.preparePlayerToSpawn(); + if(this.worldObj != null) { + this.worldObj.playerEntity = this; + } + + this.health = 20; + this.deathTime = 0; + } + + public void onLivingUpdate() { + if(this.worldObj.difficultySetting == 0 && this.health < 20 && this.ticksExisted % 20 << 2 == 0) { + this.heal(1); + } + + InventoryPlayer var3 = this.inventory; + + for(int var4 = 0; var4 < var3.mainInventory.length; ++var4) { + if(var3.mainInventory[var4] != null && var3.mainInventory[var4].animationsToGo > 0) { + --var3.mainInventory[var4].animationsToGo; + } + } + + this.prevCameraYaw = this.cameraYaw; + super.onLivingUpdate(); + float var1 = MathHelper.sqrt_float(this.motionX * this.motionX + this.motionZ * this.motionZ); + float var2 = (float)Math.atan((double)(-this.motionY * 0.2F)) * 15.0F; + if(var1 > 0.1F) { + var1 = 0.1F; + } + + if(!this.onGround || this.health <= 0) { + var1 = 0.0F; + } + + if(this.onGround || this.health <= 0) { + var2 = 0.0F; + } + + this.cameraYaw += (var1 - this.cameraYaw) * 0.4F; + this.cameraPitch += (var2 - this.cameraPitch) * 0.8F; + if(this.health > 0) { + List var5 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(1.0F, 0.0F, 1.0F)); + if(var5 != null) { + for(int var6 = 0; var6 < var5.size(); ++var6) { + Entity var7 = (Entity)var5.get(var6); + var7.onCollideWithPlayer(this); + } + } + } + + } + + public final void onDeath(Entity var1) { + this.setSize(0.2F, 0.2F); + this.setPosition(this.posX, this.posY, this.posZ); + this.motionY = 0.1F; + if(var1 != null) { + this.motionX = -MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F; + this.motionZ = -MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F; + } else { + this.motionX = this.motionZ = 0.0F; + } + + this.yOffset = 0.1F; + } + + public final void setEntityDead() { + } + + public final void dropPlayerItem(ItemStack var1) { + this.dropPlayerItemWithRandomChoice(var1, false); + } + + public final void dropPlayerItemWithRandomChoice(ItemStack var1, boolean var2) { + if(var1 != null) { + EntityItem var4 = new EntityItem(this.worldObj, this.posX, this.posY - 0.3F, this.posZ, var1); + var4.delayBeforeCanPickup = 40; + var4.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * 0.3F; + var4.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * 0.3F; + var4.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * 0.3F + 0.1F; + float var3 = this.rand.nextFloat() * (float)Math.PI * 2.0F; + float var5 = 0.02F * this.rand.nextFloat(); + var4.motionX = (float)((double)var4.motionX + Math.cos((double)var3) * (double)var5); + var4.motionY += (this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F; + var4.motionZ = (float)((double)var4.motionZ + Math.sin((double)var3) * (double)var5); + this.worldObj.spawnEntityInWorld(var4); + } + } + + public final boolean canHarvestBlock(Block var1) { + Block var2 = var1; + InventoryPlayer var3 = this.inventory; + if(var2.material != Material.rock && var2.material != Material.iron) { + return true; + } else { + ItemStack var4 = var3.getStackInSlot(var3.currentItem); + return var4 != null ? Item.itemsList[var4.itemID].canHarvestBlock(var2) : false; + } + } + + protected void readEntityFromNBT(NBTTagCompound var1) { + super.readEntityFromNBT(var1); + } + + protected void writeEntityToNBT(NBTTagCompound var1) { + super.writeEntityToNBT(var1); + } + + protected String getEntityString() { + return null; + } + + public void displayGUIChest(IInventory var1) { + } + + public void displayWorkbenchGUI() { + } + + public void onItemPickup(Entity var1) { + } + + protected final float getEyeHeight() { + return 0.12F; + } + + public final boolean attackEntityFrom(Entity var1, int var2) { + if(!this.worldObj.survivalWorld) { + return false; + } else { + this.entityAge = 0; + if(this.health <= 0) { + return false; + } else if((float)this.heartsLife > (float)this.heartsHalvesLife / 2.0F) { + return false; + } else { + if(var1 instanceof EntityMob || var1 instanceof EntityArrow) { + if(this.worldObj.difficultySetting == 0) { + var2 = 0; + } + + if(this.worldObj.difficultySetting == 1) { + var2 = var2 / 3 + 1; + } + + if(this.worldObj.difficultySetting == 3) { + var2 = var2 * 3 / 2; + } + } + + int var3 = 25 - this.inventory.getPlayerArmorValue(); + var3 = var2 * var3 + this.damageRemainder; + int var4 = var2; + InventoryPlayer var6 = this.inventory; + + for(int var5 = 0; var5 < var6.armorInventory.length; ++var5) { + if(var6.armorInventory[var5] != null && var6.armorInventory[var5].getItem() instanceof ItemArmor) { + var6.armorInventory[var5].damageItem(var4); + if(var6.armorInventory[var5].stackSize == 0) { + var6.armorInventory[var5] = null; + } + } + } + + var2 = var3 / 25; + this.damageRemainder = var3 % 25; + if(var2 == 0) { + return false; + } else { + return super.attackEntityFrom(var1, var2); + } + } + } + } + + public void displayGUIFurnace(TileEntityFurnace var1) { + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/player/InventoryPlayer.java b/src/teavm/java/net/minecraft/game/entity/player/InventoryPlayer.java new file mode 100644 index 0000000..77cf712 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/player/InventoryPlayer.java @@ -0,0 +1,218 @@ +package net.minecraft.game.entity.player; + +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemArmor; +import net.minecraft.game.item.ItemStack; + +public final class InventoryPlayer implements IInventory { + public ItemStack[] mainInventory = new ItemStack[36]; + public ItemStack[] armorInventory = new ItemStack[4]; + public int currentItem = 0; + private EntityPlayer player; + + public InventoryPlayer(EntityPlayer var1) { + this.player = var1; + } + + public final ItemStack getCurrentItem() { + return this.mainInventory[this.currentItem]; + } + + private int getInventorySlotContainItem(int var1) { + for(int var2 = 0; var2 < this.mainInventory.length; ++var2) { + if(this.mainInventory[var2] != null && this.mainInventory[var2].itemID == var1) { + return var2; + } + } + + return -1; + } + + private int storeItemStack() { + for(int var1 = 0; var1 < this.mainInventory.length; ++var1) { + if(this.mainInventory[var1] == null) { + return var1; + } + } + + return -1; + } + + public final void getFirstEmptyStack(int var1) { + var1 = this.getInventorySlotContainItem(var1); + if(var1 >= 0 && var1 < 9) { + this.currentItem = var1; + } + } + + public final boolean consumeInventoryItem(int var1) { + var1 = this.getInventorySlotContainItem(var1); + if(var1 < 0) { + return false; + } else { + if(--this.mainInventory[var1].stackSize <= 0) { + this.mainInventory[var1] = null; + } + + return true; + } + } + + public final boolean storePartialItemStack(ItemStack var1) { + if(var1.itemDamage == 0) { + int var4 = var1.stackSize; + int var3 = var1.itemID; + int var6 = var3; + InventoryPlayer var5 = this; + int var7 = 0; + + int var10001; + ItemStack var8; + while(true) { + if(var7 >= var5.mainInventory.length) { + var10001 = -1; + break; + } + + if(var5.mainInventory[var7] != null && var5.mainInventory[var7].itemID == var6) { + var8 = var5.mainInventory[var7]; + if(var5.mainInventory[var7].stackSize < var8.getItem().getItemStackLimit() && var5.mainInventory[var7].stackSize < 64) { + var10001 = var7; + break; + } + } + + ++var7; + } + + int var9 = var10001; + if(var9 < 0) { + var9 = this.storeItemStack(); + } + + if(var9 < 0) { + var10001 = var4; + } else { + if(this.mainInventory[var9] == null) { + this.mainInventory[var9] = new ItemStack(var3, 0); + } + + var3 = var4; + var8 = this.mainInventory[var9]; + if(var4 > var8.getItem().getItemStackLimit() - this.mainInventory[var9].stackSize) { + var8 = this.mainInventory[var9]; + var3 = var8.getItem().getItemStackLimit() - this.mainInventory[var9].stackSize; + } + + if(var3 > 64 - this.mainInventory[var9].stackSize) { + var3 = 64 - this.mainInventory[var9].stackSize; + } + + if(var3 == 0) { + var10001 = var4; + } else { + var4 -= var3; + this.mainInventory[var9].stackSize += var3; + this.mainInventory[var9].animationsToGo = 5; + var10001 = var4; + } + } + + var1.stackSize = var10001; + if(var1.stackSize == 0) { + return true; + } + } + + int var2 = this.storeItemStack(); + if(var2 >= 0) { + this.mainInventory[var2] = var1; + this.mainInventory[var2].animationsToGo = 5; + return true; + } else { + return false; + } + } + + public final ItemStack decrStackSize(int var1, int var2) { + ItemStack[] var3 = this.mainInventory; + if(var1 >= this.mainInventory.length) { + var3 = this.armorInventory; + var1 -= this.mainInventory.length; + } + + if(var3[var1] != null) { + ItemStack var4; + if(var3[var1].stackSize <= var2) { + var4 = var3[var1]; + var3[var1] = null; + return var4; + } else { + var4 = var3[var1].splitStack(var2); + if(var3[var1].stackSize == 0) { + var3[var1] = null; + } + + return var4; + } + } else { + return null; + } + } + + public final void setInventorySlotContents(int var1, ItemStack var2) { + ItemStack[] var3 = this.mainInventory; + if(var1 >= this.mainInventory.length) { + var3 = this.armorInventory; + var1 -= this.mainInventory.length; + } + + var3[var1] = var2; + } + + public final int getSizeInventory() { + return this.mainInventory.length + 4; + } + + public final ItemStack getStackInSlot(int var1) { + ItemStack[] var2 = this.mainInventory; + if(var1 >= this.mainInventory.length) { + var2 = this.armorInventory; + var1 -= this.mainInventory.length; + } + + return var2[var1]; + } + + public final String getInvName() { + return "Inventory"; + } + + public final int getInventoryStackLimit() { + return 64; + } + + public final int getPlayerArmorValue() { + int var1 = 0; + int var2 = 0; + int var3 = 0; + + for(int var4 = 0; var4 < this.armorInventory.length; ++var4) { + if(this.armorInventory[var4] != null && this.armorInventory[var4].getItem() instanceof ItemArmor) { + int var5 = this.armorInventory[var4].isItemStackDamageable(); + int var6 = this.armorInventory[var4].itemDamage; + var6 = var5 - var6; + var2 += var6; + var3 += var5; + var5 = ((ItemArmor)this.armorInventory[var4].getItem()).damageReduceAmount; + var1 += var5; + } + } + + if(var3 == 0) { + return 0; + } else { + return (var1 - 1) * var2 / var3 + 1; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/entity/projectile/EntityArrow.java b/src/teavm/java/net/minecraft/game/entity/projectile/EntityArrow.java new file mode 100644 index 0000000..bbe20a9 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/entity/projectile/EntityArrow.java @@ -0,0 +1,225 @@ +package net.minecraft.game.entity.projectile; + +import java.util.List; + +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.physics.AxisAlignedBB; +import net.minecraft.game.physics.MovingObjectPosition; +import net.minecraft.game.physics.Vec3D; + +public class EntityArrow extends Entity { + private int xTile = -1; + private int yTile = -1; + private int zTile = -1; + private int inTile = 0; + private boolean inGround = false; + public int arrowShake = 0; + private EntityLiving owner; + private int ticksInGround; + private int ticksInAir = 0; + + public EntityArrow(World var1, EntityLiving var2) { + super(var1); + this.owner = var2; + this.setSize(0.5F, 0.5F); + this.setPositionAndRotation(var2.posX, var2.posY, var2.posZ, var2.rotationYaw, var2.rotationPitch); + this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F; + this.posY -= 0.1F; + this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F; + this.setPosition(this.posX, this.posY, this.posZ); + this.yOffset = 0.0F; + this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI); + this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI); + this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI); + this.setArrowHeading(this.motionX, this.motionY, this.motionZ, 1.5F, 1.0F); + } + + public final void setArrowHeading(float var1, float var2, float var3, float var4, float var5) { + float var6 = MathHelper.sqrt_float(var1 * var1 + var2 * var2 + var3 * var3); + var1 /= var6; + var2 /= var6; + var3 /= var6; + var1 = (float)((double)var1 + this.rand.nextGaussian() * (double)0.0075F * (double)var5); + var2 = (float)((double)var2 + this.rand.nextGaussian() * (double)0.0075F * (double)var5); + var3 = (float)((double)var3 + this.rand.nextGaussian() * (double)0.0075F * (double)var5); + var1 *= var4; + var2 *= var4; + var3 *= var4; + this.motionX = var1; + this.motionY = var2; + this.motionZ = var3; + var4 = MathHelper.sqrt_float(var1 * var1 + var3 * var3); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2((double)var1, (double)var3) * 180.0D / (double)((float)Math.PI)); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2((double)var2, (double)var4) * 180.0D / (double)((float)Math.PI)); + this.ticksInGround = 0; + } + + public final void onEntityUpdate() { + super.onEntityUpdate(); + if(this.arrowShake > 0) { + --this.arrowShake; + } + + if(this.inGround) { + int var1 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + if(var1 == this.inTile) { + ++this.ticksInGround; + if(this.ticksInGround == 1200) { + this.setEntityDead(); + } + + return; + } + + this.inGround = false; + this.motionX *= this.rand.nextFloat() * 0.2F; + this.motionY *= this.rand.nextFloat() * 0.2F; + this.motionZ *= this.rand.nextFloat() * 0.2F; + this.ticksInGround = 0; + this.ticksInAir = 0; + } else { + ++this.ticksInAir; + } + + Vec3D var10 = new Vec3D(this.posX, this.posY, this.posZ); + Vec3D var2 = new Vec3D(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var10, var2); + var10 = new Vec3D(this.posX, this.posY, this.posZ); + var2 = new Vec3D(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + if(var3 != null) { + var2 = new Vec3D(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord); + } + + Entity var4 = null; + List var5 = this.worldObj.entityMap.getEntitiesWithinAABB(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0F, 1.0F, 1.0F)); + float var6 = 0.0F; + + for(int var7 = 0; var7 < var5.size(); ++var7) { + Entity var8 = (Entity)var5.get(var7); + if(var8.canBeCollidedWith() && (var8 != this.owner || this.ticksInAir >= 5)) { + AxisAlignedBB var9 = var8.boundingBox.expand(0.3F, 0.3F, 0.3F); + MovingObjectPosition var13 = var9.calculateIntercept(var10, var2); + if(var13 != null) { + float var14 = var10.distance(var13.hitVec); + if(var14 < var6 || var6 == 0.0F) { + var4 = var8; + var6 = var14; + } + } + } + } + + if(var4 != null) { + var3 = new MovingObjectPosition(var4); + } + + float var11; + if(var3 != null) { + if(var3.entityHit != null) { + if(var3.entityHit.attackEntityFrom(this, 4)) { + this.setEntityDead(); + } else { + this.motionX *= -0.1F; + this.motionY *= -0.1F; + this.motionZ *= -0.1F; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } else { + this.xTile = var3.blockX; + this.yTile = var3.blockY; + this.zTile = var3.blockZ; + this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + this.motionX = var3.hitVec.xCoord - this.posX; + this.motionY = var3.hitVec.yCoord - this.posY; + this.motionZ = var3.hitVec.zCoord - this.posZ; + var11 = MathHelper.sqrt_float(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / var11 * 0.05F; + this.posY -= this.motionY / var11 * 0.05F; + this.posZ -= this.motionZ / var11 * 0.05F; + this.inGround = true; + this.arrowShake = 7; + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + var11 = MathHelper.sqrt_float(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2((double)this.motionX, (double)this.motionZ) * 180.0D / (double)((float)Math.PI)); + + for(this.rotationPitch = (float)(Math.atan2((double)this.motionY, (double)var11) * 180.0D / (double)((float)Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + } + + while(this.rotationPitch - this.prevRotationPitch >= 180.0F) { + this.prevRotationPitch += 360.0F; + } + + while(this.rotationYaw - this.prevRotationYaw < -180.0F) { + this.prevRotationYaw -= 360.0F; + } + + while(this.rotationYaw - this.prevRotationYaw >= 180.0F) { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float var12 = 0.99F; + if(this.handleWaterMovement()) { + for(int var15 = 0; var15 < 4; ++var15) { + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * 0.25F, this.posY - this.motionY * 0.25F, this.posZ - this.motionZ * 0.25F, this.motionX, this.motionY, this.motionZ); + } + + var12 = 0.8F; + } + + this.motionX *= var12; + this.motionY *= var12; + this.motionZ *= var12; + this.motionY -= 0.03F; + this.setPosition(this.posX, this.posY, this.posZ); + } + + protected final void writeEntityToNBT(NBTTagCompound var1) { + var1.setShort("xTile", (short)this.xTile); + var1.setShort("yTile", (short)this.yTile); + var1.setShort("zTile", (short)this.zTile); + var1.setByte("inTile", (byte)this.inTile); + var1.setByte("shake", (byte)this.arrowShake); + var1.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + } + + protected final void readEntityFromNBT(NBTTagCompound var1) { + this.xTile = var1.getShort("xTile"); + this.yTile = var1.getShort("yTile"); + this.zTile = var1.getShort("zTile"); + this.inTile = var1.getByte("inTile") & 255; + this.arrowShake = var1.getByte("shake") & 255; + this.inGround = var1.getByte("inGround") == 1; + } + + protected final String getEntityString() { + return "Arrow"; + } + + public final void onCollideWithPlayer(EntityPlayer var1) { + if(this.inGround && this.owner == var1 && this.arrowShake <= 0 && var1.inventory.storePartialItemStack(new ItemStack(Item.arrow.shiftedIndex, 1))) { + var1.onItemPickup(this); + this.setEntityDead(); + } + + } + + public final float getShadowSize() { + return 0.0F; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/Item.java b/src/teavm/java/net/minecraft/game/item/Item.java new file mode 100644 index 0000000..c22b3e1 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/Item.java @@ -0,0 +1,464 @@ +package net.minecraft.game.item; + +import java.util.Random; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public class Item { + protected static Random rand = new Random(); + public static Item[] itemsList = new Item[1024]; + public static Item shovel; + public static Item pickaxeSteel; + public static Item axeSteel; + public static Item striker; + public static Item bow; + public static Item arrow; + public static Item coal; + public static Item diamond; + public static Item ingotIron; + public static Item ingotGold; + public static Item swordSteel; + public static Item swordWood; + public static Item shovelWood; + public static Item pickaxeWood; + public static Item axeWood; + public static Item swordStone; + public static Item shovelStone; + public static Item pickaxeStone; + public static Item axeStone; + public static Item swordDiamond; + public static Item shovelDiamond; + public static Item pickaxeDiamond; + public static Item axeDiamond; + public static Item stick; + public static Item bowlEmpty; + public static Item bowlSoup; + public static Item swordGold; + public static Item shovelGold; + public static Item pickaxeGold; + public static Item axeGold; + public static Item silk; + public static Item feather; + public static Item gunpowder; + public static Item hoeWood; + public static Item hoeStone; + public static Item hoeSteel; + public static Item hoeDiamond; + public static Item hoeGold; + public static Item seeds; + public static Item wheat; + public static Item bread; + public static Item helmetLeather; + public static Item plateLeather; + public static Item legsLeather; + public static Item bootsLeather; + public static Item helmetChain; + public static Item plateChain; + public static Item legsChain; + public static Item bootsChain; + public static Item helmetSteel; + public static Item plateSteel; + public static Item legsSteel; + public static Item bootsSteel; + public static Item helmetDiamond; + public static Item plateDiamond; + public static Item legsDiamond; + public static Item bootsDiamond; + public static Item helmetGold; + public static Item plateGold; + public static Item legsGold; + public static Item bootsGold; + public static Item flint; + public static Item porkRaw; + public static Item porkCooked; + public static Item painting; + public final int shiftedIndex; + protected int maxStackSize = 64; + protected int maxDamage = 32; + protected int iconIndex; + + protected Item(int var1) { + this.shiftedIndex = var1 + 256; + if(itemsList[var1 + 256] != null) { + System.out.println("CONFLICT @ " + var1); + } + + itemsList[var1 + 256] = this; + } + + public final Item setIconIndex(int var1) { + this.iconIndex = var1; + return this; + } + + public final int getIconIndex() { + return this.iconIndex; + } + + public boolean onItemUse(ItemStack var1, World var2, int var3, int var4, int var5, int var6) { + return false; + } + + public float getStrVsBlock(Block var1) { + return 1.0F; + } + + public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3) { + return var1; + } + + public final int getItemStackLimit() { + return this.maxStackSize; + } + + public final int getMaxDamage() { + return this.maxDamage; + } + + public void hitEntity(ItemStack var1) { + } + + public void onBlockDestroyed(ItemStack var1) { + } + + public int getDamageVsEntity() { + return 1; + } + + public boolean canHarvestBlock(Block var1) { + return false; + } + + static { + ItemSpade var10000 = new ItemSpade(0, 2); + byte var1 = 82; + ItemSpade var0 = var10000; + var0.iconIndex = var1; + shovel = var0; + ItemPickaxe var15 = new ItemPickaxe(1, 2); + var1 = 98; + ItemPickaxe var2 = var15; + var2.iconIndex = var1; + pickaxeSteel = var2; + ItemAxe var16 = new ItemAxe(2, 2); + var1 = 114; + ItemAxe var3 = var16; + var3.iconIndex = var1; + axeSteel = var3; + ItemFlintAndSteel var17 = new ItemFlintAndSteel(3); + var1 = 5; + ItemFlintAndSteel var4 = var17; + var4.iconIndex = var1; + striker = var4; + ItemFood var18 = new ItemFood(4, 4); + var1 = 4; + ItemFood var5 = var18; + var5.iconIndex = var1; + ItemBow var19 = new ItemBow(5); + var1 = 21; + ItemBow var6 = var19; + var6.iconIndex = var1; + bow = var6; + Item var20 = new Item(6); + var1 = 37; + Item var7 = var20; + var7.iconIndex = var1; + arrow = var7; + var20 = new Item(7); + var1 = 7; + var7 = var20; + var7.iconIndex = var1; + coal = var7; + var20 = new Item(8); + var1 = 55; + var7 = var20; + var7.iconIndex = var1; + diamond = var7; + var20 = new Item(9); + var1 = 23; + var7 = var20; + var7.iconIndex = var1; + ingotIron = var7; + var20 = new Item(10); + var1 = 39; + var7 = var20; + var7.iconIndex = var1; + ingotGold = var7; + ItemSword var21 = new ItemSword(11, 2); + var1 = 66; + ItemSword var8 = var21; + var8.iconIndex = var1; + swordSteel = var8; + var21 = new ItemSword(12, 0); + var1 = 64; + var8 = var21; + var8.iconIndex = var1; + swordWood = var8; + var10000 = new ItemSpade(13, 0); + var1 = 80; + var0 = var10000; + var0.iconIndex = var1; + shovelWood = var0; + var15 = new ItemPickaxe(14, 0); + var1 = 96; + var2 = var15; + var2.iconIndex = var1; + pickaxeWood = var2; + var16 = new ItemAxe(15, 0); + var1 = 112; + var3 = var16; + var3.iconIndex = var1; + axeWood = var3; + var21 = new ItemSword(16, 1); + var1 = 65; + var8 = var21; + var8.iconIndex = var1; + swordStone = var8; + var10000 = new ItemSpade(17, 1); + var1 = 81; + var0 = var10000; + var0.iconIndex = var1; + shovelStone = var0; + var15 = new ItemPickaxe(18, 1); + var1 = 97; + var2 = var15; + var2.iconIndex = var1; + pickaxeStone = var2; + var16 = new ItemAxe(19, 1); + var1 = 113; + var3 = var16; + var3.iconIndex = var1; + axeStone = var3; + var21 = new ItemSword(20, 3); + var1 = 67; + var8 = var21; + var8.iconIndex = var1; + swordDiamond = var8; + var10000 = new ItemSpade(21, 3); + var1 = 83; + var0 = var10000; + var0.iconIndex = var1; + shovelDiamond = var0; + var15 = new ItemPickaxe(22, 3); + var1 = 99; + var2 = var15; + var2.iconIndex = var1; + pickaxeDiamond = var2; + var16 = new ItemAxe(23, 3); + var1 = 115; + var3 = var16; + var3.iconIndex = var1; + axeDiamond = var3; + var20 = new Item(24); + var1 = 53; + var7 = var20; + var7.iconIndex = var1; + stick = var7; + var20 = new Item(25); + var1 = 71; + var7 = var20; + var7.iconIndex = var1; + bowlEmpty = var7; + ItemSoup var22 = new ItemSoup(26, 10); + var1 = 72; + ItemSoup var9 = var22; + var9.iconIndex = var1; + bowlSoup = var9; + var21 = new ItemSword(27, 0); + var1 = 68; + var8 = var21; + var8.iconIndex = var1; + swordGold = var8; + var10000 = new ItemSpade(28, 0); + var1 = 84; + var0 = var10000; + var0.iconIndex = var1; + shovelGold = var0; + var15 = new ItemPickaxe(29, 0); + var1 = 100; + var2 = var15; + var2.iconIndex = var1; + pickaxeGold = var2; + var16 = new ItemAxe(30, 0); + var1 = 116; + var3 = var16; + var3.iconIndex = var1; + axeGold = var3; + var20 = new Item(31); + var1 = 8; + var7 = var20; + var7.iconIndex = var1; + silk = var7; + var20 = new Item(32); + var1 = 24; + var7 = var20; + var7.iconIndex = var1; + feather = var7; + var20 = new Item(33); + var1 = 40; + var7 = var20; + var7.iconIndex = var1; + gunpowder = var7; + ItemHoe var23 = new ItemHoe(34, 0); + short var11 = 128; + ItemHoe var10 = var23; + var10.iconIndex = var11; + hoeWood = var10; + var23 = new ItemHoe(35, 1); + var11 = 129; + var10 = var23; + var10.iconIndex = var11; + hoeStone = var10; + var23 = new ItemHoe(36, 2); + var11 = 130; + var10 = var23; + var10.iconIndex = var11; + hoeSteel = var10; + var23 = new ItemHoe(37, 3); + var11 = 131; + var10 = var23; + var10.iconIndex = var11; + hoeDiamond = var10; + var23 = new ItemHoe(38, 4); + var11 = 132; + var10 = var23; + var10.iconIndex = var11; + hoeGold = var10; + ItemSeeds var24 = new ItemSeeds(39, Block.crops.blockID); + var1 = 9; + ItemSeeds var12 = var24; + var12.iconIndex = var1; + seeds = var12; + var20 = new Item(40); + var1 = 25; + var7 = var20; + var7.iconIndex = var1; + wheat = var7; + var18 = new ItemFood(41, 5); + var1 = 41; + var5 = var18; + var5.iconIndex = var1; + bread = var5; + ItemArmor var25 = new ItemArmor(42, 0, 0, 0); + var1 = 0; + ItemArmor var13 = var25; + var13.iconIndex = var1; + helmetLeather = var13; + var25 = new ItemArmor(43, 0, 0, 1); + var1 = 16; + var13 = var25; + var13.iconIndex = var1; + plateLeather = var13; + var25 = new ItemArmor(44, 0, 0, 2); + var1 = 32; + var13 = var25; + var13.iconIndex = var1; + legsLeather = var13; + var25 = new ItemArmor(45, 0, 0, 3); + var1 = 48; + var13 = var25; + var13.iconIndex = var1; + bootsLeather = var13; + var25 = new ItemArmor(46, 1, 1, 0); + var1 = 1; + var13 = var25; + var13.iconIndex = var1; + helmetChain = var13; + var25 = new ItemArmor(47, 1, 1, 1); + var1 = 17; + var13 = var25; + var13.iconIndex = var1; + plateChain = var13; + var25 = new ItemArmor(48, 1, 1, 2); + var1 = 33; + var13 = var25; + var13.iconIndex = var1; + legsChain = var13; + var25 = new ItemArmor(49, 1, 1, 3); + var1 = 49; + var13 = var25; + var13.iconIndex = var1; + bootsChain = var13; + var25 = new ItemArmor(50, 2, 2, 0); + var1 = 2; + var13 = var25; + var13.iconIndex = var1; + helmetSteel = var13; + var25 = new ItemArmor(51, 2, 2, 1); + var1 = 18; + var13 = var25; + var13.iconIndex = var1; + plateSteel = var13; + var25 = new ItemArmor(52, 2, 2, 2); + var1 = 34; + var13 = var25; + var13.iconIndex = var1; + legsSteel = var13; + var25 = new ItemArmor(53, 2, 2, 3); + var1 = 50; + var13 = var25; + var13.iconIndex = var1; + bootsSteel = var13; + var25 = new ItemArmor(54, 3, 3, 0); + var1 = 3; + var13 = var25; + var13.iconIndex = var1; + helmetDiamond = var13; + var25 = new ItemArmor(55, 3, 3, 1); + var1 = 19; + var13 = var25; + var13.iconIndex = var1; + plateDiamond = var13; + var25 = new ItemArmor(56, 3, 3, 2); + var1 = 35; + var13 = var25; + var13.iconIndex = var1; + legsDiamond = var13; + var25 = new ItemArmor(57, 3, 3, 3); + var1 = 51; + var13 = var25; + var13.iconIndex = var1; + bootsDiamond = var13; + var25 = new ItemArmor(58, 1, 4, 0); + var1 = 4; + var13 = var25; + var13.iconIndex = var1; + helmetGold = var13; + var25 = new ItemArmor(59, 1, 4, 1); + var1 = 20; + var13 = var25; + var13.iconIndex = var1; + plateGold = var13; + var25 = new ItemArmor(60, 1, 4, 2); + var1 = 36; + var13 = var25; + var13.iconIndex = var1; + legsGold = var13; + var25 = new ItemArmor(61, 1, 4, 3); + var1 = 52; + var13 = var25; + var13.iconIndex = var1; + bootsGold = var13; + var20 = new Item(62); + var1 = 6; + var7 = var20; + var7.iconIndex = var1; + flint = var7; + var18 = new ItemFood(63, 3); + var1 = 87; + var5 = var18; + var5.iconIndex = var1; + porkRaw = var5; + var18 = new ItemFood(64, 8); + var1 = 88; + var5 = var18; + var5.iconIndex = var1; + porkCooked = var5; + ItemPainting var26 = new ItemPainting(65); + var1 = 26; + ItemPainting var14 = var26; + var14.iconIndex = var1; + painting = var14; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemArmor.java b/src/teavm/java/net/minecraft/game/item/ItemArmor.java new file mode 100644 index 0000000..0ef51b3 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemArmor.java @@ -0,0 +1,18 @@ +package net.minecraft.game.item; + +public final class ItemArmor extends Item { + private static final int[] damageReduceAmountArray = new int[]{3, 8, 6, 3}; + private static final int[] maxDamageArray = new int[]{11, 16, 15, 13}; + public final int armorType; + public final int damageReduceAmount; + public final int renderIndex; + + public ItemArmor(int var1, int var2, int var3, int var4) { + super(var1); + this.armorType = var4; + this.renderIndex = var3; + this.damageReduceAmount = damageReduceAmountArray[var4]; + this.maxDamage = maxDamageArray[var4] * 3 << var2; + this.maxStackSize = 1; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemAxe.java b/src/teavm/java/net/minecraft/game/item/ItemAxe.java new file mode 100644 index 0000000..4f15fad --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemAxe.java @@ -0,0 +1,11 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.block.Block; + +public final class ItemAxe extends ItemTool { + private static Block[] blocksEffectiveAgainst = new Block[]{Block.planks, Block.bookShelf, Block.wood, Block.crate}; + + public ItemAxe(int var1, int var2) { + super(var1, 3, var2, blocksEffectiveAgainst); + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemBlock.java b/src/teavm/java/net/minecraft/game/item/ItemBlock.java new file mode 100644 index 0000000..8faf164 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemBlock.java @@ -0,0 +1,61 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.StepSound; +import net.minecraft.game.physics.AxisAlignedBB; + +public final class ItemBlock extends Item { + private int blockID; + + public ItemBlock(int var1) { + super(var1); + this.blockID = var1 + 256; + this.setIconIndex(Block.blocksList[var1 + 256].getBlockTextureFromSide(2)); + } + + public final boolean onItemUse(ItemStack var1, World var2, int var3, int var4, int var5, int var6) { + if(var6 == 0) { + --var4; + } + + if(var6 == 1) { + ++var4; + } + + if(var6 == 2) { + --var5; + } + + if(var6 == 3) { + ++var5; + } + + if(var6 == 4) { + --var3; + } + + if(var6 == 5) { + ++var3; + } + + if(var1.stackSize == 0) { + return false; + } else if(var3 > 0 && var4 > 0 && var5 > 0 && var3 < var2.width - 1 && var4 < var2.height - 1 && var5 < var2.length - 1) { + int var7 = var2.getBlockId(var3, var4, var5); + Block var10 = Block.blocksList[var7]; + if(this.blockID > 0 && var10 == null || var10 == Block.waterMoving || var10 == Block.waterStill || var10 == Block.lavaMoving || var10 == Block.lavaStill || var10 == Block.fire) { + var10 = Block.blocksList[this.blockID]; + AxisAlignedBB var8 = var10.getCollisionBoundingBoxFromPool(var3, var4, var5); + if(var2.checkIfAABBIsClear(var8) && var10.canPlaceBlockAt(var2, var3, var4, var5) && var2.setBlockWithNotify(var3, var4, var5, this.blockID)) { + Block.blocksList[this.blockID].onBlockPlaced(var2, var3, var4, var5, var6); + --var1.stackSize; + } + } + + return true; + } else { + return false; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemBow.java b/src/teavm/java/net/minecraft/game/item/ItemBow.java new file mode 100644 index 0000000..6023720 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemBow.java @@ -0,0 +1,20 @@ +package net.minecraft.game.item; + +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.entity.projectile.EntityArrow; +import net.minecraft.game.level.World; + +public final class ItemBow extends Item { + public ItemBow(int var1) { + super(5); + this.maxStackSize = 1; + } + + public final ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3) { + if(var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex)) { + var2.spawnEntityInWorld(new EntityArrow(var2, var3)); + } + + return var1; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemFlintAndSteel.java b/src/teavm/java/net/minecraft/game/item/ItemFlintAndSteel.java new file mode 100644 index 0000000..98c852e --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemFlintAndSteel.java @@ -0,0 +1,50 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public final class ItemFlintAndSteel extends Item { + public ItemFlintAndSteel(int var1) { + super(3); + this.maxStackSize = 1; + this.maxDamage = 64; + } + + public final boolean onItemUse(ItemStack var1, World var2, int var3, int var4, int var5, int var6) { + if(var6 == 0) { + --var4; + } + + if(var6 == 1) { + ++var4; + } + + if(var6 == 2) { + --var5; + } + + if(var6 == 3) { + ++var5; + } + + if(var6 == 4) { + --var3; + } + + if(var6 == 5) { + ++var3; + } + + if(var3 > 0 && var4 > 0 && var5 > 0 && var3 < var2.width - 1 && var4 < var2.height - 1 && var5 < var2.length - 1) { + var6 = var2.getBlockId(var3, var4, var5); + if(var6 == 0) { + var2.setBlockWithNotify(var3, var4, var5, Block.fire.blockID); + } + + var1.damageItem(1); + return true; + } else { + return false; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemFood.java b/src/teavm/java/net/minecraft/game/item/ItemFood.java new file mode 100644 index 0000000..aa295f1 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemFood.java @@ -0,0 +1,20 @@ +package net.minecraft.game.item; + +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.level.World; + +public class ItemFood extends Item { + private int healAmount; + + public ItemFood(int var1, int var2) { + super(var1); + this.healAmount = var2; + this.maxStackSize = 1; + } + + public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3) { + --var1.stackSize; + var3.heal(this.healAmount); + return var1; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemHoe.java b/src/teavm/java/net/minecraft/game/item/ItemHoe.java new file mode 100644 index 0000000..1915613 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemHoe.java @@ -0,0 +1,42 @@ +package net.minecraft.game.item; + +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.StepSound; +import net.minecraft.game.level.material.Material; + +public final class ItemHoe extends Item { + public ItemHoe(int var1, int var2) { + super(var1); + this.maxStackSize = 1; + this.maxDamage = 32 << var2; + } + + public final boolean onItemUse(ItemStack var1, World var2, int var3, int var4, int var5, int var6) { + if(var3 > 0 && var4 > 0 && var5 > 0 && var3 < var2.width - 1 && var4 < var2.height - 1 && var5 < var2.length - 1) { + var6 = var2.getBlockId(var3, var4, var5); + Material var7 = var2.getBlockMaterial(var3, var4 + 1, var5); + if((var7.isSolid() || var6 != Block.grass.blockID) && var6 != Block.dirt.blockID) { + return false; + } else { + Block var12 = Block.tilledField; + var2.setBlockWithNotify(var3, var4, var5, var12.blockID); + var1.damageItem(1); + if(var2.random.nextInt(8) == 0 && var6 == Block.grass.blockID) { + for(int var9 = 0; var9 <= 0; ++var9) { + float var10 = var2.random.nextFloat() * 0.7F + 0.15F; + float var13 = var2.random.nextFloat() * 0.7F + 0.15F; + EntityItem var11 = new EntityItem(var2, (float)var3 + var10, (float)var4 + 1.2F, (float)var5 + var13, new ItemStack(Item.seeds)); + var11.delayBeforeCanPickup = 10; + var2.spawnEntityInWorld(var11); + } + } + + return true; + } + } else { + return false; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemPainting.java b/src/teavm/java/net/minecraft/game/item/ItemPainting.java new file mode 100644 index 0000000..bb2ad72 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemPainting.java @@ -0,0 +1,42 @@ +package net.minecraft.game.item; + +import net.minecraft.game.entity.EntityPainting; +import net.minecraft.game.level.World; + +public final class ItemPainting extends Item { + public ItemPainting(int var1) { + super(65); + this.maxDamage = 64; + } + + public final boolean onItemUse(ItemStack var1, World var2, int var3, int var4, int var5, int var6) { + if(var6 == 0) { + return false; + } else if(var6 == 1) { + return false; + } else if(var3 > 0 && var4 > 0 && var5 > 0 && var3 < var2.width - 1 && var4 < var2.height - 1 && var5 < var2.length - 1) { + byte var7 = 0; + if(var6 == 4) { + var7 = 1; + } + + if(var6 == 3) { + var7 = 2; + } + + if(var6 == 5) { + var7 = 3; + } + + EntityPainting var8 = new EntityPainting(var2, var3, var4, var5, var7); + if(var8.onValidSurface()) { + var2.spawnEntityInWorld(var8); + --var1.stackSize; + } + + return true; + } else { + return false; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemPickaxe.java b/src/teavm/java/net/minecraft/game/item/ItemPickaxe.java new file mode 100644 index 0000000..d2d8ee8 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemPickaxe.java @@ -0,0 +1,18 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.material.Material; + +public final class ItemPickaxe extends ItemTool { + private static Block[] blocksEffectiveAgainst = new Block[]{Block.cobblestone, Block.stairDouble, Block.stairSingle, Block.stone, Block.cobblestoneMossy, Block.oreIron, Block.blockSteel, Block.oreCoal, Block.blockGold, Block.oreGold, Block.oreDiamond, Block.blockDiamond}; + private int harvestLevel; + + public ItemPickaxe(int var1, int var2) { + super(var1, 2, var2, blocksEffectiveAgainst); + this.harvestLevel = var2; + } + + public final boolean canHarvestBlock(Block var1) { + return var1 == Block.obsidian ? this.harvestLevel == 3 : (var1 != Block.blockDiamond && var1 != Block.oreDiamond ? (var1 != Block.blockGold && var1 != Block.oreGold ? (var1 != Block.blockSteel && var1 != Block.oreIron ? (var1.material == Material.rock ? true : var1.material == Material.iron) : this.harvestLevel > 0) : this.harvestLevel >= 2) : this.harvestLevel >= 2); + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemSeeds.java b/src/teavm/java/net/minecraft/game/item/ItemSeeds.java new file mode 100644 index 0000000..f4462a2 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemSeeds.java @@ -0,0 +1,30 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; + +public final class ItemSeeds extends Item { + private int blockType; + + public ItemSeeds(int var1, int var2) { + super(39); + this.blockType = var2; + } + + public final boolean onItemUse(ItemStack var1, World var2, int var3, int var4, int var5, int var6) { + if(var6 != 1) { + return false; + } else if(var3 > 0 && var4 > 0 && var5 > 0 && var3 < var2.width - 1 && var4 < var2.height - 1 && var5 < var2.length - 1) { + var6 = var2.getBlockId(var3, var4, var5); + if(var6 == Block.tilledField.blockID) { + var2.setBlockWithNotify(var3, var4 + 1, var5, this.blockType); + --var1.stackSize; + return true; + } else { + return false; + } + } else { + return false; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemSoup.java b/src/teavm/java/net/minecraft/game/item/ItemSoup.java new file mode 100644 index 0000000..63eb6d3 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemSoup.java @@ -0,0 +1,15 @@ +package net.minecraft.game.item; + +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.level.World; + +public final class ItemSoup extends ItemFood { + public ItemSoup(int var1, int var2) { + super(26, 10); + } + + public final ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3) { + super.onItemRightClick(var1, var2, var3); + return new ItemStack(Item.bowlEmpty); + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemSpade.java b/src/teavm/java/net/minecraft/game/item/ItemSpade.java new file mode 100644 index 0000000..a6aa423 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemSpade.java @@ -0,0 +1,11 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.block.Block; + +public final class ItemSpade extends ItemTool { + private static Block[] blocksEffectiveAgainst = new Block[]{Block.grass, Block.dirt, Block.sand, Block.gravel}; + + public ItemSpade(int var1, int var2) { + super(var1, 1, var2, blocksEffectiveAgainst); + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemStack.java b/src/teavm/java/net/minecraft/game/item/ItemStack.java new file mode 100644 index 0000000..44a10b1 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemStack.java @@ -0,0 +1,84 @@ +package net.minecraft.game.item; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.level.block.Block; + +public final class ItemStack { + public int stackSize; + public int animationsToGo; + public int itemID; + public int itemDamage; + + public ItemStack(Block var1) { + this((Block)var1, 1); + } + + public ItemStack(Block var1, int var2) { + this(var1.blockID, var2); + } + + public ItemStack(Item var1) { + this((Item)var1, 1); + } + + public ItemStack(Item var1, int var2) { + this(var1.shiftedIndex, var2); + } + + public ItemStack(int var1) { + this(var1, 1); + } + + public ItemStack(int var1, int var2) { + this.stackSize = 0; + this.itemID = var1; + this.stackSize = var2; + } + + public ItemStack(int var1, int var2, int var3) { + this.stackSize = 0; + this.itemID = var1; + this.stackSize = var2; + this.itemDamage = var3; + } + + public ItemStack(NBTTagCompound var1) { + this.stackSize = 0; + this.itemID = var1.getShort("id"); + this.stackSize = var1.getByte("Count"); + this.itemDamage = var1.getShort("Damage"); + } + + public final ItemStack splitStack(int var1) { + this.stackSize -= var1; + return new ItemStack(this.itemID, var1, this.itemDamage); + } + + public final Item getItem() { + return Item.itemsList[this.itemID]; + } + + public final NBTTagCompound writeToNBT(NBTTagCompound var1) { + var1.setShort("id", (short)this.itemID); + var1.setByte("Count", (byte)this.stackSize); + var1.setShort("Damage", (short)this.itemDamage); + return var1; + } + + public final int isItemStackDamageable() { + return Item.itemsList[this.itemID].getMaxDamage(); + } + + public final void damageItem(int var1) { + this.itemDamage += var1; + if(this.itemDamage > this.isItemStackDamageable()) { + --this.stackSize; + if(this.stackSize < 0) { + this.stackSize = 0; + } + + this.itemDamage = 0; + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemSword.java b/src/teavm/java/net/minecraft/game/item/ItemSword.java new file mode 100644 index 0000000..e27c4df --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemSword.java @@ -0,0 +1,30 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.block.Block; + +public final class ItemSword extends Item { + private int weaponDamage; + + public ItemSword(int var1, int var2) { + super(var1); + this.maxStackSize = 1; + this.maxDamage = 32 << var2; + this.weaponDamage = 4 + (var2 << 1); + } + + public final float getStrVsBlock(Block var1) { + return 1.5F; + } + + public final void hitEntity(ItemStack var1) { + var1.damageItem(1); + } + + public final void onBlockDestroyed(ItemStack var1) { + var1.damageItem(2); + } + + public final int getDamageVsEntity() { + return this.weaponDamage; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/ItemTool.java b/src/teavm/java/net/minecraft/game/item/ItemTool.java new file mode 100644 index 0000000..bff2064 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/ItemTool.java @@ -0,0 +1,40 @@ +package net.minecraft.game.item; + +import net.minecraft.game.level.block.Block; + +public class ItemTool extends Item { + private Block[] blocksEffectiveAgainst; + private float efficiencyOnProperMaterial = 4.0F; + private int damageVsEntity; + + public ItemTool(int var1, int var2, int var3, Block[] var4) { + super(var1); + this.blocksEffectiveAgainst = var4; + this.maxStackSize = 1; + this.maxDamage = 32 << var3; + this.efficiencyOnProperMaterial = (float)(var3 + 1 << 1); + this.damageVsEntity = var2 + var3; + } + + public final float getStrVsBlock(Block var1) { + for(int var2 = 0; var2 < this.blocksEffectiveAgainst.length; ++var2) { + if(this.blocksEffectiveAgainst[var2] == var1) { + return this.efficiencyOnProperMaterial; + } + } + + return 1.0F; + } + + public final void hitEntity(ItemStack var1) { + var1.damageItem(2); + } + + public final void onBlockDestroyed(ItemStack var1) { + var1.damageItem(1); + } + + public final int getDamageVsEntity() { + return this.damageVsEntity; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/CraftingManager.java b/src/teavm/java/net/minecraft/game/item/recipe/CraftingManager.java new file mode 100644 index 0000000..fd04432 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/CraftingManager.java @@ -0,0 +1,107 @@ +package net.minecraft.game.item.recipe; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.block.Block; + +public final class CraftingManager { + private static final CraftingManager instance = new CraftingManager(); + private List recipes = new ArrayList(); + + public static final CraftingManager getInstance() { + return instance; + } + + private CraftingManager() { + (new RecipesTools()).addRecipes(this); + (new RecipesWeapons()).addRecipes(this); + (new RecipesIngots()).addRecipes(this); + new RecipesFood(); + this.addRecipe(new ItemStack(Item.bowlSoup), new Object[]{"Y", "X", "#", Character.valueOf('X'), Block.mushroomBrown, Character.valueOf('Y'), Block.mushroomRed, Character.valueOf('#'), Item.bowlEmpty}); + this.addRecipe(new ItemStack(Item.bowlSoup), new Object[]{"Y", "X", "#", Character.valueOf('X'), Block.mushroomRed, Character.valueOf('Y'), Block.mushroomBrown, Character.valueOf('#'), Item.bowlEmpty}); + new RecipesCrafting(); + this.addRecipe(new ItemStack(Block.crate), new Object[]{"###", "# #", "###", Character.valueOf('#'), Block.planks}); + this.addRecipe(new ItemStack(Block.stoneOvenIdle), new Object[]{"###", "# #", "###", Character.valueOf('#'), Block.cobblestone}); + this.addRecipe(new ItemStack(Block.workbench), new Object[]{"##", "##", Character.valueOf('#'), Block.planks}); + (new RecipesArmor()).addRecipes(this); + this.addRecipe(new ItemStack(Block.clothGray, 1), new Object[]{"###", "###", "###", Character.valueOf('#'), Item.silk}); + this.addRecipe(new ItemStack(Block.tnt, 1), new Object[]{"X#X", "#X#", "X#X", Character.valueOf('X'), Item.gunpowder, Character.valueOf('#'), Block.sand}); + this.addRecipe(new ItemStack(Block.stairSingle, 3), new Object[]{"###", Character.valueOf('#'), Block.cobblestone}); + this.addRecipe(new ItemStack(Block.planks, 4), new Object[]{"#", Character.valueOf('#'), Block.wood}); + this.addRecipe(new ItemStack(Item.stick, 4), new Object[]{"#", "#", Character.valueOf('#'), Block.planks}); + this.addRecipe(new ItemStack(Block.torch, 4), new Object[]{"X", "#", Character.valueOf('X'), Item.coal, Character.valueOf('#'), Item.stick}); + this.addRecipe(new ItemStack(Item.bowlEmpty, 4), new Object[]{"# #", " # ", Character.valueOf('#'), Block.planks}); + this.addRecipe(new ItemStack(Item.striker, 1), new Object[]{"A ", " B", Character.valueOf('A'), Item.ingotIron, Character.valueOf('B'), Item.flint}); + this.addRecipe(new ItemStack(Item.bread, 1), new Object[]{"###", Character.valueOf('#'), Item.wheat}); + this.addRecipe(new ItemStack(Item.painting, 1), new Object[]{"###", "#X#", "###", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Block.clothGray}); + Collections.sort(this.recipes, new RecipeSorter(this)); + System.out.println(this.recipes.size() + " recipes"); + } + + final void addRecipe(ItemStack var1, Object... var2) { + String var3 = ""; + int var4 = 0; + int var5 = 0; + int var6 = 0; + if(var2[0] instanceof String[]) { + ++var4; + String[] var11 = (String[])var2[0]; + + for(int var8 = 0; var8 < var11.length; ++var8) { + String var9 = var11[var8]; + ++var6; + var5 = var9.length(); + var3 = var3 + var9; + } + } else { + while(var2[var4] instanceof String) { + String var7 = (String)var2[var4++]; + ++var6; + var5 = var7.length(); + var3 = var3 + var7; + } + } + + HashMap var12; + int var15; + for(var12 = new HashMap(); var4 < var2.length; var4 += 2) { + Character var13 = (Character)var2[var4]; + var15 = 0; + if(var2[var4 + 1] instanceof Item) { + var15 = ((Item)var2[var4 + 1]).shiftedIndex; + } else if(var2[var4 + 1] instanceof Block) { + var15 = ((Block)var2[var4 + 1]).blockID; + } + + var12.put(var13, Integer.valueOf(var15)); + } + + int[] var14 = new int[var5 * var6]; + + for(var15 = 0; var15 < var5 * var6; ++var15) { + char var10 = var3.charAt(var15); + if(var12.containsKey(Character.valueOf(var10))) { + var14[var15] = ((Integer)var12.get(Character.valueOf(var10))).intValue(); + } else { + var14[var15] = -1; + } + } + + this.recipes.add(new CraftingRecipe(var5, var6, var14, var1)); + } + + public final ItemStack findMatchingRecipe(int[] var1) { + for(int var2 = 0; var2 < this.recipes.size(); ++var2) { + CraftingRecipe var3 = (CraftingRecipe)this.recipes.get(var2); + if(var3.matchRecipe(var1)) { + return var3.createResult(); + } + } + + return null; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/CraftingRecipe.java b/src/teavm/java/net/minecraft/game/item/recipe/CraftingRecipe.java new file mode 100644 index 0000000..1d4c58b --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/CraftingRecipe.java @@ -0,0 +1,64 @@ +package net.minecraft.game.item.recipe; + +import net.minecraft.game.item.ItemStack; + +public final class CraftingRecipe { + private int width; + private int height; + private int[] ingredientMap; + private ItemStack recipeOutput; + + public CraftingRecipe(int var1, int var2, int[] var3, ItemStack var4) { + this.width = var1; + this.height = var2; + this.ingredientMap = var3; + this.recipeOutput = var4; + } + + public final boolean matchRecipe(int[] var1) { + for(int var2 = 0; var2 <= 3 - this.width; ++var2) { + for(int var3 = 0; var3 <= 3 - this.height; ++var3) { + if(this.matches(var1, var2, var3, true)) { + return true; + } + + if(this.matches(var1, var2, var3, false)) { + return true; + } + } + } + + return false; + } + + private boolean matches(int[] var1, int var2, int var3, boolean var4) { + for(int var5 = 0; var5 < 3; ++var5) { + for(int var6 = 0; var6 < 3; ++var6) { + int var7 = var5 - var2; + int var8 = var6 - var3; + int var9 = -1; + if(var7 >= 0 && var8 >= 0 && var7 < this.width && var8 < this.height) { + if(var4) { + var9 = this.ingredientMap[this.width - var7 - 1 + var8 * this.width]; + } else { + var9 = this.ingredientMap[var7 + var8 * this.width]; + } + } + + if(var1[var5 + var6 * 3] != var9) { + return false; + } + } + } + + return true; + } + + public final ItemStack createResult() { + return new ItemStack(this.recipeOutput.itemID, this.recipeOutput.stackSize); + } + + public final int b() { + return this.width * this.height; + } +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/RecipeSorter.java b/src/teavm/java/net/minecraft/game/item/recipe/RecipeSorter.java new file mode 100644 index 0000000..97fa3a0 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/RecipeSorter.java @@ -0,0 +1,15 @@ +package net.minecraft.game.item.recipe; + +import java.util.Comparator; + +final class RecipeSorter implements Comparator { + RecipeSorter(CraftingManager var1) { + } + + public final int compare(Object var1, Object var2) { + CraftingRecipe var10000 = (CraftingRecipe)var1; + CraftingRecipe var4 = (CraftingRecipe)var2; + CraftingRecipe var3 = var10000; + return var4.b() < var3.b() ? -1 : (var4.b() > var3.b() ? 1 : 0); + } +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/RecipesArmor.java b/src/teavm/java/net/minecraft/game/item/recipe/RecipesArmor.java new file mode 100644 index 0000000..d5c8bb5 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/RecipesArmor.java @@ -0,0 +1,22 @@ +package net.minecraft.game.item.recipe; + +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.block.Block; + +public final class RecipesArmor { + private String[][] recipePatterns = new String[][]{{"XXX", "X X"}, {"X X", "XXX", "XXX"}, {"XXX", "X X", "X X"}, {"X X", "X X"}}; + private Object[][] recipeItems = new Object[][]{{Block.clothGray, Block.fire, Item.ingotIron, Item.diamond, Item.ingotGold}, {Item.helmetLeather, Item.helmetChain, Item.helmetSteel, Item.helmetDiamond, Item.helmetGold}, {Item.plateLeather, Item.plateChain, Item.plateSteel, Item.plateDiamond, Item.plateGold}, {Item.legsLeather, Item.legsChain, Item.legsSteel, Item.legsDiamond, Item.legsGold}, {Item.bootsLeather, Item.bootsChain, Item.bootsSteel, Item.bootsDiamond, Item.bootsGold}}; + + public final void addRecipes(CraftingManager var1) { + for(int var2 = 0; var2 < this.recipeItems[0].length; ++var2) { + Object var3 = this.recipeItems[0][var2]; + + for(int var4 = 0; var4 < this.recipeItems.length - 1; ++var4) { + Item var5 = (Item)this.recipeItems[var4 + 1][var2]; + var1.addRecipe(new ItemStack(var5), new Object[]{this.recipePatterns[var4], Character.valueOf('X'), var3}); + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/RecipesCrafting.java b/src/teavm/java/net/minecraft/game/item/recipe/RecipesCrafting.java new file mode 100644 index 0000000..bb069b3 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/RecipesCrafting.java @@ -0,0 +1,4 @@ +package net.minecraft.game.item.recipe; + +public final class RecipesCrafting { +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/RecipesFood.java b/src/teavm/java/net/minecraft/game/item/recipe/RecipesFood.java new file mode 100644 index 0000000..16f2e61 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/RecipesFood.java @@ -0,0 +1,4 @@ +package net.minecraft.game.item.recipe; + +public final class RecipesFood { +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/RecipesIngots.java b/src/teavm/java/net/minecraft/game/item/recipe/RecipesIngots.java new file mode 100644 index 0000000..6e728a6 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/RecipesIngots.java @@ -0,0 +1,19 @@ +package net.minecraft.game.item.recipe; + +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.block.Block; + +public final class RecipesIngots { + private Object[][] recipeItems = new Object[][]{{Block.blockGold, Item.ingotGold}, {Block.blockSteel, Item.ingotIron}, {Block.blockDiamond, Item.diamond}}; + + public final void addRecipes(CraftingManager var1) { + for(int var2 = 0; var2 < this.recipeItems.length; ++var2) { + Block var3 = (Block)this.recipeItems[var2][0]; + Item var4 = (Item)this.recipeItems[var2][1]; + var1.addRecipe(new ItemStack(var3), new Object[]{"###", "###", "###", Character.valueOf('#'), var4}); + var1.addRecipe(new ItemStack(var4, 9), new Object[]{"#", Character.valueOf('#'), var3}); + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/RecipesTools.java b/src/teavm/java/net/minecraft/game/item/recipe/RecipesTools.java new file mode 100644 index 0000000..6e4ccf2 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/RecipesTools.java @@ -0,0 +1,22 @@ +package net.minecraft.game.item.recipe; + +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.block.Block; + +public final class RecipesTools { + private String[][] recipePatterns = new String[][]{{"XXX", " # ", " # "}, {"X", "#", "#"}, {"XX", "X#", " #"}, {"XX", " #", " #"}}; + private Object[][] recipeItems = new Object[][]{{Block.planks, Block.cobblestone, Item.ingotIron, Item.diamond, Item.ingotGold}, {Item.pickaxeWood, Item.pickaxeStone, Item.pickaxeSteel, Item.pickaxeDiamond, Item.pickaxeGold}, {Item.shovelWood, Item.shovelStone, Item.shovel, Item.shovelDiamond, Item.shovelGold}, {Item.axeWood, Item.axeStone, Item.axeSteel, Item.axeDiamond, Item.axeGold}, {Item.hoeWood, Item.hoeStone, Item.hoeSteel, Item.hoeDiamond, Item.hoeGold}}; + + public final void addRecipes(CraftingManager var1) { + for(int var2 = 0; var2 < this.recipeItems[0].length; ++var2) { + Object var3 = this.recipeItems[0][var2]; + + for(int var4 = 0; var4 < this.recipeItems.length - 1; ++var4) { + Item var5 = (Item)this.recipeItems[var4 + 1][var2]; + var1.addRecipe(new ItemStack(var5), new Object[]{this.recipePatterns[var4], Character.valueOf('#'), Item.stick, Character.valueOf('X'), var3}); + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/item/recipe/RecipesWeapons.java b/src/teavm/java/net/minecraft/game/item/recipe/RecipesWeapons.java new file mode 100644 index 0000000..088ee17 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/item/recipe/RecipesWeapons.java @@ -0,0 +1,24 @@ +package net.minecraft.game.item.recipe; + +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.block.Block; + +public final class RecipesWeapons { + private String[][] recipePatterns = new String[][]{{"X", "X", "#"}}; + private Object[][] recipeItems = new Object[][]{{Block.planks, Block.cobblestone, Item.ingotIron, Item.diamond, Item.ingotGold}, {Item.swordWood, Item.swordStone, Item.swordSteel, Item.swordDiamond, Item.swordGold}}; + + public final void addRecipes(CraftingManager var1) { + for(int var2 = 0; var2 < this.recipeItems[0].length; ++var2) { + Object var3 = this.recipeItems[0][var2]; + + for(int var4 = 0; var4 < this.recipeItems.length - 1; ++var4) { + Item var5 = (Item)this.recipeItems[var4 + 1][var2]; + var1.addRecipe(new ItemStack(var5), new Object[]{this.recipePatterns[var4], Character.valueOf('#'), Item.stick, Character.valueOf('X'), var3}); + } + } + + var1.addRecipe(new ItemStack(Item.bow, 1), new Object[]{" #X", "# X", " #X", Character.valueOf('X'), Item.silk, Character.valueOf('#'), Item.stick}); + var1.addRecipe(new ItemStack(Item.arrow, 4), new Object[]{"X", "#", "Y", Character.valueOf('Y'), Item.feather, Character.valueOf('X'), Item.ingotIron, Character.valueOf('#'), Item.stick}); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/EntityMap.java b/src/teavm/java/net/minecraft/game/level/EntityMap.java new file mode 100644 index 0000000..502d0d6 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/EntityMap.java @@ -0,0 +1,126 @@ +package net.minecraft.game.level; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.physics.AxisAlignedBB; + +public final class EntityMap { + public int width; + public int depth; + public int height; + private EntityMapSlot slot = new EntityMapSlot(this); + private EntityMapSlot slot2 = new EntityMapSlot(this); + public List[] entityGrid; + public List entities = new ArrayList(); + private List entitiesExcludingEntity = new ArrayList(); + + public EntityMap(int var1, int var2, int var3) { + this.width = var1 / 8; + this.depth = var2 / 8; + this.height = var3 / 8; + if(this.width == 0) { + this.width = 1; + } + + if(this.depth == 0) { + this.depth = 1; + } + + if(this.height == 0) { + this.height = 1; + } + + this.entityGrid = new ArrayList[this.width * this.depth * this.height]; + + for(var1 = 0; var1 < this.width; ++var1) { + for(var2 = 0; var2 < this.depth; ++var2) { + for(var3 = 0; var3 < this.height; ++var3) { + this.entityGrid[(var3 * this.depth + var2) * this.width + var1] = new ArrayList(); + } + } + } + + } + + public final void insert(Entity var1) { + this.entities.add(var1); + this.slot.init(var1.posX, var1.posY, var1.posZ).add(var1); + var1.lastTickPosX = var1.posX; + var1.lastTickPosY = var1.posY; + var1.lastTickPosZ = var1.posZ; + } + + public final void remove(Entity var1) { + this.slot.init(var1.lastTickPosX, var1.lastTickPosY, var1.lastTickPosZ).remove(var1); + this.slot.init(var1.posX, var1.posY, var1.posZ).remove(var1); + this.entities.remove(var1); + } + + public final List getEntities(Entity var1, float var2, float var3, float var4, float var5, float var6, float var7) { + this.entitiesExcludingEntity.clear(); + return this.getEntities(var1, var2, var3, var4, var5, var6, var7, this.entitiesExcludingEntity); + } + + private List getEntities(Entity var1, float var2, float var3, float var4, float var5, float var6, float var7, List var8) { + EntityMapSlot var9 = this.slot.init(var2, var3, var4); + EntityMapSlot var10 = this.slot2.init(var5, var6, var7); + + for(int var11 = EntityMapSlot.a(var9) - 1; var11 <= EntityMapSlot.a(var10) + 1; ++var11) { + for(int var12 = EntityMapSlot.b(var9) - 1; var12 <= EntityMapSlot.b(var10) + 1; ++var12) { + for(int var13 = EntityMapSlot.c(var9) - 1; var13 <= EntityMapSlot.c(var10) + 1; ++var13) { + if(var11 >= 0 && var12 >= 0 && var13 >= 0 && var11 < this.width && var12 < this.depth && var13 < this.height) { + List var14 = this.entityGrid[(var13 * this.depth + var12) * this.width + var11]; + + for(int var15 = 0; var15 < var14.size(); ++var15) { + Entity var16 = (Entity)var14.get(var15); + if(var16 != var1) { + AxisAlignedBB var17 = var16.boundingBox; + if(var5 > var17.minX && var2 < var17.maxX ? (var6 > var17.minY && var3 < var17.maxY ? var7 > var17.minZ && var4 < var17.maxZ : false) : false) { + var8.add(var16); + } + } + } + } + } + } + } + + return var8; + } + + public final List getEntitiesWithinAABB(Entity var1, AxisAlignedBB var2) { + this.entitiesExcludingEntity.clear(); + return var2 == null ? this.entitiesExcludingEntity : this.getEntities(var1, var2.minX, var2.minY, var2.minZ, var2.maxX, var2.maxY, var2.maxZ, this.entitiesExcludingEntity); + } + + public final void updateEntities() { + for(int var1 = 0; var1 < this.entities.size(); ++var1) { + Entity var2 = (Entity)this.entities.get(var1); + var2.lastTickPosX = var2.posX; + var2.lastTickPosY = var2.posY; + var2.lastTickPosZ = var2.posZ; + var2.onEntityUpdate(); + if(var2.isDead) { + this.entities.remove(var1--); + this.slot.init(var2.lastTickPosX, var2.lastTickPosY, var2.lastTickPosZ).remove(var2); + } else { + int var3 = (int)(var2.lastTickPosX / 8.0F); + int var4 = (int)(var2.lastTickPosY / 8.0F); + int var5 = (int)(var2.lastTickPosZ / 8.0F); + int var6 = (int)(var2.posX / 8.0F); + int var7 = (int)(var2.posY / 8.0F); + int var8 = (int)(var2.posZ / 8.0F); + if(var3 != var6 || var4 != var7 || var5 != var8) { + EntityMapSlot var11 = this.slot.init(var2.lastTickPosX, var2.lastTickPosY, var2.lastTickPosZ); + EntityMapSlot var9 = this.slot2.init(var2.posX, var2.posY, var2.posZ); + if(!var11.equals(var9)) { + var11.remove(var2); + var9.add(var2); + } + } + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/EntityMapSlot.java b/src/teavm/java/net/minecraft/game/level/EntityMapSlot.java new file mode 100644 index 0000000..3ef7cdb --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/EntityMapSlot.java @@ -0,0 +1,75 @@ +package net.minecraft.game.level; + +import net.minecraft.game.entity.Entity; + +final class EntityMapSlot { + private int xSlot; + private int ySlot; + private int zSlot; + private EntityMap entityMap; + + private EntityMapSlot(EntityMap var1, byte var2) { + this.entityMap = var1; + } + + public final EntityMapSlot init(float var1, float var2, float var3) { + this.xSlot = (int)(var1 / 8.0F); + this.ySlot = (int)(var2 / 8.0F); + this.zSlot = (int)(var3 / 8.0F); + if(this.xSlot < 0) { + this.xSlot = 0; + } + + if(this.ySlot < 0) { + this.ySlot = 0; + } + + if(this.zSlot < 0) { + this.zSlot = 0; + } + + if(this.xSlot >= this.entityMap.width) { + this.xSlot = this.entityMap.width - 1; + } + + if(this.ySlot >= this.entityMap.depth) { + this.ySlot = this.entityMap.depth - 1; + } + + if(this.zSlot >= this.entityMap.height) { + this.zSlot = this.entityMap.height - 1; + } + + return this; + } + + public final void add(Entity var1) { + if(this.xSlot >= 0 && this.ySlot >= 0 && this.zSlot >= 0) { + this.entityMap.entityGrid[(this.zSlot * this.entityMap.depth + this.ySlot) * this.entityMap.width + this.xSlot].add(var1); + } + + } + + public final void remove(Entity var1) { + if(this.xSlot >= 0 && this.ySlot >= 0 && this.zSlot >= 0) { + this.entityMap.entityGrid[(this.zSlot * this.entityMap.depth + this.ySlot) * this.entityMap.width + this.xSlot].remove(var1); + } + + } + + EntityMapSlot(EntityMap var1) { + this(var1, (byte)0); + } + + static int a(EntityMapSlot var0) { + return var0.xSlot; + } + + static int b(EntityMapSlot var0) { + return var0.ySlot; + } + + static int c(EntityMapSlot var0) { + return var0.zSlot; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/IWorldAccess.java b/src/teavm/java/net/minecraft/game/level/IWorldAccess.java new file mode 100644 index 0000000..445d5c3 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/IWorldAccess.java @@ -0,0 +1,19 @@ +package net.minecraft.game.level; + +import net.minecraft.game.entity.Entity; + +public interface IWorldAccess { + void markBlockAndNeighborsNeedsUpdate(int var1, int var2, int var3); + + void markBlockRangeNeedsUpdate(int var1, int var2, int var3, int var4, int var5, int var6); + + void loadRenderers(); + + void spawnParticle(String var1, float var2, float var3, float var4, float var5, float var6, float var7); + + void obtainEntitySkin(Entity var1); + + void releaseEntitySkin(Entity var1); + + void updateAllRenderers(); +} diff --git a/src/teavm/java/net/minecraft/game/level/LevelLoader.java b/src/teavm/java/net/minecraft/game/level/LevelLoader.java new file mode 100644 index 0000000..9774d96 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/LevelLoader.java @@ -0,0 +1,221 @@ +package net.minecraft.game.level; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.zip.GZIPOutputStream; + +import net.PeytonPlayz585.nbt.NBTBase; +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.PeytonPlayz585.nbt.NBTTagList; +import net.PeytonPlayz585.nbt.NBTTagShort; +import net.minecraft.client.LoadingScreenRenderer; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityPainting; +import net.minecraft.game.entity.animal.EntityPig; +import net.minecraft.game.entity.animal.EntitySheep; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.entity.monster.EntityCreeper; +import net.minecraft.game.entity.monster.EntityGiantZombie; +import net.minecraft.game.entity.monster.EntitySkeleton; +import net.minecraft.game.entity.monster.EntitySpider; +import net.minecraft.game.entity.monster.EntityZombie; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.tileentity.TileEntity; +import net.minecraft.game.level.block.tileentity.TileEntityChest; +import net.minecraft.game.level.block.tileentity.TileEntityFurnace; +import util.IProgressUpdate; + +public abstract class LevelLoader { + private IProgressUpdate guiLoading; + + public LevelLoader(IProgressUpdate var1) { + this.guiLoading = var1; + } + + public final World load(InputStream var1) throws IOException { + if(this.guiLoading != null) { + this.guiLoading.displayProgressMessage("Loading level"); + } + + if(this.guiLoading != null) { + this.guiLoading.displayLoadingString("Reading.."); + } + + NBTTagCompound var13 = LoadingScreenRenderer.writeLevelTags(var1); + NBTTagCompound var2 = var13.getCompoundTag("About"); + NBTTagCompound var3 = var13.getCompoundTag("Map"); + NBTTagCompound var4 = var13.getCompoundTag("Environment"); + NBTTagList var5 = var13.getTagList("Entities"); + short var6 = var3.getShort("Width"); + short var7 = var3.getShort("Length"); + short var8 = var3.getShort("Height"); + World var9 = new World(); + if(this.guiLoading != null) { + this.guiLoading.displayLoadingString("Preparing level.."); + } + + NBTTagList var10 = var3.getTagList("Spawn"); + var9.xSpawn = ((NBTTagShort)var10.tagAt(0)).shortValue; + var9.ySpawn = ((NBTTagShort)var10.tagAt(1)).shortValue; + var9.zSpawn = ((NBTTagShort)var10.tagAt(2)).shortValue; + var9.authorName = var2.getString("Author"); + var9.name = var2.getString("Name"); + var9.createTime = var2.getLong("CreatedOn"); + var9.cloudColor = var4.getInteger("CloudColor"); + var9.skyColor = var4.getInteger("SkyColor"); + var9.fogColor = var4.getInteger("FogColor"); + var9.skyBrightness = var4.getByte("SkyBrightness"); + if(var9.skyBrightness < 0) { + var9.skyBrightness = 0; + } + + if(var9.skyBrightness > 16) { + var9.skyBrightness = var9.skyBrightness * 15 / 100; + } + + var9.cloudHeight = var4.getShort("CloudHeight"); + var9.groundLevel = var4.getShort("SurroundingGroundHeight"); + var9.waterLevel = var4.getShort("SurroundingWaterHeight"); + var9.defaultFluid = var4.getByte("SurroundingWaterType"); + var9.worldTime = var4.getShort("TimeOfDay"); + var9.skylightSubtracted = var9.getSkyBrightness(); + var9.generate(var6, var8, var7, var3.getByteArray("Blocks"), var3.getByteArray("Data")); + if(this.guiLoading != null) { + this.guiLoading.displayLoadingString("Preparing entities.."); + } + + for(int var16 = 0; var16 < var5.tagCount(); ++var16) { + try { + var3 = (NBTTagCompound)var5.tagAt(var16); + String var19 = var3.getString("id"); + Entity var21 = this.loadEntity(var9, var19); + if(var21 != null) { + var21.readFromNBT(var3); + var9.spawnEntityInWorld(var21); + } else { + System.out.println("Skipping unknown entity id \"" + var19 + "\""); + } + } catch (Exception var12) { + System.out.println("Error reading entity"); + var12.printStackTrace(); + } + } + + NBTTagList var17 = var13.getTagList("TileEntities"); + + for(int var18 = 0; var18 < var17.tagCount(); ++var18) { + try { + var4 = (NBTTagCompound)var17.tagAt(var18); + int var22 = var4.getInteger("Pos"); + String var14 = var4.getString("id"); + Object var20 = var14.equals("Chest") ? new TileEntityChest() : (var14.equals("Furnace") ? new TileEntityFurnace() : null); + if(var20 != null) { + int var15 = var22 % 1024; + int var23 = (var22 >> 10) % 1024; + var22 = (var22 >> 20) % 1024; + ((TileEntity)var20).readFromNBT(var4); + var9.setBlockTileEntity(var15, var23, var22, (TileEntity)var20); + } else { + System.out.println("Skipping unknown tile entity id \"" + var14 + "\""); + } + } catch (Exception var11) { + System.out.println("Error reading tileentity"); + var11.printStackTrace(); + } + } + + return var9; + } + + protected Entity loadEntity(World var1, String var2) { + return (Entity)(var2.equals("Pig") ? new EntityPig(var1) : (var2.equals("Sheep") ? new EntitySheep(var1) : (var2.equals("Creeper") ? new EntityCreeper(var1) : (var2.equals("Skeleton") ? new EntitySkeleton(var1) : (var2.equals("Spider") ? new EntitySpider(var1) : (var2.equals("Zombie") ? new EntityZombie(var1) : (var2.equals("Giant") ? new EntityGiantZombie(var1) : (var2.equals("Item") ? new EntityItem(var1) : (var2.equals("Painting") ? new EntityPainting(var1) : null))))))))); + } + + public final void save(World var1, OutputStream var2) throws IOException { + if(this.guiLoading != null) { + this.guiLoading.displayProgressMessage("Saving level"); + } + + if(this.guiLoading != null) { + this.guiLoading.displayLoadingString("Preparing level.."); + } + + NBTTagCompound var3 = new NBTTagCompound(); + var3.setInteger("CloudColor", var1.cloudColor); + var3.setInteger("SkyColor", var1.skyColor); + var3.setInteger("FogColor", var1.fogColor); + var3.setByte("SkyBrightness", (byte)var1.skyBrightness); + var3.setShort("CloudHeight", (short)var1.cloudHeight); + var3.setShort("SurroundingGroundHeight", (short)var1.groundLevel); + var3.setShort("SurroundingWaterHeight", (short)var1.waterLevel); + var3.setByte("SurroundingGroundType", (byte)Block.grass.blockID); + var3.setByte("SurroundingWaterType", (byte)var1.defaultFluid); + var3.setShort("TimeOfDay", (short)var1.worldTime); + NBTTagCompound var4 = new NBTTagCompound(); + var4.setShort("Width", (short)var1.width); + var4.setShort("Length", (short)var1.length); + var4.setShort("Height", (short)var1.height); + var4.setByteArray("Blocks", var1.blocks); + var4.setByteArray("Data", var1.data); + NBTTagList var5 = new NBTTagList(); + var5.setTag(new NBTTagShort((short)var1.xSpawn)); + var5.setTag(new NBTTagShort((short)var1.ySpawn)); + var5.setTag(new NBTTagShort((short)var1.zSpawn)); + var4.setTag("Spawn", var5); + NBTTagCompound var15 = new NBTTagCompound(); + var15.setString("Author", var1.authorName); + var15.setString("Name", var1.name); + var15.setLong("CreatedOn", var1.createTime); + if(this.guiLoading != null) { + this.guiLoading.displayLoadingString("Preparing entities.."); + } + + NBTTagList var6 = new NBTTagList(); + Iterator var7 = var1.entityMap.entities.iterator(); + + while(var7.hasNext()) { + Entity var8 = (Entity)var7.next(); + NBTTagCompound var9 = new NBTTagCompound(); + var8.writeToNBT(var9); + if(!var9.emptyNBTMap()) { + var6.setTag(var9); + } + } + + NBTTagList var16 = new NBTTagList(); + Iterator var17 = var1.map.keySet().iterator(); + + while(var17.hasNext()) { + int var19 = ((Integer)var17.next()).intValue(); + NBTTagCompound var10 = new NBTTagCompound(); + var10.setInteger("Pos", var19); + TileEntity var20 = (TileEntity)var1.map.get(Integer.valueOf(var19)); + var20.writeToNBT(var10); + var16.setTag(var10); + } + + NBTTagCompound var18 = new NBTTagCompound(); + var18.setKey("MinecraftLevel"); + var18.setCompoundTag("About", var15); + var18.setCompoundTag("Map", var4); + var18.setCompoundTag("Environment", var3); + var18.setTag("Entities", var6); + var18.setTag("TileEntities", var16); + if(this.guiLoading != null) { + this.guiLoading.displayLoadingString("Writing.."); + } + + NBTTagCompound var13 = var18; + DataOutputStream var14 = new DataOutputStream(new GZIPOutputStream(var2)); + + try { + NBTBase.writeTag(var13, var14); + } finally { + var14.close(); + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/Light.java b/src/teavm/java/net/minecraft/game/level/Light.java new file mode 100644 index 0000000..7e554c0 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/Light.java @@ -0,0 +1,406 @@ +package net.minecraft.game.level; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.game.level.block.Block; + +public final class Light { + private int lightingUpdateCounter = 0; + private List lightingUpdateList = new ArrayList(); + private World worldObj; + private int worldWidth; + private int worldLength; + private int worldHeight; + private byte[] blocks; + private byte[] data; + private int[] heightMap; + private List skyLightList = new ArrayList(); + private List blockLightList = new ArrayList(); + private List lightingUpdateList1 = new ArrayList(); + private List lightingUpdateList2 = new ArrayList(); + private int[] lightingUpdateList3 = this.getLightingUpdates(); + private byte[] chunks; + private MetadataChunkBlock metadataChunkBlock = null; + private int lightValue = 0; + private int skylightSubtracted; + + public Light(World var1) { + this.worldObj = var1; + this.worldWidth = var1.width; + this.worldLength = var1.length; + this.worldHeight = var1.height; + this.chunks = new byte[var1.blocks.length / 8]; + this.blocks = var1.blocks; + this.data = var1.data; + this.heightMap = var1.heightMap; + } + + private int[] getLightingUpdates() { + return this.lightingUpdateList2.size() > 0 ? (int[])this.lightingUpdateList2.remove(this.lightingUpdateList2.size() - 1) : new int[-Short.MIN_VALUE]; + } + + public final void updateSkylight(int var1, int var2, int var3, int var4) { + this.lightingUpdateList1.add(new MetadataChunkBlock(this, var1, var2, 0, var3, var4, 1)); + } + + public final void updateDaylightCycle(int var1) { + if(var1 > 15) { + var1 = 15; + } + + if(var1 < 0) { + var1 = 0; + } + + this.skylightSubtracted = var1 - this.worldObj.skylightSubtracted; + if(this.skylightSubtracted != 0) { + this.lightValue = this.worldObj.skylightSubtracted; + this.worldObj.skylightSubtracted = var1; + + while(this.metadataChunkBlock != null) { + this.updateLight(64); + } + + this.metadataChunkBlock = new MetadataChunkBlock(this, 0, 0, 0, this.worldObj.width, this.worldObj.height, this.worldObj.length); + } + } + + private void updateLight(int var1) { + int var2 = this.metadataChunkBlock.x; + int var3 = this.metadataChunkBlock.maxX; + int var4 = this.metadataChunkBlock.z; + int var5 = this.metadataChunkBlock.maxZ; + + int var6; + int var7; + for(var2 = var2; var2 < var3; ++var2) { + if(var1-- <= 0 && var2 != var3 - 1) { + this.metadataChunkBlock.x = var2; + return; + } + + for(var6 = var4; var6 < var5; ++var6) { + for(var7 = this.heightMap[var2 + var6 * this.worldWidth] - 1; var7 > 0 && Block.lightOpacity[this.blocks[(var7 * this.worldLength + var6) * this.worldWidth + var2]] < 100; --var7) { + } + + ++var7; + + for(; var7 < this.worldHeight; ++var7) { + int var8 = (var7 * this.worldLength + var6) * this.worldWidth + var2; + if(Block.lightValue[this.blocks[var8]] == 0) { + int var9 = this.data[var8] & 15; + if(var9 <= this.lightValue) { + if(this.skylightSubtracted < 0 && var9 > 0) { + --this.data[var8]; + } else if(this.skylightSubtracted > 0 && var9 < 15) { + ++this.data[var8]; + } + } + } + } + } + } + + for(var6 = 0; var6 < this.worldWidth; var6 += 32) { + for(var7 = 0; var7 < this.worldLength; var7 += 32) { + this.blockLightList.add(new MetadataChunkBlock(this, var6, 0, var7, var6 + 32, this.worldHeight, var7 + 32)); + this.skyLightList.add(new MetadataChunkBlock(this, var6, 0, var7, var6 + 32, this.worldHeight, var7 + 32)); + } + } + + for(var6 = 0; var6 < this.worldObj.worldAccesses.size(); ++var6) { + IWorldAccess var10 = (IWorldAccess)this.worldObj.worldAccesses.get(var6); + var10.updateAllRenderers(); + } + + this.metadataChunkBlock = null; + } + + public final void updateBlockLight(int var1, int var2, int var3, int var4, int var5, int var6) { + this.blockLightList.add(new MetadataChunkBlock(this, var1, var2, var3, var4, var5, var6)); + } + + private void updateLists(int var1, int var2, int var3, int var4, int var5, int var6) { + for(var2 = var2; var2 < var5; ++var2) { + for(int var7 = var3; var7 < var6; ++var7) { + for(int var8 = var1; var8 < var4; ++var8) { + int var9 = var8 + var2 * this.worldWidth + var7 * this.worldWidth * this.worldHeight; + if((this.chunks[var9 >> 3] & 1 << (var9 & 7)) == 0) { + this.chunks[var9 >> 3] = (byte)(this.chunks[var9 >> 3] | 1 << (var9 & 7)); + this.lightingUpdateList3[this.lightingUpdateCounter++] = var9; + if((this.chunks[var9 >> 3] & 1 << (var9 & 7)) == 0) { + System.out.println("OMG ERROR!"); + } + + if(this.lightingUpdateCounter > this.lightingUpdateList3.length - 32) { + var9 = this.lightingUpdateList3[--this.lightingUpdateCounter]; + this.lightingUpdateList3[this.lightingUpdateList3.length - 1] = this.lightingUpdateCounter; + this.lightingUpdateList.add(this.lightingUpdateList3); + this.lightingUpdateList3 = this.getLightingUpdates(); + this.lightingUpdateCounter = 1; + this.lightingUpdateList3[0] = var9; + } + } + } + } + } + + } + + public final void updateLight() { + if(this.lightingUpdateList2.size() > 0) { + this.lightingUpdateList2.remove(this.lightingUpdateList2.size() - 1); + } + + int var1 = 5; + + while(this.skyLightList.size() > 0 && var1-- > 0) { + MetadataChunkBlock var2 = (MetadataChunkBlock)this.skyLightList.remove(0); + + for(int var3 = 0; var3 < this.worldObj.worldAccesses.size(); ++var3) { + ((IWorldAccess)this.worldObj.worldAccesses.get(var3)).markBlockRangeNeedsUpdate(var2.x, var2.y, var2.z, var2.maxX, var2.maxY, var2.maxZ); + } + } + + if(this.metadataChunkBlock != null) { + this.updateLight(8); + } else { + for(int var19 = 0; var19 < 16; ++var19) { + boolean var20 = false; + MetadataChunkBlock var21; + if(this.blockLightList.size() > 0) { + var20 = true; + var21 = (MetadataChunkBlock)this.blockLightList.remove(0); + this.updateLists(var21.x, var21.y, var21.z, var21.maxX, var21.maxY, var21.maxZ); + } + + int var4; + int var5; + int var6; + int var7; + int var8; + int var9; + int var10; + int var11; + int var12; + int var13; + Light var22; + if(this.lightingUpdateList1.size() > 0) { + var20 = true; + var21 = (MetadataChunkBlock)this.lightingUpdateList1.remove(0); + var7 = var21.maxY; + var6 = var21.maxX; + var5 = var21.y; + var4 = var21.x; + var22 = this; + + for(var8 = var4; var8 < var4 + var6; ++var8) { + for(var9 = var5; var9 < var5 + var7; ++var9) { + var10 = var22.heightMap[var8 + var9 * var22.worldWidth]; + + for(var11 = var22.worldHeight - 1; var11 > 0 && Block.lightOpacity[var22.blocks[(var11 * var22.worldLength + var9) * var22.worldWidth + var8]] == 0; --var11) { + } + + var22.heightMap[var8 + var9 * var22.worldWidth] = var11 + 1; + if(var10 != var11) { + var12 = var10 < var11 ? var10 : var11; + var13 = var10 > var11 ? var10 : var11; + var22.updateLists(var8, var12, var9, var8 + 1, var13, var9 + 1); + } + } + } + } + + var22 = this; + var4 = this.worldObj.skylightSubtracted; + var5 = -999; + var6 = -999; + var7 = -999; + var8 = -999; + var9 = -999; + var10 = -999; + var11 = 1024; + var12 = 0; + + while(var11-- > 0 && (var22.lightingUpdateCounter > 0 || var22.lightingUpdateList.size() > 0)) { + ++var12; + if(var22.lightingUpdateCounter == 0) { + if(var22.lightingUpdateList3 != null) { + int[] var23 = var22.lightingUpdateList3; + var22.lightingUpdateList2.add(var23); + } + + var22.lightingUpdateList3 = (int[])var22.lightingUpdateList.remove(var22.lightingUpdateList.size() - 1); + var22.lightingUpdateCounter = var22.lightingUpdateList3[var22.lightingUpdateList3.length - 1]; + } + + if(var22.lightingUpdateCounter > var22.lightingUpdateList3.length - 32) { + var13 = var22.lightingUpdateList3[--var22.lightingUpdateCounter]; + var22.lightingUpdateList3[var22.lightingUpdateList3.length - 1] = var22.lightingUpdateCounter; + var22.lightingUpdateList.add(var22.lightingUpdateList3); + var22.lightingUpdateList3 = var22.getLightingUpdates(); + var22.lightingUpdateCounter = 1; + var22.lightingUpdateList3[0] = var13; + } else { + var13 = var22.lightingUpdateList3[--var22.lightingUpdateCounter]; + var1 = var13 % var22.worldWidth; + int var14 = var13 / var22.worldWidth % var22.worldHeight; + int var15 = var13 / var22.worldWidth / var22.worldHeight % var22.worldLength; + var22.chunks[var13 >> 3] = (byte)(var22.chunks[var13 >> 3] ^ 1 << (var13 & 7)); + var13 = var22.heightMap[var1 + var15 * var22.worldWidth]; + int var16 = var14 >= var13 ? var4 : 0; + byte var24 = var22.blocks[(var14 * var22.worldLength + var15) * var22.worldWidth + var1]; + int var17 = Block.lightOpacity[var24]; + if(var17 > 100) { + var16 = 0; + } else if(var16 < 15) { + var17 = var17; + if(var17 == 0) { + var17 = 1; + } + + int var18; + if(var1 > 0) { + var18 = (var22.data[(var14 * var22.worldLength + var15) * var22.worldWidth + (var1 - 1)] & 15) - var17; + if(var18 > var16) { + var16 = var18; + } + } + + if(var1 < var22.worldWidth - 1) { + var18 = (var22.data[(var14 * var22.worldLength + var15) * var22.worldWidth + var1 + 1] & 15) - var17; + if(var18 > var16) { + var16 = var18; + } + } + + if(var14 > 0) { + var18 = (var22.data[((var14 - 1) * var22.worldLength + var15) * var22.worldWidth + var1] & 15) - var17; + if(var18 > var16) { + var16 = var18; + } + } + + if(var14 < var22.worldHeight - 1) { + var18 = (var22.data[((var14 + 1) * var22.worldLength + var15) * var22.worldWidth + var1] & 15) - var17; + if(var18 > var16) { + var16 = var18; + } + } + + if(var15 > 0) { + var18 = (var22.data[(var14 * var22.worldLength + (var15 - 1)) * var22.worldWidth + var1] & 15) - var17; + if(var18 > var16) { + var16 = var18; + } + } + + if(var15 < var22.worldLength - 1) { + var18 = (var22.data[(var14 * var22.worldLength + var15 + 1) * var22.worldWidth + var1] & 15) - var17; + if(var18 > var16) { + var16 = var18; + } + } + } + + if(var16 < Block.lightValue[var24]) { + var16 = Block.lightValue[var24]; + } + + var17 = var22.data[(var14 * var22.worldLength + var15) * var22.worldWidth + var1] & 15; + if(var17 != var16) { + var22.data[(var14 * var22.worldLength + var15) * var22.worldWidth + var1] = (byte)((var22.data[(var14 * var22.worldLength + var15) * var22.worldWidth + var1] & 240) + var16); + if(var1 > 0 && (var22.data[(var14 * var22.worldLength + var15) * var22.worldWidth + (var1 - 1)] & 15) != var16 - 1) { + var13 = var1 - 1 + var14 * var22.worldWidth + var15 * var22.worldWidth * var22.worldHeight; + if((var22.chunks[var13 >> 3] & 1 << (var13 & 7)) == 0) { + var22.chunks[var13 >> 3] = (byte)(var22.chunks[var13 >> 3] | 1 << (var13 & 7)); + var22.lightingUpdateList3[var22.lightingUpdateCounter++] = var13; + } + } + + if(var1 < var22.worldWidth - 1 && (var22.data[(var14 * var22.worldLength + var15) * var22.worldWidth + var1 + 1] & 15) != var16 - 1) { + var13 = var1 + 1 + var14 * var22.worldWidth + var15 * var22.worldWidth * var22.worldHeight; + if((var22.chunks[var13 >> 3] & 1 << (var13 & 7)) == 0) { + var22.chunks[var13 >> 3] = (byte)(var22.chunks[var13 >> 3] | 1 << (var13 & 7)); + var22.lightingUpdateList3[var22.lightingUpdateCounter++] = var13; + } + } + + if(var14 > 0 && (var22.data[((var14 - 1) * var22.worldLength + var15) * var22.worldWidth + var1] & 15) != var16 - 1) { + var13 = var1 + (var14 - 1) * var22.worldWidth + var15 * var22.worldWidth * var22.worldHeight; + if((var22.chunks[var13 >> 3] & 1 << (var13 & 7)) == 0) { + var22.chunks[var13 >> 3] = (byte)(var22.chunks[var13 >> 3] | 1 << (var13 & 7)); + var22.lightingUpdateList3[var22.lightingUpdateCounter++] = var13; + } + } + + if(var14 < var22.worldHeight - 1 && (var22.data[((var14 + 1) * var22.worldLength + var15) * var22.worldWidth + var1] & 15) != var16 - 1) { + var13 = var1 + (var14 + 1) * var22.worldWidth + var15 * var22.worldWidth * var22.worldHeight; + if((var22.chunks[var13 >> 3] & 1 << (var13 & 7)) == 0) { + var22.chunks[var13 >> 3] = (byte)(var22.chunks[var13 >> 3] | 1 << (var13 & 7)); + var22.lightingUpdateList3[var22.lightingUpdateCounter++] = var13; + } + } + + if(var15 > 0 && (var22.data[(var14 * var22.worldLength + (var15 - 1)) * var22.worldWidth + var1] & 15) != var16 - 1) { + var13 = var1 + var14 * var22.worldWidth + (var15 - 1) * var22.worldWidth * var22.worldHeight; + if((var22.chunks[var13 >> 3] & 1 << (var13 & 7)) == 0) { + var22.chunks[var13 >> 3] = (byte)(var22.chunks[var13 >> 3] | 1 << (var13 & 7)); + var22.lightingUpdateList3[var22.lightingUpdateCounter++] = var13; + } + } + + if(var15 < var22.worldLength - 1 && (var22.data[(var14 * var22.worldLength + var15 + 1) * var22.worldWidth + var1] & 15) != var16 - 1) { + var13 = var1 + var14 * var22.worldWidth + (var15 + 1) * var22.worldWidth * var22.worldHeight; + if((var22.chunks[var13 >> 3] & 1 << (var13 & 7)) == 0) { + var22.chunks[var13 >> 3] = (byte)(var22.chunks[var13 >> 3] | 1 << (var13 & 7)); + var22.lightingUpdateList3[var22.lightingUpdateCounter++] = var13; + } + } + + if(var5 == -999) { + var5 = var1; + var6 = var1; + var7 = var14; + var8 = var14; + var9 = var15; + var10 = var15; + } + + if(var1 < var5) { + var5 = var1; + } else if(var1 > var6) { + var6 = var1; + } + + if(var14 > var8) { + var8 = var14; + } else if(var14 < var7) { + var7 = var14; + } + + if(var15 < var9) { + var9 = var15; + } else if(var15 > var10) { + var10 = var15; + } + } + } + } + + if(var5 > -999) { + var22.skyLightList.add(new MetadataChunkBlock(var22, var5, var7, var9, var6, var8, var10)); + } + + if(var12 > 0) { + var20 = true; + } + } + + } + } + + public final String debugLightUpdates() { + return "" + (this.blockLightList.size() + this.skyLightList.size()); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/MetadataChunkBlock.java b/src/teavm/java/net/minecraft/game/level/MetadataChunkBlock.java new file mode 100644 index 0000000..deb0463 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/MetadataChunkBlock.java @@ -0,0 +1,19 @@ +package net.minecraft.game.level; + +final class MetadataChunkBlock { + public int x; + public int y; + public int z; + public int maxX; + public int maxY; + public int maxZ; + + public MetadataChunkBlock(Light var1, int var2, int var3, int var4, int var5, int var6, int var7) { + this.x = var2; + this.y = var3; + this.z = var4; + this.maxX = var5; + this.maxY = var6; + this.maxZ = var7; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/MobSpawner.java b/src/teavm/java/net/minecraft/game/level/MobSpawner.java new file mode 100644 index 0000000..7e969d5 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/MobSpawner.java @@ -0,0 +1,206 @@ +package net.minecraft.game.level; + +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.entity.animal.EntityAnimal; +import net.minecraft.game.entity.animal.EntityPig; +import net.minecraft.game.entity.animal.EntitySheep; +import net.minecraft.game.entity.monster.EntityCreeper; +import net.minecraft.game.entity.monster.EntityMob; +import net.minecraft.game.entity.monster.EntitySkeleton; +import net.minecraft.game.entity.monster.EntitySpider; +import net.minecraft.game.entity.monster.EntityZombie; + +public class MobSpawner { + private World worldObj; + + public MobSpawner(World var1) { + this.worldObj = var1; + } + + public final void performSpawning() { + int var1 = this.worldObj.width * this.worldObj.length * this.worldObj.height * 20 / 64 / 64 / 64; + var1 /= 2; + if(this.worldObj.difficultySetting == 0) { + var1 = 0 / 4; + } + + if(this.worldObj.difficultySetting == 1) { + var1 = var1 * 3 / 4; + } + + if(this.worldObj.difficultySetting == 2) { + var1 = (var1 << 2) / 4; + } + + if(this.worldObj.difficultySetting == 3) { + var1 = var1 * 6 / 4; + } + + int var2 = this.worldObj.width * this.worldObj.length / 4000; + int var3 = this.worldObj.entitiesInLevelList(EntityMob.class); + + int var4; + EntityLiving var5; + int var6; + int var7; + int var8; + int var9; + int var10; + int var11; + int var12; + int var13; + int var14; + int var15; + float var16; + float var17; + float var18; + float var19; + float var20; + float var21; + MobSpawner var22; + Object var23; + for(var4 = 0; var4 < 4; ++var4) { + if(var3 < var1) { + var5 = this.worldObj.playerEntity; + var22 = this; + var6 = 0; + var7 = this.worldObj.random.nextInt(5); + var8 = this.worldObj.random.nextInt(this.worldObj.width); + var9 = (int)(Math.min(this.worldObj.random.nextFloat(), this.worldObj.random.nextFloat()) * (float)this.worldObj.height); + var10 = this.worldObj.random.nextInt(this.worldObj.length); + + for(var11 = 0; var11 < 2; ++var11) { + var12 = var8; + var13 = var9; + var14 = var10; + + for(var15 = 0; var15 < 3; ++var15) { + var12 += var22.worldObj.random.nextInt(6) - var22.worldObj.random.nextInt(6); + var13 += var22.worldObj.random.nextInt(1) - var22.worldObj.random.nextInt(1); + var14 += var22.worldObj.random.nextInt(6) - var22.worldObj.random.nextInt(6); + if(var12 >= 0 && var14 > 0 && var13 >= 0 && var13 < var22.worldObj.height - 2 && var12 < var22.worldObj.width && var14 < var22.worldObj.length) { + var16 = (float)var12 + 0.5F; + var17 = (float)var13 + 0.5F; + var18 = (float)var14 + 0.5F; + if(var5 != null) { + var19 = var16 - var5.posX; + var20 = var17 - var5.posY; + var21 = var18 - var5.posZ; + var19 = var19 * var19 + var20 * var20 + var21 * var21; + if(var19 < 1024.0F) { + continue; + } + } else { + var19 = var16 - (float)var22.worldObj.xSpawn; + var20 = var17 - (float)var22.worldObj.ySpawn; + var21 = var18 - (float)var22.worldObj.zSpawn; + var19 = var19 * var19 + var20 * var20 + var21 * var21; + if(var19 < 1024.0F) { + continue; + } + } + + var23 = null; + if(var7 == 0) { + var23 = new EntitySkeleton(var22.worldObj); + } + + if(var7 == 1) { + var23 = new EntityCreeper(var22.worldObj); + } + + if(var7 == 2) { + var23 = new EntitySpider(var22.worldObj); + } + + if(var7 == 3) { + var23 = new EntityZombie(var22.worldObj); + } + + if(var23 instanceof EntityMob && var22.worldObj.difficultySetting == 0) { + var23 = null; + } + + if(var23 != null && !var22.worldObj.isBlockNormalCube(var12, var13, var14) && var22.worldObj.isBlockNormalCube(var12, var13 - 1, var14) && ((EntityLiving)var23).getCanSpawnHere(var16, var17, var18)) { + var21 = var22.worldObj.random.nextFloat() * 360.0F; + ((EntityLiving)var23).setPositionAndRotation(var16, var17, var18, var21, 0.0F); + ++var6; + var22.worldObj.spawnEntityInWorld((Entity)var23); + } + } + } + } + + var3 += var6; + } + } + + var4 = this.worldObj.entitiesInLevelList(EntityAnimal.class); + + for(var1 = 0; var1 < 4; ++var1) { + if(var4 < var2) { + var5 = this.worldObj.playerEntity; + var22 = this; + var6 = 0; + var7 = this.worldObj.random.nextInt(2); + var8 = this.worldObj.random.nextInt(this.worldObj.width); + var9 = this.worldObj.random.nextInt(this.worldObj.height); + var10 = this.worldObj.random.nextInt(this.worldObj.length); + + for(var11 = 0; var11 < 2; ++var11) { + var12 = var8; + var13 = var9; + var14 = var10; + + for(var15 = 0; var15 < 3; ++var15) { + var12 += var22.worldObj.random.nextInt(6) - var22.worldObj.random.nextInt(6); + var13 += var22.worldObj.random.nextInt(1) - var22.worldObj.random.nextInt(1); + var14 += var22.worldObj.random.nextInt(6) - var22.worldObj.random.nextInt(6); + if(var12 >= 0 && var14 > 0 && var13 >= 0 && var13 < var22.worldObj.height - 2 && var12 < var22.worldObj.width && var14 < var22.worldObj.length) { + var16 = (float)var12 + 0.5F; + var17 = (float)var13 + 0.5F; + var18 = (float)var14 + 0.5F; + if(var5 != null) { + var19 = var16 - var5.posX; + var20 = var17 - var5.posY; + var21 = var18 - var5.posZ; + var19 = var19 * var19 + var20 * var20 + var21 * var21; + if(var19 < 1024.0F) { + continue; + } + } else { + var19 = var16 - (float)var22.worldObj.xSpawn; + var20 = var17 - (float)var22.worldObj.ySpawn; + var21 = var18 - (float)var22.worldObj.zSpawn; + var19 = var19 * var19 + var20 * var20 + var21 * var21; + if(var19 < 1024.0F) { + continue; + } + } + + var23 = null; + if(var7 == 0) { + var23 = new EntityPig(var22.worldObj); + } + + if(var7 == 1) { + var23 = new EntitySheep(var22.worldObj); + } + + if(var23 != null && !var22.worldObj.isBlockNormalCube(var12, var13, var14) && var22.worldObj.isBlockNormalCube(var12, var13 - 1, var14) && ((EntityLiving)var23).getCanSpawnHere(var16, var17, var18)) { + var21 = var22.worldObj.random.nextFloat() * 360.0F; + ((EntityLiving)var23).setPositionAndRotation(var16, var17, var18, var21, 0.0F); + ++var6; + var22.worldObj.spawnEntityInWorld((Entity)var23); + } + } + } + } + + var4 += var6; + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/NextTickListEntry.java b/src/teavm/java/net/minecraft/game/level/NextTickListEntry.java new file mode 100644 index 0000000..3d25a1f --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/NextTickListEntry.java @@ -0,0 +1,16 @@ +package net.minecraft.game.level; + +public final class NextTickListEntry { + public int xCoord; + public int yCoord; + public int zCoord; + public int blockID; + public int scheduledTime; + + public NextTickListEntry(int var1, int var2, int var3, int var4) { + this.xCoord = var1; + this.yCoord = var2; + this.zCoord = var3; + this.blockID = var4; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/World.java b/src/teavm/java/net/minecraft/game/level/World.java new file mode 100644 index 0000000..877c365 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/World.java @@ -0,0 +1,1585 @@ +package net.minecraft.game.level; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.TreeSet; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.entity.EntityLiving; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.BlockContainer; +import net.minecraft.game.level.block.tileentity.TileEntity; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.level.path.Pathfinder; +import net.minecraft.game.physics.AxisAlignedBB; +import net.minecraft.game.physics.MovingObjectPosition; +import net.minecraft.game.physics.Vec3D; + +public final class World { + private static float[] lightBrightnessTable = new float[16]; + public int width; + public int length; + public int height; + public byte[] blocks; + public byte[] data; + public String name; + public String authorName; + public long createTime; + public int xSpawn; + public int ySpawn; + public int zSpawn; + public float rotSpawn; + public int defaultFluid = Block.waterMoving.blockID; + List worldAccesses = new ArrayList(); + private List tickList = new LinkedList(); + public Map map = new HashMap(); + private List list = new ArrayList(); + int[] heightMap; + public Random random = new Random(); + private Random rand = new Random(); + private int randId = this.random.nextInt(); + public EntityMap entityMap; + public int waterLevel; + public int groundLevel; + public int cloudHeight; + public int skyColor = 10079487; + public int fogColor = 16777215; + public int cloudColor = 16777215; + private int updateLCG = 0; + private int playTime = 0; + public EntityLiving playerEntity; + public boolean survivalWorld = true; + public int skyBrightness = 15; + public int skylightSubtracted = 15; + public Pathfinder pathFinder = new Pathfinder(this); + private Light lightUpdates; + public int worldTime = 0; + private static short floodFillCounter; + private short[] floodFillCounters = new short[1048576]; + private int[] coords = new int[1048576]; + private int[] floodedBlocks = new int[1048576]; + public int difficultySetting = 2; + + public final void load() { + if(this.blocks == null) { + throw new RuntimeException("The level is corrupt!"); + } else { + this.worldAccesses = new ArrayList(); + this.heightMap = new int[this.width * this.length]; + Arrays.fill(this.heightMap, this.height); + this.lightUpdates.updateSkylight(0, 0, this.width, this.length); + this.random = new Random(); + this.randId = this.random.nextInt(); + this.tickList = new ArrayList(); + if(this.entityMap == null) { + this.entityMap = new EntityMap(this.width, this.height, this.length); + } + + } + } + + public final void generate(int var1, int var2, int var3, byte[] var4, byte[] var5) { + if(var5 != null && var5.length == 0) { + var5 = null; + } + + this.width = var1; + this.length = var3; + this.height = var2; + this.blocks = var4; + + int var6; + int var7; + for(var2 = 0; var2 < this.width; ++var2) { + for(var6 = 0; var6 < this.length; ++var6) { + for(var7 = 0; var7 < this.height; ++var7) { + int var8 = 0; + if(var7 <= 1 && var7 < this.groundLevel - 1 && var4[((var7 + 1) * this.length + var6) * this.width + var2] == 0) { + var8 = Block.lavaStill.blockID; + } else if(var7 < this.groundLevel - 1) { + var8 = Block.bedrock.blockID; + } else if(var7 < this.groundLevel) { + if(this.groundLevel > this.waterLevel && this.defaultFluid == Block.waterMoving.blockID) { + var8 = Block.grass.blockID; + } else { + var8 = Block.dirt.blockID; + } + } else if(var7 < this.waterLevel) { + var8 = this.defaultFluid; + } + + var4[(var7 * this.length + var6) * this.width + var2] = (byte)var8; + if(var7 == 1 && var2 != 0 && var6 != 0 && var2 != this.width - 1 && var6 != this.length - 1) { + var7 = this.height - 2; + } + } + } + } + + this.heightMap = new int[var1 * var3]; + Arrays.fill(this.heightMap, this.height); + if(var5 == null) { + this.data = new byte[var4.length]; + this.lightUpdates = new Light(this); + boolean var10 = true; + World var11 = this; + var2 = this.skylightSubtracted; + + for(var3 = 0; var3 < var11.width; ++var3) { + for(int var12 = 0; var12 < var11.length; ++var12) { + int var13; + for(var13 = var11.height - 1; var13 > 0 && Block.lightOpacity[var11.getBlockId(var3, var13, var12)] == 0; --var13) { + } + + var11.heightMap[var3 + var12 * var11.width] = var13 + 1; + + for(var13 = 0; var13 < var11.height; ++var13) { + var6 = (var13 * var11.length + var12) * var11.width + var3; + var7 = var11.heightMap[var3 + var12 * var11.width]; + var7 = var13 >= var7 ? var2 : 0; + byte var14 = var11.blocks[var6]; + if(var7 < Block.lightValue[var14]) { + var7 = Block.lightValue[var14]; + } + + var11.data[var6] = (byte)((var11.data[var6] & 240) + var7); + } + } + } + + var11.lightUpdates.updateBlockLight(0, 0, 0, var11.width, var11.height, var11.length); + } else { + this.data = var5; + this.lightUpdates = new Light(this); + } + + for(var2 = 0; var2 < this.worldAccesses.size(); ++var2) { + ((IWorldAccess)this.worldAccesses.get(var2)).loadRenderers(); + } + + this.tickList.clear(); + this.findSpawn(); + this.load(); + System.gc(); + } + + public final void findSpawn() { + Random var1 = new Random(); + int var2 = 0; + + while(true) { + label58: + while(true) { + int var3; + int var4; + int var5; + do { + do { + ++var2; + var3 = var1.nextInt(this.width / 2) + this.width / 4; + var4 = var1.nextInt(this.length / 2) + this.length / 4; + var5 = this.getFirstUncoveredBlock(var3, var4) + 1; + if(var2 == 1000000) { + this.xSpawn = var3; + this.ySpawn = this.height + 100; + this.zSpawn = var4; + this.rotSpawn = 180.0F; + return; + } + } while(var5 < 4); + } while(var5 <= this.waterLevel); + + int var6; + int var7; + int var8; + for(var6 = var3 - 3; var6 <= var3 + 3; ++var6) { + for(var7 = var5 - 1; var7 <= var5 + 2; ++var7) { + for(var8 = var4 - 3 - 2; var8 <= var4 + 3; ++var8) { + if(this.getBlockMaterial(var6, var7, var8).isSolid()) { + continue label58; + } + } + } + } + + var6 = var5 - 2; + + for(var7 = var3 - 3; var7 <= var3 + 3; ++var7) { + for(var8 = var4 - 3 - 2; var8 <= var4 + 3; ++var8) { + if(!Block.opaqueCubeLookup[this.getBlockId(var7, var6, var8)]) { + continue label58; + } + } + } + + this.xSpawn = var3; + this.ySpawn = var5; + this.zSpawn = var4; + this.rotSpawn = 180.0F; + return; + } + } + } + + public final void addWorldAccess(IWorldAccess var1) { + for(int var2 = 0; var2 < this.entityMap.entities.size(); ++var2) { + var1.obtainEntitySkin((Entity)this.entityMap.entities.get(var2)); + } + + this.worldAccesses.add(var1); + } + + public final void finalize() { + } + + public final void removeWorldAccess(IWorldAccess var1) { + this.worldAccesses.remove(var1); + } + + public final ArrayList getCollidingBoundingBoxes(AxisAlignedBB var1) { + ArrayList var2 = new ArrayList(); + int var3 = (int)var1.minX; + int var4 = (int)var1.maxX + 1; + int var5 = (int)var1.minY; + int var6 = (int)var1.maxY + 1; + int var7 = (int)var1.minZ; + int var8 = (int)var1.maxZ + 1; + if(var1.minX < 0.0F) { + --var3; + } + + if(var1.minY < 0.0F) { + --var5; + } + + if(var1.minZ < 0.0F) { + --var7; + } + + for(var3 = var3; var3 < var4; ++var3) { + for(int var9 = var5; var9 < var6; ++var9) { + for(int var10 = var7; var10 < var8; ++var10) { + Block var11 = Block.blocksList[this.getBlockId(var3, var9, var10)]; + AxisAlignedBB var12; + if(var11 != null) { + var12 = var11.getCollisionBoundingBoxFromPool(var3, var9, var10); + if(var12 != null && var1.intersectsWith(var12)) { + var2.add(var12); + } + } else if(this.groundLevel < 0 && (var9 < this.groundLevel || var9 < this.waterLevel)) { + var12 = Block.bedrock.getCollisionBoundingBoxFromPool(var3, var9, var10); + if(var12 != null && var1.intersectsWith(var12)) { + var2.add(var12); + } + } + } + } + } + + return var2; + } + + public final void swap(int var1, int var2, int var3, int var4, int var5, int var6) { + int var7 = this.getBlockId(var1, var2, var3); + int var8 = this.getBlockId(var4, var5, var6); + this.setBlock(var1, var2, var3, var8); + this.setBlock(var4, var5, var6, var7); + this.notifyBlocksOfNeighborChange(var1, var2, var3, var8); + this.notifyBlocksOfNeighborChange(var4, var5, var6, var7); + } + + public final boolean setBlock(int var1, int var2, int var3, int var4) { + if(var1 > 0 && var2 > 0 && var3 > 0 && var1 < this.width - 1 && var2 < this.height - 1 && var3 < this.length - 1) { + if(var4 == this.blocks[(var2 * this.length + var3) * this.width + var1]) { + return false; + } else { + if(var4 == 0 && (var1 == 0 || var3 == 0 || var1 == this.width - 1 || var3 == this.length - 1) && var2 >= this.groundLevel && var2 < this.waterLevel) { + var4 = Block.waterMoving.blockID; + } + + byte var5 = this.blocks[(var2 * this.length + var3) * this.width + var1]; + this.blocks[(var2 * this.length + var3) * this.width + var1] = (byte)var4; + this.setBlockMetadata(var1, var2, var3, 0); + if(var5 != 0) { + Block.blocksList[var5].onBlockRemoval(this, var1, var2, var3); + } + + if(var4 != 0) { + Block.blocksList[var4].onBlockAdded(this, var1, var2, var3); + } + + if(Block.lightOpacity[var5] != Block.lightOpacity[var4] || Block.lightValue[var5] != 0 || Block.lightValue[var4] != 0) { + this.lightUpdates.updateSkylight(var1, var3, 1, 1); + this.lightUpdates.updateBlockLight(var1, var2, var3, var1 + 1, var2 + 1, var3 + 1); + } + + for(var4 = 0; var4 < this.worldAccesses.size(); ++var4) { + ((IWorldAccess)this.worldAccesses.get(var4)).markBlockAndNeighborsNeedsUpdate(var1, var2, var3); + } + + return true; + } + } else { + return false; + } + } + + public final boolean setBlockWithNotify(int var1, int var2, int var3, int var4) { + if(this.setBlock(var1, var2, var3, var4)) { + this.notifyBlocksOfNeighborChange(var1, var2, var3, var4); + return true; + } else { + return false; + } + } + + public final void notifyBlocksOfNeighborChange(int var1, int var2, int var3, int var4) { + this.notifyBlockOfNeighborChange(var1 - 1, var2, var3, var4); + this.notifyBlockOfNeighborChange(var1 + 1, var2, var3, var4); + this.notifyBlockOfNeighborChange(var1, var2 - 1, var3, var4); + this.notifyBlockOfNeighborChange(var1, var2 + 1, var3, var4); + this.notifyBlockOfNeighborChange(var1, var2, var3 - 1, var4); + this.notifyBlockOfNeighborChange(var1, var2, var3 + 1, var4); + } + + public final boolean setTileNoUpdate(int var1, int var2, int var3, int var4) { + if(var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.height && var3 < this.length) { + if(var4 == this.blocks[(var2 * this.length + var3) * this.width + var1]) { + return false; + } else { + this.blocks[(var2 * this.length + var3) * this.width + var1] = (byte)var4; + this.lightUpdates.updateBlockLight(var1, var2, var3, var1 + 1, var2 + 1, var3 + 1); + return true; + } + } else { + return false; + } + } + + private void notifyBlockOfNeighborChange(int var1, int var2, int var3, int var4) { + if(var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.height && var3 < this.length) { + Block var5 = Block.blocksList[this.blocks[(var2 * this.length + var3) * this.width + var1]]; + if(var5 != null) { + var5.onNeighborBlockChange(this, var1, var2, var3, var4); + } + + } + } + + public final int getBlockId(int var1, int var2, int var3) { + if(var1 < 0) { + var1 = 0; + } else if(var1 >= this.width) { + var1 = this.width - 1; + } + + if(var2 < 0) { + var2 = 0; + } else if(var2 >= this.height) { + var2 = this.height - 1; + } + + if(var3 < 0) { + var3 = 0; + } else if(var3 >= this.length) { + var3 = this.length - 1; + } + + return this.blocks[(var2 * this.length + var3) * this.width + var1] & 255; + } + + public final boolean isBlockNormalCube(int var1, int var2, int var3) { + Block var4 = Block.blocksList[this.getBlockId(var1, var2, var3)]; + return var4 == null ? false : var4.isOpaqueCube(); + } + + public final void updateEntities() { + this.entityMap.updateEntities(); + + for(int var1 = 0; var1 < this.list.size(); ++var1) { + TileEntity var2 = (TileEntity)this.list.get(var1); + var2.updateEntity(); + } + + } + + public final void updateLighting() { + this.lightUpdates.updateLight(); + } + + public final float getStarBrightness(float var1) { + var1 = this.getCelestialAngle(var1); + var1 = 1.0F - (MathHelper.cos(var1 * (float)Math.PI * 2.0F) * 2.0F + 12.0F / 16.0F); + if(var1 < 0.0F) { + var1 = 0.0F; + } + + if(var1 > 1.0F) { + var1 = 1.0F; + } + + return var1 * var1 * 0.5F; + } + + public final Vec3D getSkyColor(float var1) { + var1 = this.getCelestialAngle(var1); + var1 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + if(var1 < 0.0F) { + var1 = 0.0F; + } + + if(var1 > 1.0F) { + var1 = 1.0F; + } + + float var2 = (float)(this.skyColor >> 16 & 255) / 255.0F; + float var3 = (float)(this.skyColor >> 8 & 255) / 255.0F; + float var4 = (float)(this.skyColor & 255) / 255.0F; + var2 *= var1; + var3 *= var1; + var4 *= var1; + return new Vec3D(var2, var3, var4); + } + + public final float getCelestialAngle(float var1) { + if(this.skyBrightness > 15) { + return 0.0F; + } else { + var1 = ((float)this.worldTime + var1) / 24000.0F - 0.15F; + return var1; + } + } + + public final Vec3D getFogColor(float var1) { + var1 = this.getCelestialAngle(var1); + var1 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + if(var1 < 0.0F) { + var1 = 0.0F; + } + + if(var1 > 1.0F) { + var1 = 1.0F; + } + + float var2 = (float)(this.fogColor >> 16 & 255) / 255.0F; + float var3 = (float)(this.fogColor >> 8 & 255) / 255.0F; + float var4 = (float)(this.fogColor & 255) / 255.0F; + var2 *= var1 * 0.94F + 0.06F; + var3 *= var1 * 0.94F + 0.06F; + var4 *= var1 * 0.91F + 0.09F; + return new Vec3D(var2, var3, var4); + } + + public final Vec3D getCloudColor(float var1) { + var1 = this.getCelestialAngle(var1); + var1 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + if(var1 < 0.0F) { + var1 = 0.0F; + } + + if(var1 > 1.0F) { + var1 = 1.0F; + } + + float var2 = (float)(this.cloudColor >> 16 & 255) / 255.0F; + float var3 = (float)(this.cloudColor >> 8 & 255) / 255.0F; + float var4 = (float)(this.cloudColor & 255) / 255.0F; + var2 *= var1 * 0.9F + 0.1F; + var3 *= var1 * 0.9F + 0.1F; + var4 *= var1 * 0.85F + 0.15F; + return new Vec3D(var2, var3, var4); + } + + public final int getSkyBrightness() { + float var1 = this.getCelestialAngle(1.0F); + var1 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) * 1.5F + 0.5F; + if(var1 < 0.0F) { + var1 = 0.0F; + } + + if(var1 > 1.0F) { + var1 = 1.0F; + } + + int var2 = (int)(var1 * ((float)(15 * this.skyBrightness) / 15.0F - 4.0F) + 4.0F); + if(var2 > 15) { + var2 = 15; + } + + if(var2 < 4) { + var2 = 4; + } + + return var2; + } + + public final void tick() { + ++this.worldTime; + if(this.worldTime == 24000) { + this.worldTime = 0; + } + + int var1 = this.getSkyBrightness(); + if(this.skylightSubtracted > var1) { + this.updateChunkLight(this.skylightSubtracted - 1); + } + + if(this.skylightSubtracted < var1) { + this.updateChunkLight(this.skylightSubtracted + 1); + } + + ++this.playTime; + var1 = 1; + + int var2; + for(var2 = 1; 1 << var1 < this.width; ++var1) { + } + + while(1 << var2 < this.length) { + ++var2; + } + + int var3 = this.length - 1; + int var4 = this.width - 1; + int var5 = this.height - 1; + int var6 = this.tickList.size(); + if(var6 > 200) { + var6 = 200; + } + + int var7; + int var10; + for(var7 = 0; var7 < var6; ++var7) { + NextTickListEntry var8 = (NextTickListEntry)this.tickList.remove(0); + if(var8.scheduledTime > 0) { + --var8.scheduledTime; + this.tickList.add(var8); + } else { + int var12 = var8.zCoord; + int var11 = var8.yCoord; + var10 = var8.xCoord; + if(var10 >= 0 && var11 >= 0 && var12 >= 0 && var10 < this.width && var11 < this.height && var12 < this.length) { + byte var9 = this.blocks[(var8.yCoord * this.length + var8.zCoord) * this.width + var8.xCoord]; + if(var9 == var8.blockID && var9 > 0) { + Block.blocksList[var9].updateTick(this, var8.xCoord, var8.yCoord, var8.zCoord, this.random); + } + } + } + } + + this.updateLCG += this.width * this.length * this.height; + var6 = this.updateLCG / 200; + this.updateLCG -= var6 * 200; + + for(var7 = 0; var7 < var6; ++var7) { + this.randId = this.randId * 3 + 1013904223; + int var13 = this.randId >> 2; + int var14 = var13 & var4; + var10 = var13 >> var1 & var3; + var13 = var13 >> var1 + var2 & var5; + byte var15 = this.blocks[(var13 * this.length + var10) * this.width + var14]; + if(Block.tickOnLoad[var15]) { + Block.blocksList[var15].updateTick(this, var14, var13, var10, this.random); + } + } + + } + + public final int entitiesInLevelList(Class var1) { + int var2 = 0; + + for(int var3 = 0; var3 < this.entityMap.entities.size(); ++var3) { + Entity var4 = (Entity)this.entityMap.entities.get(var3); + if(var1.isAssignableFrom(var4.getClass())) { + ++var2; + } + } + + return var2; + } + + public final int getGroundLevel() { + return this.groundLevel; + } + + public final int getWaterLevel() { + return this.waterLevel; + } + + public final boolean getIsAnyLiquid(AxisAlignedBB var1) { + int var2 = (int)var1.minX; + int var3 = (int)var1.maxX + 1; + int var4 = (int)var1.minY; + int var5 = (int)var1.maxY + 1; + int var6 = (int)var1.minZ; + int var7 = (int)var1.maxZ + 1; + if(var1.minX < 0.0F) { + --var2; + } + + if(var1.minY < 0.0F) { + --var4; + } + + if(var1.minZ < 0.0F) { + --var6; + } + + if(var2 < 0) { + var2 = 0; + } + + if(var4 < 0) { + var4 = 0; + } + + if(var6 < 0) { + var6 = 0; + } + + if(var3 > this.width) { + var3 = this.width; + } + + if(var5 > this.height) { + var5 = this.height; + } + + if(var7 > this.length) { + var7 = this.length; + } + + for(int var10 = var2; var10 < var3; ++var10) { + for(var2 = var4; var2 < var5; ++var2) { + for(int var8 = var6; var8 < var7; ++var8) { + Block var9 = Block.blocksList[this.getBlockId(var10, var2, var8)]; + if(var9 != null && var9.material.getIsLiquid()) { + return true; + } + } + } + } + + return false; + } + + public final boolean isBoundingBoxBurning(AxisAlignedBB var1) { + int var2 = (int)var1.minX; + int var3 = (int)var1.maxX + 1; + int var4 = (int)var1.minY; + int var5 = (int)var1.maxY + 1; + int var6 = (int)var1.minZ; + int var10 = (int)var1.maxZ + 1; + + for(var2 = var2; var2 < var3; ++var2) { + for(int var7 = var4; var7 < var5; ++var7) { + for(int var8 = var6; var8 < var10; ++var8) { + int var9 = this.getBlockId(var2, var7, var8); + if(var9 == Block.fire.blockID || var9 == Block.lavaMoving.blockID || var9 == Block.lavaStill.blockID) { + return true; + } + } + } + } + + return false; + } + + public final boolean handleMaterialAcceleration(AxisAlignedBB var1, Material var2) { + int var3 = (int)var1.minX; + int var4 = (int)var1.maxX + 1; + int var5 = (int)var1.minY; + int var6 = (int)var1.maxY + 1; + int var7 = (int)var1.minZ; + int var11 = (int)var1.maxZ + 1; + + for(var3 = var3; var3 < var4; ++var3) { + for(int var8 = var5; var8 < var6; ++var8) { + for(int var9 = var7; var9 < var11; ++var9) { + Block var10 = Block.blocksList[this.getBlockId(var3, var8, var9)]; + if(var10 != null && var10.material == var2) { + return true; + } + } + } + } + + return false; + } + + public final void scheduleBlockUpdate(int var1, int var2, int var3, int var4) { + NextTickListEntry var5 = new NextTickListEntry(var1, var2, var3, var4); + if(var4 > 0) { + var3 = Block.blocksList[var4].tickRate(); + var5.scheduledTime = var3; + } + + this.tickList.add(var5); + } + + public final boolean checkIfAABBIsClear1(AxisAlignedBB var1) { + return this.entityMap.getEntitiesWithinAABB((Entity)null, var1).size() == 0; + } + + public final boolean checkIfAABBIsClear(AxisAlignedBB var1) { + List var4 = this.entityMap.getEntitiesWithinAABB((Entity)null, var1); + + for(int var2 = 0; var2 < var4.size(); ++var2) { + Entity var3 = (Entity)var4.get(var2); + if(var3.preventEntitySpawning) { + return false; + } + } + + return true; + } + + public final List getEntitiesWithinAABBExcludingEntity(Entity var1, AxisAlignedBB var2) { + return this.entityMap.getEntitiesWithinAABB(var1, var2); + } + + public final boolean isSolid(float var1, float var2, float var3, float var4) { + return this.isSolid(var1 - 0.1F, var2 - 0.1F, var3 - 0.1F) ? true : (this.isSolid(var1 - 0.1F, var2 - 0.1F, var3 + 0.1F) ? true : (this.isSolid(var1 - 0.1F, var2 + 0.1F, var3 - 0.1F) ? true : (this.isSolid(var1 - 0.1F, var2 + 0.1F, var3 + 0.1F) ? true : (this.isSolid(var1 + 0.1F, var2 - 0.1F, var3 - 0.1F) ? true : (this.isSolid(var1 + 0.1F, var2 - 0.1F, var3 + 0.1F) ? true : (this.isSolid(var1 + 0.1F, var2 + 0.1F, var3 - 0.1F) ? true : this.isSolid(var1 + 0.1F, var2 + 0.1F, var3 + 0.1F))))))); + } + + private boolean isSolid(float var1, float var2, float var3) { + int var4 = this.getBlockId((int)var1, (int)var2, (int)var3); + return var4 > 0 && Block.blocksList[var4].isOpaqueCube(); + } + + private int getFirstUncoveredBlock(int var1, int var2) { + int var3; + for(var3 = this.height; (this.getBlockId(var1, var3 - 1, var2) == 0 || Block.blocksList[this.getBlockId(var1, var3 - 1, var2)].material == Material.air) && var3 > 0; --var3) { + } + + return var3; + } + + public final void setSpawnLocation(int var1, int var2, int var3, float var4) { + this.xSpawn = var1; + this.ySpawn = var2; + this.zSpawn = var3; + this.rotSpawn = var4; + } + + public final float getLightBrightness(int var1, int var2, int var3) { + return lightBrightnessTable[this.getBlockLightValue(var1, var2, var3)]; + } + + public final byte getBlockLightValue(int var1, int var2, int var3) { + if(var1 < 0) { + var1 = 0; + } else if(var1 >= this.width) { + var1 = this.width - 1; + } + + if(var2 < 0) { + var2 = 0; + } else if(var2 >= this.height) { + var2 = this.height - 1; + } + + if(var3 < 0) { + var3 = 0; + } else if(var3 >= this.length) { + var3 = this.length - 1; + } + + return this.blocks[(var2 * this.length + var3) * this.width + var1] == Block.stairSingle.blockID ? (var2 < this.height - 1 ? (byte)(this.data[((var2 + 1) * this.length + var3) * this.width + var1] & 15) : 15) : (byte)(this.data[(var2 * this.length + var3) * this.width + var1] & 15); + } + + public final byte getBlockMetadata(int var1, int var2, int var3) { + if(var1 < 0) { + var1 = 0; + } else if(var1 >= this.width) { + var1 = this.width - 1; + } + + if(var2 < 0) { + var2 = 0; + } else if(var2 >= this.height) { + var2 = this.height - 1; + } + + if(var3 < 0) { + var3 = 0; + } else if(var3 >= this.length) { + var3 = this.length - 1; + } + + return (byte)(this.data[(var2 * this.length + var3) * this.width + var1] >>> 4 & 15); + } + + public final void setBlockMetadata(int var1, int var2, int var3, int var4) { + if(var1 < 0) { + var1 = 0; + } else if(var1 >= this.width) { + var1 = this.width - 1; + } + + if(var2 < 0) { + var2 = 0; + } else if(var2 >= this.height) { + var2 = this.height - 1; + } + + if(var3 < 0) { + var3 = 0; + } else if(var3 >= this.length) { + var3 = this.length - 1; + } + + this.data[(var2 * this.length + var3) * this.width + var1] = (byte)((this.data[(var2 * this.length + var3) * this.width + var1] & 15) + (var4 << 4)); + + for(var4 = 0; var4 < this.worldAccesses.size(); ++var4) { + ((IWorldAccess)this.worldAccesses.get(var4)).markBlockAndNeighborsNeedsUpdate(var1, var2, var3); + } + + } + + public final Material getBlockMaterial(int var1, int var2, int var3) { + var1 = this.getBlockId(var1, var2, var3); + return var1 == 0 ? Material.air : Block.blocksList[var1].material; + } + + public final boolean isWater(int var1, int var2, int var3) { + var1 = this.getBlockId(var1, var2, var3); + return var1 > 0 && Block.blocksList[var1].material == Material.water; + } + + public final MovingObjectPosition rayTraceBlocks(Vec3D var1, Vec3D var2) { + if(!Float.isNaN(var1.xCoord) && !Float.isNaN(var1.yCoord) && !Float.isNaN(var1.zCoord)) { + if(!Float.isNaN(var2.xCoord) && !Float.isNaN(var2.yCoord) && !Float.isNaN(var2.zCoord)) { + int var3 = MathHelper.floor_float(var2.xCoord); + int var4 = MathHelper.floor_float(var2.yCoord); + int var5 = MathHelper.floor_float(var2.zCoord); + int var6 = MathHelper.floor_float(var1.xCoord); + int var7 = MathHelper.floor_float(var1.yCoord); + int var8 = MathHelper.floor_float(var1.zCoord); + int var9 = 20; + + while(var9-- >= 0) { + if(Float.isNaN(var1.xCoord) || Float.isNaN(var1.yCoord) || Float.isNaN(var1.zCoord)) { + return null; + } + + if(var6 == var3 && var7 == var4 && var8 == var5) { + return null; + } + + float var10 = 999.0F; + float var11 = 999.0F; + float var12 = 999.0F; + if(var3 > var6) { + var10 = (float)var6 + 1.0F; + } + + if(var3 < var6) { + var10 = (float)var6; + } + + if(var4 > var7) { + var11 = (float)var7 + 1.0F; + } + + if(var4 < var7) { + var11 = (float)var7; + } + + if(var5 > var8) { + var12 = (float)var8 + 1.0F; + } + + if(var5 < var8) { + var12 = (float)var8; + } + + float var13 = 999.0F; + float var14 = 999.0F; + float var15 = 999.0F; + float var16 = var2.xCoord - var1.xCoord; + float var17 = var2.yCoord - var1.yCoord; + float var18 = var2.zCoord - var1.zCoord; + if(var10 != 999.0F) { + var13 = (var10 - var1.xCoord) / var16; + } + + if(var11 != 999.0F) { + var14 = (var11 - var1.yCoord) / var17; + } + + if(var12 != 999.0F) { + var15 = (var12 - var1.zCoord) / var18; + } + + byte var19; + if(var13 < var14 && var13 < var15) { + if(var3 > var6) { + var19 = 4; + } else { + var19 = 5; + } + + var1.xCoord = var10; + var1.yCoord += var17 * var13; + var1.zCoord += var18 * var13; + } else if(var14 < var15) { + if(var4 > var7) { + var19 = 0; + } else { + var19 = 1; + } + + var1.xCoord += var16 * var14; + var1.yCoord = var11; + var1.zCoord += var18 * var14; + } else { + if(var5 > var8) { + var19 = 2; + } else { + var19 = 3; + } + + var1.xCoord += var16 * var15; + var1.yCoord += var17 * var15; + var1.zCoord = var12; + } + + Vec3D var20 = new Vec3D(var1.xCoord, var1.yCoord, var1.zCoord); + var6 = (int)(var20.xCoord = (float)MathHelper.floor_float(var1.xCoord)); + if(var19 == 5) { + --var6; + ++var20.xCoord; + } + + var7 = (int)(var20.yCoord = (float)MathHelper.floor_float(var1.yCoord)); + if(var19 == 1) { + --var7; + ++var20.yCoord; + } + + var8 = (int)(var20.zCoord = (float)MathHelper.floor_float(var1.zCoord)); + if(var19 == 3) { + --var8; + ++var20.zCoord; + } + + int var21 = this.getBlockId(var6, var7, var8); + Block var23 = Block.blocksList[var21]; + if(var21 > 0 && var23.isCollidable()) { + MovingObjectPosition var22 = var23.collisionRayTrace(this, var6, var7, var8, var1, var2); + if(var22 != null) { + return var22; + } + } + } + + return null; + } else { + return null; + } + } else { + return null; + } + } + + public final boolean growTrees(int var1, int var2, int var3) { + int var4 = this.random.nextInt(3) + 4; + boolean var5 = true; + if(var2 > 0 && var2 + var4 + 1 <= this.height) { + int var6; + int var8; + int var9; + int var10; + for(var6 = var2; var6 <= var2 + 1 + var4; ++var6) { + byte var7 = 1; + if(var6 == var2) { + var7 = 0; + } + + if(var6 >= var2 + 1 + var4 - 2) { + var7 = 2; + } + + for(var8 = var1 - var7; var8 <= var1 + var7 && var5; ++var8) { + for(var9 = var3 - var7; var9 <= var3 + var7 && var5; ++var9) { + if(var8 >= 0 && var6 >= 0 && var9 >= 0 && var8 < this.width && var6 < this.height && var9 < this.length) { + var10 = this.blocks[(var6 * this.length + var9) * this.width + var8] & 255; + if(var10 != 0) { + var5 = false; + } + } else { + var5 = false; + } + } + } + } + + if(!var5) { + return false; + } else { + var6 = this.blocks[((var2 - 1) * this.length + var3) * this.width + var1] & 255; + if((var6 == Block.grass.blockID || var6 == Block.dirt.blockID) && var2 < this.height - var4 - 1) { + this.setBlockWithNotify(var1, var2 - 1, var3, Block.dirt.blockID); + + int var13; + for(var13 = var2 - 3 + var4; var13 <= var2 + var4; ++var13) { + var8 = var13 - (var2 + var4); + var9 = 1 - var8 / 2; + + for(var10 = var1 - var9; var10 <= var1 + var9; ++var10) { + int var12 = var10 - var1; + + for(var6 = var3 - var9; var6 <= var3 + var9; ++var6) { + int var11 = var6 - var3; + if((Math.abs(var12) != var9 || Math.abs(var11) != var9 || this.random.nextInt(2) != 0 && var8 != 0) && !Block.opaqueCubeLookup[this.getBlockId(var10, var13, var6)]) { + this.setBlockWithNotify(var10, var13, var6, Block.leaves.blockID); + } + } + } + } + + for(var13 = 0; var13 < var4; ++var13) { + if(!Block.opaqueCubeLookup[this.getBlockId(var1, var2 + var13, var3)]) { + this.setBlockWithNotify(var1, var2 + var13, var3, Block.wood.blockID); + } + } + + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + public final Entity getPlayerEntity() { + return this.playerEntity; + } + + public final void spawnEntityInWorld(Entity var1) { + this.entityMap.insert(var1); + var1.setWorld(this); + + for(int var2 = 0; var2 < this.worldAccesses.size(); ++var2) { + ((IWorldAccess)this.worldAccesses.get(var2)).obtainEntitySkin(var1); + } + + } + + public final void releaseEntitySkin(Entity var1) { + this.entityMap.remove(var1); + + for(int var2 = 0; var2 < this.worldAccesses.size(); ++var2) { + ((IWorldAccess)this.worldAccesses.get(var2)).releaseEntitySkin(var1); + } + + } + + public final void createExplosion(Entity var1, float var2, float var3, float var4, float var5) { + TreeSet var6 = new TreeSet(); + float var7 = var5; + + int var8; + int var9; + int var10; + float var11; + float var18; + int var19; + int var20; + int var21; + int var22; + for(var8 = 0; var8 < 16; ++var8) { + for(var9 = 0; var9 < 16; ++var9) { + for(var10 = 0; var10 < 16; ++var10) { + if(var8 == 0 || var8 == 15 || var9 == 0 || var9 == 15 || var10 == 0 || var10 == 15) { + var11 = (float)var8 / 15.0F * 2.0F - 1.0F; + float var12 = (float)var9 / 15.0F * 2.0F - 1.0F; + float var13 = (float)var10 / 15.0F * 2.0F - 1.0F; + float var14 = (float)Math.sqrt((double)(var11 * var11 + var12 * var12 + var13 * var13)); + var11 /= var14; + var12 /= var14; + var13 /= var14; + float var15 = var5 * (0.7F + this.random.nextFloat() * 0.6F); + float var16 = var2; + float var17 = var3; + + for(var18 = var4; var15 > 0.0F; var15 -= 0.22500001F) { + var19 = (int)var16; + var20 = (int)var17; + var21 = (int)var18; + var22 = this.getBlockId(var19, var20, var21); + if(var22 > 0) { + var15 -= (Block.blocksList[var22].getExplosionResistance() + 0.3F) * 0.3F; + } + + if(var15 > 0.0F) { + int var23 = var19 + (var20 << 10) + (var21 << 10 << 10); + var6.add(Integer.valueOf(var23)); + } + + var16 += var11 * 0.3F; + var17 += var12 * 0.3F; + var18 += var13 * 0.3F; + } + } + } + } + } + + var5 *= 2.0F; + var8 = (int)(var2 - var5 - 1.0F); + var9 = (int)(var2 + var5 + 1.0F); + var10 = (int)(var3 - var5 - 1.0F); + int var29 = (int)(var3 + var5 + 1.0F); + int var30 = (int)(var4 - var5 - 1.0F); + int var31 = (int)(var4 + var5 + 1.0F); + List var32 = this.entityMap.getEntities(var1, (float)var8, (float)var10, (float)var30, (float)var9, (float)var29, (float)var31); + Vec3D var33 = new Vec3D(var2, var3, var4); + + float var27; + float var28; + float var43; + for(int var34 = 0; var34 < var32.size(); ++var34) { + Entity var36 = (Entity)var32.get(var34); + var27 = var36.posX - var2; + var28 = var36.posY - var3; + float var26 = var36.posZ - var4; + var18 = MathHelper.sqrt_float(var27 * var27 + var28 * var28 + var26 * var26) / var5; + if(var18 <= 1.0F) { + var26 = var36.posX - var2; + float var39 = var36.posY - var3; + float var40 = var36.posZ - var4; + float var41 = MathHelper.sqrt_float(var26 * var26 + var39 * var39 + var40 * var40); + var26 /= var41; + var39 /= var41; + var40 /= var41; + float var42 = this.getBlockDensity(var33, var36.boundingBox); + var43 = (1.0F - var18) * var42; + var36.attackEntityFrom(var1, (int)((var43 * var43 + var43) / 2.0F * 8.0F * var5 + 1.0F)); + var36.motionX += var26 * var43; + var36.motionY += var39 * var43; + var36.motionZ += var40 * var43; + } + } + + var5 = var7; + ArrayList var35 = new ArrayList(); + var35.addAll(var6); + + for(int var37 = var35.size() - 1; var37 >= 0; --var37) { + int var38 = ((Integer)var35.get(var37)).intValue(); + var8 = var38 & 1023; + var19 = var38 >> 10 & 1023; + var20 = var38 >> 20 & 1023; + if(var8 >= 0 && var19 >= 0 && var20 >= 0 && var8 < this.width && var19 < this.height && var20 < this.length) { + var21 = this.getBlockId(var8, var19, var20); + + for(var22 = 0; var22 <= 0; ++var22) { + var43 = (float)var8 + this.random.nextFloat(); + var27 = (float)var19 + this.random.nextFloat(); + float var24 = (float)var20 + this.random.nextFloat(); + float var25 = var43 - var2; + var7 = var27 - var3; + var28 = var24 - var4; + var11 = MathHelper.sqrt_float(var25 * var25 + var7 * var7 + var28 * var28); + var25 /= var11; + var7 /= var11; + var28 /= var11; + var11 = 0.5F / (var11 / var5 + 0.1F); + var11 *= this.random.nextFloat() * this.random.nextFloat() + 0.3F; + var25 *= var11; + var7 *= var11; + var28 *= var11; + this.spawnParticle("explode", (var43 + var2) / 2.0F, (var27 + var3) / 2.0F, (var24 + var4) / 2.0F, var25, var7, var28); + this.spawnParticle("smoke", var43, var27, var24, var25, var7, var28); + } + + if(var21 > 0) { + Block.blocksList[var21].dropBlockAsItemWithChance(this, var8, var19, var20, this.getBlockMetadata(var8, var19, var20), 0.3F); + this.setBlockWithNotify(var8, var19, var20, 0); + Block.blocksList[var21].onBlockDestroyedByExplosion(this, var8, var19, var20); + } + } + } + + } + + private float getBlockDensity(Vec3D var1, AxisAlignedBB var2) { + float var3 = 1.0F / ((var2.maxX - var2.minX) * 2.0F + 1.0F); + float var4 = 1.0F / ((var2.maxY - var2.minY) * 2.0F + 1.0F); + float var5 = 1.0F / ((var2.maxZ - var2.minZ) * 2.0F + 1.0F); + int var6 = 0; + int var7 = 0; + + for(float var8 = 0.0F; var8 <= 1.0F; var8 += var3) { + for(float var9 = 0.0F; var9 <= 1.0F; var9 += var4) { + for(float var10 = 0.0F; var10 <= 1.0F; var10 += var5) { + float var11 = var2.minX + (var2.maxX - var2.minX) * var8; + float var12 = var2.minY + (var2.maxY - var2.minY) * var9; + float var13 = var2.minZ + (var2.maxZ - var2.minZ) * var10; + if(this.rayTraceBlocks(new Vec3D(var11, var12, var13), var1) == null) { + ++var6; + } + + ++var7; + } + } + } + + return (float)var6 / (float)var7; + } + + public final Entity findSubclassOf(Class var1) { + for(int var2 = 0; var2 < this.entityMap.entities.size(); ++var2) { + Entity var3 = (Entity)this.entityMap.entities.get(var2); + if(var1.isAssignableFrom(var3.getClass())) { + return var3; + } + } + + return null; + } + + public final int fluidFlowCheck(int var1, int var2, int var3, int var4, int var5) { + if(var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.height && var3 < this.length) { + int var6 = var1; + int var7 = var3; + int var8 = ((var2 << 10) + var3 << 10) + var1; + byte var9 = 0; + int var20 = var9 + 1; + this.coords[0] = var1 + (var3 << 10); + int var11 = -9999; + if(var4 == Block.waterStill.blockID || var4 == Block.waterMoving.blockID) { + var11 = Block.waterSource.blockID; + } + + if(var4 == Block.lavaStill.blockID || var4 == Block.lavaMoving.blockID) { + var11 = Block.lavaSource.blockID; + } + + int var10; + boolean var12; + label170: + do { + var12 = false; + int var13 = -1; + var10 = 0; + if(++floodFillCounter == 30000) { + Arrays.fill(this.floodFillCounters, (short)0); + floodFillCounter = 1; + } + + while(true) { + int var14; + do { + if(var20 <= 0) { + ++var2; + int[] var21 = this.floodedBlocks; + this.floodedBlocks = this.coords; + this.coords = var21; + var20 = var10; + continue label170; + } + + --var20; + var14 = this.coords[var20]; + } while(this.floodFillCounters[var14] == floodFillCounter); + + var1 = var14 % 1024; + var3 = var14 / 1024; + int var15 = var3 - var7; + + for(var15 *= var15; var1 > 0 && this.floodFillCounters[var14 - 1] != floodFillCounter && (this.blocks[(var2 * this.length + var3) * this.width + var1 - 1] == var4 || this.blocks[(var2 * this.length + var3) * this.width + var1 - 1] == var5); --var14) { + --var1; + } + + if(var1 > 0 && this.blocks[(var2 * this.length + var3) * this.width + var1 - 1] == var11) { + var12 = true; + } + + boolean var16 = false; + boolean var17 = false; + + for(boolean var18 = false; var1 < this.width && this.floodFillCounters[var14] != floodFillCounter && (this.blocks[(var2 * this.length + var3) * this.width + var1] == var4 || this.blocks[(var2 * this.length + var3) * this.width + var1] == var5); ++var1) { + byte var19; + boolean var22; + if(var3 > 0) { + var19 = this.blocks[(var2 * this.length + var3 - 1) * this.width + var1]; + if(var19 == var11) { + var12 = true; + } + + var22 = this.floodFillCounters[var14 - 1024] != floodFillCounter && (var19 == var4 || var19 == var5); + if(var22 && !var16) { + this.coords[var20++] = var14 - 1024; + } + + var16 = var22; + } + + if(var3 < this.length - 1) { + var19 = this.blocks[(var2 * this.length + var3 + 1) * this.width + var1]; + if(var19 == var11) { + var12 = true; + } + + var22 = this.floodFillCounters[var14 + 1024] != floodFillCounter && (var19 == var4 || var19 == var5); + if(var22 && !var17) { + this.coords[var20++] = var14 + 1024; + } + + var17 = var22; + } + + if(var2 < this.height - 1) { + var19 = this.blocks[((var2 + 1) * this.length + var3) * this.width + var1]; + var22 = var19 == var4 || var19 == var5; + if(var22 && !var18) { + this.floodedBlocks[var10++] = var14; + } + + var18 = var22; + } + + int var23 = var1 - var6; + var23 *= var23; + var23 += var15; + if(var23 > var13) { + var13 = var23; + var8 = ((var2 << 10) + var3 << 10) + var1; + } + + this.floodFillCounters[var14++] = floodFillCounter; + } + + if(var1 < this.width && this.blocks[(var2 * this.length + var3) * this.width + var1] == var11) { + var12 = true; + } + } + } while(var10 > 0); + + if(var12) { + return -9999; + } else { + return var8; + } + } else { + return -1; + } + } + + public final int floodFill(int var1, int var2, int var3, int var4, int var5) { + if(var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.height && var3 < this.length) { + if(++floodFillCounter == 30000) { + Arrays.fill(this.floodFillCounters, (short)0); + floodFillCounter = 1; + } + + byte var6 = 0; + int var11 = var6 + 1; + this.coords[0] = var1 + (var3 << 10); + + do { + int var7; + do { + if(var11 <= 0) { + return 1; + } + + --var11; + var7 = this.coords[var11]; + } while(this.floodFillCounters[var7] == floodFillCounter); + + var1 = var7 % 1024; + var3 = var7 / 1024; + if(var1 == 0 || var1 == this.width - 1 || var2 == 0 || var2 == this.height - 1 || var3 == 0 || var3 == this.length - 1) { + return 2; + } + + while(var1 > 0 && this.floodFillCounters[var7 - 1] != floodFillCounter && (this.blocks[(var2 * this.length + var3) * this.width + var1 - 1] == var4 || this.blocks[(var2 * this.length + var3) * this.width + var1 - 1] == var5)) { + --var1; + --var7; + } + + if(var1 > 0 && this.blocks[(var2 * this.length + var3) * this.width + var1 - 1] == 0) { + return 0; + } + + boolean var8 = false; + + for(boolean var9 = false; var1 < this.width && this.floodFillCounters[var7] != floodFillCounter && (this.blocks[(var2 * this.length + var3) * this.width + var1] == var4 || this.blocks[(var2 * this.length + var3) * this.width + var1] == var5); ++var1) { + if(var1 == 0 || var1 == this.width - 1) { + return 2; + } + + byte var10; + boolean var12; + if(var3 > 0) { + var10 = this.blocks[(var2 * this.length + var3 - 1) * this.width + var1]; + if(var10 == 0) { + return 0; + } + + var12 = this.floodFillCounters[var7 - 1024] != floodFillCounter && (var10 == var4 || var10 == var5); + if(var12 && !var8) { + this.coords[var11++] = var7 - 1024; + } + + var8 = var12; + } + + if(var3 < this.length - 1) { + var10 = this.blocks[(var2 * this.length + var3 + 1) * this.width + var1]; + if(var10 == 0) { + return 0; + } + + var12 = this.floodFillCounters[var7 + 1024] != floodFillCounter && (var10 == var4 || var10 == var5); + if(var12 && !var9) { + this.coords[var11++] = var7 + 1024; + } + + var9 = var12; + } + + this.floodFillCounters[var7] = floodFillCounter; + ++var7; + } + } while(var1 >= this.width || this.blocks[(var2 * this.length + var3) * this.width + var1] != 0); + + return 0; + } else { + return 0; + } + } + + public final void extinguishFire(int var1, int var2, int var3, int var4) { + if(var4 == 0) { + --var2; + } + + if(var4 == 1) { + ++var2; + } + + if(var4 == 2) { + --var3; + } + + if(var4 == 3) { + ++var3; + } + + if(var4 == 4) { + --var1; + } + + if(var4 == 5) { + ++var1; + } + + if(this.getBlockId(var1, var2, var3) == Block.fire.blockID) { + this.setBlockWithNotify(var1, var2, var3, 0); + } + + } + + public final void setBlockTileEntity(int var1, int var2, int var3, TileEntity var4) { + var4.worldObj = this; + var4.xCoord = var1; + var4.yCoord = var2; + var4.zCoord = var3; + this.map.put(Integer.valueOf(var1 + (var2 << 10) + (var3 << 10 << 10)), var4); + this.list.add(var4); + } + + public final void removeBlockTileEntity(int var1, int var2, int var3) { + this.list.remove(this.map.remove(Integer.valueOf(var1 + (var2 << 10) + (var3 << 10 << 10)))); + } + + public final TileEntity getBlockTileEntity(int var1, int var2, int var3) { + int var4 = var1 + (var2 << 10) + (var3 << 10 << 10); + TileEntity var5 = (TileEntity)this.map.get(Integer.valueOf(var4)); + if(var5 == null) { + int var6 = this.getBlockId(var1, var2, var3); + BlockContainer var7 = (BlockContainer)Block.blocksList[var6]; + var7.onBlockAdded(this, var1, var2, var3); + var5 = (TileEntity)this.map.get(Integer.valueOf(var4)); + } + + return var5; + } + + public final void spawnParticle(String var1, float var2, float var3, float var4, float var5, float var6, float var7) { + for(int var8 = 0; var8 < this.worldAccesses.size(); ++var8) { + ((IWorldAccess)this.worldAccesses.get(var8)).spawnParticle(var1, var2, var3, var4, var5, var6, var7); + } + + } + + public final void randomDisplayUpdates(int var1, int var2, int var3) { + for(int var4 = 0; var4 < 1000; ++var4) { + int var5 = var1 + this.random.nextInt(16) - this.random.nextInt(16); + int var6 = var2 + this.random.nextInt(16) - this.random.nextInt(16); + int var7 = var3 + this.random.nextInt(16) - this.random.nextInt(16); + int var8 = this.getBlockId(var5, var6, var7); + if(var8 > 0) { + Block.blocksList[var8].randomDisplayTick(this, var5, var6, var7, this.rand); + } + } + + } + + public final String debugSkylightUpdates() { + return "" + this.tickList.size() + ". L: " + this.lightUpdates.debugLightUpdates(); + } + + public final void setLevel() { + for(int var1 = 0; var1 < this.worldAccesses.size(); ++var1) { + IWorldAccess var2 = (IWorldAccess)this.worldAccesses.get(var1); + + for(int var3 = 0; var3 < this.entityMap.entities.size(); ++var3) { + var2.releaseEntitySkin((Entity)this.entityMap.entities.get(var1)); + } + } + + } + + private void updateChunkLight(int var1) { + this.lightUpdates.updateDaylightCycle(var1); + } + + public final boolean canBlockSeeTheSky(int var1, int var2, int var3) { + if(this.heightMap[var1 + var3 * this.width] <= var2) { + return true; + } else { + while(var2 < this.height) { + if(Block.opaqueCubeLookup[this.getBlockId(var1, var2, var3)]) { + return false; + } + + ++var2; + } + + return true; + } + } + + static { + for(int var0 = 0; var0 <= 15; ++var0) { + float var1 = 1.0F - (float)var0 / 15.0F; + lightBrightnessTable[var0] = (1.0F - var1) / (var1 * 3.0F + 1.0F) * 0.95F + 0.05F; + } + + floodFillCounter = 0; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/Block.java b/src/teavm/java/net/minecraft/game/level/block/Block.java new file mode 100644 index 0000000..f6a8f8d --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/Block.java @@ -0,0 +1,721 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.entity.player.InventoryPlayer; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemBlock; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; +import net.minecraft.game.physics.MovingObjectPosition; +import net.minecraft.game.physics.Vec3D; + +public class Block { + private static StepSound soundPowderFootstep = new StepSound("stone", 1.0F, 1.0F); + private static StepSound soundWoodFootstep = new StepSound("wood", 1.0F, 1.0F); + private static StepSound soundGravelFootstep = new StepSound("gravel", 1.0F, 1.0F); + private static StepSound soundGrassFootstep = new StepSound("grass", 1.0F, 1.0F); + private static StepSound soundStoneFootstep = new StepSound("stone", 1.0F, 1.0F); + private static StepSound soundMetalFootstep = new StepSound("stone", 1.0F, 1.5F); + private static StepSound soundGlassFootstep = new StepSoundGlass("stone", 1.0F, 1.0F); + private static StepSound soundClothFootstep = new StepSound("cloth", 1.0F, 1.0F); + private static StepSound soundSandFootstep = new StepSoundSand("sand", 1.0F, 1.0F); + public static final Block[] blocksList = new Block[256]; + public static final boolean[] tickOnLoad = new boolean[256]; + public static final boolean[] opaqueCubeLookup = new boolean[256]; + public static final int[] lightOpacity = new int[256]; + private static boolean[] canBlockGrass = new boolean[256]; + public static final boolean[] isBlockFluid = new boolean[256]; + public static final int[] lightValue = new int[256]; + public static final Block stone; + public static final BlockGrass grass; + public static final Block dirt; + public static final Block cobblestone; + public static final Block planks; + public static final Block sapling; + public static final Block bedrock; + public static final Block waterMoving; + public static final Block waterStill; + public static final Block lavaMoving; + public static final Block lavaStill; + public static final Block sand; + public static final Block gravel; + public static final Block oreGold; + public static final Block oreIron; + public static final Block oreCoal; + public static final Block wood; + public static final Block leaves; + public static final Block sponge; + public static final Block glass; + public static final Block clothRed; + public static final Block clothOrange; + public static final Block clothYellow; + public static final Block clothChartreuse; + public static final Block clothGreen; + public static final Block clothSpringGreen; + public static final Block clothCyan; + public static final Block clothCapri; + public static final Block clothUltramarine; + public static final Block clothViolet; + public static final Block clothPurple; + public static final Block clothMagenta; + public static final Block clothRose; + public static final Block clothDarkGray; + public static final Block clothGray; + public static final Block clothWhite; + public static final BlockFlower plantYellow; + public static final BlockFlower plantRed; + public static final BlockFlower mushroomBrown; + public static final BlockFlower mushroomRed; + public static final Block blockGold; + public static final Block blockSteel; + public static final Block stairDouble; + public static final Block stairSingle; + public static final Block brick; + public static final Block tnt; + public static final Block bookShelf; + public static final Block cobblestoneMossy; + public static final Block obsidian; + public static final Block torch; + public static final BlockFire fire; + public static final Block waterSource; + public static final Block lavaSource; + public static final Block crate; + public static final Block cog; + public static final Block oreDiamond; + public static final Block blockDiamond; + public static final Block workbench; + public static final Block crops; + public static final Block tilledField; + public static final Block stoneOvenIdle; + public static final Block stoneOvenActive; + public int blockIndexInTexture; + public final int blockID; + private float hardness; + private float resistance; + public float minX; + public float minY; + public float minZ; + public float maxX; + public float maxY; + public float maxZ; + public StepSound stepSound; + public float blockParticleGravity; + public final Material material; + + protected Block(int var1, Material var2) { + this.stepSound = soundPowderFootstep; + this.blockParticleGravity = 1.0F; + if(blocksList[var1] != null) { + throw new IllegalArgumentException("Slot " + var1 + " is already occupied by " + blocksList[var1] + " when adding " + this); + } else { + this.material = var2; + blocksList[var1] = this; + this.blockID = var1; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + opaqueCubeLookup[var1] = this.isOpaqueCube(); + lightOpacity[var1] = this.isOpaqueCube() ? 255 : 0; + canBlockGrass[var1] = this.renderAsNormalBlock(); + isBlockFluid[var1] = false; + } + } + + protected Block(int var1, int var2, Material var3) { + this(var1, var3); + this.blockIndexInTexture = var2; + } + + protected final Block setLightOpacity(int var1) { + lightOpacity[this.blockID] = var1; + return this; + } + + private Block setLightValue(float var1) { + lightValue[this.blockID] = (int)(15.0F * var1); + return this; + } + + protected final Block setResistance(float var1) { + this.resistance = var1 * 3.0F; + return this; + } + + public boolean renderAsNormalBlock() { + return true; + } + + public int getRenderType() { + return 0; + } + + protected final Block setHardness(float var1) { + this.hardness = var1; + if(this.resistance < var1 * 5.0F) { + this.resistance = var1 * 5.0F; + } + + return this; + } + + protected final void setTickOnLoad(boolean var1) { + tickOnLoad[this.blockID] = var1; + } + + protected final void setBlockBounds(float var1, float var2, float var3, float var4, float var5, float var6) { + this.minX = var1; + this.minY = var2; + this.minZ = var3; + this.maxX = var4; + this.maxY = var5; + this.maxZ = var6; + } + + public float getBlockBrightness(World var1, int var2, int var3, int var4) { + return var1.getLightBrightness(var2, var3, var4); + } + + public boolean shouldSideBeRendered(World var1, int var2, int var3, int var4, int var5) { + return !var1.isBlockNormalCube(var2, var3, var4); + } + + public int getBlockTexture(World var1, int var2, int var3, int var4, int var5) { + return this.getBlockTextureFromSideAndMetadata(var5, var1.getBlockMetadata(var2, var3, var4)); + } + + public int getBlockTextureFromSideAndMetadata(int var1, int var2) { + return this.getBlockTextureFromSide(var1); + } + + public int getBlockTextureFromSide(int var1) { + return this.blockIndexInTexture; + } + + public final AxisAlignedBB getSelectedBoundingBoxFromPool(int var1, int var2, int var3) { + return new AxisAlignedBB((float)var1 + this.minX, (float)var2 + this.minY, (float)var3 + this.minZ, (float)var1 + this.maxX, (float)var2 + this.maxY, (float)var3 + this.maxZ); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return new AxisAlignedBB((float)var1 + this.minX, (float)var2 + this.minY, (float)var3 + this.minZ, (float)var1 + this.maxX, (float)var2 + this.maxY, (float)var3 + this.maxZ); + } + + public boolean isOpaqueCube() { + return true; + } + + public boolean isCollidable() { + return true; + } + + public void updateTick(World var1, int var2, int var3, int var4, Random var5) { + } + + public void randomDisplayTick(World var1, int var2, int var3, int var4, Random var5) { + } + + public void onBlockDestroyedByPlayer(World var1, int var2, int var3, int var4, int var5) { + } + + public void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + } + + public int tickRate() { + return 5; + } + + public void onBlockAdded(World var1, int var2, int var3, int var4) { + } + + public void onBlockRemoval(World var1, int var2, int var3, int var4) { + } + + public int quantityDropped(Random var1) { + return 1; + } + + public int idDropped(int var1, Random var2) { + return this.blockID; + } + + public final float blockStrength(EntityPlayer var1) { + if(this.hardness < 0.0F) { + return 0.0F; + } else if(!var1.canHarvestBlock(this)) { + return 1.0F / this.hardness / 100.0F; + } else { + InventoryPlayer var2 = var1.inventory; + float var4 = 1.0F; + if(var2.mainInventory[var2.currentItem] != null) { + ItemStack var5 = var2.mainInventory[var2.currentItem]; + var4 = 1.0F * var5.getItem().getStrVsBlock(this); + } + + float var6 = var4; + if(var1.isInsideOfWater()) { + var6 = var4 / 5.0F; + } + + if(!var1.onGround) { + var6 /= 5.0F; + } + + return var6 / this.hardness / 30.0F; + } + } + + public final void dropBlockAsItem(World var1, int var2, int var3, int var4, int var5) { + this.dropBlockAsItemWithChance(var1, var2, var3, var4, var5, 1.0F); + } + + public final void dropBlockAsItemWithChance(World var1, int var2, int var3, int var4, int var5, float var6) { + int var7 = this.quantityDropped(var1.random); + + for(int var8 = 0; var8 < var7; ++var8) { + if(var1.random.nextFloat() <= var6) { + int var9 = this.idDropped(var5, var1.random); + if(var9 > 0) { + float var10 = var1.random.nextFloat() * 0.7F + 0.15F; + float var11 = var1.random.nextFloat() * 0.7F + 0.15F; + float var12 = var1.random.nextFloat() * 0.7F + 0.15F; + EntityItem var13 = new EntityItem(var1, (float)var2 + var10, (float)var3 + var11, (float)var4 + var12, new ItemStack(var9)); + var13.delayBeforeCanPickup = 10; + var1.spawnEntityInWorld(var13); + } + } + } + + } + + public final float getExplosionResistance() { + return this.resistance / 5.0F; + } + + public MovingObjectPosition collisionRayTrace(World var1, int var2, int var3, int var4, Vec3D var5, Vec3D var6) { + var5 = var5.addVector((float)(-var2), (float)(-var3), (float)(-var4)); + var6 = var6.addVector((float)(-var2), (float)(-var3), (float)(-var4)); + Vec3D var12 = var5.getIntermediateWithXValue(var6, this.minX); + Vec3D var7 = var5.getIntermediateWithXValue(var6, this.maxX); + Vec3D var8 = var5.getIntermediateWithYValue(var6, this.minY); + Vec3D var9 = var5.getIntermediateWithYValue(var6, this.maxY); + Vec3D var10 = var5.getIntermediateWithZValue(var6, this.minZ); + var6 = var5.getIntermediateWithZValue(var6, this.maxZ); + if(!this.isVecInsideYZBounds(var12)) { + var12 = null; + } + + if(!this.isVecInsideYZBounds(var7)) { + var7 = null; + } + + if(!this.isVecInsideXZBounds(var8)) { + var8 = null; + } + + if(!this.isVecInsideXZBounds(var9)) { + var9 = null; + } + + if(!this.isVecInsideXYBounds(var10)) { + var10 = null; + } + + if(!this.isVecInsideXYBounds(var6)) { + var6 = null; + } + + Vec3D var11 = null; + if(var12 != null) { + var11 = var12; + } + + if(var7 != null && (var11 == null || var5.distance(var7) < var5.distance(var11))) { + var11 = var7; + } + + if(var8 != null && (var11 == null || var5.distance(var8) < var5.distance(var11))) { + var11 = var8; + } + + if(var9 != null && (var11 == null || var5.distance(var9) < var5.distance(var11))) { + var11 = var9; + } + + if(var10 != null && (var11 == null || var5.distance(var10) < var5.distance(var11))) { + var11 = var10; + } + + if(var6 != null && (var11 == null || var5.distance(var6) < var5.distance(var11))) { + var11 = var6; + } + + if(var11 == null) { + return null; + } else { + byte var13 = -1; + if(var11 == var12) { + var13 = 4; + } + + if(var11 == var7) { + var13 = 5; + } + + if(var11 == var8) { + var13 = 0; + } + + if(var11 == var9) { + var13 = 1; + } + + if(var11 == var10) { + var13 = 2; + } + + if(var11 == var6) { + var13 = 3; + } + + return new MovingObjectPosition(var2, var3, var4, var13, var11.addVector((float)var2, (float)var3, (float)var4)); + } + } + + private boolean isVecInsideYZBounds(Vec3D var1) { + return var1 == null ? false : var1.yCoord >= this.minY && var1.yCoord <= this.maxY && var1.zCoord >= this.minZ && var1.zCoord <= this.maxZ; + } + + private boolean isVecInsideXZBounds(Vec3D var1) { + return var1 == null ? false : var1.xCoord >= this.minX && var1.xCoord <= this.maxX && var1.zCoord >= this.minZ && var1.zCoord <= this.maxZ; + } + + private boolean isVecInsideXYBounds(Vec3D var1) { + return var1 == null ? false : var1.xCoord >= this.minX && var1.xCoord <= this.maxX && var1.yCoord >= this.minY && var1.yCoord <= this.maxY; + } + + public void onBlockDestroyedByExplosion(World var1, int var2, int var3, int var4) { + } + + public int getRenderBlockPass() { + return 0; + } + + public boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) { + return true; + } + + public boolean blockActivated(World var1, int var2, int var3, int var4, EntityPlayer var5) { + return false; + } + + public void onEntityWalking(World var1, int var2, int var3, int var4) { + } + + public void onBlockPlaced(World var1, int var2, int var3, int var4, int var5) { + } + + static { + Block var10000 = (new BlockStone(1, 1)).setHardness(1.5F).setResistance(10.0F); + StepSound var1 = soundStoneFootstep; + Block var0 = var10000; + var0.stepSound = var1; + stone = var0; + var10000 = (new BlockGrass(2)).setHardness(0.6F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + grass = (BlockGrass)var0; + var10000 = (new BlockDirt(3, 2)).setHardness(0.5F); + var1 = soundGravelFootstep; + var0 = var10000; + var0.stepSound = var1; + dirt = var0; + var10000 = (new Block(4, 16, Material.rock)).setHardness(2.0F).setResistance(10.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + cobblestone = var0; + var10000 = (new Block(5, 4, Material.wood)).setHardness(2.0F).setResistance(5.0F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + planks = var0; + var10000 = (new BlockSapling(6, 15)).setHardness(0.0F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + sapling = var0; + var10000 = (new Block(7, 17, Material.rock)).setHardness(-1.0F).setResistance(6000000.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + bedrock = var0; + waterMoving = (new BlockFlowing(8, Material.water)).setHardness(100.0F).setLightOpacity(3); + waterStill = (new BlockStationary(9, Material.water)).setHardness(100.0F).setLightOpacity(3); + lavaMoving = (new BlockFlowing(10, Material.lava)).setHardness(0.0F).setLightValue(1.0F).setLightOpacity(255); + lavaStill = (new BlockStationary(11, Material.lava)).setHardness(100.0F).setLightValue(1.0F).setLightOpacity(255); + var10000 = (new BlockSand(12, 18)).setHardness(0.5F); + var1 = soundSandFootstep; + var0 = var10000; + var0.stepSound = var1; + sand = var0; + var10000 = (new BlockGravel(13, 19)).setHardness(0.6F); + var1 = soundGravelFootstep; + var0 = var10000; + var0.stepSound = var1; + gravel = var0; + var10000 = (new BlockOre(14, 32)).setHardness(3.0F).setResistance(5.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + oreGold = var0; + var10000 = (new BlockOre(15, 33)).setHardness(3.0F).setResistance(5.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + oreIron = var0; + var10000 = (new BlockOre(16, 34)).setHardness(3.0F).setResistance(5.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + oreCoal = var0; + var10000 = (new BlockLog(17)).setHardness(2.0F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + wood = var0; + var10000 = (new BlockLeaves(18, 52)).setHardness(0.2F).setLightOpacity(1); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + leaves = var0; + var10000 = (new BlockSponge(19)).setHardness(0.6F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + sponge = var0; + var10000 = (new BlockGlass(20, 49, Material.glass, false)).setHardness(0.3F); + var1 = soundGlassFootstep; + var0 = var10000; + var0.stepSound = var1; + glass = var0; + var10000 = (new Block(21, 64, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothRed = var0; + var10000 = (new Block(22, 65, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothOrange = var0; + var10000 = (new Block(23, 66, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothYellow = var0; + var10000 = (new Block(24, 67, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothChartreuse = var0; + var10000 = (new Block(25, 68, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothGreen = var0; + var10000 = (new Block(26, 69, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothSpringGreen = var0; + var10000 = (new Block(27, 70, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothCyan = var0; + var10000 = (new Block(28, 71, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothCapri = var0; + var10000 = (new Block(29, 72, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothUltramarine = var0; + var10000 = (new Block(30, 73, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothViolet = var0; + var10000 = (new Block(31, 74, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothPurple = var0; + var10000 = (new Block(32, 75, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothMagenta = var0; + var10000 = (new Block(33, 76, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothRose = var0; + var10000 = (new Block(34, 77, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothDarkGray = var0; + var10000 = (new Block(35, 78, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothGray = var0; + var10000 = (new Block(36, 79, Material.cloth)).setHardness(0.8F); + var1 = soundClothFootstep; + var0 = var10000; + var0.stepSound = var1; + clothWhite = var0; + var10000 = (new BlockFlower(37, 13)).setHardness(0.0F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + plantYellow = (BlockFlower)var0; + var10000 = (new BlockFlower(38, 12)).setHardness(0.0F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + plantRed = (BlockFlower)var0; + var10000 = (new BlockMushroom(39, 29)).setHardness(0.0F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + mushroomBrown = (BlockFlower)var0.setLightValue(2.0F / 16.0F); + var10000 = (new BlockMushroom(40, 28)).setHardness(0.0F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + mushroomRed = (BlockFlower)var0; + var10000 = (new BlockOreBlock(41, 39)).setHardness(3.0F).setResistance(10.0F); + var1 = soundMetalFootstep; + var0 = var10000; + var0.stepSound = var1; + blockGold = var0; + var10000 = (new BlockOreBlock(42, 38)).setHardness(5.0F).setResistance(10.0F); + var1 = soundMetalFootstep; + var0 = var10000; + var0.stepSound = var1; + blockSteel = var0; + var10000 = (new BlockStep(43, true)).setHardness(2.0F).setResistance(10.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + stairDouble = var0; + var10000 = (new BlockStep(44, false)).setHardness(2.0F).setResistance(10.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + stairSingle = var0; + var10000 = (new Block(45, 7, Material.rock)).setHardness(2.0F).setResistance(10.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + brick = var0; + var10000 = (new BlockTNT(46, 8)).setHardness(0.0F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + tnt = var0; + var10000 = (new BlockBookshelf(47, 35)).setHardness(1.5F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + bookShelf = var0; + var10000 = (new Block(48, 36, Material.rock)).setHardness(2.0F).setResistance(10.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + cobblestoneMossy = var0; + var10000 = (new BlockStone(49, 37)).setHardness(10.0F).setResistance(10.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + obsidian = var0; + var10000 = (new BlockTorch(50, 80)).setHardness(0.0F).setLightValue(14.0F / 16.0F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + torch = var0; + var10000 = (new BlockFire(51, 31)).setHardness(0.0F).setLightValue(1.0F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + fire = (BlockFire)var0; + var10000 = (new BlockSource(52, waterMoving.blockID)).setHardness(0.0F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + waterSource = var0; + var10000 = (new BlockSource(53, lavaMoving.blockID)).setHardness(0.0F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + lavaSource = var0; + var10000 = (new BlockChest(54)).setHardness(2.5F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + crate = var0; + var10000 = (new BlockGears(55, 62)).setHardness(0.5F); + var1 = soundMetalFootstep; + var0 = var10000; + var0.stepSound = var1; + cog = var0; + var10000 = (new BlockOre(56, 50)).setHardness(3.0F).setResistance(5.0F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + oreDiamond = var0; + var10000 = (new BlockOreBlock(57, 40)).setHardness(5.0F).setResistance(10.0F); + var1 = soundMetalFootstep; + var0 = var10000; + var0.stepSound = var1; + blockDiamond = var0; + var10000 = (new BlockWorkbench(58)).setHardness(2.5F); + var1 = soundWoodFootstep; + var0 = var10000; + var0.stepSound = var1; + workbench = var0; + var10000 = (new BlockCrops(59, 88)).setHardness(0.0F); + var1 = soundGrassFootstep; + var0 = var10000; + var0.stepSound = var1; + crops = var0; + var10000 = (new BlockFarmland(60)).setHardness(0.6F); + var1 = soundGravelFootstep; + var0 = var10000; + var0.stepSound = var1; + tilledField = var0; + var10000 = (new BlockFurnace(61, false)).setHardness(3.5F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + stoneOvenIdle = var0; + var10000 = (new BlockFurnace(62, true)).setHardness(3.5F); + var1 = soundStoneFootstep; + var0 = var10000; + var0.stepSound = var1; + stoneOvenActive = var0.setLightValue(14.0F / 16.0F); + + for(int var2 = 0; var2 < 256; ++var2) { + if(blocksList[var2] != null) { + Item.itemsList[var2] = new ItemBlock(var2 - 256); + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockBookshelf.java b/src/teavm/java/net/minecraft/game/level/block/BlockBookshelf.java new file mode 100644 index 0000000..a97dcf0 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockBookshelf.java @@ -0,0 +1,18 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.material.Material; + +public final class BlockBookshelf extends Block { + public BlockBookshelf(int var1, int var2) { + super(47, 35, Material.wood); + } + + public final int getBlockTextureFromSide(int var1) { + return var1 <= 1 ? 4 : this.blockIndexInTexture; + } + + public final int quantityDropped(Random var1) { + return 0; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockBreakable.java b/src/teavm/java/net/minecraft/game/level/block/BlockBreakable.java new file mode 100644 index 0000000..6ec44f7 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockBreakable.java @@ -0,0 +1,22 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public class BlockBreakable extends Block { + private boolean localFlag; + + protected BlockBreakable(int var1, int var2, Material var3, boolean var4) { + super(var1, var2, var3); + this.localFlag = var4; + } + + public final boolean isOpaqueCube() { + return false; + } + + public final boolean shouldSideBeRendered(World var1, int var2, int var3, int var4, int var5) { + int var6 = var1.getBlockId(var2, var3, var4); + return !this.localFlag && var6 == this.blockID ? false : super.shouldSideBeRendered(var1, var2, var3, var4, var5); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockChest.java b/src/teavm/java/net/minecraft/game/level/block/BlockChest.java new file mode 100644 index 0000000..f64bfe4 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockChest.java @@ -0,0 +1,204 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.IInventory; +import net.minecraft.game.InventoryLargeChest; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.tileentity.TileEntity; +import net.minecraft.game.level.block.tileentity.TileEntityChest; +import net.minecraft.game.level.material.Material; + +public final class BlockChest extends BlockContainer { + private Random random = new Random(); + + protected BlockChest(int var1) { + super(54, Material.wood); + this.blockIndexInTexture = 26; + } + + public final int getBlockTexture(World var1, int var2, int var3, int var4, int var5) { + if(var5 == 1) { + return this.blockIndexInTexture - 1; + } else if(var5 == 0) { + return this.blockIndexInTexture - 1; + } else { + int var6 = var1.getBlockId(var2, var3, var4 - 1); + int var7 = var1.getBlockId(var2, var3, var4 + 1); + int var8 = var1.getBlockId(var2 - 1, var3, var4); + int var9 = var1.getBlockId(var2 + 1, var3, var4); + int var10; + int var11; + int var12; + byte var13; + if(var6 != this.blockID && var7 != this.blockID) { + if(var8 != this.blockID && var9 != this.blockID) { + byte var14 = 3; + if(Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var7]) { + var14 = 3; + } + + if(Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var6]) { + var14 = 2; + } + + if(Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var9]) { + var14 = 5; + } + + if(Block.opaqueCubeLookup[var9] && !Block.opaqueCubeLookup[var8]) { + var14 = 4; + } + + return var5 == var14 ? this.blockIndexInTexture + 1 : this.blockIndexInTexture; + } else if(var5 != 4 && var5 != 5) { + var10 = 0; + if(var8 == this.blockID) { + var10 = -1; + } + + var11 = var1.getBlockId(var8 == this.blockID ? var2 - 1 : var2 + 1, var3, var4 - 1); + var12 = var1.getBlockId(var8 == this.blockID ? var2 - 1 : var2 + 1, var3, var4 + 1); + if(var5 == 3) { + var10 = -1 - var10; + } + + var13 = 3; + if((Block.opaqueCubeLookup[var6] || Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var12]) { + var13 = 3; + } + + if((Block.opaqueCubeLookup[var7] || Block.opaqueCubeLookup[var12]) && !Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var11]) { + var13 = 2; + } + + return (var5 == var13 ? this.blockIndexInTexture + 16 : this.blockIndexInTexture + 32) + var10; + } else { + return this.blockIndexInTexture; + } + } else if(var5 != 2 && var5 != 3) { + var10 = 0; + if(var6 == this.blockID) { + var10 = -1; + } + + var11 = var1.getBlockId(var2 - 1, var3, var6 == this.blockID ? var4 - 1 : var4 + 1); + var12 = var1.getBlockId(var2 + 1, var3, var6 == this.blockID ? var4 - 1 : var4 + 1); + if(var5 == 4) { + var10 = -1 - var10; + } + + var13 = 5; + if((Block.opaqueCubeLookup[var8] || Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var9] && !Block.opaqueCubeLookup[var12]) { + var13 = 5; + } + + if((Block.opaqueCubeLookup[var9] || Block.opaqueCubeLookup[var12]) && !Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var11]) { + var13 = 4; + } + + return (var5 == var13 ? this.blockIndexInTexture + 16 : this.blockIndexInTexture + 32) + var10; + } else { + return this.blockIndexInTexture; + } + } + } + + public final int getBlockTextureFromSide(int var1) { + return var1 == 1 ? this.blockIndexInTexture - 1 : (var1 == 0 ? this.blockIndexInTexture - 1 : (var1 == 3 ? this.blockIndexInTexture + 1 : this.blockIndexInTexture)); + } + + public final boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) { + int var5 = 0; + if(var1.getBlockId(var2 - 1, var3, var4) == this.blockID) { + ++var5; + } + + if(var1.getBlockId(var2 + 1, var3, var4) == this.blockID) { + ++var5; + } + + if(var1.getBlockId(var2, var3, var4 - 1) == this.blockID) { + ++var5; + } + + if(var1.getBlockId(var2, var3, var4 + 1) == this.blockID) { + ++var5; + } + + return var5 > 1 ? false : (this.isThereANeighborChest(var1, var2 - 1, var3, var4) ? false : (this.isThereANeighborChest(var1, var2 + 1, var3, var4) ? false : (this.isThereANeighborChest(var1, var2, var3, var4 - 1) ? false : !this.isThereANeighborChest(var1, var2, var3, var4 + 1)))); + } + + private boolean isThereANeighborChest(World var1, int var2, int var3, int var4) { + return var1.getBlockId(var2, var3, var4) != this.blockID ? false : (var1.getBlockId(var2 - 1, var3, var4) == this.blockID ? true : (var1.getBlockId(var2 + 1, var3, var4) == this.blockID ? true : (var1.getBlockId(var2, var3, var4 - 1) == this.blockID ? true : var1.getBlockId(var2, var3, var4 + 1) == this.blockID))); + } + + public final void onBlockRemoval(World var1, int var2, int var3, int var4) { + TileEntityChest var5 = (TileEntityChest)var1.getBlockTileEntity(var2, var3, var4); + + for(int var6 = 0; var6 < var5.getSizeInventory(); ++var6) { + ItemStack var7 = var5.getStackInSlot(var6); + if(var7 != null) { + float var8 = this.random.nextFloat() * 0.8F + 0.1F; + float var9 = this.random.nextFloat() * 0.8F + 0.1F; + float var10 = this.random.nextFloat() * 0.8F + 0.1F; + + while(var7.stackSize > 0) { + int var11 = this.random.nextInt(21) + 10; + if(var11 > var7.stackSize) { + var11 = var7.stackSize; + } + + var7.stackSize -= var11; + EntityItem var12 = new EntityItem(var1, (float)var2 + var8, (float)var3 + var9, (float)var4 + var10, new ItemStack(var7.itemID, var11, var7.itemDamage)); + var12.motionX = (float)this.random.nextGaussian() * 0.05F; + var12.motionY = (float)this.random.nextGaussian() * 0.05F + 0.2F; + var12.motionZ = (float)this.random.nextGaussian() * 0.05F; + var1.spawnEntityInWorld(var12); + } + } + } + + super.onBlockRemoval(var1, var2, var3, var4); + } + + public final boolean blockActivated(World var1, int var2, int var3, int var4, EntityPlayer var5) { + Object var6 = (TileEntityChest)var1.getBlockTileEntity(var2, var3, var4); + if(var1.isBlockNormalCube(var2, var3 + 1, var4)) { + return true; + } else if(var1.getBlockId(var2 - 1, var3, var4) == this.blockID && var1.isBlockNormalCube(var2 - 1, var3 + 1, var4)) { + return true; + } else if(var1.getBlockId(var2 + 1, var3, var4) == this.blockID && var1.isBlockNormalCube(var2 + 1, var3 + 1, var4)) { + return true; + } else if(var1.getBlockId(var2, var3, var4 - 1) == this.blockID && var1.isBlockNormalCube(var2, var3 + 1, var4 - 1)) { + return true; + } else if(var1.getBlockId(var2, var3, var4 + 1) == this.blockID && var1.isBlockNormalCube(var2, var3 + 1, var4 + 1)) { + return true; + } else { + if(var1.getBlockId(var2 - 1, var3, var4) == this.blockID) { + var6 = new InventoryLargeChest("Large chest", (TileEntityChest)var1.getBlockTileEntity(var2 - 1, var3, var4), (IInventory)var6); + } + + if(var1.getBlockId(var2 + 1, var3, var4) == this.blockID) { + var6 = new InventoryLargeChest("Large chest", (IInventory)var6, (TileEntityChest)var1.getBlockTileEntity(var2 + 1, var3, var4)); + } + + if(var1.getBlockId(var2, var3, var4 - 1) == this.blockID) { + var6 = new InventoryLargeChest("Large chest", (TileEntityChest)var1.getBlockTileEntity(var2, var3, var4 - 1), (IInventory)var6); + } + + if(var1.getBlockId(var2, var3, var4 + 1) == this.blockID) { + var6 = new InventoryLargeChest("Large chest", (IInventory)var6, (TileEntityChest)var1.getBlockTileEntity(var2, var3, var4 + 1)); + } + + var5.displayGUIChest((IInventory)var6); + return true; + } + } + + protected final TileEntity getBlockEntity() { + return new TileEntityChest(); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockContainer.java b/src/teavm/java/net/minecraft/game/level/block/BlockContainer.java new file mode 100644 index 0000000..cf5b7be --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockContainer.java @@ -0,0 +1,23 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.tileentity.TileEntity; +import net.minecraft.game.level.material.Material; + +public abstract class BlockContainer extends Block { + protected BlockContainer(int var1, Material var2) { + super(var1, var2); + } + + public void onBlockAdded(World var1, int var2, int var3, int var4) { + super.onBlockAdded(var1, var2, var3, var4); + var1.setBlockTileEntity(var2, var3, var4, this.getBlockEntity()); + } + + public void onBlockRemoval(World var1, int var2, int var3, int var4) { + super.onBlockRemoval(var1, var2, var3, var4); + var1.removeBlockTileEntity(var2, var3, var4); + } + + protected abstract TileEntity getBlockEntity(); +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockCrops.java b/src/teavm/java/net/minecraft/game/level/block/BlockCrops.java new file mode 100644 index 0000000..8a0d69c --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockCrops.java @@ -0,0 +1,111 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.entity.misc.EntityItem; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; + +public final class BlockCrops extends BlockFlower { + protected BlockCrops(int var1, int var2) { + super(59, 88); + this.blockIndexInTexture = 88; + this.setTickOnLoad(true); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); + } + + protected final boolean canThisPlantGrowOnThisBlockID(int var1) { + return var1 == Block.tilledField.blockID; + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + super.updateTick(var1, var2, var3, var4, var5); + if(var1.getBlockLightValue(var2, var3 + 1, var4) >= 9) { + byte var6 = var1.getBlockMetadata(var2, var3, var4); + if(var6 < 7) { + int var11 = var4; + int var10 = var3; + int var9 = var2; + World var8 = var1; + float var12 = 1.0F; + int var13 = var1.getBlockId(var2, var3, var4 - 1); + int var14 = var1.getBlockId(var2, var3, var4 + 1); + int var15 = var1.getBlockId(var2 - 1, var3, var4); + int var16 = var1.getBlockId(var2 + 1, var3, var4); + int var17 = var1.getBlockId(var2 - 1, var3, var4 - 1); + int var18 = var1.getBlockId(var2 + 1, var3, var4 - 1); + int var19 = var1.getBlockId(var2 + 1, var3, var4 + 1); + int var20 = var1.getBlockId(var2 - 1, var3, var4 + 1); + boolean var23 = var15 == this.blockID || var16 == this.blockID; + boolean var22 = var13 == this.blockID || var14 == this.blockID; + boolean var7 = var17 == this.blockID || var18 == this.blockID || var19 == this.blockID || var20 == this.blockID; + + for(var14 = var2 - 1; var14 <= var9 + 1; ++var14) { + for(var16 = var11 - 1; var16 <= var11 + 1; ++var16) { + var17 = var8.getBlockId(var14, var10 - 1, var16); + float var24 = 0.0F; + if(var17 == Block.tilledField.blockID) { + var24 = 1.0F; + if(var8.getBlockMetadata(var14, var10 - 1, var16) > 0) { + var24 = 3.0F; + } + } + + if(var14 != var9 || var16 != var11) { + var24 /= 4.0F; + } + + var12 += var24; + } + } + + if(var7 || var23 && var22) { + var12 /= 2.0F; + } + + if(var5.nextInt((int)(100.0F / var12)) == 0) { + int var21 = var6 + 1; + var1.setBlockMetadata(var2, var3, var4, var21); + } + } + } + + } + + public final int getBlockTextureFromSideAndMetadata(int var1, int var2) { + if(var2 < 0) { + var2 = 7; + } + + return this.blockIndexInTexture + var2; + } + + public final int getRenderType() { + return 6; + } + + public final void onBlockDestroyedByPlayer(World var1, int var2, int var3, int var4, int var5) { + super.onBlockDestroyedByPlayer(var1, var2, var3, var4, var5); + + for(int var6 = 0; var6 < 3; ++var6) { + if(var1.random.nextInt(15) <= var5) { + float var7 = var1.random.nextFloat() * 0.7F + 0.15F; + float var8 = var1.random.nextFloat() * 0.7F + 0.15F; + float var9 = var1.random.nextFloat() * 0.7F + 0.15F; + EntityItem var10 = new EntityItem(var1, (float)var2 + var7, (float)var3 + var8, (float)var4 + var9, new ItemStack(Item.seeds)); + var10.delayBeforeCanPickup = 10; + var1.spawnEntityInWorld(var10); + } + } + + } + + public final int idDropped(int var1, Random var2) { + System.out.println("Get resource: " + var1); + return var1 == 7 ? Item.wheat.shiftedIndex : -1; + } + + public final int quantityDropped(Random var1) { + return 1; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockDirt.java b/src/teavm/java/net/minecraft/game/level/block/BlockDirt.java new file mode 100644 index 0000000..ed5e942 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockDirt.java @@ -0,0 +1,9 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.level.material.Material; + +public final class BlockDirt extends Block { + protected BlockDirt(int var1, int var2) { + super(3, 2, Material.ground); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockFarmland.java b/src/teavm/java/net/minecraft/game/level/block/BlockFarmland.java new file mode 100644 index 0000000..84a4b31 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockFarmland.java @@ -0,0 +1,123 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public final class BlockFarmland extends Block { + protected BlockFarmland(int var1) { + super(60, Material.ground); + this.blockIndexInTexture = 87; + this.setTickOnLoad(true); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 15.0F / 16.0F, 1.0F); + this.setLightOpacity(255); + } + + public final AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return new AxisAlignedBB((float)var1, (float)var2, (float)var3, (float)(var1 + 1), (float)(var2 + 1), (float)(var3 + 1)); + } + + public final boolean isOpaqueCube() { + return false; + } + + public final boolean renderAsNormalBlock() { + return false; + } + + public final int getBlockTextureFromSideAndMetadata(int var1, int var2) { + return var1 == 1 && var2 > 0 ? this.blockIndexInTexture - 1 : (var1 == 1 ? this.blockIndexInTexture : 2); + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + if(var5.nextInt(5) == 0) { + int var8 = var4; + int var7 = var3; + int var6 = var2; + World var12 = var1; + int var9 = var2 - 4; + + int var10; + int var11; + boolean var10000; + label69: + while(true) { + if(var9 > var6 + 4) { + var10000 = false; + break; + } + + for(var10 = var7; var10 <= var7 + 1; ++var10) { + for(var11 = var8 - 4; var11 <= var8 + 4; ++var11) { + if(var12.getBlockMaterial(var9, var10, var11) == Material.water) { + var10000 = true; + break label69; + } + } + } + + ++var9; + } + + if(var10000) { + var1.setBlockMetadata(var2, var3, var4, 7); + return; + } + + byte var13 = var1.getBlockMetadata(var2, var3, var4); + if(var13 > 0) { + var1.setBlockMetadata(var2, var3, var4, var13 - 1); + return; + } + + var8 = var4; + var7 = var3; + var6 = var2; + var12 = var1; + var10 = var2; + + label49: + while(true) { + if(var10 > var6) { + var10000 = false; + break; + } + + for(var11 = var8; var11 <= var8; ++var11) { + if(var12.getBlockId(var10, var7 + 1, var11) == Block.crops.blockID) { + var10000 = true; + break label49; + } + } + + ++var10; + } + + if(!var10000) { + var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID); + } + } + + } + + public final void onEntityWalking(World var1, int var2, int var3, int var4) { + if(var1.random.nextInt(4) == 0) { + var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID); + } + + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + super.onNeighborBlockChange(var1, var2, var3, var4, var5); + Material var6 = var1.getBlockMaterial(var2, var3 + 1, var4); + if(var6.isSolid()) { + var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID); + } + + } + + public final int idDropped(int var1, Random var2) { + return Block.dirt.idDropped(0, var2); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockFire.java b/src/teavm/java/net/minecraft/game/level/block/BlockFire.java new file mode 100644 index 0000000..7a057b2 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockFire.java @@ -0,0 +1,272 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public final class BlockFire extends Block { + private int[] chanceToEncourageFire = new int[256]; + private int[] abilityToCatchFire = new int[256]; + + protected BlockFire(int var1, int var2) { + super(51, 31, Material.fire); + this.setBurnRate(Block.planks.blockID, 5, 20); + this.setBurnRate(Block.wood.blockID, 5, 5); + this.setBurnRate(Block.leaves.blockID, 30, 60); + this.setBurnRate(Block.bookShelf.blockID, 30, 20); + this.setBurnRate(Block.tnt.blockID, 15, 100); + + for(var1 = 0; var1 < 16; ++var1) { + this.setBurnRate(Block.clothRed.blockID + var1, 30, 60); + } + + this.setTickOnLoad(true); + } + + private void setBurnRate(int var1, int var2, int var3) { + this.chanceToEncourageFire[var1] = var2; + this.abilityToCatchFire[var1] = var3; + } + + public final AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return null; + } + + public final boolean isOpaqueCube() { + return false; + } + + public final boolean renderAsNormalBlock() { + return false; + } + + public final int getRenderType() { + return 3; + } + + public final int quantityDropped(Random var1) { + return 0; + } + + public final int tickRate() { + return 20; + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + byte var6 = var1.getBlockMetadata(var2, var3, var4); + if(var6 < 15) { + var1.setBlockMetadata(var2, var3, var4, var6 + 1); + var1.scheduleBlockUpdate(var2, var3, var4, this.blockID); + } + + if(!this.canNeighborCatchFire(var1, var2, var3, var4)) { + if(!var1.isBlockNormalCube(var2, var3 - 1, var4) || var6 > 3) { + var1.setBlockWithNotify(var2, var3, var4, 0); + } + + } else if(!this.canBlockCatchFire(var1, var2, var3 - 1, var4) && var6 == 15 && var5.nextInt(4) == 0) { + var1.setBlockWithNotify(var2, var3, var4, 0); + } else { + if(var6 % 5 == 0 && var6 > 5) { + this.tryToCatchBlockOnFire(var1, var2 + 1, var3, var4, 300, var5); + this.tryToCatchBlockOnFire(var1, var2 - 1, var3, var4, 300, var5); + this.tryToCatchBlockOnFire(var1, var2, var3 - 1, var4, 100, var5); + this.tryToCatchBlockOnFire(var1, var2, var3 + 1, var4, 200, var5); + this.tryToCatchBlockOnFire(var1, var2, var3, var4 - 1, 300, var5); + this.tryToCatchBlockOnFire(var1, var2, var3, var4 + 1, 300, var5); + + for(int var16 = var2 - 1; var16 <= var2 + 1; ++var16) { + for(int var7 = var4 - 1; var7 <= var4 + 1; ++var7) { + for(int var8 = var3 - 1; var8 <= var3 + 4; ++var8) { + if(var16 != var2 || var8 != var3 || var7 != var4) { + int var9 = 100; + if(var8 > var3 + 1) { + var9 = 100 + (var8 - (var3 + 1)) * 100; + } + + int var10000; + if(var1.getBlockId(var16, var8, var7) != 0) { + var10000 = 0; + } else { + int var15 = this.getChanceToEncourageFire(var1, var16 + 1, var8, var7, 0); + var15 = this.getChanceToEncourageFire(var1, var16 - 1, var8, var7, var15); + var15 = this.getChanceToEncourageFire(var1, var16, var8 - 1, var7, var15); + var15 = this.getChanceToEncourageFire(var1, var16, var8 + 1, var7, var15); + var15 = this.getChanceToEncourageFire(var1, var16, var8, var7 - 1, var15); + var15 = this.getChanceToEncourageFire(var1, var16, var8, var7 + 1, var15); + var10000 = var15; + } + + int var10 = var10000; + if(var10 > 0 && var5.nextInt(var9) <= var10) { + var1.setBlockWithNotify(var16, var8, var7, this.blockID); + } + } + } + } + } + } + + } + } + + private void tryToCatchBlockOnFire(World var1, int var2, int var3, int var4, int var5, Random var6) { + int var7 = this.abilityToCatchFire[var1.getBlockId(var2, var3, var4)]; + if(var6.nextInt(var5) < var7) { + boolean var8 = var1.getBlockId(var2, var3, var4) == Block.tnt.blockID; + if(var6.nextInt(2) == 0) { + var1.setBlockWithNotify(var2, var3, var4, this.blockID); + } else { + var1.setBlockWithNotify(var2, var3, var4, 0); + } + + if(var8) { + Block.tnt.onBlockDestroyedByPlayer(var1, var2, var3, var4, 0); + } + } + + } + + private boolean canNeighborCatchFire(World var1, int var2, int var3, int var4) { + return this.canBlockCatchFire(var1, var2 + 1, var3, var4) ? true : (this.canBlockCatchFire(var1, var2 - 1, var3, var4) ? true : (this.canBlockCatchFire(var1, var2, var3 - 1, var4) ? true : (this.canBlockCatchFire(var1, var2, var3 + 1, var4) ? true : (this.canBlockCatchFire(var1, var2, var3, var4 - 1) ? true : this.canBlockCatchFire(var1, var2, var3, var4 + 1))))); + } + + public final boolean isCollidable() { + return false; + } + + public final boolean canBlockCatchFire(World var1, int var2, int var3, int var4) { + return this.chanceToEncourageFire[var1.getBlockId(var2, var3, var4)] > 0; + } + + private int getChanceToEncourageFire(World var1, int var2, int var3, int var4, int var5) { + int var6 = this.chanceToEncourageFire[var1.getBlockId(var2, var3, var4)]; + return var6 > var5 ? var6 : var5; + } + + public final boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) { + return var1.isBlockNormalCube(var2, var3 - 1, var4) || this.canNeighborCatchFire(var1, var2, var3, var4); + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + if(!var1.isBlockNormalCube(var2, var3 - 1, var4) && !this.canNeighborCatchFire(var1, var2, var3, var4)) { + var1.setBlockWithNotify(var2, var3, var4, 0); + } + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + if(!var1.isBlockNormalCube(var2, var3 - 1, var4) && !this.canNeighborCatchFire(var1, var2, var3, var4)) { + var1.setBlockWithNotify(var2, var3, var4, 0); + } else { + var1.scheduleBlockUpdate(var2, var3, var4, this.blockID); + } + } + + public final boolean getChanceOfNeighborsEncouragingFire(int var1) { + return this.chanceToEncourageFire[var1] > 0; + } + + public final void fireSpread(World var1, int var2, int var3, int var4) { + boolean var5 = false; + var5 = fireCheck(var1, var2, var3 + 1, var4); + if(!var5) { + var5 = fireCheck(var1, var2 - 1, var3, var4); + } + + if(!var5) { + var5 = fireCheck(var1, var2 + 1, var3, var4); + } + + if(!var5) { + var5 = fireCheck(var1, var2, var3, var4 - 1); + } + + if(!var5) { + var5 = fireCheck(var1, var2, var3, var4 + 1); + } + + if(!var5) { + var5 = fireCheck(var1, var2, var3 - 1, var4); + } + + if(!var5) { + var1.setBlockWithNotify(var2, var3, var4, Block.fire.blockID); + } + + } + + public final void randomDisplayTick(World var1, int var2, int var3, int var4, Random var5) { + int var6; + float var7; + float var8; + float var9; + if(!var1.isBlockNormalCube(var2, var3 - 1, var4) && !Block.fire.canBlockCatchFire(var1, var2, var3 - 1, var4)) { + if(Block.fire.canBlockCatchFire(var1, var2 - 1, var3, var4)) { + for(var6 = 0; var6 < 2; ++var6) { + var7 = (float)var2 + var5.nextFloat() * 0.1F; + var8 = (float)var3 + var5.nextFloat(); + var9 = (float)var4 + var5.nextFloat(); + var1.spawnParticle("largesmoke", var7, var8, var9, 0.0F, 0.0F, 0.0F); + } + } + + if(Block.fire.canBlockCatchFire(var1, var2 + 1, var3, var4)) { + for(var6 = 0; var6 < 2; ++var6) { + var7 = (float)(var2 + 1) - var5.nextFloat() * 0.1F; + var8 = (float)var3 + var5.nextFloat(); + var9 = (float)var4 + var5.nextFloat(); + var1.spawnParticle("largesmoke", var7, var8, var9, 0.0F, 0.0F, 0.0F); + } + } + + if(Block.fire.canBlockCatchFire(var1, var2, var3, var4 - 1)) { + for(var6 = 0; var6 < 2; ++var6) { + var7 = (float)var2 + var5.nextFloat(); + var8 = (float)var3 + var5.nextFloat(); + var9 = (float)var4 + var5.nextFloat() * 0.1F; + var1.spawnParticle("largesmoke", var7, var8, var9, 0.0F, 0.0F, 0.0F); + } + } + + if(Block.fire.canBlockCatchFire(var1, var2, var3, var4 + 1)) { + for(var6 = 0; var6 < 2; ++var6) { + var7 = (float)var2 + var5.nextFloat(); + var8 = (float)var3 + var5.nextFloat(); + var9 = (float)(var4 + 1) - var5.nextFloat() * 0.1F; + var1.spawnParticle("largesmoke", var7, var8, var9, 0.0F, 0.0F, 0.0F); + } + } + + if(Block.fire.canBlockCatchFire(var1, var2, var3 + 1, var4)) { + for(var6 = 0; var6 < 2; ++var6) { + var7 = (float)var2 + var5.nextFloat(); + var8 = (float)(var3 + 1) - var5.nextFloat() * 0.1F; + var9 = (float)var4 + var5.nextFloat(); + var1.spawnParticle("largesmoke", var7, var8, var9, 0.0F, 0.0F, 0.0F); + } + } + + } else { + for(var6 = 0; var6 < 3; ++var6) { + var7 = (float)var2 + var5.nextFloat(); + var8 = (float)var3 + var5.nextFloat() * 0.5F + 0.5F; + var9 = (float)var4 + var5.nextFloat(); + var1.spawnParticle("largesmoke", var7, var8, var9, 0.0F, 0.0F, 0.0F); + } + + } + } + + private static boolean fireCheck(World var0, int var1, int var2, int var3) { + int var4 = var0.getBlockId(var1, var2, var3); + if(var4 == Block.fire.blockID) { + return true; + } else if(var4 == 0) { + var0.setBlockWithNotify(var1, var2, var3, Block.fire.blockID); + return true; + } else { + return false; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockFlower.java b/src/teavm/java/net/minecraft/game/level/block/BlockFlower.java new file mode 100644 index 0000000..9a88615 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockFlower.java @@ -0,0 +1,60 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public class BlockFlower extends Block { + protected BlockFlower(int var1, int var2) { + super(var1, Material.plants); + this.blockIndexInTexture = var2; + this.setTickOnLoad(true); + this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F); + } + + public final boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) { + return this.canThisPlantGrowOnThisBlockID(var1.getBlockId(var2, var3 - 1, var4)); + } + + protected boolean canThisPlantGrowOnThisBlockID(int var1) { + return var1 == Block.grass.blockID || var1 == Block.dirt.blockID || var1 == Block.tilledField.blockID; + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + super.onNeighborBlockChange(var1, var2, var3, var4, var5); + this.checkFlowerChange(var1, var2, var3, var4); + } + + public void updateTick(World var1, int var2, int var3, int var4, Random var5) { + this.checkFlowerChange(var1, var2, var3, var4); + } + + private void checkFlowerChange(World var1, int var2, int var3, int var4) { + if(!this.canBlockStay(var1, var2, var3, var4)) { + this.dropBlockAsItem(var1, var2, var3, var4, var1.getBlockMetadata(var2, var3, var4)); + var1.setBlockWithNotify(var2, var3, var4, 0); + } + + } + + public boolean canBlockStay(World var1, int var2, int var3, int var4) { + return (var1.getBlockLightValue(var2, var3, var4) >= 8 || var1.getBlockLightValue(var2, var3, var4) >= 4 && var1.canBlockSeeTheSky(var2, var3, var4)) && this.canThisPlantGrowOnThisBlockID(var1.getBlockId(var2, var3 - 1, var4)); + } + + public final AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return null; + } + + public final boolean isOpaqueCube() { + return false; + } + + public final boolean renderAsNormalBlock() { + return false; + } + + public int getRenderType() { + return 1; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockFlowing.java b/src/teavm/java/net/minecraft/game/level/block/BlockFlowing.java new file mode 100644 index 0000000..6e5ea43 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockFlowing.java @@ -0,0 +1,241 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public final class BlockFlowing extends BlockFluid { + private int stillId1; + private int movingId1; + private Random rand = new Random(); + private int[] liquidIntArray = new int[]{0, 1, 2, 3}; + + protected BlockFlowing(int var1, Material var2) { + super(var1, var2); + this.blockIndexInTexture = 14; + if(var2 == Material.lava) { + this.blockIndexInTexture = 30; + } + + Block.isBlockFluid[var1] = true; + this.movingId1 = var1; + this.stillId1 = var1 + 1; + this.setBlockBounds(0.01F, -0.09F, 0.01F, 1.01F, 0.90999997F, 1.01F); + this.setTickOnLoad(true); + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + var1.scheduleBlockUpdate(var2, var3, var4, this.movingId1); + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + this.update(var1, var2, var3, var4, 0); + } + + public final boolean update(World var1, int var2, int var3, int var4, int var5) { + boolean var10 = false; + boolean var6 = this.canFlow(var1, var2 - 1, var3, var4) || this.canFlow(var1, var2 + 1, var3, var4) || this.canFlow(var1, var2, var3, var4 - 1) || this.canFlow(var1, var2, var3, var4 + 1); + int var7; + int var8; + int var9; + if(var6 && var1.getBlockMaterial(var2, var3 - 1, var4) == this.material) { + var5 = var1.floodFill(var2, var3 - 1, var4, this.movingId1, this.stillId1); + if(var5 == 1) { + var7 = var1.fluidFlowCheck(var2, var3, var4, this.movingId1, this.stillId1); + if(var7 != -9999) { + if(var7 < 0) { + return false; + } + + var8 = var7 % 1024; + var7 >>= 10; + var9 = var7 % 1024; + var7 >>= 10; + var2 = var7 % 1024; + var1.setBlockWithNotify(var8, var2, var9, 0); + return false; + } + + return false; + } + } + + var10 = this.liquidSpread2(var1, var2, var3, var4, var2, var3 - 1, var4); + + for(var7 = 0; var7 < 4; ++var7) { + var8 = this.rand.nextInt(4 - var7) + var7; + var9 = this.liquidIntArray[var7]; + this.liquidIntArray[var7] = this.liquidIntArray[var8]; + this.liquidIntArray[var8] = var9; + if(this.liquidIntArray[var7] == 0 && !var10) { + var10 = this.liquidSpread2(var1, var2, var3, var4, var2 - 1, var3, var4); + } + + if(this.liquidIntArray[var7] == 1 && !var10) { + var10 = this.liquidSpread2(var1, var2, var3, var4, var2 + 1, var3, var4); + } + + if(this.liquidIntArray[var7] == 2 && !var10) { + var10 = this.liquidSpread2(var1, var2, var3, var4, var2, var3, var4 - 1); + } + + if(this.liquidIntArray[var7] == 3 && !var10) { + var10 = this.liquidSpread2(var1, var2, var3, var4, var2, var3, var4 + 1); + } + } + + if(!var10 && var6) { + if(this.rand.nextInt(3) == 0) { + if(this.rand.nextInt(3) == 0) { + var10 = false; + + for(var7 = 0; var7 < 4; ++var7) { + var8 = this.rand.nextInt(4 - var7) + var7; + var9 = this.liquidIntArray[var7]; + this.liquidIntArray[var7] = this.liquidIntArray[var8]; + this.liquidIntArray[var8] = var9; + if(this.liquidIntArray[var7] == 0 && !var10) { + var10 = this.liquidSpread(var1, var2, var3, var4, var2 - 1, var3, var4); + } + + if(this.liquidIntArray[var7] == 1 && !var10) { + var10 = this.liquidSpread(var1, var2, var3, var4, var2 + 1, var3, var4); + } + + if(this.liquidIntArray[var7] == 2 && !var10) { + var10 = this.liquidSpread(var1, var2, var3, var4, var2, var3, var4 - 1); + } + + if(this.liquidIntArray[var7] == 3 && !var10) { + var10 = this.liquidSpread(var1, var2, var3, var4, var2, var3, var4 + 1); + } + } + } else if(this.material == Material.lava) { + var1.setBlockWithNotify(var2, var3, var4, Block.stone.blockID); + } else { + var1.setBlockWithNotify(var2, var3, var4, 0); + } + } + + return false; + } else { + if(this.material == Material.water) { + var10 |= extinguishFireLava(var1, var2 - 1, var3, var4); + var10 |= extinguishFireLava(var1, var2 + 1, var3, var4); + var10 |= extinguishFireLava(var1, var2, var3, var4 - 1); + var10 |= extinguishFireLava(var1, var2, var3, var4 + 1); + } + + if(this.material == Material.lava) { + var10 |= flow(var1, var2 - 1, var3, var4); + var10 |= flow(var1, var2 + 1, var3, var4); + var10 |= flow(var1, var2, var3, var4 - 1); + var10 |= flow(var1, var2, var3, var4 + 1); + } + + if(!var10) { + var1.setTileNoUpdate(var2, var3, var4, this.stillId1); + } else { + var1.scheduleBlockUpdate(var2, var3, var4, this.movingId1); + } + + return var10; + } + } + + private boolean liquidSpread(World var1, int var2, int var3, int var4, int var5, int var6, int var7) { + if(this.canFlow(var1, var5, var6, var7)) { + var1.setBlockWithNotify(var5, var6, var7, this.blockID); + var1.scheduleBlockUpdate(var5, var6, var7, this.blockID); + return true; + } else { + return false; + } + } + + private boolean liquidSpread2(World var1, int var2, int var3, int var4, int var5, int var6, int var7) { + if(!this.canFlow(var1, var5, var6, var7)) { + return false; + } else { + var2 = var1.fluidFlowCheck(var2, var3, var4, this.movingId1, this.stillId1); + if(var2 != -9999) { + if(var2 < 0) { + return false; + } + + var3 = var2 % 1024; + var2 >>= 10; + var4 = var2 % 1024; + var2 >>= 10; + var2 %= 1024; + if((var2 > var6 || !this.canFlow(var1, var5, var6 - 1, var7)) && var2 <= var6 && var3 != 0 && var3 != var1.width - 1 && var4 != 0 && var4 != var1.length - 1) { + return false; + } + + var1.setBlockWithNotify(var3, var2, var4, 0); + } + + var1.setBlockWithNotify(var5, var6, var7, this.blockID); + var1.scheduleBlockUpdate(var5, var6, var7, this.blockID); + return true; + } + } + + public final boolean shouldSideBeRendered(World var1, int var2, int var3, int var4, int var5) { + if(var2 >= 0 && var3 >= 0 && var4 >= 0 && var2 < var1.width && var4 < var1.length) { + int var6 = var1.getBlockId(var2, var3, var4); + return var6 != this.movingId1 && var6 != this.stillId1 ? (var5 != 1 || var1.getBlockId(var2 - 1, var3, var4) != 0 && var1.getBlockId(var2 + 1, var3, var4) != 0 && var1.getBlockId(var2, var3, var4 - 1) != 0 && var1.getBlockId(var2, var3, var4 + 1) != 0 ? super.shouldSideBeRendered(var1, var2, var3, var4, var5) : true) : false; + } else { + return false; + } + } + + public final boolean isCollidable() { + return false; + } + + public final AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return null; + } + + public final boolean isOpaqueCube() { + return false; + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + } + + public final int tickRate() { + return this.material == Material.lava ? 25 : 5; + } + + public final int quantityDropped(Random var1) { + return 0; + } + + public final int getRenderBlockPass() { + return this.material == Material.water ? 1 : 0; + } + + private static boolean extinguishFireLava(World var0, int var1, int var2, int var3) { + if(var0.getBlockId(var1, var2, var3) == Block.fire.blockID) { + var0.setBlockWithNotify(var1, var2, var3, 0); + return true; + } else if(var0.getBlockId(var1, var2, var3) != Block.lavaMoving.blockID && var0.getBlockId(var1, var2, var3) != Block.lavaStill.blockID) { + return false; + } else { + var0.setBlockWithNotify(var1, var2, var3, Block.stone.blockID); + return true; + } + } + + private static boolean flow(World var0, int var1, int var2, int var3) { + if(Block.fire.getChanceOfNeighborsEncouragingFire(var0.getBlockId(var1, var2, var3))) { + Block.fire.fireSpread(var0, var1, var2, var3); + return true; + } else { + return false; + } + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockFluid.java b/src/teavm/java/net/minecraft/game/level/block/BlockFluid.java new file mode 100644 index 0000000..60d50b2 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockFluid.java @@ -0,0 +1,215 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public class BlockFluid extends Block { + protected int stillId; + protected int movingId; + + protected BlockFluid(int var1, Material var2) { + super(var1, var2); + this.blockIndexInTexture = 14; + if(var2 == Material.lava) { + this.blockIndexInTexture = 30; + } + + Block.isBlockFluid[var1] = true; + this.movingId = var1; + this.stillId = var1 + 1; + this.setBlockBounds(0.01F, -0.09F, 0.01F, 1.01F, 0.90999997F, 1.01F); + this.setTickOnLoad(true); + this.setResistance(2.0F); + } + + public final int getBlockTextureFromSide(int var1) { + return this.material == Material.lava ? this.blockIndexInTexture : (var1 == 1 ? this.blockIndexInTexture : (var1 == 0 ? this.blockIndexInTexture : this.blockIndexInTexture + 32)); + } + + public final boolean renderAsNormalBlock() { + return false; + } + + public void onBlockAdded(World var1, int var2, int var3, int var4) { + var1.scheduleBlockUpdate(var2, var3, var4, this.movingId); + } + + public void updateTick(World var1, int var2, int var3, int var4, Random var5) { + this.update(var1, var2, var3, var4, 0); + } + + public boolean update(World var1, int var2, int var3, int var4, int var5) { + boolean var7 = false; + + boolean var6; + do { + --var3; + if(!this.canFlow(var1, var2, var3, var4)) { + break; + } + + var6 = var1.setBlockWithNotify(var2, var3, var4, this.movingId); + if(var6) { + var7 = true; + } + } while(var6 && this.material != Material.lava); + + ++var3; + if(this.material == Material.water || !var7) { + var7 |= this.flow(var1, var2 - 1, var3, var4); + var7 |= this.flow(var1, var2 + 1, var3, var4); + var7 |= this.flow(var1, var2, var3, var4 - 1); + var7 |= this.flow(var1, var2, var3, var4 + 1); + } + + if(this.material == Material.lava) { + var7 |= extinguishFireLava(var1, var2 - 1, var3, var4); + var7 |= extinguishFireLava(var1, var2 + 1, var3, var4); + var7 |= extinguishFireLava(var1, var2, var3, var4 - 1); + var7 |= extinguishFireLava(var1, var2, var3, var4 + 1); + } + + if(!var7) { + var1.setTileNoUpdate(var2, var3, var4, this.stillId); + } else { + var1.scheduleBlockUpdate(var2, var3, var4, this.movingId); + } + + return var7; + } + + protected final boolean canFlow(World var1, int var2, int var3, int var4) { + if(!var1.getBlockMaterial(var2, var3, var4).liquidSolidCheck()) { + return false; + } else { + if(this.material == Material.water) { + for(int var5 = var2 - 2; var5 <= var2 + 2; ++var5) { + for(int var6 = var3 - 2; var6 <= var3 + 2; ++var6) { + for(int var7 = var4 - 2; var7 <= var4 + 2; ++var7) { + if(var1.getBlockId(var5, var6, var7) == Block.sponge.blockID) { + return false; + } + } + } + } + } + + return true; + } + } + + private static boolean extinguishFireLava(World var0, int var1, int var2, int var3) { + if(Block.fire.getChanceOfNeighborsEncouragingFire(var0.getBlockId(var1, var2, var3))) { + Block.fire.fireSpread(var0, var1, var2, var3); + return true; + } else { + return false; + } + } + + private boolean flow(World var1, int var2, int var3, int var4) { + if(!this.canFlow(var1, var2, var3, var4)) { + return false; + } else { + boolean var5 = var1.setBlockWithNotify(var2, var3, var4, this.movingId); + if(var5) { + var1.scheduleBlockUpdate(var2, var3, var4, this.movingId); + } + + return false; + } + } + + public final float getBlockBrightness(World var1, int var2, int var3, int var4) { + return this.material == Material.lava ? 100.0F : var1.getLightBrightness(var2, var3, var4); + } + + public boolean shouldSideBeRendered(World var1, int var2, int var3, int var4, int var5) { + if(var2 >= 0 && var3 >= 0 && var4 >= 0 && var2 < var1.width && var4 < var1.length) { + int var6 = var1.getBlockId(var2, var3, var4); + return var6 != this.movingId && var6 != this.stillId ? (var5 != 1 || var1.getBlockId(var2 - 1, var3, var4) != 0 && var1.getBlockId(var2 + 1, var3, var4) != 0 && var1.getBlockId(var2, var3, var4 - 1) != 0 && var1.getBlockId(var2, var3, var4 + 1) != 0 ? super.shouldSideBeRendered(var1, var2, var3, var4, var5) : true) : false; + } else { + return false; + } + } + + public boolean isCollidable() { + return false; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return null; + } + + public boolean isOpaqueCube() { + return false; + } + + public void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + if(var5 != 0) { + Material var6 = Block.blocksList[var5].material; + if(this.material == Material.water && var6 == Material.lava || var6 == Material.water && this.material == Material.lava) { + var1.setBlockWithNotify(var2, var3, var4, Block.stone.blockID); + } + } + + var1.scheduleBlockUpdate(var2, var3, var4, this.blockID); + } + + public int tickRate() { + return this.material == Material.lava ? 25 : 5; + } + + public int quantityDropped(Random var1) { + return 0; + } + + public int getRenderBlockPass() { + return this.material == Material.water ? 1 : 0; + } + + public final void randomDisplayTick(World var1, int var2, int var3, int var4, Random var5) { + if(this.material == Material.lava && var1.getBlockMaterial(var2, var3 + 1, var4) == Material.air && !var1.isBlockNormalCube(var2, var3 + 1, var4) && var5.nextInt(100) == 0) { + float var6 = (float)var2 + var5.nextFloat(); + float var7 = (float)var3 + this.maxY; + float var8 = (float)var4 + var5.nextFloat(); + var1.spawnParticle("lava", var6, var7, var8, 0.0F, 0.0F, 0.0F); + } + + if(this.material == Material.water) { + int var9; + if(liquidAirCheck(var1, var2 + 1, var3, var4)) { + for(var9 = 0; var9 < 4; ++var9) { + var1.spawnParticle("splash", (float)(var2 + 1) + 2.0F / 16.0F, (float)var3, (float)var4 + var5.nextFloat(), 0.0F, 0.0F, 0.0F); + } + } + + if(liquidAirCheck(var1, var2 - 1, var3, var4)) { + for(var9 = 0; var9 < 4; ++var9) { + var1.spawnParticle("splash", (float)var2 - 2.0F / 16.0F, (float)var3, (float)var4 + var5.nextFloat(), 0.0F, 0.0F, 0.0F); + } + } + + if(liquidAirCheck(var1, var2, var3, var4 + 1)) { + for(var9 = 0; var9 < 4; ++var9) { + var1.spawnParticle("splash", (float)var2 + var5.nextFloat(), (float)var3, (float)(var4 + 1) + 2.0F / 16.0F, 0.0F, 0.0F, 0.0F); + } + } + + if(liquidAirCheck(var1, var2, var3, var4 - 1)) { + for(var9 = 0; var9 < 4; ++var9) { + var1.spawnParticle("splash", (float)var2 + var5.nextFloat(), (float)var3, (float)var4 - 2.0F / 16.0F, 0.0F, 0.0F, 0.0F); + } + } + } + + } + + private static boolean liquidAirCheck(World var0, int var1, int var2, int var3) { + Material var4 = var0.getBlockMaterial(var1, var2, var3); + Material var5 = var0.getBlockMaterial(var1, var2 - 1, var3); + return !var4.getIsSolid() && !var4.getIsLiquid() ? var5.getIsSolid() || var5.getIsLiquid() : false; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockFurnace.java b/src/teavm/java/net/minecraft/game/level/block/BlockFurnace.java new file mode 100644 index 0000000..f17b593 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockFurnace.java @@ -0,0 +1,104 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.tileentity.TileEntity; +import net.minecraft.game.level.block.tileentity.TileEntityFurnace; +import net.minecraft.game.level.material.Material; + +public final class BlockFurnace extends BlockContainer { + private final boolean isActive; + + protected BlockFurnace(int var1, boolean var2) { + super(var1, Material.rock); + this.isActive = var2; + this.blockIndexInTexture = 45; + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + super.onBlockAdded(var1, var2, var3, var4); + setDefaultDirection(var1, var2, var3, var4); + } + + private static void setDefaultDirection(World var0, int var1, int var2, int var3) { + int var4 = var0.getBlockId(var1, var2, var3 - 1); + int var5 = var0.getBlockId(var1, var2, var3 + 1); + int var6 = var0.getBlockId(var1 - 1, var2, var3); + int var7 = var0.getBlockId(var1 + 1, var2, var3); + byte var8 = 3; + if(Block.opaqueCubeLookup[var4] && !Block.opaqueCubeLookup[var5]) { + var8 = 3; + } + + if(Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var4]) { + var8 = 2; + } + + if(Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var7]) { + var8 = 5; + } + + if(Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var6]) { + var8 = 4; + } + + var0.setBlockMetadata(var1, var2, var3, var8); + } + + public final int getBlockTexture(World var1, int var2, int var3, int var4, int var5) { + if(var5 == 1) { + return Block.stone.blockIndexInTexture; + } else if(var5 == 0) { + return Block.stone.blockIndexInTexture; + } else { + byte var6 = var1.getBlockMetadata(var2, var3, var4); + if(var6 == 0) { + setDefaultDirection(var1, var2, var3, var4); + var6 = var1.getBlockMetadata(var2, var3, var4); + } + + return var5 != var6 ? this.blockIndexInTexture : (this.isActive ? this.blockIndexInTexture + 16 : this.blockIndexInTexture - 1); + } + } + + public final void randomDisplayTick(World var1, int var2, int var3, int var4, Random var5) { + if(this.isActive) { + byte var6 = var1.getBlockMetadata(var2, var3, var4); + float var7 = (float)var2 + 0.5F; + float var8 = (float)var3 + var5.nextFloat() * 6.0F / 16.0F; + float var9 = (float)var4 + 0.5F; + float var10 = var5.nextFloat() * 0.6F - 0.3F; + if(var6 == 4) { + var1.spawnParticle("smoke", var7 - 0.52F, var8, var9 + var10, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var7 - 0.52F, var8, var9 + var10, 0.0F, 0.0F, 0.0F); + } else if(var6 == 5) { + var1.spawnParticle("smoke", var7 + 0.52F, var8, var9 + var10, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var7 + 0.52F, var8, var9 + var10, 0.0F, 0.0F, 0.0F); + } else if(var6 == 2) { + var1.spawnParticle("smoke", var7 + var10, var8, var9 - 0.52F, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var7 + var10, var8, var9 - 0.52F, 0.0F, 0.0F, 0.0F); + } else { + if(var6 == 3) { + var1.spawnParticle("smoke", var7 + var10, var8, var9 + 0.52F, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var7 + var10, var8, var9 + 0.52F, 0.0F, 0.0F, 0.0F); + } + + } + } + } + + public final int getBlockTextureFromSide(int var1) { + return var1 == 1 ? Block.stone.blockID : (var1 == 0 ? Block.stone.blockID : (var1 == 3 ? this.blockIndexInTexture - 1 : this.blockIndexInTexture)); + } + + public final boolean blockActivated(World var1, int var2, int var3, int var4, EntityPlayer var5) { + TileEntityFurnace var6 = (TileEntityFurnace)var1.getBlockTileEntity(var2, var3, var4); + var5.displayGUIFurnace(var6); + return true; + } + + protected final TileEntity getBlockEntity() { + return new TileEntityFurnace(); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockGears.java b/src/teavm/java/net/minecraft/game/level/block/BlockGears.java new file mode 100644 index 0000000..c43f929 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockGears.java @@ -0,0 +1,35 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; + +public final class BlockGears extends Block { + protected BlockGears(int var1, int var2) { + super(55, 62, Material.circuits); + } + + public final AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return null; + } + + public final boolean isOpaqueCube() { + return false; + } + + public final boolean renderAsNormalBlock() { + return false; + } + + public final int getRenderType() { + return 5; + } + + public final int quantityDropped(Random var1) { + return 1; + } + + public final boolean isCollidable() { + return false; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockGlass.java b/src/teavm/java/net/minecraft/game/level/block/BlockGlass.java new file mode 100644 index 0000000..4129c7d --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockGlass.java @@ -0,0 +1,14 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.material.Material; + +public final class BlockGlass extends BlockBreakable { + public BlockGlass(int var1, int var2, Material var3, boolean var4) { + super(20, 49, var3, false); + } + + public final int quantityDropped(Random var1) { + return 0; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockGrass.java b/src/teavm/java/net/minecraft/game/level/block/BlockGrass.java new file mode 100644 index 0000000..cef63b8 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockGrass.java @@ -0,0 +1,39 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockGrass extends Block { + protected BlockGrass(int var1) { + super(2, Material.ground); + this.blockIndexInTexture = 3; + this.setTickOnLoad(true); + } + + public final int getBlockTextureFromSide(int var1) { + return var1 == 1 ? 0 : (var1 == 0 ? 2 : 3); + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + if(var1.getBlockLightValue(var2, var3 + 1, var4) < 4 && var1.getBlockMaterial(var2, var3 + 1, var4).getCanBlockGrass()) { + if(var5.nextInt(4) == 0) { + var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID); + } + } else { + if(var1.getBlockLightValue(var2, var3 + 1, var4) >= 9) { + var2 = var2 + var5.nextInt(3) - 1; + var3 = var3 + var5.nextInt(5) - 3; + var4 = var4 + var5.nextInt(3) - 1; + if(var1.getBlockId(var2, var3, var4) == Block.dirt.blockID && var1.getBlockLightValue(var2, var3 + 1, var4) >= 4 && !var1.getBlockMaterial(var2, var3 + 1, var4).getCanBlockGrass()) { + var1.setBlockWithNotify(var2, var3, var4, Block.grass.blockID); + } + } + + } + } + + public final int idDropped(int var1, Random var2) { + return Block.dirt.idDropped(0, var2); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockGravel.java b/src/teavm/java/net/minecraft/game/level/block/BlockGravel.java new file mode 100644 index 0000000..5d47e77 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockGravel.java @@ -0,0 +1,14 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.item.Item; + +public final class BlockGravel extends BlockSand { + public BlockGravel(int var1, int var2) { + super(13, 19); + } + + public final int idDropped(int var1, Random var2) { + return var2.nextInt(10) == 0 ? Item.flint.shiftedIndex : this.blockID; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockLeaves.java b/src/teavm/java/net/minecraft/game/level/block/BlockLeaves.java new file mode 100644 index 0000000..fba0763 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockLeaves.java @@ -0,0 +1,37 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockLeaves extends BlockLeavesBase { + protected BlockLeaves(int var1, int var2) { + super(18, 52, Material.leaves, true); + this.setTickOnLoad(true); + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + if(!var1.getBlockMaterial(var2, var3 - 1, var4).isSolid()) { + for(int var8 = var2 - 2; var8 <= var2 + 2; ++var8) { + for(int var6 = var3 - 1; var6 <= var3; ++var6) { + for(int var7 = var4 - 2; var7 <= var4 + 2; ++var7) { + if(var1.getBlockId(var8, var6, var7) == Block.wood.blockID) { + return; + } + } + } + } + + this.dropBlockAsItem(var1, var2, var3, var4, var1.getBlockMetadata(var2, var3, var4)); + var1.setBlockWithNotify(var2, var3, var4, 0); + } + } + + public final int quantityDropped(Random var1) { + return var1.nextInt(10) == 0 ? 1 : 0; + } + + public final int idDropped(int var1, Random var2) { + return Block.sapling.blockID; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockLeavesBase.java b/src/teavm/java/net/minecraft/game/level/block/BlockLeavesBase.java new file mode 100644 index 0000000..14ece31 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockLeavesBase.java @@ -0,0 +1,21 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public class BlockLeavesBase extends Block { + private boolean graphicsLevel = true; + + protected BlockLeavesBase(int var1, int var2, Material var3, boolean var4) { + super(var1, var2, var3); + } + + public final boolean isOpaqueCube() { + return false; + } + + public final boolean shouldSideBeRendered(World var1, int var2, int var3, int var4, int var5) { + int var6 = var1.getBlockId(var2, var3, var4); + return !this.graphicsLevel && var6 == this.blockID ? false : super.shouldSideBeRendered(var1, var2, var3, var4, var5); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockLog.java b/src/teavm/java/net/minecraft/game/level/block/BlockLog.java new file mode 100644 index 0000000..423529f --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockLog.java @@ -0,0 +1,23 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.material.Material; + +public final class BlockLog extends Block { + protected BlockLog(int var1) { + super(17, Material.wood); + this.blockIndexInTexture = 20; + } + + public final int quantityDropped(Random var1) { + return 1; + } + + public final int idDropped(int var1, Random var2) { + return Block.wood.blockID; + } + + public final int getBlockTextureFromSide(int var1) { + return var1 == 1 ? 21 : (var1 == 0 ? 21 : 20); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockMushroom.java b/src/teavm/java/net/minecraft/game/level/block/BlockMushroom.java new file mode 100644 index 0000000..71e4fc7 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockMushroom.java @@ -0,0 +1,25 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.level.World; + +public final class BlockMushroom extends BlockFlower { + protected BlockMushroom(int var1, int var2) { + super(var1, var2); + this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.4F, 0.7F); + } + + protected final boolean canThisPlantGrowOnThisBlockID(int var1) { + return Block.opaqueCubeLookup[var1]; + } + + public final boolean canBlockStay(World var1, int var2, int var3, int var4) { + if(var1.getBlockLightValue(var2, var3, var4) <= 13) { + var2 = var1.getBlockId(var2, var3 - 1, var4); + if(Block.opaqueCubeLookup[var2]) { + return true; + } + } + + return false; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockOre.java b/src/teavm/java/net/minecraft/game/level/block/BlockOre.java new file mode 100644 index 0000000..61c0e0a --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockOre.java @@ -0,0 +1,19 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.item.Item; +import net.minecraft.game.level.material.Material; + +public final class BlockOre extends Block { + public BlockOre(int var1, int var2) { + super(var1, var2, Material.rock); + } + + public final int idDropped(int var1, Random var2) { + return this.blockID == Block.oreCoal.blockID ? Item.coal.shiftedIndex : (this.blockID == Block.oreDiamond.blockID ? Item.diamond.shiftedIndex : this.blockID); + } + + public final int quantityDropped(Random var1) { + return 1; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockOreBlock.java b/src/teavm/java/net/minecraft/game/level/block/BlockOreBlock.java new file mode 100644 index 0000000..8d46faf --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockOreBlock.java @@ -0,0 +1,14 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.level.material.Material; + +public final class BlockOreBlock extends Block { + public BlockOreBlock(int var1, int var2) { + super(var1, Material.iron); + this.blockIndexInTexture = var2; + } + + public final int getBlockTextureFromSide(int var1) { + return var1 == 1 ? this.blockIndexInTexture - 16 : (var1 == 0 ? this.blockIndexInTexture + 16 : this.blockIndexInTexture); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockSand.java b/src/teavm/java/net/minecraft/game/level/block/BlockSand.java new file mode 100644 index 0000000..0d86bfd --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockSand.java @@ -0,0 +1,60 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public class BlockSand extends Block { + public BlockSand(int var1, int var2) { + super(var1, var2, Material.sand); + new Random(); + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + this.tryToFall(var1, var2, var3, var4); + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + this.tryToFall(var1, var2, var3, var4); + } + + private void tryToFall(World var1, int var2, int var3, int var4) { + int var5 = var3; + + while(true) { + int var8 = var5 - 1; + int var6 = var1.getBlockId(var2, var8, var4); + boolean var10000; + if(var6 == 0) { + var10000 = true; + } else if(var6 == Block.fire.blockID) { + var10000 = true; + } else { + Material var10 = Block.blocksList[var6].material; + var10000 = var10 == Material.water ? true : var10 == Material.lava; + } + + if(!var10000 || var5 < 0) { + if(var5 < 0) { + var1.setTileNoUpdate(var2, var3, var4, 0); + } + + if(var5 != var3) { + var6 = var1.getBlockId(var2, var5, var4); + if(var6 > 0 && Block.blocksList[var6].material != Material.air) { + var1.setTileNoUpdate(var2, var5, var4, 0); + } + + var1.swap(var2, var3, var4, var2, var5, var4); + } + + return; + } + + --var5; + if(var1.getBlockId(var2, var5, var4) == Block.fire.blockID) { + var1.setBlock(var2, var5, var4, 0); + } + } + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockSapling.java b/src/teavm/java/net/minecraft/game/level/block/BlockSapling.java new file mode 100644 index 0000000..504ab9a --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockSapling.java @@ -0,0 +1,28 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; + +public final class BlockSapling extends BlockFlower { + protected BlockSapling(int var1, int var2) { + super(6, 15); + this.setBlockBounds(10.0F * 0.01F, 0.0F, 10.0F * 0.01F, 0.9F, 0.8F, 0.9F); + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + super.updateTick(var1, var2, var3, var4, var5); + if(var1.getBlockLightValue(var2, var3 + 1, var4) >= 9 && var5.nextInt(5) == 0) { + byte var6 = var1.getBlockMetadata(var2, var3, var4); + if(var6 < 15) { + var1.setBlockMetadata(var2, var3, var4, var6 + 1); + return; + } + + var1.setTileNoUpdate(var2, var3, var4, 0); + if(!var1.growTrees(var2, var3, var4)) { + var1.setTileNoUpdate(var2, var3, var4, this.blockID); + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockSource.java b/src/teavm/java/net/minecraft/game/level/block/BlockSource.java new file mode 100644 index 0000000..a1a5982 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockSource.java @@ -0,0 +1,55 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockSource extends Block { + private int fluid; + + protected BlockSource(int var1, int var2) { + super(var1, Block.blocksList[var2].blockIndexInTexture, Material.water); + this.fluid = var2; + this.setTickOnLoad(true); + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + super.onBlockAdded(var1, var2, var3, var4); + if(var1.getBlockId(var2 - 1, var3, var4) == 0) { + var1.setBlockWithNotify(var2 - 1, var3, var4, this.fluid); + } + + if(var1.getBlockId(var2 + 1, var3, var4) == 0) { + var1.setBlockWithNotify(var2 + 1, var3, var4, this.fluid); + } + + if(var1.getBlockId(var2, var3, var4 - 1) == 0) { + var1.setBlockWithNotify(var2, var3, var4 - 1, this.fluid); + } + + if(var1.getBlockId(var2, var3, var4 + 1) == 0) { + var1.setBlockWithNotify(var2, var3, var4 + 1, this.fluid); + } + + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + super.updateTick(var1, var2, var3, var4, var5); + if(var1.getBlockId(var2 - 1, var3, var4) == 0) { + var1.setBlockWithNotify(var2 - 1, var3, var4, this.fluid); + } + + if(var1.getBlockId(var2 + 1, var3, var4) == 0) { + var1.setBlockWithNotify(var2 + 1, var3, var4, this.fluid); + } + + if(var1.getBlockId(var2, var3, var4 - 1) == 0) { + var1.setBlockWithNotify(var2, var3, var4 - 1, this.fluid); + } + + if(var1.getBlockId(var2, var3, var4 + 1) == 0) { + var1.setBlockWithNotify(var2, var3, var4 + 1, this.fluid); + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockSponge.java b/src/teavm/java/net/minecraft/game/level/block/BlockSponge.java new file mode 100644 index 0000000..50be912 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockSponge.java @@ -0,0 +1,35 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockSponge extends Block { + protected BlockSponge(int var1) { + super(19, Material.sponge); + this.blockIndexInTexture = 48; + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + for(int var5 = var2 - 2; var5 <= var2 + 2; ++var5) { + for(int var6 = var3 - 2; var6 <= var3 + 2; ++var6) { + for(int var7 = var4 - 2; var7 <= var4 + 2; ++var7) { + if(var1.isWater(var5, var6, var7)) { + var1.setBlock(var5, var6, var7, 0); + } + } + } + } + + } + + public final void onBlockRemoval(World var1, int var2, int var3, int var4) { + for(int var5 = var2 - 2; var5 <= var2 + 2; ++var5) { + for(int var6 = var3 - 2; var6 <= var3 + 2; ++var6) { + for(int var7 = var4 - 2; var7 <= var4 + 2; ++var7) { + var1.notifyBlocksOfNeighborChange(var5, var6, var7, var1.getBlockId(var5, var6, var7)); + } + } + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockStationary.java b/src/teavm/java/net/minecraft/game/level/block/BlockStationary.java new file mode 100644 index 0000000..ce310fe --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockStationary.java @@ -0,0 +1,58 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockStationary extends BlockFluid { + protected BlockStationary(int var1, Material var2) { + super(var1, var2); + this.movingId = var1 - 1; + this.stillId = var1; + this.setTickOnLoad(false); + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + boolean var6 = false; + if(this.canFlow(var1, var2, var3 - 1, var4)) { + var6 = true; + } + + if(!var6 && this.canFlow(var1, var2 - 1, var3, var4)) { + var6 = true; + } + + if(!var6 && this.canFlow(var1, var2 + 1, var3, var4)) { + var6 = true; + } + + if(!var6 && this.canFlow(var1, var2, var3, var4 - 1)) { + var6 = true; + } + + if(!var6 && this.canFlow(var1, var2, var3, var4 + 1)) { + var6 = true; + } + + if(var5 != 0) { + Material var7 = Block.blocksList[var5].material; + if(this.material == Material.water && var7 == Material.lava || var7 == Material.water && this.material == Material.lava) { + var1.setBlockWithNotify(var2, var3, var4, Block.stone.blockID); + return; + } + } + + if(Block.fire.getChanceOfNeighborsEncouragingFire(var5)) { + var6 = true; + } + + if(var6) { + var1.setTileNoUpdate(var2, var3, var4, this.movingId); + var1.scheduleBlockUpdate(var2, var3, var4, this.movingId); + } + + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockStep.java b/src/teavm/java/net/minecraft/game/level/block/BlockStep.java new file mode 100644 index 0000000..8682a4b --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockStep.java @@ -0,0 +1,57 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockStep extends Block { + private boolean blockType; + + public BlockStep(int var1, boolean var2) { + super(var1, 6, Material.rock); + this.blockType = var2; + if(!var2) { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + + this.setLightOpacity(255); + } + + public final int getBlockTextureFromSide(int var1) { + return var1 <= 1 ? 6 : 5; + } + + public final boolean isOpaqueCube() { + return this.blockType; + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + if(this == Block.stairSingle) { + } + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + if(this != Block.stairSingle) { + super.onBlockAdded(var1, var2, var3, var4); + } + + int var5 = var1.getBlockId(var2, var3 - 1, var4); + if(var5 == stairSingle.blockID) { + var1.setBlockWithNotify(var2, var3, var4, 0); + var1.setBlockWithNotify(var2, var3 - 1, var4, Block.stairDouble.blockID); + } + + } + + public final int idDropped(int var1, Random var2) { + return Block.stairSingle.blockID; + } + + public final boolean renderAsNormalBlock() { + return this.blockType; + } + + public final boolean shouldSideBeRendered(World var1, int var2, int var3, int var4, int var5) { + return var5 == 1 ? true : (!super.shouldSideBeRendered(var1, var2, var3, var4, var5) ? false : (var5 == 0 ? true : var1.getBlockId(var2, var3, var4) != this.blockID)); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockStone.java b/src/teavm/java/net/minecraft/game/level/block/BlockStone.java new file mode 100644 index 0000000..1bdbe74 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockStone.java @@ -0,0 +1,14 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.material.Material; + +public final class BlockStone extends Block { + public BlockStone(int var1, int var2) { + super(var1, var2, Material.rock); + } + + public final int idDropped(int var1, Random var2) { + return Block.cobblestone.blockID; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockTNT.java b/src/teavm/java/net/minecraft/game/level/block/BlockTNT.java new file mode 100644 index 0000000..bbfd755 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockTNT.java @@ -0,0 +1,31 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.entity.misc.EntityTNTPrimed; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockTNT extends Block { + public BlockTNT(int var1, int var2) { + super(46, 8, Material.tnt); + } + + public final int getBlockTextureFromSide(int var1) { + return var1 == 0 ? this.blockIndexInTexture + 2 : (var1 == 1 ? this.blockIndexInTexture + 1 : this.blockIndexInTexture); + } + + public final int quantityDropped(Random var1) { + return 0; + } + + public final void onBlockDestroyedByExplosion(World var1, int var2, int var3, int var4) { + EntityTNTPrimed var5 = new EntityTNTPrimed(var1, (float)var2 + 0.5F, (float)var3 + 0.5F, (float)var4 + 0.5F); + var5.fuse = var1.random.nextInt(var5.fuse / 4) + var5.fuse / 8; + var1.spawnEntityInWorld(var5); + } + + public final void onBlockDestroyedByPlayer(World var1, int var2, int var3, int var4, int var5) { + EntityTNTPrimed var6 = new EntityTNTPrimed(var1, (float)var2 + 0.5F, (float)var3 + 0.5F, (float)var4 + 0.5F); + var1.spawnEntityInWorld(var6); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockTorch.java b/src/teavm/java/net/minecraft/game/level/block/BlockTorch.java new file mode 100644 index 0000000..42a576b --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockTorch.java @@ -0,0 +1,166 @@ +package net.minecraft.game.level.block; + +import java.util.Random; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; +import net.minecraft.game.physics.AxisAlignedBB; +import net.minecraft.game.physics.MovingObjectPosition; +import net.minecraft.game.physics.Vec3D; + +public final class BlockTorch extends Block { + protected BlockTorch(int var1, int var2) { + super(50, 80, Material.circuits); + this.setTickOnLoad(true); + } + + public final AxisAlignedBB getCollisionBoundingBoxFromPool(int var1, int var2, int var3) { + return null; + } + + public final boolean isOpaqueCube() { + return false; + } + + public final boolean renderAsNormalBlock() { + return false; + } + + public final int getRenderType() { + return 2; + } + + public final boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) { + return var1.isBlockNormalCube(var2 - 1, var3, var4) ? true : (var1.isBlockNormalCube(var2 + 1, var3, var4) ? true : (var1.isBlockNormalCube(var2, var3, var4 - 1) ? true : (var1.isBlockNormalCube(var2, var3, var4 + 1) ? true : var1.isBlockNormalCube(var2, var3 - 1, var4)))); + } + + public final void onBlockPlaced(World var1, int var2, int var3, int var4, int var5) { + byte var6 = var1.getBlockMetadata(var2, var3, var4); + if(var5 == 1 && var1.isBlockNormalCube(var2, var3 - 1, var4)) { + var6 = 5; + } + + if(var5 == 2 && var1.isBlockNormalCube(var2, var3, var4 + 1)) { + var6 = 4; + } + + if(var5 == 3 && var1.isBlockNormalCube(var2, var3, var4 - 1)) { + var6 = 3; + } + + if(var5 == 4 && var1.isBlockNormalCube(var2 + 1, var3, var4)) { + var6 = 2; + } + + if(var5 == 5 && var1.isBlockNormalCube(var2 - 1, var3, var4)) { + var6 = 1; + } + + var1.setBlockMetadata(var2, var3, var4, var6); + } + + public final void updateTick(World var1, int var2, int var3, int var4, Random var5) { + super.updateTick(var1, var2, var3, var4, var5); + if(var1.getBlockMetadata(var2, var3, var4) == 0) { + this.onBlockAdded(var1, var2, var3, var4); + } + + } + + public final void onBlockAdded(World var1, int var2, int var3, int var4) { + if(var1.isBlockNormalCube(var2 - 1, var3, var4)) { + var1.setBlockMetadata(var2, var3, var4, 1); + } else if(var1.isBlockNormalCube(var2 + 1, var3, var4)) { + var1.setBlockMetadata(var2, var3, var4, 2); + } else if(var1.isBlockNormalCube(var2, var3, var4 - 1)) { + var1.setBlockMetadata(var2, var3, var4, 3); + } else if(var1.isBlockNormalCube(var2, var3, var4 + 1)) { + var1.setBlockMetadata(var2, var3, var4, 4); + } else if(var1.isBlockNormalCube(var2, var3 - 1, var4)) { + var1.setBlockMetadata(var2, var3, var4, 5); + } + + this.dropTorchIfCantStay(var1, var2, var3, var4); + } + + public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { + if(this.dropTorchIfCantStay(var1, var2, var3, var4)) { + byte var7 = var1.getBlockMetadata(var2, var3, var4); + boolean var6 = false; + if(!var1.isBlockNormalCube(var2 - 1, var3, var4) && var7 == 1) { + var6 = true; + } + + if(!var1.isBlockNormalCube(var2 + 1, var3, var4) && var7 == 2) { + var6 = true; + } + + if(!var1.isBlockNormalCube(var2, var3, var4 - 1) && var7 == 3) { + var6 = true; + } + + if(!var1.isBlockNormalCube(var2, var3, var4 + 1) && var7 == 4) { + var6 = true; + } + + if(!var1.isBlockNormalCube(var2, var3 - 1, var4) && var7 == 5) { + var6 = true; + } + + if(var6) { + this.dropBlockAsItem(var1, var2, var3, var4, var1.getBlockMetadata(var2, var3, var4)); + var1.setBlockWithNotify(var2, var3, var4, 0); + } + } + + } + + private boolean dropTorchIfCantStay(World var1, int var2, int var3, int var4) { + if(!this.canPlaceBlockAt(var1, var2, var3, var4)) { + this.dropBlockAsItem(var1, var2, var3, var4, var1.getBlockMetadata(var2, var3, var4)); + var1.setBlockWithNotify(var2, var3, var4, 0); + return false; + } else { + return true; + } + } + + public final MovingObjectPosition collisionRayTrace(World var1, int var2, int var3, int var4, Vec3D var5, Vec3D var6) { + byte var7 = var1.getBlockMetadata(var2, var3, var4); + if(var7 == 1) { + this.setBlockBounds(0.0F, 0.2F, 0.35F, 0.3F, 0.8F, 0.65F); + } else if(var7 == 2) { + this.setBlockBounds(0.7F, 0.2F, 0.35F, 1.0F, 0.8F, 0.65F); + } else if(var7 == 3) { + this.setBlockBounds(0.35F, 0.2F, 0.0F, 0.65F, 0.8F, 0.3F); + } else if(var7 == 4) { + this.setBlockBounds(0.35F, 0.2F, 0.7F, 0.65F, 0.8F, 1.0F); + } else { + this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 0.6F, 0.6F); + } + + return super.collisionRayTrace(var1, var2, var3, var4, var5, var6); + } + + public final void randomDisplayTick(World var1, int var2, int var3, int var4, Random var5) { + byte var9 = var1.getBlockMetadata(var2, var3, var4); + float var6 = (float)var2 + 0.5F; + float var7 = (float)var3 + 0.7F; + float var8 = (float)var4 + 0.5F; + if(var9 == 1) { + var1.spawnParticle("smoke", var6 - 0.27F, var7 + 0.22F, var8, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var6 - 0.27F, var7 + 0.22F, var8, 0.0F, 0.0F, 0.0F); + } else if(var9 == 2) { + var1.spawnParticle("smoke", var6 + 0.27F, var7 + 0.22F, var8, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var6 + 0.27F, var7 + 0.22F, var8, 0.0F, 0.0F, 0.0F); + } else if(var9 == 3) { + var1.spawnParticle("smoke", var6, var7 + 0.22F, var8 - 0.27F, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var6, var7 + 0.22F, var8 - 0.27F, 0.0F, 0.0F, 0.0F); + } else if(var9 == 4) { + var1.spawnParticle("smoke", var6, var7 + 0.22F, var8 + 0.27F, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var6, var7 + 0.22F, var8 + 0.27F, 0.0F, 0.0F, 0.0F); + } else { + var1.spawnParticle("smoke", var6, var7, var8, 0.0F, 0.0F, 0.0F); + var1.spawnParticle("flame", var6, var7, var8, 0.0F, 0.0F, 0.0F); + } + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/BlockWorkbench.java b/src/teavm/java/net/minecraft/game/level/block/BlockWorkbench.java new file mode 100644 index 0000000..64dfb85 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/BlockWorkbench.java @@ -0,0 +1,21 @@ +package net.minecraft.game.level.block; + +import net.minecraft.game.entity.player.EntityPlayer; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class BlockWorkbench extends Block { + protected BlockWorkbench(int var1) { + super(58, Material.wood); + this.blockIndexInTexture = 59; + } + + public final int getBlockTextureFromSide(int var1) { + return var1 == 1 ? this.blockIndexInTexture - 16 : (var1 == 0 ? Block.planks.getBlockTextureFromSide(0) : (var1 != 2 && var1 != 4 ? this.blockIndexInTexture : this.blockIndexInTexture + 1)); + } + + public final boolean blockActivated(World var1, int var2, int var3, int var4, EntityPlayer var5) { + var5.displayWorkbenchGUI(); + return true; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/StepSound.java b/src/teavm/java/net/minecraft/game/level/block/StepSound.java new file mode 100644 index 0000000..f266928 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/StepSound.java @@ -0,0 +1,21 @@ +package net.minecraft.game.level.block; + +public class StepSound { + private String sound; + public final float soundVolume; + public final float soundPitch; + + public StepSound(String var1, float var2, float var3) { + this.sound = var1; + this.soundVolume = var2; + this.soundPitch = var3; + } + + public String stepSoundDir() { + return "step." + this.sound; + } + + public final String stepSoundDir2() { + return "step." + this.sound; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/StepSoundGlass.java b/src/teavm/java/net/minecraft/game/level/block/StepSoundGlass.java new file mode 100644 index 0000000..cea2361 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/StepSoundGlass.java @@ -0,0 +1,11 @@ +package net.minecraft.game.level.block; + +final class StepSoundGlass extends StepSound { + StepSoundGlass(String var1, float var2, float var3) { + super(var1, 1.0F, 1.0F); + } + + public final String stepSoundDir() { + return "random.glass"; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/StepSoundSand.java b/src/teavm/java/net/minecraft/game/level/block/StepSoundSand.java new file mode 100644 index 0000000..d51d877 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/StepSoundSand.java @@ -0,0 +1,11 @@ +package net.minecraft.game.level.block; + +final class StepSoundSand extends StepSound { + StepSoundSand(String var1, float var2, float var3) { + super(var1, 1.0F, 1.0F); + } + + public final String stepSoundDir() { + return "step.gravel"; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntity.java b/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntity.java new file mode 100644 index 0000000..1feae51 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntity.java @@ -0,0 +1,20 @@ +package net.minecraft.game.level.block.tileentity; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.minecraft.game.level.World; + +public class TileEntity { + public World worldObj; + public int xCoord; + public int yCoord; + public int zCoord; + + public void readFromNBT(NBTTagCompound var1) { + } + + public void writeToNBT(NBTTagCompound var1) { + } + + public void updateEntity() { + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntityChest.java b/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntityChest.java new file mode 100644 index 0000000..7c77a68 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntityChest.java @@ -0,0 +1,84 @@ +package net.minecraft.game.level.block.tileentity; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.PeytonPlayz585.nbt.NBTTagList; +import net.minecraft.game.IInventory; +import net.minecraft.game.item.ItemStack; + +public final class TileEntityChest extends TileEntity implements IInventory { + private ItemStack[] chestContents = new ItemStack[36]; + + public final int getSizeInventory() { + return 27; + } + + public final ItemStack getStackInSlot(int var1) { + return this.chestContents[var1]; + } + + public final ItemStack decrStackSize(int var1, int var2) { + if(this.chestContents[var1] != null) { + ItemStack var3; + if(this.chestContents[var1].stackSize <= var2) { + var3 = this.chestContents[var1]; + this.chestContents[var1] = null; + return var3; + } else { + var3 = this.chestContents[var1].splitStack(var2); + if(this.chestContents[var1].stackSize == 0) { + this.chestContents[var1] = null; + } + + return var3; + } + } else { + return null; + } + } + + public final void setInventorySlotContents(int var1, ItemStack var2) { + this.chestContents[var1] = var2; + if(var2 != null && var2.stackSize > 64) { + var2.stackSize = 64; + } + + } + + public final String getInvName() { + return "Chest"; + } + + public final void readFromNBT(NBTTagCompound var1) { + NBTTagList var5 = var1.getTagList("Items"); + this.chestContents = new ItemStack[27]; + + for(int var2 = 0; var2 < var5.tagCount(); ++var2) { + NBTTagCompound var3 = (NBTTagCompound)var5.tagAt(var2); + int var4 = var3.getByte("Slot") & 255; + if(var4 >= 0 && var4 < this.chestContents.length) { + this.chestContents[var4] = new ItemStack(var3); + } + } + + } + + public final void writeToNBT(NBTTagCompound var1) { + var1.setString("id", "Chest"); + NBTTagList var2 = new NBTTagList(); + + for(int var3 = 0; var3 < this.chestContents.length; ++var3) { + if(this.chestContents[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.chestContents[var3].writeToNBT(var4); + var2.setTag(var4); + } + } + + var1.setTag("Items", var2); + } + + public final int getInventoryStackLimit() { + return 64; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntityFurnace.java b/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntityFurnace.java new file mode 100644 index 0000000..b3d74c3 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/block/tileentity/TileEntityFurnace.java @@ -0,0 +1,192 @@ +package net.minecraft.game.level.block.tileentity; + +import net.PeytonPlayz585.nbt.NBTTagCompound; +import net.PeytonPlayz585.nbt.NBTTagList; +import net.minecraft.game.IInventory; +import net.minecraft.game.item.Item; +import net.minecraft.game.item.ItemStack; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.material.Material; + +public final class TileEntityFurnace extends TileEntity implements IInventory { + private ItemStack[] furnaceItemStacks = new ItemStack[3]; + private int furnaceBurnTime = 0; + private int currentItemBurnTime = 0; + private int furnaceCookTime = 0; + + public final int getSizeInventory() { + return this.furnaceItemStacks.length; + } + + public final ItemStack getStackInSlot(int var1) { + return this.furnaceItemStacks[var1]; + } + + public final ItemStack decrStackSize(int var1, int var2) { + if(this.furnaceItemStacks[var1] != null) { + ItemStack var3; + if(this.furnaceItemStacks[var1].stackSize <= var2) { + var3 = this.furnaceItemStacks[var1]; + this.furnaceItemStacks[var1] = null; + return var3; + } else { + var3 = this.furnaceItemStacks[var1].splitStack(var2); + if(this.furnaceItemStacks[var1].stackSize == 0) { + this.furnaceItemStacks[var1] = null; + } + + return var3; + } + } else { + return null; + } + } + + public final void setInventorySlotContents(int var1, ItemStack var2) { + this.furnaceItemStacks[var1] = var2; + if(var2 != null && var2.stackSize > 64) { + var2.stackSize = 64; + } + + } + + public final String getInvName() { + return "Chest"; + } + + public final void readFromNBT(NBTTagCompound var1) { + super.readFromNBT(var1); + NBTTagList var2 = var1.getTagList("Items"); + this.furnaceItemStacks = new ItemStack[this.furnaceItemStacks.length]; + + for(int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + byte var5 = var4.getByte("Slot"); + if(var5 >= 0 && var5 < this.furnaceItemStacks.length) { + this.furnaceItemStacks[var5] = new ItemStack(var4); + } + } + + this.furnaceBurnTime = var1.getShort("BurnTime"); + this.furnaceCookTime = var1.getShort("CookTime"); + this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]); + System.out.println("Lit: " + this.furnaceBurnTime + "/" + this.currentItemBurnTime); + } + + public final void writeToNBT(NBTTagCompound var1) { + super.writeToNBT(var1); + var1.setShort("BurnTime", (short)this.furnaceBurnTime); + var1.setShort("CookTime", (short)this.furnaceCookTime); + var1.setString("id", "Furnace"); + NBTTagList var2 = new NBTTagList(); + + for(int var3 = 0; var3 < this.furnaceItemStacks.length; ++var3) { + if(this.furnaceItemStacks[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.furnaceItemStacks[var3].writeToNBT(var4); + var2.setTag(var4); + } + } + + var1.setTag("Items", var2); + } + + public final int getInventoryStackLimit() { + return 64; + } + + public final int getCookProgressScaled(int var1) { + return this.furnaceCookTime * 24 / 200; + } + + public final int getBurnTimeRemainingScaled(int var1) { + return this.furnaceBurnTime * 12 / this.currentItemBurnTime; + } + + public final boolean isBurning() { + return this.furnaceBurnTime > 0; + } + + public final void updateEntity() { + boolean var1 = this.furnaceBurnTime > 0; + if(this.furnaceBurnTime > 0) { + --this.furnaceBurnTime; + } + + if(this.furnaceBurnTime == 0 && this.canSmelt()) { + this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]); + if(this.furnaceBurnTime > 0 && this.furnaceItemStacks[1] != null) { + --this.furnaceItemStacks[1].stackSize; + if(this.furnaceItemStacks[1].stackSize == 0) { + this.furnaceItemStacks[1] = null; + } + } + } + + if(this.isBurning() && this.canSmelt()) { + ++this.furnaceCookTime; + if(this.furnaceCookTime == 200) { + this.furnaceCookTime = 0; + if(this.canSmelt()) { + int var3 = smeltItem(this.furnaceItemStacks[0].getItem().shiftedIndex); + if(this.furnaceItemStacks[2] == null) { + this.furnaceItemStacks[2] = new ItemStack(var3, 1); + } else if(this.furnaceItemStacks[2].itemID == var3) { + ++this.furnaceItemStacks[2].stackSize; + } + + --this.furnaceItemStacks[0].stackSize; + if(this.furnaceItemStacks[0].stackSize <= 0) { + this.furnaceItemStacks[0] = null; + } + } + } + } else { + this.furnaceCookTime = 0; + } + + if(var1 != this.furnaceBurnTime > 0) { + boolean var10000 = this.furnaceBurnTime > 0; + int var5 = this.zCoord; + int var4 = this.yCoord; + int var8 = this.xCoord; + World var9 = this.worldObj; + boolean var2 = var10000; + byte var6 = var9.getBlockMetadata(var8, var4, var5); + TileEntity var7 = var9.getBlockTileEntity(var8, var4, var5); + if(var2) { + var9.setBlockWithNotify(var8, var4, var5, Block.stoneOvenActive.blockID); + } else { + var9.setBlockWithNotify(var8, var4, var5, Block.stoneOvenIdle.blockID); + } + + var9.setBlockMetadata(var8, var4, var5, var6); + var9.setBlockTileEntity(var8, var4, var5, var7); + } + + } + + private boolean canSmelt() { + if(this.furnaceItemStacks[0] == null) { + return false; + } else { + int var1 = smeltItem(this.furnaceItemStacks[0].getItem().shiftedIndex); + return var1 < 0 ? false : (this.furnaceItemStacks[2] == null ? true : (this.furnaceItemStacks[2].itemID != var1 ? false : (this.furnaceItemStacks[2].stackSize < 64 ? true : this.furnaceItemStacks[2].stackSize < Item.itemsList[var1].getItemStackLimit()))); + } + } + + private static int smeltItem(int var0) { + return var0 == Block.oreIron.blockID ? Item.ingotIron.shiftedIndex : (var0 == Block.oreGold.blockID ? Item.ingotGold.shiftedIndex : (var0 == Block.oreDiamond.blockID ? Item.diamond.shiftedIndex : (var0 == Block.sand.blockID ? Block.glass.blockID : (var0 == Item.porkRaw.shiftedIndex ? Item.porkCooked.shiftedIndex : (var0 == Block.cobblestone.blockID ? Block.stone.blockID : -1))))); + } + + private static int getItemBurnTime(ItemStack var0) { + if(var0 == null) { + return 0; + } else { + int var1 = var0.getItem().shiftedIndex; + return var1 < 256 && Block.blocksList[var1].material == Material.wood ? 300 : (var1 == Item.stick.shiftedIndex ? 100 : (var1 == Item.coal.shiftedIndex ? 1600 : 0)); + } + } +} diff --git a/src/teavm/java/net/minecraft/game/level/generator/LevelGenerator.java b/src/teavm/java/net/minecraft/game/level/generator/LevelGenerator.java new file mode 100644 index 0000000..c59bc85 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/generator/LevelGenerator.java @@ -0,0 +1,825 @@ +package net.minecraft.game.level.generator; + +import java.util.ArrayList; +import java.util.Random; + +import net.PeytonPlayz585.math.MathHelper; +import net.minecraft.game.level.MobSpawner; +import net.minecraft.game.level.World; +import net.minecraft.game.level.block.Block; +import net.minecraft.game.level.block.BlockFlower; +import net.minecraft.game.level.generator.noise.NoiseGeneratorDistort; +import net.minecraft.game.level.generator.noise.NoiseGeneratorOctaves; +import util.IProgressUpdate; + +public final class LevelGenerator { + private IProgressUpdate guiLoading; + private int width; + private int depth; + private int height; + private Random rand = new Random(); + private byte[] blocksByteArray; + private int waterLevel; + private int groundLevel; + public boolean islandGen = false; + public boolean floatingGen = false; + public boolean flatGen = false; + public int levelType; + private int phaseBar; + private int phases; + private float phaseBareLength = 0.0F; + private int[] floodFillBlocks = new int[1048576]; + + public LevelGenerator(IProgressUpdate var1) { + this.guiLoading = var1; + } + + public final World generate(String var1, int var2, int var3, int var4) { + int var5 = 1; + if(this.floatingGen) { + var5 = (var4 - 64) / 48 + 1; + } + + this.phases = 13 + var5 * 4; + this.guiLoading.displayProgressMessage("Generating level"); + World var6 = new World(); + var6.waterLevel = this.waterLevel; + var6.groundLevel = this.groundLevel; + this.width = var2; + this.depth = var3; + this.height = var4; + this.blocksByteArray = new byte[var2 * var3 * var4]; + + int var7; + LevelGenerator var9; + int var21; + int var25; + int var31; + int var45; + int var51; + int var52; + int var53; + int var56; + for(var7 = 0; var7 < var5; ++var7) { + this.waterLevel = var4 - 32 - var7 * 48; + this.groundLevel = this.waterLevel - 2; + int[] var8; + NoiseGeneratorOctaves var13; + int var22; + double var32; + int[] var46; + if(this.flatGen) { + var8 = new int[var2 * var3]; + + for(var45 = 0; var45 < var8.length; ++var45) { + var8[var45] = 0; + } + + this.loadingBar(); + this.loadingBar(); + } else { + this.guiLoading.displayLoadingString("Raising.."); + this.loadingBar(); + var9 = this; + NoiseGeneratorDistort var10 = new NoiseGeneratorDistort(new NoiseGeneratorOctaves(this.rand, 8), new NoiseGeneratorOctaves(this.rand, 8)); + NoiseGeneratorDistort var11 = new NoiseGeneratorDistort(new NoiseGeneratorOctaves(this.rand, 8), new NoiseGeneratorOctaves(this.rand, 8)); + NoiseGeneratorOctaves var12 = new NoiseGeneratorOctaves(this.rand, 6); + var13 = new NoiseGeneratorOctaves(this.rand, 2); + int[] var14 = new int[this.width * this.depth]; + var22 = 0; + + label349: + while(true) { + if(var22 >= var9.width) { + var8 = var14; + this.guiLoading.displayLoadingString("Eroding.."); + this.loadingBar(); + var46 = var14; + var9 = this; + var11 = new NoiseGeneratorDistort(new NoiseGeneratorOctaves(this.rand, 8), new NoiseGeneratorOctaves(this.rand, 8)); + NoiseGeneratorDistort var50 = new NoiseGeneratorDistort(new NoiseGeneratorOctaves(this.rand, 8), new NoiseGeneratorOctaves(this.rand, 8)); + var52 = 0; + + while(true) { + if(var52 >= var9.width) { + break label349; + } + + var9.setNextPhase((float)var52 * 100.0F / (float)(var9.width - 1)); + + for(var53 = 0; var53 < var9.depth; ++var53) { + double var20 = var11.generateNoise((double)(var52 << 1), (double)(var53 << 1)) / 8.0D; + var22 = var50.generateNoise((double)(var52 << 1), (double)(var53 << 1)) > 0.0D ? 1 : 0; + if(var20 > 2.0D) { + int var58 = var46[var52 + var53 * var9.width]; + var58 = ((var58 - var22) / 2 << 1) + var22; + var46[var52 + var53 * var9.width] = var58; + } + } + + ++var52; + } + } + + double var23 = Math.abs(((double)var22 / ((double)var9.width - 1.0D) - 0.5D) * 2.0D); + var9.setNextPhase((float)var22 * 100.0F / (float)(var9.width - 1)); + + for(var25 = 0; var25 < var9.depth; ++var25) { + double var26 = Math.abs(((double)var25 / ((double)var9.depth - 1.0D) - 0.5D) * 2.0D); + double var28 = var10.generateNoise((double)((float)var22 * 1.3F), (double)((float)var25 * 1.3F)) / 6.0D + -4.0D; + double var30 = var11.generateNoise((double)((float)var22 * 1.3F), (double)((float)var25 * 1.3F)) / 5.0D + 10.0D + -4.0D; + var32 = var12.generateNoise((double)var22, (double)var25) / 8.0D; + if(var32 > 0.0D) { + var30 = var28; + } + + double var34 = Math.max(var28, var30) / 2.0D; + if(var9.islandGen) { + double var36 = Math.sqrt(var23 * var23 + var26 * var26) * (double)1.2F; + double var39 = var13.generateNoise((double)((float)var22 * 0.05F), (double)((float)var25 * 0.05F)) / 4.0D + 1.0D; + var36 = Math.min(var36, var39); + var36 = Math.max(var36, Math.max(var23, var26)); + if(var36 > 1.0D) { + var36 = 1.0D; + } + + if(var36 < 0.0D) { + var36 = 0.0D; + } + + var36 *= var36; + var34 = var34 * (1.0D - var36) - var36 * 10.0D + 5.0D; + if(var34 < 0.0D) { + var34 -= var34 * var34 * (double)0.2F; + } + } else if(var34 < 0.0D) { + var34 *= 0.8D; + } + + var14[var22 + var25 * var9.width] = (int)var34; + } + + ++var22; + } + } + + this.guiLoading.displayLoadingString("Soiling.."); + this.loadingBar(); + var46 = var8; + var9 = this; + int var49 = this.width; + var51 = this.depth; + var52 = this.height; + NoiseGeneratorOctaves var54 = new NoiseGeneratorOctaves(this.rand, 8); + NoiseGeneratorOctaves var55 = new NoiseGeneratorOctaves(this.rand, 8); + + for(var21 = 0; var21 < var49; ++var21) { + double var57 = Math.abs(((double)var21 / ((double)var49 - 1.0D) - 0.5D) * 2.0D); + var9.setNextPhase((float)var21 * 100.0F / (float)(var49 - 1)); + + for(int var24 = 0; var24 < var51; ++var24) { + double var64 = Math.abs(((double)var24 / ((double)var51 - 1.0D) - 0.5D) * 2.0D); + double var27 = Math.max(var57, var64); + var27 = var27 * var27 * var27; + int var29 = (int)(var54.generateNoise((double)var21, (double)var24) / 24.0D) - 4; + int var72 = var46[var21 + var24 * var49] + var9.waterLevel; + var31 = var72 + var29; + var46[var21 + var24 * var49] = Math.max(var72, var31); + if(var46[var21 + var24 * var49] > var52 - 2) { + var46[var21 + var24 * var49] = var52 - 2; + } + + if(var46[var21 + var24 * var49] <= 0) { + var46[var21 + var24 * var49] = 1; + } + + var32 = var55.generateNoise((double)var21 * 2.3D, (double)var24 * 2.3D) / 24.0D; + int var76 = (int)(Math.sqrt(Math.abs(var32)) * Math.signum(var32) * 20.0D) + var9.waterLevel; + var76 = (int)((double)var76 * (1.0D - var27) + var27 * (double)var9.height); + if(var76 > var9.waterLevel) { + var76 = var9.height; + } + + for(int var35 = 0; var35 < var52; ++var35) { + int var79 = (var35 * var9.depth + var24) * var9.width + var21; + int var37 = 0; + if(var35 <= var72) { + var37 = Block.dirt.blockID; + } + + if(var35 <= var31) { + var37 = Block.stone.blockID; + } + + if(var9.floatingGen && var35 < var76) { + var37 = 0; + } + + if(var9.blocksByteArray[var79] == 0) { + var9.blocksByteArray[var79] = (byte)var37; + } + } + } + } + + this.guiLoading.displayLoadingString("Growing.."); + this.loadingBar(); + var46 = var8; + var9 = this; + var49 = this.width; + var51 = this.depth; + var13 = new NoiseGeneratorOctaves(this.rand, 8); + var54 = new NoiseGeneratorOctaves(this.rand, 8); + var56 = this.waterLevel - 1; + if(this.levelType == 2) { + var56 += 2; + } + + for(var21 = 0; var21 < var49; ++var21) { + var9.setNextPhase((float)var21 * 100.0F / (float)(var49 - 1)); + + for(var22 = 0; var22 < var51; ++var22) { + boolean var60 = var13.generateNoise((double)var21, (double)var22) > 8.0D; + if(var9.islandGen) { + var60 = var13.generateNoise((double)var21, (double)var22) > -8.0D; + } + + if(var9.levelType == 2) { + var60 = var13.generateNoise((double)var21, (double)var22) > -32.0D; + } + + boolean var61 = var54.generateNoise((double)var21, (double)var22) > 12.0D; + if(var9.levelType == 1 || var9.levelType == 3) { + var60 = var13.generateNoise((double)var21, (double)var22) > -8.0D; + } + + var25 = var46[var21 + var22 * var49]; + int var65 = (var25 * var9.depth + var22) * var9.width + var21; + int var67 = var9.blocksByteArray[((var25 + 1) * var9.depth + var22) * var9.width + var21] & 255; + if((var67 == Block.waterMoving.blockID || var67 == Block.waterStill.blockID || var67 == 0) && var25 <= var9.waterLevel - 1 && var61) { + var9.blocksByteArray[var65] = (byte)Block.gravel.blockID; + } + + if(var67 == 0) { + int var69 = -1; + if(var25 <= var56 && var60) { + var69 = Block.sand.blockID; + if(var9.levelType == 1) { + var69 = Block.grass.blockID; + } + } + + if(var9.blocksByteArray[var65] != 0 && var69 > 0) { + var9.blocksByteArray[var65] = (byte)var69; + } + } + } + } + } + + this.guiLoading.displayLoadingString("Carving.."); + this.loadingBar(); + var9 = this; + var51 = this.width; + var52 = this.depth; + var53 = this.height; + var56 = var51 * var52 * var53 / 256 / 64 << 1; + + for(var21 = 0; var21 < var56; ++var21) { + var9.setNextPhase((float)var21 * 100.0F / (float)(var56 - 1)); + float var59 = var9.rand.nextFloat() * (float)var51; + float var63 = var9.rand.nextFloat() * (float)var53; + float var62 = var9.rand.nextFloat() * (float)var52; + var25 = (int)((var9.rand.nextFloat() + var9.rand.nextFloat()) * 200.0F); + float var66 = var9.rand.nextFloat() * (float)Math.PI * 2.0F; + float var68 = 0.0F; + float var71 = var9.rand.nextFloat() * (float)Math.PI * 2.0F; + float var70 = 0.0F; + float var73 = var9.rand.nextFloat() * var9.rand.nextFloat(); + + for(var31 = 0; var31 < var25; ++var31) { + var59 += MathHelper.sin(var66) * MathHelper.cos(var71); + var62 += MathHelper.cos(var66) * MathHelper.cos(var71); + var63 += MathHelper.sin(var71); + var66 += var68 * 0.2F; + var68 *= 0.9F; + var68 += var9.rand.nextFloat() - var9.rand.nextFloat(); + var71 += var70 * 0.5F; + var71 *= 0.5F; + var70 *= 12.0F / 16.0F; + var70 += var9.rand.nextFloat() - var9.rand.nextFloat(); + if(var9.rand.nextFloat() >= 0.25F) { + float var74 = var59 + (var9.rand.nextFloat() * 4.0F - 2.0F) * 0.2F; + float var33 = var63 + (var9.rand.nextFloat() * 4.0F - 2.0F) * 0.2F; + float var77 = var62 + (var9.rand.nextFloat() * 4.0F - 2.0F) * 0.2F; + float var75 = ((float)var9.height - var33) / (float)var9.height; + float var80 = 1.2F + (var75 * 3.5F + 1.0F) * var73; + float var78 = MathHelper.sin((float)var31 * (float)Math.PI / (float)var25) * var80; + + for(var5 = (int)(var74 - var78); var5 <= (int)(var74 + var78); ++var5) { + for(int var81 = (int)(var33 - var78); var81 <= (int)(var33 + var78); ++var81) { + for(int var40 = (int)(var77 - var78); var40 <= (int)(var77 + var78); ++var40) { + float var41 = (float)var5 - var74; + float var42 = (float)var81 - var33; + float var48 = (float)var40 - var77; + var41 = var41 * var41 + var42 * var42 * 2.0F + var48 * var48; + if(var41 < var78 * var78 && var5 > 0 && var81 > 0 && var40 > 0 && var5 < var9.width - 1 && var81 < var9.height - 1 && var40 < var9.depth - 1) { + var7 = (var81 * var9.depth + var40) * var9.width + var5; + if(var9.blocksByteArray[var7] == Block.stone.blockID) { + var9.blocksByteArray[var7] = 0; + } + } + } + } + } + } + } + } + + var7 = this.populateOre(Block.oreCoal.blockID, 1000, 10, (var4 << 2) / 5); + int var44 = this.populateOre(Block.oreIron.blockID, 800, 8, var4 * 3 / 5); + var45 = this.populateOre(Block.oreGold.blockID, 500, 6, (var4 << 1) / 5); + var5 = this.populateOre(Block.oreDiamond.blockID, 800, 2, var4 / 5); + System.out.println("Coal: " + var7 + ", Iron: " + var44 + ", Gold: " + var45 + ", Diamond: " + var5); + this.guiLoading.displayLoadingString("Melting.."); + this.loadingBar(); + this.lavaGen(); + var6.cloudHeight = var4 + 2; + if(this.floatingGen) { + this.groundLevel = -128; + this.waterLevel = this.groundLevel + 1; + var6.cloudHeight = -16; + } else if(!this.islandGen) { + this.groundLevel = this.waterLevel + 1; + this.waterLevel = this.groundLevel - 16; + } else { + this.groundLevel = this.waterLevel - 9; + } + + this.guiLoading.displayLoadingString("Watering.."); + this.loadingBar(); + this.liquidThemeSpawner(); + if(!this.floatingGen) { + var5 = Block.waterStill.blockID; + if(this.levelType == 1) { + var5 = Block.lavaStill.blockID; + } + + for(var7 = 0; var7 < var2; ++var7) { + this.floodFill(var7, this.waterLevel - 1, 0, 0, var5); + this.floodFill(var7, this.waterLevel - 1, var3 - 1, 0, var5); + } + + for(var7 = 0; var7 < var3; ++var7) { + this.floodFill(var2 - 1, this.waterLevel - 1, var7, 0, var5); + this.floodFill(0, this.waterLevel - 1, var7, 0, var5); + } + } + + if(this.levelType == 0) { + var6.skyColor = 10079487; + var6.fogColor = 16777215; + var6.cloudColor = 16777215; + } + + if(this.levelType == 1) { + var6.cloudColor = 2164736; + var6.fogColor = 1049600; + var6.skyColor = 1049600; + var6.skylightSubtracted = var6.skyBrightness = 7; + var6.defaultFluid = Block.lavaMoving.blockID; + if(this.floatingGen) { + var6.cloudHeight = var4 + 2; + this.waterLevel = -16; + } + } + + if(this.levelType == 2) { + var6.skyColor = 13033215; + var6.fogColor = 13033215; + var6.cloudColor = 15658751; + var6.skylightSubtracted = var6.skyBrightness = 15; + var6.skyBrightness = 16; + var6.cloudHeight = var4 + 64; + } + + if(this.levelType == 3) { + var6.skyColor = 7699847; + var6.fogColor = 5069403; + var6.cloudColor = 5069403; + var6.skylightSubtracted = var6.skyBrightness = 12; + } + + var6.waterLevel = this.waterLevel; + var6.groundLevel = this.groundLevel; + this.guiLoading.displayLoadingString("Assembling.."); + this.loadingBar(); + this.setNextPhase(0.0F); + var6.generate(var2, var4, var3, this.blocksByteArray, (byte[])null); + this.guiLoading.displayLoadingString("Building.."); + this.loadingBar(); + this.setNextPhase(0.0F); + var6.findSpawn(); + generateHouse(var6); + this.guiLoading.displayLoadingString("Planting.."); + this.loadingBar(); + if(this.levelType != 1) { + this.growGrassOnDirt(var6); + } + + this.loadingBar(); + this.growTrees(var6); + if(this.levelType == 3) { + for(var5 = 0; var5 < 50; ++var5) { + this.growTrees(var6); + } + } + + short var43 = 100; + if(this.levelType == 2) { + var43 = 1000; + } + + this.loadingBar(); + this.populateFlowersAndMushrooms(var6, Block.plantYellow, var43); + this.loadingBar(); + this.populateFlowersAndMushrooms(var6, Block.plantRed, var43); + this.loadingBar(); + this.populateFlowersAndMushrooms(var6, Block.mushroomBrown, 50); + this.loadingBar(); + this.populateFlowersAndMushrooms(var6, Block.mushroomRed, 50); + this.guiLoading.displayLoadingString("Lighting.."); + this.loadingBar(); + + for(var7 = 0; var7 < 10000; ++var7) { + this.setNextPhase((float)(var7 * 100 / 10000)); + var6.updateLighting(); + } + + this.guiLoading.displayLoadingString("Spawning.."); + this.loadingBar(); + MobSpawner var47 = new MobSpawner(var6); + + for(var2 = 0; var2 < 1000; ++var2) { + this.setNextPhase((float)var2 * 100.0F / 999.0F); + var47.performSpawning(); + } + + var6.createTime = System.currentTimeMillis(); + var6.authorName = var1; + var6.name = "A Nice World"; + if(this.phaseBar != this.phases) { + throw new IllegalStateException("Wrong number of phases! Wanted " + this.phases + ", got " + this.phaseBar); + } else { + return var6; + } + } + + private static void generateHouse(World var0) { + int var1 = var0.xSpawn; + int var2 = var0.ySpawn; + int var3 = var0.zSpawn; + + for(int var4 = var1 - 3; var4 <= var1 + 3; ++var4) { + for(int var5 = var2 - 2; var5 <= var2 + 2; ++var5) { + for(int var6 = var3 - 3; var6 <= var3 + 3; ++var6) { + int var7 = var5 < var2 - 1 ? Block.obsidian.blockID : 0; + if(var4 == var1 - 3 || var6 == var3 - 3 || var4 == var1 + 3 || var6 == var3 + 3 || var5 == var2 - 2 || var5 == var2 + 2) { + var7 = Block.stone.blockID; + if(var5 >= var2 - 1) { + var7 = Block.planks.blockID; + } + } + + if(var6 == var3 - 3 && var4 == var1 && var5 >= var2 - 1 && var5 <= var2) { + var7 = 0; + } + + var0.setBlockWithNotify(var4, var5, var6, var7); + } + } + } + + var0.setBlockWithNotify(var1 - 3 + 1, var2, var3, Block.torch.blockID); + var0.setBlockWithNotify(var1 + 3 - 1, var2, var3, Block.torch.blockID); + } + + private void growGrassOnDirt(World var1) { + for(int var2 = 0; var2 < this.width; ++var2) { + this.setNextPhase((float)var2 * 100.0F / (float)(this.width - 1)); + + for(int var3 = 0; var3 < this.height; ++var3) { + for(int var4 = 0; var4 < this.depth; ++var4) { + if(var1.getBlockId(var2, var3, var4) == Block.dirt.blockID && var1.getBlockLightValue(var2, var3 + 1, var4) >= 4 && !var1.getBlockMaterial(var2, var3 + 1, var4).getCanBlockGrass()) { + var1.setBlock(var2, var3, var4, Block.grass.blockID); + } + } + } + } + + } + + private void growTrees(World var1) { + int var2 = this.width * this.depth * this.height / 80000; + + for(int var3 = 0; var3 < var2; ++var3) { + if(var3 % 100 == 0) { + this.setNextPhase((float)var3 * 100.0F / (float)(var2 - 1)); + } + + int var4 = this.rand.nextInt(this.width); + int var5 = this.rand.nextInt(this.height); + int var6 = this.rand.nextInt(this.depth); + + for(int var7 = 0; var7 < 25; ++var7) { + int var8 = var4; + int var9 = var5; + int var10 = var6; + + for(int var11 = 0; var11 < 20; ++var11) { + var8 += this.rand.nextInt(12) - this.rand.nextInt(12); + var9 += this.rand.nextInt(3) - this.rand.nextInt(6); + var10 += this.rand.nextInt(12) - this.rand.nextInt(12); + if(var8 >= 0 && var9 >= 0 && var10 >= 0 && var8 < this.width && var9 < this.height && var10 < this.depth) { + var1.growTrees(var8, var9, var10); + } + } + } + } + + } + + private void populateFlowersAndMushrooms(World var1, BlockFlower var2, int var3) { + var3 = (int)((long)this.width * (long)this.depth * (long)this.height * (long)var3 / 1600000L); + + for(int var4 = 0; var4 < var3; ++var4) { + if(var4 % 100 == 0) { + this.setNextPhase((float)var4 * 100.0F / (float)(var3 - 1)); + } + + int var5 = this.rand.nextInt(this.width); + int var6 = this.rand.nextInt(this.height); + int var7 = this.rand.nextInt(this.depth); + + for(int var8 = 0; var8 < 10; ++var8) { + int var9 = var5; + int var10 = var6; + int var11 = var7; + + for(int var12 = 0; var12 < 10; ++var12) { + var9 += this.rand.nextInt(4) - this.rand.nextInt(4); + var10 += this.rand.nextInt(2) - this.rand.nextInt(2); + var11 += this.rand.nextInt(4) - this.rand.nextInt(4); + if(var9 >= 0 && var11 >= 0 && var10 > 0 && var9 < this.width && var11 < this.depth && var10 < this.height && var1.getBlockId(var9, var10, var11) == 0 && var2.canBlockStay(var1, var9, var10, var11)) { + var1.setBlockWithNotify(var9, var10, var11, var2.blockID); + } + } + } + } + + } + + private int populateOre(int var1, int var2, int var3, int var4) { + int var5 = 0; + byte var26 = (byte)var1; + int var6 = this.width; + int var7 = this.depth; + int var8 = this.height; + var2 = var6 * var7 * var8 / 256 / 64 * var2 / 100; + + for(int var9 = 0; var9 < var2; ++var9) { + this.setNextPhase((float)var9 * 100.0F / (float)(var2 - 1)); + float var10 = this.rand.nextFloat() * (float)var6; + float var11 = this.rand.nextFloat() * (float)var8; + float var12 = this.rand.nextFloat() * (float)var7; + if(var11 <= (float)var4) { + int var13 = (int)((this.rand.nextFloat() + this.rand.nextFloat()) * 75.0F * (float)var3 / 100.0F); + float var14 = this.rand.nextFloat() * (float)Math.PI * 2.0F; + float var15 = 0.0F; + float var16 = this.rand.nextFloat() * (float)Math.PI * 2.0F; + float var17 = 0.0F; + + for(int var18 = 0; var18 < var13; ++var18) { + var10 += MathHelper.sin(var14) * MathHelper.cos(var16); + var12 += MathHelper.cos(var14) * MathHelper.cos(var16); + var11 += MathHelper.sin(var16); + var14 += var15 * 0.2F; + var15 *= 0.9F; + var15 += this.rand.nextFloat() - this.rand.nextFloat(); + var16 += var17 * 0.5F; + var16 *= 0.5F; + var17 *= 0.9F; + var17 += this.rand.nextFloat() - this.rand.nextFloat(); + float var19 = MathHelper.sin((float)var18 * (float)Math.PI / (float)var13) * (float)var3 / 100.0F + 1.0F; + + for(int var20 = (int)(var10 - var19); var20 <= (int)(var10 + var19); ++var20) { + for(int var21 = (int)(var11 - var19); var21 <= (int)(var11 + var19); ++var21) { + for(int var22 = (int)(var12 - var19); var22 <= (int)(var12 + var19); ++var22) { + float var23 = (float)var20 - var10; + float var24 = (float)var21 - var11; + float var25 = (float)var22 - var12; + var23 = var23 * var23 + var24 * var24 * 2.0F + var25 * var25; + if(var23 < var19 * var19 && var20 > 0 && var21 > 0 && var22 > 0 && var20 < this.width - 1 && var21 < this.height - 1 && var22 < this.depth - 1) { + int var27 = (var21 * this.depth + var22) * this.width + var20; + if(this.blocksByteArray[var27] == Block.stone.blockID) { + this.blocksByteArray[var27] = var26; + ++var5; + } + } + } + } + } + } + } + } + + return var5; + } + + private void liquidThemeSpawner() { + int var1 = Block.waterStill.blockID; + if(this.levelType == 1) { + var1 = Block.lavaStill.blockID; + } + + int var2 = this.width * this.depth * this.height / 1000; + + for(int var3 = 0; var3 < var2; ++var3) { + if(var3 % 100 == 0) { + this.setNextPhase((float)var3 * 100.0F / (float)(var2 - 1)); + } + + int var4 = this.rand.nextInt(this.width); + int var5 = this.rand.nextInt(this.height); + int var6 = this.rand.nextInt(this.depth); + if(this.blocksByteArray[(var5 * this.depth + var6) * this.width + var4] == 0) { + long var7 = this.floodFill(var4, var5, var6, 0, 255); + if(var7 > 0L && var7 < 640L) { + this.floodFill(var4, var5, var6, 255, var1); + } else { + this.floodFill(var4, var5, var6, 255, 0); + } + } + } + + this.setNextPhase(100.0F); + } + + private void loadingBar() { + ++this.phaseBar; + this.phaseBareLength = 0.0F; + this.setNextPhase(0.0F); + } + + private void setNextPhase(float var1) { + if(var1 < 0.0F) { + throw new IllegalStateException("Failed to set next phase!"); + } else { + int var2 = (int)(((float)(this.phaseBar - 1) + var1 / 100.0F) * 100.0F / (float)this.phases); + this.guiLoading.setLoadingProgress(var2); + } + } + + private void lavaGen() { + int var1 = this.width * this.depth * this.height / 2000; + int var2 = this.groundLevel; + + for(int var3 = 0; var3 < var1; ++var3) { + if(var3 % 100 == 0) { + this.setNextPhase((float)var3 * 100.0F / (float)(var1 - 1)); + } + + int var4 = this.rand.nextInt(this.width); + int var5 = Math.min(Math.min(this.rand.nextInt(var2), this.rand.nextInt(var2)), Math.min(this.rand.nextInt(var2), this.rand.nextInt(var2))); + int var6 = this.rand.nextInt(this.depth); + if(this.blocksByteArray[(var5 * this.depth + var6) * this.width + var4] == 0) { + long var7 = this.floodFill(var4, var5, var6, 0, 255); + if(var7 > 0L && var7 < 640L) { + this.floodFill(var4, var5, var6, 255, Block.lavaStill.blockID); + } else { + this.floodFill(var4, var5, var6, 255, 0); + } + } + } + + this.setNextPhase(100.0F); + } + + private long floodFill(int var1, int var2, int var3, int var4, int var5) { + byte var6 = (byte)var5; + byte var22 = (byte)var4; + ArrayList var7 = new ArrayList(); + byte var8 = 0; + int var9 = 1; + + int var10; + for(var10 = 1; 1 << var9 < this.width; ++var9) { + } + + while(1 << var10 < this.depth) { + ++var10; + } + + int var11 = this.depth - 1; + int var12 = this.width - 1; + int var23 = var8 + 1; + this.floodFillBlocks[0] = ((var2 << var10) + var3 << var9) + var1; + long var14 = 0L; + var1 = this.width * this.depth; + + while(var23 > 0) { + --var23; + var2 = this.floodFillBlocks[var23]; + if(var23 == 0 && var7.size() > 0) { + this.floodFillBlocks = (int[])var7.remove(var7.size() - 1); + var23 = this.floodFillBlocks.length; + } + + var3 = var2 >> var9 & var11; + int var13 = var2 >> var9 + var10; + int var16 = var2 & var12; + + int var17; + for(var17 = var16; var16 > 0 && this.blocksByteArray[var2 - 1] == var22; --var2) { + --var16; + } + + while(var17 < this.width && this.blocksByteArray[var2 + var17 - var16] == var22) { + ++var17; + } + + int var18 = var2 >> var9 & var11; + int var19 = var2 >> var9 + var10; + if(var5 == 255 && (var16 == 0 || var17 == this.width - 1 || var13 == 0 || var13 == this.height - 1 || var3 == 0 || var3 == this.depth - 1)) { + return -1L; + } + + if(var18 != var3 || var19 != var13) { + System.out.println("Diagonal flood!?"); + } + + boolean var24 = false; + boolean var25 = false; + boolean var20 = false; + var14 += (long)(var17 - var16); + + for(var16 = var16; var16 < var17; ++var16) { + this.blocksByteArray[var2] = var6; + boolean var21; + if(var3 > 0) { + var21 = this.blocksByteArray[var2 - this.width] == var22; + if(var21 && !var24) { + if(var23 == this.floodFillBlocks.length) { + var7.add(this.floodFillBlocks); + this.floodFillBlocks = new int[1048576]; + var23 = 0; + } + + this.floodFillBlocks[var23++] = var2 - this.width; + } + + var24 = var21; + } + + if(var3 < this.depth - 1) { + var21 = this.blocksByteArray[var2 + this.width] == var22; + if(var21 && !var25) { + if(var23 == this.floodFillBlocks.length) { + var7.add(this.floodFillBlocks); + this.floodFillBlocks = new int[1048576]; + var23 = 0; + } + + this.floodFillBlocks[var23++] = var2 + this.width; + } + + var25 = var21; + } + + if(var13 > 0) { + byte var26 = this.blocksByteArray[var2 - var1]; + if((var6 == Block.lavaMoving.blockID || var6 == Block.lavaStill.blockID) && (var26 == Block.waterMoving.blockID || var26 == Block.waterStill.blockID)) { + this.blocksByteArray[var2 - var1] = (byte)Block.stone.blockID; + } + + var21 = var26 == var22; + if(var21 && !var20) { + if(var23 == this.floodFillBlocks.length) { + var7.add(this.floodFillBlocks); + this.floodFillBlocks = new int[1048576]; + var23 = 0; + } + + this.floodFillBlocks[var23++] = var2 - var1; + } + + var20 = var21; + } + + ++var2; + } + } + + return var14; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGenerator.java b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGenerator.java new file mode 100644 index 0000000..bc31ab2 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGenerator.java @@ -0,0 +1,5 @@ +package net.minecraft.game.level.generator.noise; + +public abstract class NoiseGenerator { + public abstract double generateNoise(double var1, double var3); +} diff --git a/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.java b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.java new file mode 100644 index 0000000..dd84f6b --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.java @@ -0,0 +1,15 @@ +package net.minecraft.game.level.generator.noise; + +public final class NoiseGeneratorDistort extends NoiseGenerator { + private NoiseGenerator source; + private NoiseGenerator distort; + + public NoiseGeneratorDistort(NoiseGenerator var1, NoiseGenerator var2) { + this.source = var1; + this.distort = var2; + } + + public final double generateNoise(double var1, double var3) { + return this.source.generateNoise(var1 + this.distort.generateNoise(var1, var3), var3); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.java b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.java new file mode 100644 index 0000000..1c66d68 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.java @@ -0,0 +1,30 @@ +package net.minecraft.game.level.generator.noise; + +import java.util.Random; + +public final class NoiseGeneratorOctaves extends NoiseGenerator { + private NoiseGeneratorPerlin[] generatorCollection; + private int octaves; + + public NoiseGeneratorOctaves(Random var1, int var2) { + this.octaves = var2; + this.generatorCollection = new NoiseGeneratorPerlin[var2]; + + for(int var3 = 0; var3 < var2; ++var3) { + this.generatorCollection[var3] = new NoiseGeneratorPerlin(var1); + } + + } + + public final double generateNoise(double var1, double var3) { + double var5 = 0.0D; + double var7 = 1.0D; + + for(int var9 = 0; var9 < this.octaves; ++var9) { + var5 += this.generatorCollection[var9].generateNoise(var1 / var7, var3 / var7) * var7; + var7 *= 2.0D; + } + + return var5; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.java b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.java new file mode 100644 index 0000000..4ac5d84 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.java @@ -0,0 +1,66 @@ +package net.minecraft.game.level.generator.noise; + +import java.util.Random; + +import net.PeytonPlayz585.math.MathHelper; + +public final class NoiseGeneratorPerlin extends NoiseGenerator { + private int[] permutations; + + public NoiseGeneratorPerlin() { + this(new Random()); + } + + public NoiseGeneratorPerlin(Random var1) { + this.permutations = new int[512]; + + int var2; + for(var2 = 0; var2 < 256; this.permutations[var2] = var2++) { + } + + for(var2 = 0; var2 < 256; ++var2) { + int var3 = var1.nextInt(256 - var2) + var2; + int var4 = this.permutations[var2]; + this.permutations[var2] = this.permutations[var3]; + this.permutations[var3] = var4; + this.permutations[var2 + 256] = this.permutations[var2]; + } + + } + + private static double generateNoise(double var0) { + return var0 * var0 * var0 * (var0 * (var0 * 6.0D - 15.0D) + 10.0D); + } + + private static double lerp(double var0, double var2, double var4) { + return var2 + var0 * (var4 - var2); + } + + private static double grad(int var0, double var1, double var3, double var5) { + var0 &= 15; + double var8 = var0 < 8 ? var1 : var3; + double var10 = var0 < 4 ? var3 : (var0 != 12 && var0 != 14 ? var5 : var1); + return ((var0 & 1) == 0 ? var8 : -var8) + ((var0 & 2) == 0 ? var10 : -var10); + } + + public final double generateNoise(double var1, double var3) { + double var10 = 0.0D; + double var8 = var3; + int var2 = MathHelper.floor_double(var1) & 255; + int var21 = MathHelper.floor_double(var3) & 255; + int var4 = MathHelper.floor_double(0.0D) & 255; + double var6 = var1 - (double)MathHelper.floor_double(var1); + var8 -= (double)MathHelper.floor_double(var8); + var10 = 0.0D - (double)MathHelper.floor_double(0.0D); + double var15 = generateNoise(var6); + double var17 = generateNoise(var8); + double var19 = generateNoise(var10); + int var5 = this.permutations[var2] + var21; + int var12 = this.permutations[var5] + var4; + var5 = this.permutations[var5 + 1] + var4; + var2 = this.permutations[var2 + 1] + var21; + var21 = this.permutations[var2] + var4; + var2 = this.permutations[var2 + 1] + var4; + return lerp(var19, lerp(var17, lerp(var15, grad(this.permutations[var12], var6, var8, var10), grad(this.permutations[var21], var6 - 1.0D, var8, var10)), lerp(var15, grad(this.permutations[var5], var6, var8 - 1.0D, var10), grad(this.permutations[var2], var6 - 1.0D, var8 - 1.0D, var10))), lerp(var17, lerp(var15, grad(this.permutations[var12 + 1], var6, var8, var10 - 1.0D), grad(this.permutations[var21 + 1], var6 - 1.0D, var8, var10 - 1.0D)), lerp(var15, grad(this.permutations[var5 + 1], var6, var8 - 1.0D, var10 - 1.0D), grad(this.permutations[var2 + 1], var6 - 1.0D, var8 - 1.0D, var10 - 1.0D)))); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/material/Material.java b/src/teavm/java/net/minecraft/game/level/material/Material.java new file mode 100644 index 0000000..2e68163 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/material/Material.java @@ -0,0 +1,40 @@ +package net.minecraft.game.level.material; + +public class Material { + public static final Material air = new MaterialTransparent(); + public static final Material ground = new Material(); + public static final Material wood = new Material(); + public static final Material rock = new Material(); + public static final Material iron = new Material(); + public static final Material water = new MaterialLiquid(); + public static final Material lava = new MaterialLiquid(); + public static final Material leaves = new Material(); + public static final Material plants = new MaterialLogic(); + public static final Material sponge = new Material(); + public static final Material cloth = new Material(); + public static final Material fire = new MaterialTransparent(); + public static final Material sand = new Material(); + public static final Material circuits = new MaterialLogic(); + public static final Material glass = new Material(); + public static final Material tnt = new Material(); + + public boolean getIsLiquid() { + return false; + } + + public final boolean liquidSolidCheck() { + return !this.getIsLiquid() && !this.isSolid(); + } + + public boolean isSolid() { + return true; + } + + public boolean getCanBlockGrass() { + return true; + } + + public boolean getIsSolid() { + return true; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/material/MaterialLiquid.java b/src/teavm/java/net/minecraft/game/level/material/MaterialLiquid.java new file mode 100644 index 0000000..2f90b89 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/material/MaterialLiquid.java @@ -0,0 +1,11 @@ +package net.minecraft.game.level.material; + +public final class MaterialLiquid extends Material { + public final boolean getIsLiquid() { + return true; + } + + public final boolean isSolid() { + return false; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/material/MaterialLogic.java b/src/teavm/java/net/minecraft/game/level/material/MaterialLogic.java new file mode 100644 index 0000000..95181c0 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/material/MaterialLogic.java @@ -0,0 +1,15 @@ +package net.minecraft.game.level.material; + +public final class MaterialLogic extends Material { + public final boolean isSolid() { + return false; + } + + public final boolean getCanBlockGrass() { + return false; + } + + public final boolean getIsSolid() { + return false; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/material/MaterialTransparent.java b/src/teavm/java/net/minecraft/game/level/material/MaterialTransparent.java new file mode 100644 index 0000000..138dbcf --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/material/MaterialTransparent.java @@ -0,0 +1,15 @@ +package net.minecraft.game.level.material; + +public final class MaterialTransparent extends Material { + public final boolean isSolid() { + return false; + } + + public final boolean getCanBlockGrass() { + return false; + } + + public final boolean getIsSolid() { + return false; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/path/Path.java b/src/teavm/java/net/minecraft/game/level/path/Path.java new file mode 100644 index 0000000..7811654 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/path/Path.java @@ -0,0 +1,118 @@ +package net.minecraft.game.level.path; + +public final class Path { + private PathPoint[] pathPoints = new PathPoint[1024]; + private int count = 0; + + public final PathPoint addPoint(PathPoint var1) { + if(var1.index >= 0) { + throw new IllegalStateException("OW KNOWS!"); + } else { + if(this.count == this.pathPoints.length) { + PathPoint[] var2 = new PathPoint[this.count << 1]; + System.arraycopy(this.pathPoints, 0, var2, 0, this.count); + this.pathPoints = var2; + } + + this.pathPoints[this.count] = var1; + var1.index = this.count; + this.sortBack(this.count++); + return var1; + } + } + + public final void clearPath() { + this.count = 0; + } + + public final PathPoint dequeue() { + PathPoint var1 = this.pathPoints[0]; + this.pathPoints[0] = this.pathPoints[--this.count]; + this.pathPoints[this.count] = null; + if(this.count > 0) { + this.sortForward(0); + } + + var1.index = -1; + return var1; + } + + public final void changeDistance(PathPoint var1, float var2) { + float var3 = var1.distanceToTarget; + var1.distanceToTarget = var2; + if(var2 < var3) { + this.sortBack(var1.index); + } else { + this.sortForward(var1.index); + } + } + + private void sortBack(int var1) { + PathPoint var2 = this.pathPoints[var1]; + + int var4; + for(float var3 = var2.distanceToTarget; var1 > 0; var1 = var4) { + var4 = var1 - 1 >> 1; + PathPoint var5 = this.pathPoints[var4]; + if(var3 >= var5.distanceToTarget) { + break; + } + + this.pathPoints[var1] = var5; + var5.index = var1; + } + + this.pathPoints[var1] = var2; + var2.index = var1; + } + + private void sortForward(int var1) { + PathPoint var2 = this.pathPoints[var1]; + float var3 = var2.distanceToTarget; + + while(true) { + int var4 = 1 + (var1 << 1); + int var5 = var4 + 1; + if(var4 >= this.count) { + break; + } + + PathPoint var6 = this.pathPoints[var4]; + float var7 = var6.distanceToTarget; + PathPoint var8; + float var9; + if(var5 >= this.count) { + var8 = null; + var9 = Float.POSITIVE_INFINITY; + } else { + var8 = this.pathPoints[var5]; + var9 = var8.distanceToTarget; + } + + if(var7 < var9) { + if(var7 >= var3) { + break; + } + + this.pathPoints[var1] = var6; + var6.index = var1; + var1 = var4; + } else { + if(var9 >= var3) { + break; + } + + this.pathPoints[var1] = var8; + var8.index = var1; + var1 = var5; + } + } + + this.pathPoints[var1] = var2; + var2.index = var1; + } + + public final boolean isPathEmpty() { + return this.count == 0; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/path/PathEntity.java b/src/teavm/java/net/minecraft/game/level/path/PathEntity.java new file mode 100644 index 0000000..10e19c9 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/path/PathEntity.java @@ -0,0 +1,28 @@ +package net.minecraft.game.level.path; + +import net.minecraft.game.entity.Entity; +import net.minecraft.game.physics.Vec3D; + +public final class PathEntity { + private final PathPoint[] points; + private int pathIndex; + + public PathEntity(PathPoint[] var1) { + this.points = var1; + } + + public final void incrementPathIndex() { + ++this.pathIndex; + } + + public final boolean isFinished() { + return this.pathIndex >= this.points.length; + } + + public final Vec3D getPosition(Entity var1) { + float var2 = (float)this.points[this.pathIndex].xCoord + (float)((int)(var1.width + 1.0F)) * 0.5F; + float var3 = (float)this.points[this.pathIndex].yCoord; + float var4 = (float)this.points[this.pathIndex].zCoord + (float)((int)(var1.width + 1.0F)) * 0.5F; + return new Vec3D(var2, var3, var4); + } +} diff --git a/src/teavm/java/net/minecraft/game/level/path/PathPoint.java b/src/teavm/java/net/minecraft/game/level/path/PathPoint.java new file mode 100644 index 0000000..6018e64 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/path/PathPoint.java @@ -0,0 +1,46 @@ +package net.minecraft.game.level.path; + +import net.PeytonPlayz585.math.MathHelper; + +public final class PathPoint { + public final int xCoord; + public final int yCoord; + public final int zCoord; + public final int hash; + int index = -1; + float totalPathDistance; + float distanceToNext; + float distanceToTarget; + PathPoint previous; + public boolean isFirst = false; + + public PathPoint(int var1, int var2, int var3) { + this.xCoord = var1; + this.yCoord = var2; + this.zCoord = var3; + this.hash = var1 | var2 << 10 | var3 << 20; + } + + public final float distanceTo(PathPoint var1) { + float var2 = (float)(var1.xCoord - this.xCoord); + float var3 = (float)(var1.yCoord - this.yCoord); + float var4 = (float)(var1.zCoord - this.zCoord); + return MathHelper.sqrt_float(var2 * var2 + var3 * var3 + var4 * var4); + } + + public final boolean equals(Object var1) { + return ((PathPoint)var1).hash == this.hash; + } + + public final int hashCode() { + return this.hash; + } + + public final boolean isAssigned() { + return this.index >= 0; + } + + public final String toString() { + return this.xCoord + ", " + this.yCoord + ", " + this.zCoord; + } +} diff --git a/src/teavm/java/net/minecraft/game/level/path/Pathfinder.java b/src/teavm/java/net/minecraft/game/level/path/Pathfinder.java new file mode 100644 index 0000000..25ac613 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/level/path/Pathfinder.java @@ -0,0 +1,222 @@ +package net.minecraft.game.level.path; + +import java.util.HashMap; +import java.util.Map; +import net.minecraft.game.entity.Entity; +import net.minecraft.game.level.World; +import net.minecraft.game.level.material.Material; + +public final class Pathfinder { + private World worldMap; + private Path path = new Path(); + private Map pointMap = new HashMap(); + private PathPoint[] pathOptions = new PathPoint[32]; + + public Pathfinder(World var1) { + this.worldMap = var1; + } + + public final PathEntity createEntityPathTo(Entity var1, Entity var2, float var3) { + return this.addToPath(var1, var2.posX, var2.boundingBox.minY, var2.posZ, 16.0F); + } + + public final PathEntity createEntityPathTo(Entity var1, int var2, int var3, int var4, float var5) { + return this.addToPath(var1, (float)var2 + 0.5F, (float)var3 + 0.5F, (float)var4 + 0.5F, 16.0F); + } + + private PathEntity addToPath(Entity var1, float var2, float var3, float var4, float var5) { + this.path.clearPath(); + this.pointMap.clear(); + PathPoint var6 = this.openPoint((int)var1.boundingBox.minX, (int)var1.boundingBox.minY, (int)var1.boundingBox.minZ); + PathPoint var22 = this.openPoint((int)(var2 - var1.width / 2.0F), (int)var3, (int)(var4 - var1.width / 2.0F)); + PathPoint var24 = new PathPoint((int)(var1.width + 1.0F), (int)(var1.height + 1.0F), (int)(var1.width + 1.0F)); + float var27 = var5; + PathPoint var26 = var24; + PathPoint var25 = var22; + Entity var23 = var1; + Pathfinder var20 = this; + var6.totalPathDistance = 0.0F; + var6.distanceToNext = var6.distanceTo(var22); + var6.distanceToTarget = var6.distanceToNext; + this.path.clearPath(); + this.path.addPoint(var6); + PathPoint var7 = var6; + + PathEntity var10000; + while(true) { + if(var20.path.isPathEmpty()) { + var10000 = var7 == var6 ? null : createEntityPath(var7); + break; + } + + PathPoint var8 = var20.path.dequeue(); + if(var8.hash == var25.hash) { + var10000 = createEntityPath(var25); + break; + } + + if(var8.distanceTo(var25) < var7.distanceTo(var25)) { + var7 = var8; + } + + var8.isFirst = true; + int var15 = 0; + byte var16 = 0; + if(var20.getVerticalOffset(var8.xCoord, var8.yCoord + 1, var8.zCoord, var26) > 0) { + var16 = 1; + } + + PathPoint var17 = var20.getSafePoint(var23, var8.xCoord, var8.yCoord, var8.zCoord + 1, var26, var16); + PathPoint var18 = var20.getSafePoint(var23, var8.xCoord - 1, var8.yCoord, var8.zCoord, var26, var16); + PathPoint var19 = var20.getSafePoint(var23, var8.xCoord + 1, var8.yCoord, var8.zCoord, var26, var16); + PathPoint var10 = var20.getSafePoint(var23, var8.xCoord, var8.yCoord, var8.zCoord - 1, var26, var16); + if(var17 != null && !var17.isFirst && var17.distanceTo(var25) < var27) { + ++var15; + var20.pathOptions[0] = var17; + } + + if(var18 != null && !var18.isFirst && var18.distanceTo(var25) < var27) { + var20.pathOptions[var15++] = var18; + } + + if(var19 != null && !var19.isFirst && var19.distanceTo(var25) < var27) { + var20.pathOptions[var15++] = var19; + } + + if(var10 != null && !var10.isFirst && var10.distanceTo(var25) < var27) { + var20.pathOptions[var15++] = var10; + } + + int var9 = var15; + + for(int var28 = 0; var28 < var9; ++var28) { + PathPoint var11 = var20.pathOptions[var28]; + float var12 = var8.totalPathDistance + var8.distanceTo(var11); + if(!var11.isAssigned() || var12 < var11.totalPathDistance) { + var11.previous = var8; + var11.totalPathDistance = var12; + var11.distanceToNext = var11.distanceTo(var25); + if(var11.isAssigned()) { + var20.path.changeDistance(var11, var11.totalPathDistance + var11.distanceToNext); + } else { + var11.distanceToTarget = var11.totalPathDistance + var11.distanceToNext; + var20.path.addPoint(var11); + } + } + } + } + + PathEntity var21 = var10000; + return var21; + } + + private PathPoint getSafePoint(Entity var1, int var2, int var3, int var4, PathPoint var5, int var6) { + PathPoint var8 = null; + if(this.getVerticalOffset(var2, var3, var4, var5) > 0) { + var8 = this.openPoint(var2, var3, var4); + } + + if(var8 == null && this.getVerticalOffset(var2, var3 + var6, var4, var5) > 0) { + var8 = this.openPoint(var2, var3 + var6, var4); + } + + if(var8 != null) { + var6 = 0; + + while(true) { + if(var3 > 0) { + int var7 = this.getVerticalOffset(var2, var3 - 1, var4, var5); + if(var7 > 0) { + if(var7 < 0) { + return null; + } + + ++var6; + if(var6 >= 4) { + return null; + } + + --var3; + var8 = this.openPoint(var2, var3, var4); + continue; + } + } + + Material var9 = this.worldMap.getBlockMaterial(var2, var3 - 1, var4); + if(var9 == Material.water || var9 == Material.lava) { + return null; + } + break; + } + } + + return var8; + } + + private final PathPoint openPoint(int var1, int var2, int var3) { + int var4 = var1 | var2 << 10 | var3 << 20; + PathPoint var5 = (PathPoint)this.pointMap.get(Integer.valueOf(var4)); + if(var5 == null) { + var5 = new PathPoint(var1, var2, var3); + this.pointMap.put(Integer.valueOf(var4), var5); + } + + return var5; + } + + private int getVerticalOffset(int var1, int var2, int var3, PathPoint var4) { + for(int var5 = var1; var5 < var1 + var4.xCoord; ++var5) { + if(var5 < 0 || var5 >= this.worldMap.width) { + return 0; + } + + for(int var6 = var2; var6 < var2 + var4.yCoord; ++var6) { + if(var6 < 0 || var6 >= this.worldMap.height) { + return 0; + } + + int var7 = var3; + + while(var7 < var3 + var4.zCoord) { + if(var7 >= 0 && var7 < this.worldMap.length) { + Material var8 = this.worldMap.getBlockMaterial(var1, var2, var3); + if(var8.getIsSolid()) { + return 0; + } + + if(var8 != Material.water && var8 != Material.lava) { + ++var7; + continue; + } + + return -1; + } + + return 0; + } + } + } + + return 1; + } + + private static PathEntity createEntityPath(PathPoint var0) { + int var1 = 1; + + PathPoint var2; + for(var2 = var0; var2.previous != null; var2 = var2.previous) { + ++var1; + } + + PathPoint[] var3 = new PathPoint[var1]; + var2 = var0; + --var1; + + for(var3[var1] = var0; var2.previous != null; var3[var1] = var2) { + var2 = var2.previous; + --var1; + } + + return new PathEntity(var3); + } +} diff --git a/src/teavm/java/net/minecraft/game/physics/AxisAlignedBB.java b/src/teavm/java/net/minecraft/game/physics/AxisAlignedBB.java new file mode 100644 index 0000000..c7931eb --- /dev/null +++ b/src/teavm/java/net/minecraft/game/physics/AxisAlignedBB.java @@ -0,0 +1,266 @@ +package net.minecraft.game.physics; + +public final class AxisAlignedBB { + private float epsilon = 0.0F; + public float minX; + public float minY; + public float minZ; + public float maxX; + public float maxY; + public float maxZ; + + public AxisAlignedBB(float var1, float var2, float var3, float var4, float var5, float var6) { + this.minX = var1; + this.minY = var2; + this.minZ = var3; + this.maxX = var4; + this.maxY = var5; + this.maxZ = var6; + } + + public final AxisAlignedBB addCoord(float var1, float var2, float var3) { + float var4 = this.minX; + float var5 = this.minY; + float var6 = this.minZ; + float var7 = this.maxX; + float var8 = this.maxY; + float var9 = this.maxZ; + if(var1 < 0.0F) { + var4 += var1; + } + + if(var1 > 0.0F) { + var7 += var1; + } + + if(var2 < 0.0F) { + var5 += var2; + } + + if(var2 > 0.0F) { + var8 += var2; + } + + if(var3 < 0.0F) { + var6 += var3; + } + + if(var3 > 0.0F) { + var9 += var3; + } + + return new AxisAlignedBB(var4, var5, var6, var7, var8, var9); + } + + public final AxisAlignedBB expand(float var1, float var2, float var3) { + if(this.minY > this.maxY) { + throw new IllegalArgumentException("NOOOOOO!"); + } else { + float var4 = this.minX - var1; + float var5 = this.minY - var2; + float var6 = this.minZ - var3; + var1 += this.maxX; + var2 += this.maxY; + var3 += this.maxZ; + return new AxisAlignedBB(var4, var5, var6, var1, var2, var3); + } + } + + public final float calculateXOffset(AxisAlignedBB var1, float var2) { + if(var1.maxY > this.minY && var1.minY < this.maxY) { + if(var1.maxZ > this.minZ && var1.minZ < this.maxZ) { + float var3; + if(var2 > 0.0F && var1.maxX <= this.minX) { + var3 = this.minX - var1.maxX; + if(var3 < var2) { + var2 = var3; + } + } + + if(var2 < 0.0F && var1.minX >= this.maxX) { + var3 = this.maxX - var1.minX; + if(var3 > var2) { + var2 = var3; + } + } + + return var2; + } else { + return var2; + } + } else { + return var2; + } + } + + public final float calculateYOffset(AxisAlignedBB var1, float var2) { + if(var1.maxX > this.minX && var1.minX < this.maxX) { + if(var1.maxZ > this.minZ && var1.minZ < this.maxZ) { + float var3; + if(var2 > 0.0F && var1.maxY <= this.minY) { + var3 = this.minY - var1.maxY; + if(var3 < var2) { + var2 = var3; + } + } + + if(var2 < 0.0F && var1.minY >= this.maxY) { + var3 = this.maxY - var1.minY; + if(var3 > var2) { + var2 = var3; + } + } + + return var2; + } else { + return var2; + } + } else { + return var2; + } + } + + public final float calculateZOffset(AxisAlignedBB var1, float var2) { + if(var1.maxX > this.minX && var1.minX < this.maxX) { + if(var1.maxY > this.minY && var1.minY < this.maxY) { + float var3; + if(var2 > 0.0F && var1.maxZ <= this.minZ) { + var3 = this.minZ - var1.maxZ; + if(var3 < var2) { + var2 = var3; + } + } + + if(var2 < 0.0F && var1.minZ >= this.maxZ) { + var3 = this.maxZ - var1.minZ; + if(var3 > var2) { + var2 = var3; + } + } + + return var2; + } else { + return var2; + } + } else { + return var2; + } + } + + public final boolean intersectsWith(AxisAlignedBB var1) { + return var1.maxX >= this.minX && var1.minX <= this.maxX ? (var1.maxY >= this.minY && var1.minY <= this.maxY ? var1.maxZ >= this.minZ && var1.minZ <= this.maxZ : false) : false; + } + + public final void offset(float var1, float var2, float var3) { + this.minX += var1; + this.minY += var2; + this.minZ += var3; + this.maxX += var1; + this.maxY += var2; + this.maxZ += var3; + } + + public final AxisAlignedBB copy() { + return new AxisAlignedBB(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ); + } + + public final MovingObjectPosition calculateIntercept(Vec3D var1, Vec3D var2) { + Vec3D var3 = var1.getIntermediateWithXValue(var2, this.minX); + Vec3D var4 = var1.getIntermediateWithXValue(var2, this.maxX); + Vec3D var5 = var1.getIntermediateWithYValue(var2, this.minY); + Vec3D var6 = var1.getIntermediateWithYValue(var2, this.maxY); + Vec3D var7 = var1.getIntermediateWithZValue(var2, this.minZ); + var2 = var1.getIntermediateWithZValue(var2, this.maxZ); + if(!this.isVecInYZ(var3)) { + var3 = null; + } + + if(!this.isVecInYZ(var4)) { + var4 = null; + } + + if(!this.isVecInXZ(var5)) { + var5 = null; + } + + if(!this.isVecInXZ(var6)) { + var6 = null; + } + + if(!this.isVecInXY(var7)) { + var7 = null; + } + + if(!this.isVecInXY(var2)) { + var2 = null; + } + + Vec3D var8 = null; + if(var3 != null) { + var8 = var3; + } + + if(var4 != null && (var8 == null || var1.squareDistanceTo(var4) < var1.squareDistanceTo(var8))) { + var8 = var4; + } + + if(var5 != null && (var8 == null || var1.squareDistanceTo(var5) < var1.squareDistanceTo(var8))) { + var8 = var5; + } + + if(var6 != null && (var8 == null || var1.squareDistanceTo(var6) < var1.squareDistanceTo(var8))) { + var8 = var6; + } + + if(var7 != null && (var8 == null || var1.squareDistanceTo(var7) < var1.squareDistanceTo(var8))) { + var8 = var7; + } + + if(var2 != null && (var8 == null || var1.squareDistanceTo(var2) < var1.squareDistanceTo(var8))) { + var8 = var2; + } + + if(var8 == null) { + return null; + } else { + byte var9 = -1; + if(var8 == var3) { + var9 = 4; + } + + if(var8 == var4) { + var9 = 5; + } + + if(var8 == var5) { + var9 = 0; + } + + if(var8 == var6) { + var9 = 1; + } + + if(var8 == var7) { + var9 = 2; + } + + if(var8 == var2) { + var9 = 3; + } + + return new MovingObjectPosition(0, 0, 0, var9, var8); + } + } + + private boolean isVecInYZ(Vec3D var1) { + return var1 == null ? false : var1.yCoord >= this.minY && var1.yCoord <= this.maxY && var1.zCoord >= this.minZ && var1.zCoord <= this.maxZ; + } + + private boolean isVecInXZ(Vec3D var1) { + return var1 == null ? false : var1.xCoord >= this.minX && var1.xCoord <= this.maxX && var1.zCoord >= this.minZ && var1.zCoord <= this.maxZ; + } + + private boolean isVecInXY(Vec3D var1) { + return var1 == null ? false : var1.xCoord >= this.minX && var1.xCoord <= this.maxX && var1.yCoord >= this.minY && var1.yCoord <= this.maxY; + } +} diff --git a/src/teavm/java/net/minecraft/game/physics/MovingObjectPosition.java b/src/teavm/java/net/minecraft/game/physics/MovingObjectPosition.java new file mode 100644 index 0000000..38ff908 --- /dev/null +++ b/src/teavm/java/net/minecraft/game/physics/MovingObjectPosition.java @@ -0,0 +1,28 @@ +package net.minecraft.game.physics; + +import net.minecraft.game.entity.Entity; + +public final class MovingObjectPosition { + public int typeOfHit; + public int blockX; + public int blockY; + public int blockZ; + public int sideHit; + public Vec3D hitVec; + public Entity entityHit; + + public MovingObjectPosition(int var1, int var2, int var3, int var4, Vec3D var5) { + this.typeOfHit = 0; + this.blockX = var1; + this.blockY = var2; + this.blockZ = var3; + this.sideHit = var4; + this.hitVec = new Vec3D(var5.xCoord, var5.yCoord, var5.zCoord); + } + + public MovingObjectPosition(Entity var1) { + this.typeOfHit = 1; + this.entityHit = var1; + this.hitVec = new Vec3D(var1.posX, var1.posY, var1.posZ); + } +} diff --git a/src/teavm/java/net/minecraft/game/physics/Vec3D.java b/src/teavm/java/net/minecraft/game/physics/Vec3D.java new file mode 100644 index 0000000..4029b4d --- /dev/null +++ b/src/teavm/java/net/minecraft/game/physics/Vec3D.java @@ -0,0 +1,82 @@ +package net.minecraft.game.physics; + +import net.PeytonPlayz585.math.MathHelper; + +public final class Vec3D { + public float xCoord; + public float yCoord; + public float zCoord; + + public Vec3D(float var1, float var2, float var3) { + this.xCoord = var1; + this.yCoord = var2; + this.zCoord = var3; + } + + public final Vec3D subtract(Vec3D var1) { + return new Vec3D(this.xCoord - var1.xCoord, this.yCoord - var1.yCoord, this.zCoord - var1.zCoord); + } + + public final Vec3D normalize() { + float var1 = MathHelper.sqrt_float(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord); + return new Vec3D(this.xCoord / var1, this.yCoord / var1, this.zCoord / var1); + } + + public final Vec3D addVector(float var1, float var2, float var3) { + return new Vec3D(this.xCoord + var1, this.yCoord + var2, this.zCoord + var3); + } + + public final float distance(Vec3D var1) { + float var2 = var1.xCoord - this.xCoord; + float var3 = var1.yCoord - this.yCoord; + float var4 = var1.zCoord - this.zCoord; + return MathHelper.sqrt_float(var2 * var2 + var3 * var3 + var4 * var4); + } + + public final float squareDistanceTo(Vec3D var1) { + float var2 = var1.xCoord - this.xCoord; + float var3 = var1.yCoord - this.yCoord; + float var4 = var1.zCoord - this.zCoord; + return var2 * var2 + var3 * var3 + var4 * var4; + } + + public final Vec3D getIntermediateWithXValue(Vec3D var1, float var2) { + float var3 = var1.xCoord - this.xCoord; + float var4 = var1.yCoord - this.yCoord; + float var5 = var1.zCoord - this.zCoord; + if(var3 * var3 < 1.0E-7F) { + return null; + } else { + var2 = (var2 - this.xCoord) / var3; + return var2 >= 0.0F && var2 <= 1.0F ? new Vec3D(this.xCoord + var3 * var2, this.yCoord + var4 * var2, this.zCoord + var5 * var2) : null; + } + } + + public final Vec3D getIntermediateWithYValue(Vec3D var1, float var2) { + float var3 = var1.xCoord - this.xCoord; + float var4 = var1.yCoord - this.yCoord; + float var5 = var1.zCoord - this.zCoord; + if(var4 * var4 < 1.0E-7F) { + return null; + } else { + var2 = (var2 - this.yCoord) / var4; + return var2 >= 0.0F && var2 <= 1.0F ? new Vec3D(this.xCoord + var3 * var2, this.yCoord + var4 * var2, this.zCoord + var5 * var2) : null; + } + } + + public final Vec3D getIntermediateWithZValue(Vec3D var1, float var2) { + float var3 = var1.xCoord - this.xCoord; + float var4 = var1.yCoord - this.yCoord; + float var5 = var1.zCoord - this.zCoord; + if(var5 * var5 < 1.0E-7F) { + return null; + } else { + var2 = (var2 - this.zCoord) / var5; + return var2 >= 0.0F && var2 <= 1.0F ? new Vec3D(this.xCoord + var3 * var2, this.yCoord + var4 * var2, this.zCoord + var5 * var2) : null; + } + } + + public final String toString() { + return "(" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ")"; + } +} diff --git a/src/teavm/java/org/lwjgl/BufferUtils.java b/src/teavm/java/org/lwjgl/BufferUtils.java new file mode 100644 index 0000000..3a28add --- /dev/null +++ b/src/teavm/java/org/lwjgl/BufferUtils.java @@ -0,0 +1,19 @@ +package org.lwjgl; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +public class BufferUtils extends GLAllocation { + public static FloatBuffer createFloatBuffer(int i1) { + return createDirectFloatBuffer(i1); + } + + public static IntBuffer createIntBuffer(int i1) { + return createDirectIntBuffer(i1); + } + + public static ByteBuffer createByteBuffer(int i1) { + return createDirectByteBuffer(i1); + } +} diff --git a/src/teavm/java/org/lwjgl/GLAllocation.java b/src/teavm/java/org/lwjgl/GLAllocation.java new file mode 100644 index 0000000..f115976 --- /dev/null +++ b/src/teavm/java/org/lwjgl/GLAllocation.java @@ -0,0 +1,60 @@ +package org.lwjgl; + +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 = GL11.glGenLists(i); + displayLists.add(Integer.valueOf(j)); + displayLists.add(Integer.valueOf(i)); + return j; + } + + public static synchronized void generateTextureNames(IntBuffer intbuffer) { + + for (int i = intbuffer.position(); i < intbuffer.limit(); i++) { + int tx = GL11.glGenTextures(); + intbuffer.put(i, tx); + textureNames.add(Integer.valueOf(tx)); + } + + } + + public static synchronized void deleteTexturesAndDisplayLists() { + for (int i = 0; i < displayLists.size(); i += 2) { + GL11.glDeleteLists(((Integer) displayLists.get(i)).intValue(), + ((Integer) displayLists.get(i + 1)).intValue()); + } + + for (int j = 0; j < textureNames.size(); j++) { + GL11.glDeleteTextures(((Integer) textureNames.get(j)).intValue()); + } + + displayLists.clear(); + textureNames.clear(); + } + + public static ByteBuffer createDirectByteBuffer(int par0) { + return ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()); + } + + public static IntBuffer createDirectIntBuffer(int par0) { + return IntBuffer.wrap(new int[par0]); + } + + public static FloatBuffer createDirectFloatBuffer(int par0) { + return FloatBuffer.wrap(new float[par0]); + } + + private static List displayLists = new ArrayList(); + private static List textureNames = new ArrayList(); + +} \ No newline at end of file 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..6228c38 --- /dev/null +++ b/src/teavm/java/org/lwjgl/opengl/GL11.java @@ -0,0 +1,5 @@ +package org.lwjgl.opengl; + +public class GL11 extends WebGLManager { + +} diff --git a/src/teavm/java/org/lwjgl/opengl/GLObjectMap.java b/src/teavm/java/org/lwjgl/opengl/GLObjectMap.java new file mode 100644 index 0000000..9826cd5 --- /dev/null +++ b/src/teavm/java/org/lwjgl/opengl/GLObjectMap.java @@ -0,0 +1,55 @@ +package org.lwjgl.opengl; + +public class GLObjectMap { + private Object[] values; + private int size; + private int insertIndex; + public int allocatedObjects; + + public GLObjectMap(int initialSize) { + this.values = new Object[initialSize]; + this.size = initialSize; + this.insertIndex = 0; + this.allocatedObjects = 0; + } + + public int register(T obj) { + int start = insertIndex; + do { + ++insertIndex; + if (insertIndex >= size) { + insertIndex = 0; + } + if (insertIndex == start) { + resize(); + return register(obj); + } + } while (values[insertIndex] != null); + values[insertIndex] = obj; + ++allocatedObjects; + return insertIndex; + } + + public T free(int obj) { + if (obj >= size || obj < 0) + return null; + Object ret = values[obj]; + values[obj] = null; + --allocatedObjects; + return (T) ret; + } + + public T get(int obj) { + if (obj >= size || obj < 0) + return null; + return (T) values[obj]; + } + + private void resize() { + int oldSize = size; + size += size / 2; + Object[] oldValues = values; + values = new Object[size]; + System.arraycopy(oldValues, 0, values, 0, oldSize); + } +} \ No newline at end of file diff --git a/src/teavm/java/org/lwjgl/opengl/RealOpenGLEnums.java b/src/teavm/java/org/lwjgl/opengl/RealOpenGLEnums.java new file mode 100644 index 0000000..75a633b --- /dev/null +++ b/src/teavm/java/org/lwjgl/opengl/RealOpenGLEnums.java @@ -0,0 +1,2417 @@ +package org.lwjgl.opengl; + +public class RealOpenGLEnums { + + // Field descriptor #544 I + public static final int GL_ACCUM = 256; + + // Field descriptor #544 I + public static final int GL_LOAD = 257; + + // Field descriptor #544 I + public static final int GL_RETURN = 258; + + // Field descriptor #544 I + public static final int GL_MULT = 259; + + // Field descriptor #544 I + public static final int GL_ADD = 260; + + // Field descriptor #544 I + public static final int GL_NEVER = 512; + + // Field descriptor #544 I + public static final int GL_LESS = 513; + + // Field descriptor #544 I + public static final int GL_EQUAL = 514; + + // Field descriptor #544 I + public static final int GL_LEQUAL = 515; + + // Field descriptor #544 I + public static final int GL_GREATER = 516; + + // Field descriptor #544 I + public static final int GL_NOTEQUAL = 517; + + // Field descriptor #544 I + public static final int GL_GEQUAL = 518; + + // Field descriptor #544 I + public static final int GL_ALWAYS = 519; + + // Field descriptor #544 I + public static final int GL_CURRENT_BIT = 1; + + // Field descriptor #544 I + public static final int GL_POINT_BIT = 2; + + // Field descriptor #544 I + public static final int GL_LINE_BIT = 4; + + // Field descriptor #544 I + public static final int GL_POLYGON_BIT = 8; + + // Field descriptor #544 I + public static final int GL_POLYGON_STIPPLE_BIT = 16; + + // Field descriptor #544 I + public static final int GL_PIXEL_MODE_BIT = 32; + + // Field descriptor #544 I + public static final int GL_LIGHTING_BIT = 64; + + // Field descriptor #544 I + public static final int GL_FOG_BIT = 128; + + // Field descriptor #544 I + public static final int GL_DEPTH_BUFFER_BIT = 256; + + // Field descriptor #544 I + public static final int GL_ACCUM_BUFFER_BIT = 512; + + // Field descriptor #544 I + public static final int GL_STENCIL_BUFFER_BIT = 1024; + + // Field descriptor #544 I + public static final int GL_VIEWPORT_BIT = 2048; + + // Field descriptor #544 I + public static final int GL_TRANSFORM_BIT = 4096; + + // Field descriptor #544 I + public static final int GL_ENABLE_BIT = 8192; + + // Field descriptor #544 I + public static final int GL_COLOR_BUFFER_BIT = 16384; + + // Field descriptor #544 I + public static final int GL_HINT_BIT = 32768; + + // Field descriptor #544 I + public static final int GL_EVAL_BIT = 65536; + + // Field descriptor #544 I + public static final int GL_LIST_BIT = 131072; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BIT = 262144; + + // Field descriptor #544 I + public static final int GL_SCISSOR_BIT = 524288; + + // Field descriptor #544 I + public static final int GL_ALL_ATTRIB_BITS = 1048575; + + // Field descriptor #544 I + public static final int GL_POINTS = 0; + + // Field descriptor #544 I + public static final int GL_LINES = 1; + + // Field descriptor #544 I + public static final int GL_LINE_LOOP = 2; + + // Field descriptor #544 I + public static final int GL_LINE_STRIP = 3; + + // Field descriptor #544 I + public static final int GL_TRIANGLES = 4; + + // Field descriptor #544 I + public static final int GL_TRIANGLE_STRIP = 5; + + // Field descriptor #544 I + public static final int GL_TRIANGLE_FAN = 6; + + // Field descriptor #544 I + public static final int GL_QUADS = 7; + + // Field descriptor #544 I + public static final int GL_QUAD_STRIP = 8; + + // Field descriptor #544 I + public static final int GL_POLYGON = 9; + + // Field descriptor #544 I + public static final int GL_ZERO = 0; + + // Field descriptor #544 I + public static final int GL_ONE = 1; + + // Field descriptor #544 I + public static final int GL_SRC_COLOR = 768; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_SRC_COLOR = 769; + + // Field descriptor #544 I + public static final int GL_SRC_ALPHA = 770; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_SRC_ALPHA = 771; + + // Field descriptor #544 I + public static final int GL_DST_ALPHA = 772; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_DST_ALPHA = 773; + + // Field descriptor #544 I + public static final int GL_DST_COLOR = 774; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_DST_COLOR = 775; + + // Field descriptor #544 I + public static final int GL_SRC_ALPHA_SATURATE = 776; + + // Field descriptor #544 I + public static final int GL_CONSTANT_COLOR = 32769; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_CONSTANT_COLOR = 32770; + + // Field descriptor #544 I + public static final int GL_CONSTANT_ALPHA = 32771; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_CONSTANT_ALPHA = 32772; + + // Field descriptor #544 I + public static final int GL_TRUE = 1; + + // Field descriptor #544 I + public static final int GL_FALSE = 0; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE0 = 12288; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE1 = 12289; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE2 = 12290; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE3 = 12291; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE4 = 12292; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE5 = 12293; + + // Field descriptor #544 I + public static final int GL_BYTE = 5120; + + // Field descriptor #544 I + public static final int GL_UNSIGNED_BYTE = 5121; + + // Field descriptor #544 I + public static final int GL_SHORT = 5122; + + // Field descriptor #544 I + public static final int GL_UNSIGNED_SHORT = 5123; + + // Field descriptor #544 I + public static final int GL_INT = 5124; + + // Field descriptor #544 I + public static final int GL_UNSIGNED_INT = 5125; + + // Field descriptor #544 I + public static final int GL_FLOAT = 5126; + + // Field descriptor #544 I + public static final int GL_2_BYTES = 5127; + + // Field descriptor #544 I + public static final int GL_3_BYTES = 5128; + + // Field descriptor #544 I + public static final int GL_4_BYTES = 5129; + + // Field descriptor #544 I + public static final int GL_DOUBLE = 5130; + + // Field descriptor #544 I + public static final int GL_NONE = 0; + + // Field descriptor #544 I + public static final int GL_FRONT_LEFT = 1024; + + // Field descriptor #544 I + public static final int GL_FRONT_RIGHT = 1025; + + // Field descriptor #544 I + public static final int GL_BACK_LEFT = 1026; + + // Field descriptor #544 I + public static final int GL_BACK_RIGHT = 1027; + + // Field descriptor #544 I + public static final int GL_FRONT = 1028; + + // Field descriptor #544 I + public static final int GL_BACK = 1029; + + // Field descriptor #544 I + public static final int GL_LEFT = 1030; + + // Field descriptor #544 I + public static final int GL_RIGHT = 1031; + + // Field descriptor #544 I + public static final int GL_FRONT_AND_BACK = 1032; + + // Field descriptor #544 I + public static final int GL_AUX0 = 1033; + + // Field descriptor #544 I + public static final int GL_AUX1 = 1034; + + // Field descriptor #544 I + public static final int GL_AUX2 = 1035; + + // Field descriptor #544 I + public static final int GL_AUX3 = 1036; + + // Field descriptor #544 I + public static final int GL_NO_ERROR = 0; + + // Field descriptor #544 I + public static final int GL_INVALID_ENUM = 1280; + + // Field descriptor #544 I + public static final int GL_INVALID_VALUE = 1281; + + // Field descriptor #544 I + public static final int GL_INVALID_OPERATION = 1282; + + // Field descriptor #544 I + public static final int GL_STACK_OVERFLOW = 1283; + + // Field descriptor #544 I + public static final int GL_STACK_UNDERFLOW = 1284; + + // Field descriptor #544 I + public static final int GL_OUT_OF_MEMORY = 1285; + + // Field descriptor #544 I + public static final int GL_2D = 1536; + + // Field descriptor #544 I + public static final int GL_3D = 1537; + + // Field descriptor #544 I + public static final int GL_3D_COLOR = 1538; + + // Field descriptor #544 I + public static final int GL_3D_COLOR_TEXTURE = 1539; + + // Field descriptor #544 I + public static final int GL_4D_COLOR_TEXTURE = 1540; + + // Field descriptor #544 I + public static final int GL_PASS_THROUGH_TOKEN = 1792; + + // Field descriptor #544 I + public static final int GL_POINT_TOKEN = 1793; + + // Field descriptor #544 I + public static final int GL_LINE_TOKEN = 1794; + + // Field descriptor #544 I + public static final int GL_POLYGON_TOKEN = 1795; + + // Field descriptor #544 I + public static final int GL_BITMAP_TOKEN = 1796; + + // Field descriptor #544 I + public static final int GL_DRAW_PIXEL_TOKEN = 1797; + + // Field descriptor #544 I + public static final int GL_COPY_PIXEL_TOKEN = 1798; + + // Field descriptor #544 I + public static final int GL_LINE_RESET_TOKEN = 1799; + + // Field descriptor #544 I + public static final int GL_EXP = 2048; + + // Field descriptor #544 I + public static final int GL_EXP2 = 2049; + + // Field descriptor #544 I + public static final int GL_CW = 2304; + + // Field descriptor #544 I + public static final int GL_CCW = 2305; + + // Field descriptor #544 I + public static final int GL_COEFF = 2560; + + // Field descriptor #544 I + public static final int GL_ORDER = 2561; + + // Field descriptor #544 I + public static final int GL_DOMAIN = 2562; + + // Field descriptor #544 I + public static final int GL_CURRENT_COLOR = 2816; + + // Field descriptor #544 I + public static final int GL_CURRENT_INDEX = 2817; + + // Field descriptor #544 I + public static final int GL_CURRENT_NORMAL = 2818; + + // Field descriptor #544 I + public static final int GL_CURRENT_TEXTURE_COORDS = 2819; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_COLOR = 2820; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_INDEX = 2821; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_TEXTURE_COORDS = 2822; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_POSITION = 2823; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_POSITION_VALID = 2824; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_DISTANCE = 2825; + + // Field descriptor #544 I + public static final int GL_POINT_SMOOTH = 2832; + + // Field descriptor #544 I + public static final int GL_POINT_SIZE = 2833; + + // Field descriptor #544 I + public static final int GL_POINT_SIZE_RANGE = 2834; + + // Field descriptor #544 I + public static final int GL_POINT_SIZE_GRANULARITY = 2835; + + // Field descriptor #544 I + public static final int GL_LINE_SMOOTH = 2848; + + // Field descriptor #544 I + public static final int GL_LINE_WIDTH = 2849; + + // Field descriptor #544 I + public static final int GL_LINE_WIDTH_RANGE = 2850; + + // Field descriptor #544 I + public static final int GL_LINE_WIDTH_GRANULARITY = 2851; + + // Field descriptor #544 I + public static final int GL_LINE_STIPPLE = 2852; + + // Field descriptor #544 I + public static final int GL_LINE_STIPPLE_PATTERN = 2853; + + // Field descriptor #544 I + public static final int GL_LINE_STIPPLE_REPEAT = 2854; + + // Field descriptor #544 I + public static final int GL_LIST_MODE = 2864; + + // Field descriptor #544 I + public static final int GL_MAX_LIST_NESTING = 2865; + + // Field descriptor #544 I + public static final int GL_LIST_BASE = 2866; + + // Field descriptor #544 I + public static final int GL_LIST_INDEX = 2867; + + // Field descriptor #544 I + public static final int GL_POLYGON_MODE = 2880; + + // Field descriptor #544 I + public static final int GL_POLYGON_SMOOTH = 2881; + + // Field descriptor #544 I + public static final int GL_POLYGON_STIPPLE = 2882; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG = 2883; + + // Field descriptor #544 I + public static final int GL_CULL_FACE = 2884; + + // Field descriptor #544 I + public static final int GL_CULL_FACE_MODE = 2885; + + // Field descriptor #544 I + public static final int GL_FRONT_FACE = 2886; + + // Field descriptor #544 I + public static final int GL_LIGHTING = 2896; + + // Field descriptor #544 I + public static final int GL_LIGHT_MODEL_LOCAL_VIEWER = 2897; + + // Field descriptor #544 I + public static final int GL_LIGHT_MODEL_TWO_SIDE = 2898; + + // Field descriptor #544 I + public static final int GL_LIGHT_MODEL_AMBIENT = 2899; + + // Field descriptor #544 I + public static final int GL_SHADE_MODEL = 2900; + + // Field descriptor #544 I + public static final int GL_COLOR_MATERIAL_FACE = 2901; + + // Field descriptor #544 I + public static final int GL_COLOR_MATERIAL_PARAMETER = 2902; + + // Field descriptor #544 I + public static final int GL_COLOR_MATERIAL = 2903; + + // Field descriptor #544 I + public static final int GL_FOG = 2912; + + // Field descriptor #544 I + public static final int GL_FOG_INDEX = 2913; + + // Field descriptor #544 I + public static final int GL_FOG_DENSITY = 2914; + + // Field descriptor #544 I + public static final int GL_FOG_START = 2915; + + // Field descriptor #544 I + public static final int GL_FOG_END = 2916; + + // Field descriptor #544 I + public static final int GL_FOG_MODE = 2917; + + // Field descriptor #544 I + public static final int GL_FOG_COLOR = 2918; + + // Field descriptor #544 I + public static final int GL_DEPTH_RANGE = 2928; + + // Field descriptor #544 I + public static final int GL_DEPTH_TEST = 2929; + + // Field descriptor #544 I + public static final int GL_DEPTH_WRITEMASK = 2930; + + // Field descriptor #544 I + public static final int GL_DEPTH_CLEAR_VALUE = 2931; + + // Field descriptor #544 I + public static final int GL_DEPTH_FUNC = 2932; + + // Field descriptor #544 I + public static final int GL_ACCUM_CLEAR_VALUE = 2944; + + // Field descriptor #544 I + public static final int GL_STENCIL_TEST = 2960; + + // Field descriptor #544 I + public static final int GL_STENCIL_CLEAR_VALUE = 2961; + + // Field descriptor #544 I + public static final int GL_STENCIL_FUNC = 2962; + + // Field descriptor #544 I + public static final int GL_STENCIL_VALUE_MASK = 2963; + + // Field descriptor #544 I + public static final int GL_STENCIL_FAIL = 2964; + + // Field descriptor #544 I + public static final int GL_STENCIL_PASS_DEPTH_FAIL = 2965; + + // Field descriptor #544 I + public static final int GL_STENCIL_PASS_DEPTH_PASS = 2966; + + // Field descriptor #544 I + public static final int GL_STENCIL_REF = 2967; + + // Field descriptor #544 I + public static final int GL_STENCIL_WRITEMASK = 2968; + + // Field descriptor #544 I + public static final int GL_MATRIX_MODE = 2976; + + // Field descriptor #544 I + public static final int GL_NORMALIZE = 2977; + + // Field descriptor #544 I + public static final int GL_VIEWPORT = 2978; + + // Field descriptor #544 I + public static final int GL_MODELVIEW_STACK_DEPTH = 2979; + + // Field descriptor #544 I + public static final int GL_PROJECTION_STACK_DEPTH = 2980; + + // Field descriptor #544 I + public static final int GL_TEXTURE_STACK_DEPTH = 2981; + + // Field descriptor #544 I + public static final int GL_MODELVIEW_MATRIX = 2982; + + // Field descriptor #544 I + public static final int GL_PROJECTION_MATRIX = 2983; + + // Field descriptor #544 I + public static final int GL_TEXTURE_MATRIX = 2984; + + // Field descriptor #544 I + public static final int GL_ATTRIB_STACK_DEPTH = 2992; + + // Field descriptor #544 I + public static final int GL_CLIENT_ATTRIB_STACK_DEPTH = 2993; + + // Field descriptor #544 I + public static final int GL_ALPHA_TEST = 3008; + + // Field descriptor #544 I + public static final int GL_ALPHA_TEST_FUNC = 3009; + + // Field descriptor #544 I + public static final int GL_ALPHA_TEST_REF = 3010; + + // Field descriptor #544 I + public static final int GL_DITHER = 3024; + + // Field descriptor #544 I + public static final int GL_BLEND_DST = 3040; + + // Field descriptor #544 I + public static final int GL_BLEND_SRC = 3041; + + // Field descriptor #544 I + public static final int GL_BLEND = 3042; + + // Field descriptor #544 I + public static final int GL_LOGIC_OP_MODE = 3056; + + // Field descriptor #544 I + public static final int GL_INDEX_LOGIC_OP = 3057; + + // Field descriptor #544 I + public static final int GL_COLOR_LOGIC_OP = 3058; + + // Field descriptor #544 I + public static final int GL_AUX_BUFFERS = 3072; + + // Field descriptor #544 I + public static final int GL_DRAW_BUFFER = 3073; + + // Field descriptor #544 I + public static final int GL_READ_BUFFER = 3074; + + // Field descriptor #544 I + public static final int GL_SCISSOR_BOX = 3088; + + // Field descriptor #544 I + public static final int GL_SCISSOR_TEST = 3089; + + // Field descriptor #544 I + public static final int GL_INDEX_CLEAR_VALUE = 3104; + + // Field descriptor #544 I + public static final int GL_INDEX_WRITEMASK = 3105; + + // Field descriptor #544 I + public static final int GL_COLOR_CLEAR_VALUE = 3106; + + // Field descriptor #544 I + public static final int GL_COLOR_WRITEMASK = 3107; + + // Field descriptor #544 I + public static final int GL_INDEX_MODE = 3120; + + // Field descriptor #544 I + public static final int GL_RGBA_MODE = 3121; + + // Field descriptor #544 I + public static final int GL_DOUBLEBUFFER = 3122; + + // Field descriptor #544 I + public static final int GL_STEREO = 3123; + + // Field descriptor #544 I + public static final int GL_RENDER_MODE = 3136; + + // Field descriptor #544 I + public static final int GL_PERSPECTIVE_CORRECTION_HINT = 3152; + + // Field descriptor #544 I + public static final int GL_POINT_SMOOTH_HINT = 3153; + + // Field descriptor #544 I + public static final int GL_LINE_SMOOTH_HINT = 3154; + + // Field descriptor #544 I + public static final int GL_POLYGON_SMOOTH_HINT = 3155; + + // Field descriptor #544 I + public static final int GL_FOG_HINT = 3156; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_S = 3168; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_T = 3169; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_R = 3170; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_Q = 3171; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_I = 3184; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_S_TO_S = 3185; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_R = 3186; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_G = 3187; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_B = 3188; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_A = 3189; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_R_TO_R = 3190; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_G_TO_G = 3191; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_B_TO_B = 3192; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_A_TO_A = 3193; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_I_SIZE = 3248; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_S_TO_S_SIZE = 3249; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_R_SIZE = 3250; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_G_SIZE = 3251; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_B_SIZE = 3252; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_A_SIZE = 3253; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_R_TO_R_SIZE = 3254; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_G_TO_G_SIZE = 3255; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_B_TO_B_SIZE = 3256; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_A_TO_A_SIZE = 3257; + + // Field descriptor #544 I + public static final int GL_UNPACK_SWAP_BYTES = 3312; + + // Field descriptor #544 I + public static final int GL_UNPACK_LSB_FIRST = 3313; + + // Field descriptor #544 I + public static final int GL_UNPACK_ROW_LENGTH = 3314; + + // Field descriptor #544 I + public static final int GL_UNPACK_SKIP_ROWS = 3315; + + // Field descriptor #544 I + public static final int GL_UNPACK_SKIP_PIXELS = 3316; + + // Field descriptor #544 I + public static final int GL_UNPACK_ALIGNMENT = 3317; + + // Field descriptor #544 I + public static final int GL_PACK_SWAP_BYTES = 3328; + + // Field descriptor #544 I + public static final int GL_PACK_LSB_FIRST = 3329; + + // Field descriptor #544 I + public static final int GL_PACK_ROW_LENGTH = 3330; + + // Field descriptor #544 I + public static final int GL_PACK_SKIP_ROWS = 3331; + + // Field descriptor #544 I + public static final int GL_PACK_SKIP_PIXELS = 3332; + + // Field descriptor #544 I + public static final int GL_PACK_ALIGNMENT = 3333; + + // Field descriptor #544 I + public static final int GL_MAP_COLOR = 3344; + + // Field descriptor #544 I + public static final int GL_MAP_STENCIL = 3345; + + // Field descriptor #544 I + public static final int GL_INDEX_SHIFT = 3346; + + // Field descriptor #544 I + public static final int GL_INDEX_OFFSET = 3347; + + // Field descriptor #544 I + public static final int GL_RED_SCALE = 3348; + + // Field descriptor #544 I + public static final int GL_RED_BIAS = 3349; + + // Field descriptor #544 I + public static final int GL_ZOOM_X = 3350; + + // Field descriptor #544 I + public static final int GL_ZOOM_Y = 3351; + + // Field descriptor #544 I + public static final int GL_GREEN_SCALE = 3352; + + // Field descriptor #544 I + public static final int GL_GREEN_BIAS = 3353; + + // Field descriptor #544 I + public static final int GL_BLUE_SCALE = 3354; + + // Field descriptor #544 I + public static final int GL_BLUE_BIAS = 3355; + + // Field descriptor #544 I + public static final int GL_ALPHA_SCALE = 3356; + + // Field descriptor #544 I + public static final int GL_ALPHA_BIAS = 3357; + + // Field descriptor #544 I + public static final int GL_DEPTH_SCALE = 3358; + + // Field descriptor #544 I + public static final int GL_DEPTH_BIAS = 3359; + + // Field descriptor #544 I + public static final int GL_MAX_EVAL_ORDER = 3376; + + // Field descriptor #544 I + public static final int GL_MAX_LIGHTS = 3377; + + // Field descriptor #544 I + public static final int GL_MAX_CLIP_PLANES = 3378; + + // Field descriptor #544 I + public static final int GL_MAX_TEXTURE_SIZE = 3379; + + // Field descriptor #544 I + public static final int GL_MAX_PIXEL_MAP_TABLE = 3380; + + // Field descriptor #544 I + public static final int GL_MAX_ATTRIB_STACK_DEPTH = 3381; + + // Field descriptor #544 I + public static final int GL_MAX_MODELVIEW_STACK_DEPTH = 3382; + + // Field descriptor #544 I + public static final int GL_MAX_NAME_STACK_DEPTH = 3383; + + // Field descriptor #544 I + public static final int GL_MAX_PROJECTION_STACK_DEPTH = 3384; + + // Field descriptor #544 I + public static final int GL_MAX_TEXTURE_STACK_DEPTH = 3385; + + // Field descriptor #544 I + public static final int GL_MAX_VIEWPORT_DIMS = 3386; + + // Field descriptor #544 I + public static final int GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 3387; + + // Field descriptor #544 I + public static final int GL_SUBPIXEL_BITS = 3408; + + // Field descriptor #544 I + public static final int GL_INDEX_BITS = 3409; + + // Field descriptor #544 I + public static final int GL_RED_BITS = 3410; + + // Field descriptor #544 I + public static final int GL_GREEN_BITS = 3411; + + // Field descriptor #544 I + public static final int GL_BLUE_BITS = 3412; + + // Field descriptor #544 I + public static final int GL_ALPHA_BITS = 3413; + + // Field descriptor #544 I + public static final int GL_DEPTH_BITS = 3414; + + // Field descriptor #544 I + public static final int GL_STENCIL_BITS = 3415; + + // Field descriptor #544 I + public static final int GL_ACCUM_RED_BITS = 3416; + + // Field descriptor #544 I + public static final int GL_ACCUM_GREEN_BITS = 3417; + + // Field descriptor #544 I + public static final int GL_ACCUM_BLUE_BITS = 3418; + + // Field descriptor #544 I + public static final int GL_ACCUM_ALPHA_BITS = 3419; + + // Field descriptor #544 I + public static final int GL_NAME_STACK_DEPTH = 3440; + + // Field descriptor #544 I + public static final int GL_AUTO_NORMAL = 3456; + + // Field descriptor #544 I + public static final int GL_MAP1_COLOR_4 = 3472; + + // Field descriptor #544 I + public static final int GL_MAP1_INDEX = 3473; + + // Field descriptor #544 I + public static final int GL_MAP1_NORMAL = 3474; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_1 = 3475; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_2 = 3476; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_3 = 3477; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_4 = 3478; + + // Field descriptor #544 I + public static final int GL_MAP1_VERTEX_3 = 3479; + + // Field descriptor #544 I + public static final int GL_MAP1_VERTEX_4 = 3480; + + // Field descriptor #544 I + public static final int GL_MAP2_COLOR_4 = 3504; + + // Field descriptor #544 I + public static final int GL_MAP2_INDEX = 3505; + + // Field descriptor #544 I + public static final int GL_MAP2_NORMAL = 3506; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_1 = 3507; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_2 = 3508; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_3 = 3509; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_4 = 3510; + + // Field descriptor #544 I + public static final int GL_MAP2_VERTEX_3 = 3511; + + // Field descriptor #544 I + public static final int GL_MAP2_VERTEX_4 = 3512; + + // Field descriptor #544 I + public static final int GL_MAP1_GRID_DOMAIN = 3536; + + // Field descriptor #544 I + public static final int GL_MAP1_GRID_SEGMENTS = 3537; + + // Field descriptor #544 I + public static final int GL_MAP2_GRID_DOMAIN = 3538; + + // Field descriptor #544 I + public static final int GL_MAP2_GRID_SEGMENTS = 3539; + + // Field descriptor #544 I + public static final int GL_TEXTURE_1D = 3552; + + // Field descriptor #544 I + public static final int GL_TEXTURE_2D = 3553; + + // Field descriptor #544 I + public static final int GL_FEEDBACK_BUFFER_POINTER = 3568; + + // Field descriptor #544 I + public static final int GL_FEEDBACK_BUFFER_SIZE = 3569; + + // Field descriptor #544 I + public static final int GL_FEEDBACK_BUFFER_TYPE = 3570; + + // Field descriptor #544 I + public static final int GL_SELECTION_BUFFER_POINTER = 3571; + + // Field descriptor #544 I + public static final int GL_SELECTION_BUFFER_SIZE = 3572; + + // Field descriptor #544 I + public static final int GL_TEXTURE_WIDTH = 4096; + + // Field descriptor #544 I + public static final int GL_TEXTURE_HEIGHT = 4097; + + // Field descriptor #544 I + public static final int GL_TEXTURE_INTERNAL_FORMAT = 4099; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BORDER_COLOR = 4100; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BORDER = 4101; + + // Field descriptor #544 I + public static final int GL_DONT_CARE = 4352; + + // Field descriptor #544 I + public static final int GL_FASTEST = 4353; + + // Field descriptor #544 I + public static final int GL_NICEST = 4354; + + // Field descriptor #544 I + public static final int GL_LIGHT0 = 16384; + + // Field descriptor #544 I + public static final int GL_LIGHT1 = 16385; + + // Field descriptor #544 I + public static final int GL_LIGHT2 = 16386; + + // Field descriptor #544 I + public static final int GL_LIGHT3 = 16387; + + // Field descriptor #544 I + public static final int GL_LIGHT4 = 16388; + + // Field descriptor #544 I + public static final int GL_LIGHT5 = 16389; + + // Field descriptor #544 I + public static final int GL_LIGHT6 = 16390; + + // Field descriptor #544 I + public static final int GL_LIGHT7 = 16391; + + // Field descriptor #544 I + public static final int GL_AMBIENT = 4608; + + // Field descriptor #544 I + public static final int GL_DIFFUSE = 4609; + + // Field descriptor #544 I + public static final int GL_SPECULAR = 4610; + + // Field descriptor #544 I + public static final int GL_POSITION = 4611; + + // Field descriptor #544 I + public static final int GL_SPOT_DIRECTION = 4612; + + // Field descriptor #544 I + public static final int GL_SPOT_EXPONENT = 4613; + + // Field descriptor #544 I + public static final int GL_SPOT_CUTOFF = 4614; + + // Field descriptor #544 I + public static final int GL_CONSTANT_ATTENUATION = 4615; + + // Field descriptor #544 I + public static final int GL_LINEAR_ATTENUATION = 4616; + + // Field descriptor #544 I + public static final int GL_QUADRATIC_ATTENUATION = 4617; + + // Field descriptor #544 I + public static final int GL_COMPILE = 4864; + + // Field descriptor #544 I + public static final int GL_COMPILE_AND_EXECUTE = 4865; + + // Field descriptor #544 I + public static final int GL_CLEAR = 5376; + + // Field descriptor #544 I + public static final int GL_AND = 5377; + + // Field descriptor #544 I + public static final int GL_AND_REVERSE = 5378; + + // Field descriptor #544 I + public static final int GL_COPY = 5379; + + // Field descriptor #544 I + public static final int GL_AND_INVERTED = 5380; + + // Field descriptor #544 I + public static final int GL_NOOP = 5381; + + // Field descriptor #544 I + public static final int GL_XOR = 5382; + + // Field descriptor #544 I + public static final int GL_OR = 5383; + + // Field descriptor #544 I + public static final int GL_NOR = 5384; + + // Field descriptor #544 I + public static final int GL_EQUIV = 5385; + + // Field descriptor #544 I + public static final int GL_INVERT = 5386; + + // Field descriptor #544 I + public static final int GL_OR_REVERSE = 5387; + + // Field descriptor #544 I + public static final int GL_COPY_INVERTED = 5388; + + // Field descriptor #544 I + public static final int GL_OR_INVERTED = 5389; + + // Field descriptor #544 I + public static final int GL_NAND = 5390; + + // Field descriptor #544 I + public static final int GL_SET = 5391; + + // Field descriptor #544 I + public static final int GL_EMISSION = 5632; + + // Field descriptor #544 I + public static final int GL_SHININESS = 5633; + + // Field descriptor #544 I + public static final int GL_AMBIENT_AND_DIFFUSE = 5634; + + // Field descriptor #544 I + public static final int GL_COLOR_INDEXES = 5635; + + // Field descriptor #544 I + public static final int GL_MODELVIEW = 5888; + + // Field descriptor #544 I + public static final int GL_PROJECTION = 5889; + + // Field descriptor #544 I + public static final int GL_TEXTURE = 5890; + + // Field descriptor #544 I + public static final int GL_COLOR = 6144; + + // Field descriptor #544 I + public static final int GL_DEPTH = 6145; + + // Field descriptor #544 I + public static final int GL_STENCIL = 6146; + + // Field descriptor #544 I + public static final int GL_COLOR_INDEX = 6400; + + // Field descriptor #544 I + public static final int GL_STENCIL_INDEX = 6401; + + // Field descriptor #544 I + public static final int GL_DEPTH_COMPONENT = 6402; + + // Field descriptor #544 I + public static final int GL_RED = 6403; + + // Field descriptor #544 I + public static final int GL_GREEN = 6404; + + // Field descriptor #544 I + public static final int GL_BLUE = 6405; + + // Field descriptor #544 I + public static final int GL_ALPHA = 6406; + + // Field descriptor #544 I + public static final int GL_RGB = 6407; + + // Field descriptor #544 I + public static final int GL_RGBA = 6408; + + // Field descriptor #544 I + public static final int GL_LUMINANCE = 6409; + + // Field descriptor #544 I + public static final int GL_LUMINANCE_ALPHA = 6410; + + // Field descriptor #544 I + public static final int GL_BITMAP = 6656; + + // Field descriptor #544 I + public static final int GL_POINT = 6912; + + // Field descriptor #544 I + public static final int GL_LINE = 6913; + + // Field descriptor #544 I + public static final int GL_FILL = 6914; + + // Field descriptor #544 I + public static final int GL_RENDER = 7168; + + // Field descriptor #544 I + public static final int GL_FEEDBACK = 7169; + + // Field descriptor #544 I + public static final int GL_SELECT = 7170; + + // Field descriptor #544 I + public static final int GL_FLAT = 7424; + + // Field descriptor #544 I + public static final int GL_SMOOTH = 7425; + + // Field descriptor #544 I + public static final int GL_KEEP = 7680; + + // Field descriptor #544 I + public static final int GL_REPLACE = 7681; + + // Field descriptor #544 I + public static final int GL_INCR = 7682; + + // Field descriptor #544 I + public static final int GL_DECR = 7683; + + // Field descriptor #544 I + public static final int GL_VENDOR = 7936; + + // Field descriptor #544 I + public static final int GL_RENDERER = 7937; + + // Field descriptor #544 I + public static final int GL_VERSION = 7938; + + // Field descriptor #544 I + public static final int GL_EXTENSIONS = 7939; + + // Field descriptor #544 I + public static final int GL_S = 8192; + + // Field descriptor #544 I + public static final int GL_T = 8193; + + // Field descriptor #544 I + public static final int GL_R = 8194; + + // Field descriptor #544 I + public static final int GL_Q = 8195; + + // Field descriptor #544 I + public static final int GL_MODULATE = 8448; + + // Field descriptor #544 I + public static final int GL_DECAL = 8449; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ENV_MODE = 8704; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ENV_COLOR = 8705; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ENV = 8960; + + // Field descriptor #544 I + public static final int GL_EYE_LINEAR = 9216; + + // Field descriptor #544 I + public static final int GL_OBJECT_LINEAR = 9217; + + // Field descriptor #544 I + public static final int GL_SPHERE_MAP = 9218; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_MODE = 9472; + + // Field descriptor #544 I + public static final int GL_OBJECT_PLANE = 9473; + + // Field descriptor #544 I + public static final int GL_EYE_PLANE = 9474; + + // Field descriptor #544 I + public static final int GL_NEAREST = 9728; + + // Field descriptor #544 I + public static final int GL_LINEAR = 9729; + + // Field descriptor #544 I + public static final int GL_NEAREST_MIPMAP_NEAREST = 9984; + + // Field descriptor #544 I + public static final int GL_LINEAR_MIPMAP_NEAREST = 9985; + + // Field descriptor #544 I + public static final int GL_NEAREST_MIPMAP_LINEAR = 9986; + + // Field descriptor #544 I + public static final int GL_LINEAR_MIPMAP_LINEAR = 9987; + + // Field descriptor #544 I + public static final int GL_TEXTURE_MAG_FILTER = 10240; + + // Field descriptor #544 I + public static final int GL_TEXTURE_MIN_FILTER = 10241; + + // Field descriptor #544 I + public static final int GL_TEXTURE_WRAP_S = 10242; + + // Field descriptor #544 I + public static final int GL_TEXTURE_WRAP_T = 10243; + + // Field descriptor #544 I + public static final int GL_CLAMP = 10496; + + // Field descriptor #544 I + public static final int GL_REPEAT = 10497; + + // Field descriptor #544 I + public static final int GL_CLIENT_PIXEL_STORE_BIT = 1; + + // Field descriptor #544 I + public static final int GL_CLIENT_VERTEX_ARRAY_BIT = 2; + + // Field descriptor #544 I + public static final int GL_ALL_CLIENT_ATTRIB_BITS = -1; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_FACTOR = 32824; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_UNITS = 10752; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_POINT = 10753; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_LINE = 10754; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_FILL = 32823; + + // Field descriptor #544 I + public static final int GL_ALPHA4 = 32827; + + // Field descriptor #544 I + public static final int GL_ALPHA8 = 32828; + + // Field descriptor #544 I + public static final int GL_ALPHA12 = 32829; + + // Field descriptor #544 I + public static final int GL_ALPHA16 = 32830; + + // Field descriptor #544 I + public static final int GL_LUMINANCE4 = 32831; + + // Field descriptor #544 I + public static final int GL_LUMINANCE8 = 32832; + + // Field descriptor #544 I + public static final int GL_LUMINANCE12 = 32833; + + // Field descriptor #544 I + public static final int GL_LUMINANCE16 = 32834; + + // Field descriptor #544 I + public static final int GL_LUMINANCE4_ALPHA4 = 32835; + + // Field descriptor #544 I + public static final int GL_LUMINANCE6_ALPHA2 = 32836; + + // Field descriptor #544 I + public static final int GL_LUMINANCE8_ALPHA8 = 32837; + + // Field descriptor #544 I + public static final int GL_LUMINANCE12_ALPHA4 = 32838; + + // Field descriptor #544 I + public static final int GL_LUMINANCE12_ALPHA12 = 32839; + + // Field descriptor #544 I + public static final int GL_LUMINANCE16_ALPHA16 = 32840; + + // Field descriptor #544 I + public static final int GL_INTENSITY = 32841; + + // Field descriptor #544 I + public static final int GL_INTENSITY4 = 32842; + + // Field descriptor #544 I + public static final int GL_INTENSITY8 = 32843; + + // Field descriptor #544 I + public static final int GL_INTENSITY12 = 32844; + + // Field descriptor #544 I + public static final int GL_INTENSITY16 = 32845; + + // Field descriptor #544 I + public static final int GL_R3_G3_B2 = 10768; + + // Field descriptor #544 I + public static final int GL_RGB4 = 32847; + + // Field descriptor #544 I + public static final int GL_RGB5 = 32848; + + // Field descriptor #544 I + public static final int GL_RGB8 = 32849; + + // Field descriptor #544 I + public static final int GL_RGB10 = 32850; + + // Field descriptor #544 I + public static final int GL_RGB12 = 32851; + + // Field descriptor #544 I + public static final int GL_RGB16 = 32852; + + // Field descriptor #544 I + public static final int GL_RGBA2 = 32853; + + // Field descriptor #544 I + public static final int GL_RGBA4 = 32854; + + // Field descriptor #544 I + public static final int GL_RGB5_A1 = 32855; + + // Field descriptor #544 I + public static final int GL_RGBA8 = 32856; + + // Field descriptor #544 I + public static final int GL_RGB10_A2 = 32857; + + // Field descriptor #544 I + public static final int GL_RGBA12 = 32858; + + // Field descriptor #544 I + public static final int GL_RGBA16 = 32859; + + // Field descriptor #544 I + public static final int GL_TEXTURE_RED_SIZE = 32860; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GREEN_SIZE = 32861; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BLUE_SIZE = 32862; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ALPHA_SIZE = 32863; + + // Field descriptor #544 I + public static final int GL_TEXTURE_LUMINANCE_SIZE = 32864; + + // Field descriptor #544 I + public static final int GL_TEXTURE_INTENSITY_SIZE = 32865; + + // Field descriptor #544 I + public static final int GL_PROXY_TEXTURE_1D = 32867; + + // Field descriptor #544 I + public static final int GL_PROXY_TEXTURE_2D = 32868; + + // Field descriptor #544 I + public static final int GL_TEXTURE_PRIORITY = 32870; + + // Field descriptor #544 I + public static final int GL_TEXTURE_RESIDENT = 32871; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BINDING_1D = 32872; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BINDING_2D = 32873; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY = 32884; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY = 32885; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY = 32886; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY = 32887; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY = 32888; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG_ARRAY = 32889; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_SIZE = 32890; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_TYPE = 32891; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_STRIDE = 32892; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY_TYPE = 32894; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY_STRIDE = 32895; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_SIZE = 32897; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_TYPE = 32898; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_STRIDE = 32899; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY_TYPE = 32901; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY_STRIDE = 32902; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_SIZE = 32904; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_TYPE = 32905; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_STRIDE = 32906; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG_ARRAY_STRIDE = 32908; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_POINTER = 32910; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY_POINTER = 32911; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_POINTER = 32912; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY_POINTER = 32913; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_POINTER = 32914; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG_ARRAY_POINTER = 32915; + + // Field descriptor #544 I + public static final int GL_V2F = 10784; + + // Field descriptor #544 I + public static final int GL_V3F = 10785; + + // Field descriptor #544 I + public static final int GL_C4UB_V2F = 10786; + + // Field descriptor #544 I + public static final int GL_C4UB_V3F = 10787; + + // Field descriptor #544 I + public static final int GL_C3F_V3F = 10788; + + // Field descriptor #544 I + public static final int GL_N3F_V3F = 10789; + + // Field descriptor #544 I + public static final int GL_C4F_N3F_V3F = 10790; + + // Field descriptor #544 I + public static final int GL_T2F_V3F = 10791; + + // Field descriptor #544 I + public static final int GL_T4F_V4F = 10792; + + // Field descriptor #544 I + public static final int GL_T2F_C4UB_V3F = 10793; + + // Field descriptor #544 I + public static final int GL_T2F_C3F_V3F = 10794; + + // Field descriptor #544 I + public static final int GL_T2F_N3F_V3F = 10795; + + // Field descriptor #544 I + public static final int GL_T2F_C4F_N3F_V3F = 10796; + + // Field descriptor #544 I + public static final int GL_T4F_C4F_N3F_V4F = 10797; + + // Field descriptor #544 I + public static final int GL_LOGIC_OP = 3057; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COMPONENTS = 4099; + + // Field descriptor #45 I + public static final int GL_TEXTURE_BINDING_3D = 32874; + + // Field descriptor #45 I + public static final int GL_PACK_SKIP_IMAGES = 32875; + + // Field descriptor #45 I + public static final int GL_PACK_IMAGE_HEIGHT = 32876; + + // Field descriptor #45 I + public static final int GL_UNPACK_SKIP_IMAGES = 32877; + + // Field descriptor #45 I + public static final int GL_UNPACK_IMAGE_HEIGHT = 32878; + + // Field descriptor #45 I + public static final int GL_TEXTURE_3D = 32879; + + // Field descriptor #45 I + public static final int GL_PROXY_TEXTURE_3D = 32880; + + // Field descriptor #45 I + public static final int GL_TEXTURE_DEPTH = 32881; + + // Field descriptor #45 I + public static final int GL_TEXTURE_WRAP_R = 32882; + + // Field descriptor #45 I + public static final int GL_MAX_3D_TEXTURE_SIZE = 32883; + + // Field descriptor #45 I + public static final int GL_BGR = 32992; + + // Field descriptor #45 I + public static final int GL_BGRA = 32993; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_BYTE_3_3_2 = 32818; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_BYTE_2_3_3_REV = 33634; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_5_6_5 = 33635; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_5_6_5_REV = 33636; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_4_4_4_4 = 32819; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_4_4_4_4_REV = 33637; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_5_5_5_1 = 32820; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_1_5_5_5_REV = 33638; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_8_8_8_8 = 32821; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_8_8_8_8_REV = 33639; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_10_10_10_2 = 32822; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 33640; + + // Field descriptor #45 I + public static final int GL_RESCALE_NORMAL = 32826; + + // Field descriptor #45 I + public static final int GL_LIGHT_MODEL_COLOR_CONTROL = 33272; + + // Field descriptor #45 I + public static final int GL_SINGLE_COLOR = 33273; + + // Field descriptor #45 I + public static final int GL_SEPARATE_SPECULAR_COLOR = 33274; + + // Field descriptor #45 I + public static final int GL_CLAMP_TO_EDGE = 33071; + + // Field descriptor #45 I + public static final int GL_TEXTURE_MIN_LOD = 33082; + + // Field descriptor #45 I + public static final int GL_TEXTURE_MAX_LOD = 33083; + + // Field descriptor #45 I + public static final int GL_TEXTURE_BASE_LEVEL = 33084; + + // Field descriptor #45 I + public static final int GL_TEXTURE_MAX_LEVEL = 33085; + + // Field descriptor #45 I + public static final int GL_MAX_ELEMENTS_VERTICES = 33000; + + // Field descriptor #45 I + public static final int GL_MAX_ELEMENTS_INDICES = 33001; + + // Field descriptor #45 I + public static final int GL_ALIASED_POINT_SIZE_RANGE = 33901; + + // Field descriptor #45 I + public static final int GL_ALIASED_LINE_WIDTH_RANGE = 33902; + + // Field descriptor #45 I + public static final int GL_SMOOTH_POINT_SIZE_RANGE = 2834; + + // Field descriptor #45 I + public static final int GL_SMOOTH_POINT_SIZE_GRANULARITY = 2835; + + // Field descriptor #45 I + public static final int GL_SMOOTH_LINE_WIDTH_RANGE = 2850; + + // Field descriptor #45 I + public static final int GL_SMOOTH_LINE_WIDTH_GRANULARITY = 2851; + + // Field descriptor #76 I + public static final int GL_TEXTURE0 = 33984; + + // Field descriptor #76 I + public static final int GL_TEXTURE1 = 33985; + + // Field descriptor #76 I + public static final int GL_TEXTURE2 = 33986; + + // Field descriptor #76 I + public static final int GL_TEXTURE3 = 33987; + + // Field descriptor #76 I + public static final int GL_TEXTURE4 = 33988; + + // Field descriptor #76 I + public static final int GL_TEXTURE5 = 33989; + + // Field descriptor #76 I + public static final int GL_TEXTURE6 = 33990; + + // Field descriptor #76 I + public static final int GL_TEXTURE7 = 33991; + + // Field descriptor #76 I + public static final int GL_TEXTURE8 = 33992; + + // Field descriptor #76 I + public static final int GL_TEXTURE9 = 33993; + + // Field descriptor #76 I + public static final int GL_TEXTURE10 = 33994; + + // Field descriptor #76 I + public static final int GL_TEXTURE11 = 33995; + + // Field descriptor #76 I + public static final int GL_TEXTURE12 = 33996; + + // Field descriptor #76 I + public static final int GL_TEXTURE13 = 33997; + + // Field descriptor #76 I + public static final int GL_TEXTURE14 = 33998; + + // Field descriptor #76 I + public static final int GL_TEXTURE15 = 33999; + + // Field descriptor #76 I + public static final int GL_TEXTURE16 = 34000; + + // Field descriptor #76 I + public static final int GL_TEXTURE17 = 34001; + + // Field descriptor #76 I + public static final int GL_TEXTURE18 = 34002; + + // Field descriptor #76 I + public static final int GL_TEXTURE19 = 34003; + + // Field descriptor #76 I + public static final int GL_TEXTURE20 = 34004; + + // Field descriptor #76 I + public static final int GL_TEXTURE21 = 34005; + + // Field descriptor #76 I + public static final int GL_TEXTURE22 = 34006; + + // Field descriptor #76 I + public static final int GL_TEXTURE23 = 34007; + + // Field descriptor #76 I + public static final int GL_TEXTURE24 = 34008; + + // Field descriptor #76 I + public static final int GL_TEXTURE25 = 34009; + + // Field descriptor #76 I + public static final int GL_TEXTURE26 = 34010; + + // Field descriptor #76 I + public static final int GL_TEXTURE27 = 34011; + + // Field descriptor #76 I + public static final int GL_TEXTURE28 = 34012; + + // Field descriptor #76 I + public static final int GL_TEXTURE29 = 34013; + + // Field descriptor #76 I + public static final int GL_TEXTURE30 = 34014; + + // Field descriptor #76 I + public static final int GL_TEXTURE31 = 34015; + + // Field descriptor #76 I + public static final int GL_ACTIVE_TEXTURE = 34016; + + // Field descriptor #76 I + public static final int GL_CLIENT_ACTIVE_TEXTURE = 34017; + + // Field descriptor #76 I + public static final int GL_MAX_TEXTURE_UNITS = 34018; + + // Field descriptor #76 I + public static final int GL_NORMAL_MAP = 34065; + + // Field descriptor #76 I + public static final int GL_REFLECTION_MAP = 34066; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP = 34067; + + // Field descriptor #76 I + public static final int GL_TEXTURE_BINDING_CUBE_MAP = 34068; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074; + + // Field descriptor #76 I + public static final int GL_PROXY_TEXTURE_CUBE_MAP = 34075; + + // Field descriptor #76 I + public static final int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 34076; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_ALPHA = 34025; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_LUMINANCE = 34026; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_LUMINANCE_ALPHA = 34027; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_INTENSITY = 34028; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_RGB = 34029; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_RGBA = 34030; + + // Field descriptor #76 I + public static final int GL_TEXTURE_COMPRESSION_HINT = 34031; + + // Field descriptor #76 I + public static final int GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 34464; + + // Field descriptor #76 I + public static final int GL_TEXTURE_COMPRESSED = 34465; + + // Field descriptor #76 I + public static final int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 34466; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_TEXTURE_FORMATS = 34467; + + // Field descriptor #76 I + public static final int GL_MULTISAMPLE = 32925; + + // Field descriptor #76 I + public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 32926; + + // Field descriptor #76 I + public static final int GL_SAMPLE_ALPHA_TO_ONE = 32927; + + // Field descriptor #76 I + public static final int GL_SAMPLE_COVERAGE = 32928; + + // Field descriptor #76 I + public static final int GL_SAMPLE_BUFFERS = 32936; + + // Field descriptor #76 I + public static final int GL_SAMPLES = 32937; + + // Field descriptor #76 I + public static final int GL_SAMPLE_COVERAGE_VALUE = 32938; + + // Field descriptor #76 I + public static final int GL_SAMPLE_COVERAGE_INVERT = 32939; + + // Field descriptor #76 I + public static final int GL_MULTISAMPLE_BIT = 536870912; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_MODELVIEW_MATRIX = 34019; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_PROJECTION_MATRIX = 34020; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_TEXTURE_MATRIX = 34021; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_COLOR_MATRIX = 34022; + + // Field descriptor #76 I + public static final int GL_COMBINE = 34160; + + // Field descriptor #76 I + public static final int GL_COMBINE_RGB = 34161; + + // Field descriptor #76 I + public static final int GL_COMBINE_ALPHA = 34162; + + // Field descriptor #76 I + public static final int GL_SOURCE0_RGB = 34176; + + // Field descriptor #76 I + public static final int GL_SOURCE1_RGB = 34177; + + // Field descriptor #76 I + public static final int GL_SOURCE2_RGB = 34178; + + // Field descriptor #76 I + public static final int GL_SOURCE0_ALPHA = 34184; + + // Field descriptor #76 I + public static final int GL_SOURCE1_ALPHA = 34185; + + // Field descriptor #76 I + public static final int GL_SOURCE2_ALPHA = 34186; + + // Field descriptor #76 I + public static final int GL_OPERAND0_RGB = 34192; + + // Field descriptor #76 I + public static final int GL_OPERAND1_RGB = 34193; + + // Field descriptor #76 I + public static final int GL_OPERAND2_RGB = 34194; + + // Field descriptor #76 I + public static final int GL_OPERAND0_ALPHA = 34200; + + // Field descriptor #76 I + public static final int GL_OPERAND1_ALPHA = 34201; + + // Field descriptor #76 I + public static final int GL_OPERAND2_ALPHA = 34202; + + // Field descriptor #76 I + public static final int GL_RGB_SCALE = 34163; + + // Field descriptor #76 I + public static final int GL_ADD_SIGNED = 34164; + + // Field descriptor #76 I + public static final int GL_INTERPOLATE = 34165; + + // Field descriptor #76 I + public static final int GL_SUBTRACT = 34023; + + // Field descriptor #76 I + public static final int GL_CONSTANT = 34166; + + // Field descriptor #76 I + public static final int GL_PRIMARY_COLOR = 34167; + + // Field descriptor #76 I + public static final int GL_PREVIOUS = 34168; + + // Field descriptor #76 I + public static final int GL_DOT3_RGB = 34478; + + // Field descriptor #76 I + public static final int GL_DOT3_RGBA = 34479; + + // Field descriptor #76 I + public static final int GL_CLAMP_TO_BORDER = 33069; + + // Field descriptor #71 I + public static final int GL_ARRAY_BUFFER = 34962; + + // Field descriptor #71 I + public static final int GL_ELEMENT_ARRAY_BUFFER = 34963; + + // Field descriptor #71 I + public static final int GL_ARRAY_BUFFER_BINDING = 34964; + + // Field descriptor #71 I + public static final int GL_ELEMENT_ARRAY_BUFFER_BINDING = 34965; + + // Field descriptor #71 I + public static final int GL_VERTEX_ARRAY_BUFFER_BINDING = 34966; + + // Field descriptor #71 I + public static final int GL_NORMAL_ARRAY_BUFFER_BINDING = 34967; + + // Field descriptor #71 I + public static final int GL_COLOR_ARRAY_BUFFER_BINDING = 34968; + + // Field descriptor #71 I + public static final int GL_INDEX_ARRAY_BUFFER_BINDING = 34969; + + // Field descriptor #71 I + public static final int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 34970; + + // Field descriptor #71 I + public static final int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = 34971; + + // Field descriptor #71 I + public static final int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = 34972; + + // Field descriptor #71 I + public static final int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 34973; + + // Field descriptor #71 I + public static final int GL_WEIGHT_ARRAY_BUFFER_BINDING = 34974; + + // Field descriptor #71 I + public static final int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 34975; + + // Field descriptor #71 I + public static final int GL_STREAM_DRAW = 35040; + + // Field descriptor #71 I + public static final int GL_STREAM_READ = 35041; + + // Field descriptor #71 I + public static final int GL_STREAM_COPY = 35042; + + // Field descriptor #71 I + public static final int GL_STATIC_DRAW = 35044; + + // Field descriptor #71 I + public static final int GL_STATIC_READ = 35045; + + // Field descriptor #71 I + public static final int GL_STATIC_COPY = 35046; + + // Field descriptor #71 I + public static final int GL_DYNAMIC_DRAW = 35048; + + // Field descriptor #71 I + public static final int GL_DYNAMIC_READ = 35049; + + // Field descriptor #71 I + public static final int GL_DYNAMIC_COPY = 35050; + + // Field descriptor #71 I + public static final int GL_READ_ONLY = 35000; + + // Field descriptor #71 I + public static final int GL_WRITE_ONLY = 35001; + + // Field descriptor #71 I + public static final int GL_READ_WRITE = 35002; + + // Field descriptor #71 I + public static final int GL_BUFFER_SIZE = 34660; + + // Field descriptor #71 I + public static final int GL_BUFFER_USAGE = 34661; + + // Field descriptor #71 I + public static final int GL_BUFFER_ACCESS = 35003; + + // Field descriptor #71 I + public static final int GL_BUFFER_MAPPED = 35004; + + // Field descriptor #71 I + public static final int GL_BUFFER_MAP_POINTER = 35005; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_SRC = 33872; + + // Field descriptor #71 I + public static final int GL_FOG_COORD = 33873; + + // Field descriptor #71 I + public static final int GL_CURRENT_FOG_COORD = 33875; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_TYPE = 33876; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_STRIDE = 33877; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_POINTER = 33878; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY = 33879; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_BUFFER_BINDING = 34973; + + // Field descriptor #71 I + public static final int GL_SRC0_RGB = 34176; + + // Field descriptor #71 I + public static final int GL_SRC1_RGB = 34177; + + // Field descriptor #71 I + public static final int GL_SRC2_RGB = 34178; + + // Field descriptor #71 I + public static final int GL_SRC0_ALPHA = 34184; + + // Field descriptor #71 I + public static final int GL_SRC1_ALPHA = 34185; + + // Field descriptor #71 I + public static final int GL_SRC2_ALPHA = 34186; + + // Field descriptor #71 I + public static final int GL_SAMPLES_PASSED = 35092; + + // Field descriptor #71 I + public static final int GL_QUERY_COUNTER_BITS = 34916; + + // Field descriptor #71 I + public static final int GL_CURRENT_QUERY = 34917; + + // Field descriptor #71 I + public static final int GL_QUERY_RESULT = 34918; + + // Field descriptor #71 I + public static final int GL_QUERY_RESULT_AVAILABLE = 34919; + + // Field descriptor #194 I + public static final int GL_SHADING_LANGUAGE_VERSION = 35724; + + // Field descriptor #194 I + public static final int GL_CURRENT_PROGRAM = 35725; + + // Field descriptor #194 I + public static final int GL_SHADER_TYPE = 35663; + + // Field descriptor #194 I + public static final int GL_DELETE_STATUS = 35712; + + // Field descriptor #194 I + public static final int GL_COMPILE_STATUS = 35713; + + // Field descriptor #194 I + public static final int GL_LINK_STATUS = 35714; + + // Field descriptor #194 I + public static final int GL_VALIDATE_STATUS = 35715; + + // Field descriptor #194 I + public static final int GL_INFO_LOG_LENGTH = 35716; + + // Field descriptor #194 I + public static final int GL_ATTACHED_SHADERS = 35717; + + // Field descriptor #194 I + public static final int GL_ACTIVE_UNIFORMS = 35718; + + // Field descriptor #194 I + public static final int GL_ACTIVE_UNIFORM_MAX_LENGTH = 35719; + + // Field descriptor #194 I + public static final int GL_ACTIVE_ATTRIBUTES = 35721; + + // Field descriptor #194 I + public static final int GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 35722; + + // Field descriptor #194 I + public static final int GL_SHADER_SOURCE_LENGTH = 35720; + + // Field descriptor #194 I + public static final int GL_SHADER_OBJECT = 35656; + + // Field descriptor #194 I + public static final int GL_FLOAT_VEC2 = 35664; + + // Field descriptor #194 I + public static final int GL_FLOAT_VEC3 = 35665; + + // Field descriptor #194 I + public static final int GL_FLOAT_VEC4 = 35666; + + // Field descriptor #194 I + public static final int GL_INT_VEC2 = 35667; + + // Field descriptor #194 I + public static final int GL_INT_VEC3 = 35668; + + // Field descriptor #194 I + public static final int GL_INT_VEC4 = 35669; + + // Field descriptor #194 I + public static final int GL_BOOL = 35670; + + // Field descriptor #194 I + public static final int GL_BOOL_VEC2 = 35671; + + // Field descriptor #194 I + public static final int GL_BOOL_VEC3 = 35672; + + // Field descriptor #194 I + public static final int GL_BOOL_VEC4 = 35673; + + // Field descriptor #194 I + public static final int GL_FLOAT_MAT2 = 35674; + + // Field descriptor #194 I + public static final int GL_FLOAT_MAT3 = 35675; + + // Field descriptor #194 I + public static final int GL_FLOAT_MAT4 = 35676; + + // Field descriptor #194 I + public static final int GL_SAMPLER_1D = 35677; + + // Field descriptor #194 I + public static final int GL_SAMPLER_2D = 35678; + + // Field descriptor #194 I + public static final int GL_SAMPLER_3D = 35679; + + // Field descriptor #194 I + public static final int GL_SAMPLER_CUBE = 35680; + + // Field descriptor #194 I + public static final int GL_SAMPLER_1D_SHADOW = 35681; + + // Field descriptor #194 I + public static final int GL_SAMPLER_2D_SHADOW = 35682; + + // Field descriptor #194 I + public static final int GL_VERTEX_SHADER = 35633; + + // Field descriptor #194 I + public static final int GL_MAX_VERTEX_UNIFORM_COMPONENTS = 35658; + + // Field descriptor #194 I + public static final int GL_MAX_VARYING_FLOATS = 35659; + + // Field descriptor #194 I + public static final int GL_MAX_VERTEX_ATTRIBS = 34921; + + // Field descriptor #194 I + public static final int GL_MAX_TEXTURE_IMAGE_UNITS = 34930; + + // Field descriptor #194 I + public static final int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 35660; + + // Field descriptor #194 I + public static final int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 35661; + + // Field descriptor #194 I + public static final int GL_MAX_TEXTURE_COORDS = 34929; + + // Field descriptor #194 I + public static final int GL_VERTEX_PROGRAM_POINT_SIZE = 34370; + + // Field descriptor #194 I + public static final int GL_VERTEX_PROGRAM_TWO_SIDE = 34371; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 34338; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_SIZE = 34339; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_STRIDE = 34340; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_TYPE = 34341; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 34922; + + // Field descriptor #194 I + public static final int GL_CURRENT_VERTEX_ATTRIB = 34342; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_POINTER = 34373; + + // Field descriptor #194 I + public static final int GL_FRAGMENT_SHADER = 35632; + + // Field descriptor #194 I + public static final int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 35657; + + // Field descriptor #194 I + public static final int GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 35723; + + // Field descriptor #194 I + public static final int GL_MAX_DRAW_BUFFERS = 34852; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER0 = 34853; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER1 = 34854; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER2 = 34855; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER3 = 34856; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER4 = 34857; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER5 = 34858; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER6 = 34859; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER7 = 34860; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER8 = 34861; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER9 = 34862; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER10 = 34863; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER11 = 34864; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER12 = 34865; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER13 = 34866; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER14 = 34867; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER15 = 34868; + + // Field descriptor #194 I + public static final int GL_POINT_SPRITE = 34913; + + // Field descriptor #194 I + public static final int GL_COORD_REPLACE = 34914; + + // Field descriptor #194 I + public static final int GL_POINT_SPRITE_COORD_ORIGIN = 36000; + + // Field descriptor #194 I + public static final int GL_LOWER_LEFT = 36001; + + // Field descriptor #194 I + public static final int GL_UPPER_LEFT = 36002; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_FUNC = 34816; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_FAIL = 34817; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_PASS_DEPTH_FAIL = 34818; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_PASS_DEPTH_PASS = 34819; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_REF = 36003; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_VALUE_MASK = 36004; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_WRITEMASK = 36005; + + // Field descriptor #194 I + public static final int GL_BLEND_EQUATION_RGB = 32777; + + // Field descriptor #194 I + public static final int GL_BLEND_EQUATION_ALPHA = 34877; + +} \ No newline at end of file diff --git a/src/teavm/java/org/lwjgl/opengl/WebGL.java b/src/teavm/java/org/lwjgl/opengl/WebGL.java new file mode 100644 index 0000000..7ac24d9 --- /dev/null +++ b/src/teavm/java/org/lwjgl/opengl/WebGL.java @@ -0,0 +1,1984 @@ +package org.lwjgl.opengl; + +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.PeytonPlayz585.MinecraftMain; +import net.PeytonPlayz585.math.MathHelper; +import net.PeytonPlayz585.minecraft.AssetRepository; +import net.PeytonPlayz585.minecraft.Base64; +import net.PeytonPlayz585.minecraft.MinecraftImage; +import net.PeytonPlayz585.storage.LocalStorageManager; +//import net.PeytonPlayz585.teavm.IndexedDBFilesystem; +//import net.PeytonPlayz585.teavm.IndexedDBFilesystem.OpenState; +import net.PeytonPlayz585.teavm.WebGL2RenderingContext; +import net.PeytonPlayz585.teavm.WebGLQuery; +import net.PeytonPlayz585.teavm.WebGLVertexArray; + +import static net.PeytonPlayz585.teavm.WebGL2RenderingContext.*; + +public class WebGL { + + 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 void onWindowUnload() { + LocalStorageManager.saveStorageG(); + LocalStorageManager.saveStorageP(); + } + + @JSBody(params = { }, script = "window.onbeforeunload = function(){javaMethods.get('org.lwjgl.opengl.WebGL.onWindowUnload()V').invoke();return false;};") + private static native void onBeforeCloseRegister(); + + 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", config()); + 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(); + } + }); + onBeforeCloseRegister(); + initFileChooser(); + +// OpenState st = IndexedDBFilesystem.initialize(); +// if(st != OpenState.OPENED) { +// if(st == OpenState.LOCKED) { +// MinecraftMain.showDatabaseLockedScreen("\nError: World folder is locked!\n\nYou are already playing Minecraft in a different Window.\nClose all other Minecraft instances and reload"); +// }else { +// MinecraftMain.showDatabaseLockedScreen("\nError: World folder could not be loaded!\n\n" + IndexedDBFilesystem.errorDetail()); +// } +// throw new MinecraftMain.AbortedLaunchException(); +// } + + downloadAssetPack(assetPackageURI); + + try { + AssetRepository.install(loadedPackage); + } catch (IOException e) { + e.printStackTrace(); + } + + 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 config(); + + 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 _wglBlendFuncSeparate(int p1, int p2, int p3, int p4) { + webgl.blendFuncSeparate(p1, p2, p3, p4); + } + 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 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) 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 MinecraftImage(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) { + if(p1) { + fullscreen(); + } else { + exitFullscreen(); + } + } + + @JSBody(script = "if(!document.fullscreenElement){document.documentElement.requestFullscreen();}") + public static final native void fullscreen(); + + @JSBody(script = "if(document.fullscreenElement){document.exitFullscreen();}") + public static final native void exitFullscreen(); + + 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("_minecraft_alpha."+key); + if(s != null) { + return Base64.decodeBase64(s); + }else { + return null; + } + } + public static final void saveLocalStorage(String key, byte[] data) { + win.getLocalStorage().setItem("_minecraft_alpha."+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/org/lwjgl/opengl/WebGLManager.java b/src/teavm/java/org/lwjgl/opengl/WebGLManager.java new file mode 100644 index 0000000..dd5acf0 --- /dev/null +++ b/src/teavm/java/org/lwjgl/opengl/WebGLManager.java @@ -0,0 +1,1226 @@ +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.vector.*; + +public class WebGLManager extends WebGL { + + 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; + public static final int GL_SMOOTH = RealOpenGLEnums.GL_SMOOTH; + public static final int GL_DEPTH_TEST = RealOpenGLEnums.GL_DEPTH_TEST; + public static final int GL_LEQUAL = RealOpenGLEnums.GL_LEQUAL; + public static final int GL_ALPHA_TEST = RealOpenGLEnums.GL_ALPHA_TEST; + public static final int GL_GREATER = RealOpenGLEnums.GL_GREATER; + public static final int GL_BACK = RealOpenGLEnums.GL_BACK; + public static final int GL_PROJECTION = RealOpenGLEnums.GL_PROJECTION; + public static final int GL_MODELVIEW = RealOpenGLEnums.GL_MODELVIEW; + public static final int GL_COLOR_BUFFER_BIT = RealOpenGLEnums.GL_COLOR_BUFFER_BIT; + public static final int GL_DEPTH_BUFFER_BIT = RealOpenGLEnums.GL_DEPTH_BUFFER_BIT; + public static final int GL_LIGHTING = RealOpenGLEnums.GL_LIGHTING; + public static final int GL_FOG = RealOpenGLEnums.GL_FOG; + public static final int GL_COLOR_MATERIAL = RealOpenGLEnums.GL_COLOR_MATERIAL; + public static final int GL_BLEND = RealOpenGLEnums.GL_BLEND; + public static final int GL_RGBA = RealOpenGLEnums.GL_RGBA; + public static final int GL_UNSIGNED_BYTE = RealOpenGLEnums.GL_UNSIGNED_BYTE; + public static final int GL_TEXTURE_WIDTH = RealOpenGLEnums.GL_TEXTURE_WIDTH; + public static final int GL_LIGHT0 = RealOpenGLEnums.GL_LIGHT0; + public static final int GL_LIGHT1 = RealOpenGLEnums.GL_LIGHT1; + public static final int GL_POSITION = RealOpenGLEnums.GL_POSITION; + public static final int GL_DIFFUSE = RealOpenGLEnums.GL_DIFFUSE; + public static final int GL_SPECULAR = RealOpenGLEnums.GL_SPECULAR; + public static final int GL_AMBIENT = RealOpenGLEnums.GL_AMBIENT; + public static final int GL_FLAT = RealOpenGLEnums.GL_FLAT; + public static final int GL_LIGHT_MODEL_AMBIENT = RealOpenGLEnums.GL_LIGHT_MODEL_AMBIENT; + public static final int GL_FRONT_AND_BACK = RealOpenGLEnums.GL_FRONT_AND_BACK; + public static final int GL_AMBIENT_AND_DIFFUSE = RealOpenGLEnums.GL_AMBIENT_AND_DIFFUSE; + public static final int GL_MODELVIEW_MATRIX = RealOpenGLEnums.GL_MODELVIEW_MATRIX; + public static final int GL_PROJECTION_MATRIX = RealOpenGLEnums.GL_PROJECTION_MATRIX; + public static final int GL_VIEWPORT = RealOpenGLEnums.GL_VIEWPORT; + public static final int GL_RESCALE_NORMAL = RealOpenGLEnums.GL_RESCALE_NORMAL; + public static final int GL_SRC_ALPHA = RealOpenGLEnums.GL_SRC_ALPHA; + public static final int GL_ONE_MINUS_SRC_ALPHA = RealOpenGLEnums.GL_ONE_MINUS_SRC_ALPHA; + public static final int GL_ONE_MINUS_DST_COLOR = RealOpenGLEnums.GL_ONE_MINUS_DST_COLOR; + public static final int GL_ONE_MINUS_SRC_COLOR = RealOpenGLEnums.GL_ONE_MINUS_SRC_COLOR; + public static final int GL_CULL_FACE = RealOpenGLEnums.GL_CULL_FACE; + public static final int GL_TEXTURE_MIN_FILTER = RealOpenGLEnums.GL_TEXTURE_MIN_FILTER; + public static final int GL_TEXTURE_MAG_FILTER = RealOpenGLEnums.GL_TEXTURE_MAG_FILTER; + public static final int GL_LINEAR = RealOpenGLEnums.GL_LINEAR; + public static final int GL_COLOR_LOGIC_OP = RealOpenGLEnums.GL_COLOR_LOGIC_OP; + public static final int GL_OR_REVERSE = RealOpenGLEnums.GL_OR_REVERSE; + public static final int GL_EQUAL = RealOpenGLEnums.GL_EQUAL; + public static final int GL_SRC_COLOR = RealOpenGLEnums.GL_SRC_COLOR; + 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_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; + public static final int GL_TEXTURE_WRAP_T = RealOpenGLEnums.GL_TEXTURE_WRAP_T; + public static final int GL_REPEAT = RealOpenGLEnums.GL_REPEAT; + 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_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; + public static final int GL_FLOAT = RealOpenGLEnums.GL_FLOAT; + public static final int GL_TEXTURE_COORD_ARRAY = RealOpenGLEnums.GL_TEXTURE_COORD_ARRAY; + public static final int GL_SHORT = RealOpenGLEnums.GL_SHORT; + public static final int GL_COLOR_ARRAY = RealOpenGLEnums.GL_COLOR_ARRAY; + public static final int GL_VERTEX_ARRAY = RealOpenGLEnums.GL_VERTEX_ARRAY; + public static final int GL_TRIANGLES = RealOpenGLEnums.GL_TRIANGLES; + public static final int GL_NORMAL_ARRAY = RealOpenGLEnums.GL_NORMAL_ARRAY; + public static final int GL_TEXTURE_3D = RealOpenGLEnums.GL_TEXTURE_3D; + public static final int GL_FOG_MODE = RealOpenGLEnums.GL_FOG_MODE; + public static final int GL_EXP = RealOpenGLEnums.GL_EXP; + public static final int GL_FOG_DENSITY = RealOpenGLEnums.GL_FOG_DENSITY; + public static final int GL_FOG_START = RealOpenGLEnums.GL_FOG_START; + public static final int GL_FOG_END = RealOpenGLEnums.GL_FOG_END; + public static final int GL_FOG_COLOR = RealOpenGLEnums.GL_FOG_COLOR; + public static final int GL_TRIANGLE_STRIP = RealOpenGLEnums.GL_TRIANGLE_STRIP; + 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_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 = -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 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 = -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; + private static boolean enableLighting = false; + private static boolean enableAlphaTest = false; + private static float alphaThresh = 0.1f; + + private static boolean isCompilingDisplayList = false; + private static DisplayList compilingDisplayList = null; + + private static boolean enableColorArray = false; + private static boolean enableNormalArray = false; + private static boolean enableTex0Array = false; + + private static float colorR = 1.0f; + private static float colorG = 1.0f; + private static float colorB = 1.0f; + private static float colorA = 1.0f; + + private static float normalX = 1.0f; + private static float normalY = 0.0f; + private static float normalZ = 0.0f; + + private static float tex0X = 0; + private static float tex0Y = 0; + + private static boolean enableColorMaterial = false; + + private static float fogColorR = 1.0f; + private static float fogColorG = 1.0f; + private static float fogColorB = 1.0f; + private static float fogColorA = 1.0f; + private static int fogMode = 1; + private static boolean fogEnabled = false; + private static boolean fogPremultiply = false; + private static float fogStart = 1.0f; + private static float fogEnd = 1.0f; + private static float fogDensity = 1.0f; + + private static int bytesUploaded = 0; + private static int vertexDrawn = 0; + private static int triangleDrawn = 0; + + private static int matrixMode = GL_MODELVIEW; + + static Matrix4f[] matModelV = new Matrix4f[32]; + static int matModelPointer = 0; + + static Matrix4f[] matProjV = new Matrix4f[6]; + static int matProjPointer = 0; + + static Matrix4f[] matTexV = new Matrix4f[16]; + static int matTexPointer = 0; + + static { + for (int i = 0; i < matModelV.length; ++i) { + matModelV[i] = new Matrix4f(); + } + for (int i = 0; i < matProjV.length; ++i) { + matProjV[i] = new Matrix4f(); + } + for (int i = 0; i < matTexV.length; ++i) { + matTexV[i] = new Matrix4f(); + } + } + + public static void glClearStack() { + matModelV[0].load(matModelV[matModelPointer]); + matModelPointer = 0; + matProjV[0].load(matProjV[matProjPointer]); + matProjPointer = 0; + matTexV[0].load(matTexV[matTexPointer]); + matTexPointer = 0; + } + + private static BufferGL quadsToTrianglesBuffer = null; + private static BufferArrayGL currentArray = null; + + private static class DisplayList { + private final int id; + private BufferArrayGL glarray; + private BufferGL glbuffer; + private int shaderMode; + private int listLength; + + private DisplayList(int id) { + this.id = id; + this.glarray = null; + this.glbuffer = null; + this.shaderMode = -1; + this.listLength = 0; + } + } + + private static final HashMap displayLists = new HashMap(); + private static final HashMap displayListsInitialized = new HashMap(); + + public static final int getDisplayListCount() { + return displayListsInitialized.size(); + } + + public static final void glEnable(int p1) { + switch (p1) { + case GL_DEPTH_TEST: + _wglEnable(_wGL_DEPTH_TEST); + break; + case GL_CULL_FACE: + _wglEnable(_wGL_CULL_FACE); + break; + case GL_BLEND: + _wglEnable(_wGL_BLEND); + break; + case GL_RESCALE_NORMAL: + break; + case GL_TEXTURE_2D: + enableTexture2D = true; + break; + case GL_LIGHTING: + enableLighting = true; + break; + case GL_ALPHA_TEST: + enableAlphaTest = true; + break; + case GL_FOG: + fogEnabled = true; + break; + case GL_COLOR_MATERIAL: + enableColorMaterial = true; + break; + case GL_POLYGON_OFFSET_FILL: + _wglEnable(_wGL_POLYGON_OFFSET_FILL); + default: + break; + } + } + + public static final void glShadeModel(int p1) { + + } + + public static final void glClearDepth(float p1) { + _wglClearDepth(-p1); + } + + public static final void glDepthFunc(int p1) { + int f = _wGL_GEQUAL; + switch (p1) { + case GL_GREATER: + f = _wGL_LESS; + break; + case GL_LEQUAL: + f = _wGL_GEQUAL; + break; + case GL_EQUAL: + f = _wGL_EQUAL; + default: + break; + } + _wglDepthFunc(f); + } + + public static final void glAlphaFunc(int p1, float p2) { + alphaThresh = p2; + } + + public static final void glCullFace(int p1) { + _wglCullFace(p1); + } + + public static final void glMatrixMode(int p1) { + matrixMode = p1; + } + + private static final Matrix4f getMatrix() { + switch (matrixMode) { + case GL_MODELVIEW: + default: + return matModelV[matModelPointer]; + case GL_PROJECTION: + return matProjV[matProjPointer]; + case GL_TEXTURE: + return matTexV[matTexPointer]; + } + } + + public static final void glLoadIdentity() { + getMatrix().setIdentity(); + } + + public static final void glViewport(int p1, int p2, int p3, int p4) { + _wglViewport(p1, p2, p3, p4); + } + + public static final void glClear(int p1) { + _wglClear(p1); + } + + 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 / (right - left)); + res.m01 = 0.0f; + res.m02 = 0.0f; + res.m03 = 0.0f; + res.m10 = 0.0f; + 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 / (zFar - zNear)); + res.m23 = 0.0f; + 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 left, float right, float bottom, float top, float zNear, float zFar) { + Matrix4f res = getMatrix(); + 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 / (top - bottom); + res.m12 = 0.0f; + res.m13 = 0.0f; + res.m20 = 0.0f; + res.m21 = 0.0f; + res.m22 = 2.0f / (zFar - zNear); + res.m23 = 0.0f; + res.m30 = -(right + left) / (right - left); + res.m31 = -(top + bottom) / (top - bottom); + res.m32 = (zFar + zNear) / (zFar - zNear); + res.m33 = 1.0f; + } + + private static final Vector3f deevis = new Vector3f(); + + public static final void glTranslatef(float p1, float p2, float p3) { + deevis.set(p1, p2, p3); + getMatrix().translate(deevis); + if (isCompilingDisplayList) { + throw new IllegalArgumentException("matrix is not supported while recording display list use tessellator class instead"); + } + } + + public static final void glClearColor(float p1, float p2, float p3, float p4) { + _wglClearColor(p1, p2, p3, p4); + } + + public static final void glDisable(int p1) { + switch (p1) { + case GL_DEPTH_TEST: + _wglDisable(_wGL_DEPTH_TEST); + break; + case GL_CULL_FACE: + _wglDisable(_wGL_CULL_FACE); + break; + case GL_BLEND: + _wglDisable(_wGL_BLEND); + break; + case GL_RESCALE_NORMAL: + break; + case GL_TEXTURE_2D: + enableTexture2D = false; + break; + case GL_LIGHTING: + enableLighting = false; + break; + case GL_ALPHA_TEST: + enableAlphaTest = false; + break; + case GL_FOG: + fogEnabled = false; + break; + case GL_COLOR_MATERIAL: + enableColorMaterial = false; + break; + case GL_POLYGON_OFFSET_FILL: + _wglDisable(_wGL_POLYGON_OFFSET_FILL); + default: + break; + } + } + + public static final void glColor4f(float p1, float p2, float p3, float p4) { + colorR = p1; + colorG = p2; + colorB = p3; + colorA = p4; + } + + public static final int glGetError() { + int err = _wglGetError(); + if (err == _wGL_CONTEXT_LOST_WEBGL) + return GL_CONTEXT_LOST_WEBGL; + return err; + } + + public static final void glFlush() { + //...??? + } + + public static final void glLineWidth(float p1) { + + } + + public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + ByteBuffer p9) { + _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGBA8, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); + } + + public static final void glLight(int p1, int p2, FloatBuffer p3) { + + } + + public static final void glLightModel(int p1, FloatBuffer p2) { + + } + + private static Vector4f lightPos0vec0 = new Vector4f(); + private static Vector4f lightPos1vec0 = new Vector4f(); + private static Vector4f lightPos0vec = new Vector4f(); + private static Vector4f lightPos1vec = new Vector4f(); + + public static final void copyModelToLightMatrix() { + lightPos0vec0.set(lightPos0vec); + lightPos1vec0.set(lightPos1vec); + lightPos0vec.set(0.2f, 1.0f, -0.7f, 0.0f); + lightPos0vec.normalise(); + lightPos1vec.set(-0.2f, 1.0f, 0.7f, 0.0f); + lightPos1vec.normalise(); + Matrix4f.transform(matModelV[matModelPointer], lightPos0vec, lightPos0vec).normalise(); + Matrix4f.transform(matModelV[matModelPointer], lightPos1vec, lightPos1vec).normalise(); + } + + public static final void flipLightMatrix() { + lightPos0vec.x = -lightPos0vec.x; + lightPos1vec.x = -lightPos1vec.x; + lightPos0vec.y = -lightPos0vec.y; + lightPos1vec.y = -lightPos1vec.y; + lightPos0vec.z = -lightPos0vec.z; + lightPos1vec.z = -lightPos1vec.z; + } + + public static final void revertLightMatrix() { + lightPos0vec.set(lightPos0vec0); + lightPos1vec.set(lightPos1vec0); + } + + public static final void glPushMatrix() { + switch (matrixMode) { + case GL_MODELVIEW: + default: + if (matModelPointer < matModelV.length - 1) { + ++matModelPointer; + matModelV[matModelPointer].load(matModelV[matModelPointer - 1]); + } else { + System.err.println("modelview matrix stack overflow"); + } + break; + case GL_PROJECTION: + if (matProjPointer < matProjV.length - 1) { + ++matProjPointer; + matProjV[matProjPointer].load(matProjV[matProjPointer - 1]); + } else { + System.err.println("projection matrix stack overflow"); + } + break; + case GL_TEXTURE: + if (matTexPointer < matTexV.length - 1) { + ++matTexPointer; + matTexV[matTexPointer].load(matTexV[matTexPointer - 1]); + } else { + System.err.println("texture matrix stack overflow"); + } + break; + } + } + + private static final float toRad = 0.0174532925f; + + public static final void glRotatef(float p1, float p2, float p3, float p4) { + deevis.set(p2, p3, p4); + getMatrix().rotate(p1 * toRad, deevis); + if (isCompilingDisplayList) { + throw new IllegalArgumentException("matrix is not supported while recording display list use tessellator class instead"); + } + } + + public static final void glPopMatrix() { + switch (matrixMode) { + case GL_MODELVIEW: + default: + if (matModelPointer > 0) { + --matModelPointer; + } else { + System.err.println("modelview matrix stack underflow"); + } + break; + case GL_PROJECTION: + if (matProjPointer > 0) { + --matProjPointer; + } else { + System.err.println("projection matrix stack underflow"); + } + break; + case GL_TEXTURE: + if (matTexPointer > 0) { + --matTexPointer; + } else { + System.err.println("texture matrix stack underflow"); + } + break; + } + } + + public static final void glColorMaterial(int p1, int p2) { + + } + + public static final void glGetFloat(int p1, FloatBuffer p2) { + switch (p1) { + case GL_MODELVIEW_MATRIX: + default: + matModelV[matModelPointer].store(p2); + break; + case GL_PROJECTION_MATRIX: + matProjV[matProjPointer].store(p2); + break; + } + } + + public static final void glGetInteger(int p1, int[] p2) { + if (p1 == GL_VIEWPORT) { + _wglGetParameter(_wGL_VIEWPORT, 4, p2); + } + } + + public static final void glScalef(float p1, float p2, float p3) { + deevis.set(p1, p2, p3); + getMatrix().scale(deevis); + if (isCompilingDisplayList) { + throw new IllegalArgumentException("matrix is not supported while recording display list use tessellator class instead"); + } + } + + public static final void glBlendFunc(int p1, int p2) { + fogPremultiply = (p1 == GL_ONE && p2 == GL_ONE_MINUS_SRC_ALPHA); + _wglBlendFunc(p1, p2); + } + + public static final void glBlendFuncSeparate(int p1, int p2, int p3, int p4) { + fogPremultiply = (p3 == GL_ONE && p4 == GL_ONE_MINUS_SRC_ALPHA); + _wglBlendFuncSeparate(p1, p2, p3, p4); + } + + public static final void glDepthMask(boolean p1) { + _wglDepthMask(p1); + } + + public static final void glColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { + _wglColorMask(p1, p2, p3, p4); + } + + public static final void glBindTexture(int p1, int p2) { + TextureGL t = texObjects.get(p2); + _wglBindTexture(_wGL_TEXTURE_2D, t); + } + + public static final void glCopyTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { + _wglCopyTexSubImage2D(_wGL_TEXTURE_2D, p2, p3, p4, p5, p6, p7, p8); + } + + public static final void glTexParameteri(int p1, int p2, int p3) { + if(p3 == RealOpenGLEnums.GL_CLAMP_TO_EDGE || p3 == 10496) { + p3 = _wGL_CLAMP; + } + _wglTexParameteri(p1, p2, p3); + } + + public static final void glTexParameterf(int p1, int p2, float p3) { + int pp1 = 0; + switch (p1) { + default: + case GL_TEXTURE_2D: + pp1 = _wGL_TEXTURE_2D; + break; + // case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; + } + int pp2 = 0; + switch (p2) { + default: + case GL_TEXTURE_MAX_ANISOTROPY: + pp2 = _wGL_TEXTURE_MAX_ANISOTROPY; + break; + } + _wglTexParameterf(pp1, pp2, p3); + } + + public static final void glLogicOp(int p1) { + + } + + public static final void glNormal3f(float p1, float p2, float p3) { + float len = (float) Math.sqrt(p1 * p1 + p2 * p2 + p3 * p3); + normalX = p1 / len; + normalY = p2 / len; + normalZ = p3 / len; + } + + public static final int glGenLists(int p1) { + int base = displayListId + 1; + for (int i = 0; i < p1; i++) { + int id = ++displayListId; + displayLists.put(id, new DisplayList(id)); + } + return base; + } + + public static final void _wglBindVertexArray0(BufferArrayGL p1) { + currentArray = p1; + _wglBindVertexArray(p1); + } + + private static int displayListId = 0; + + public static final void glCallList(int p1) { + if (!isCompilingDisplayList) { + DisplayList d = displayListsInitialized.get(p1); + if (d != null && d.listLength > 0) { + bindTheShader(d.shaderMode | getShaderModeFlag1()); + _wglBindVertexArray0(d.glarray); + _wglDrawQuadArrays(0, d.listLength); + shader.unuseProgram(); + vertexDrawn += d.listLength * 6 / 4; + triangleDrawn += d.listLength / 2; + } + } + } + + public static final void glNewList(int p1, int p2) { + if (!isCompilingDisplayList) { + compilingDisplayList = displayLists.get(p1); + if (compilingDisplayList != null) { + compilingDisplayList.shaderMode = -1; + compilingDisplayList.listLength = 0; + isCompilingDisplayList = true; + } + } + } + + public static final void glEndList() { + if (isCompilingDisplayList) { + isCompilingDisplayList = false; + Object upload = _wGetLowLevelBuffersAppended(); + int l = _wArrayByteLength(upload); + if (l > 0) { + if (compilingDisplayList.glbuffer == null) { + displayListsInitialized.put(compilingDisplayList.id, compilingDisplayList); + compilingDisplayList.glarray = _wglCreateVertexArray(); + compilingDisplayList.glbuffer = _wglCreateBuffer(); + FixedFunctionShader f = FixedFunctionShader.instance(compilingDisplayList.shaderMode); + _wglBindVertexArray0(compilingDisplayList.glarray); + _wglBindBuffer(_wGL_ARRAY_BUFFER, compilingDisplayList.glbuffer); + f.setupArrayForProgram(); + } + _wglBindBuffer(_wGL_ARRAY_BUFFER, compilingDisplayList.glbuffer); + _wglBufferData(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); + bytesUploaded += l; + } + } + } + + public static final void glColor3f(float p1, float p2, float p3) { + colorR = p1; + colorG = p2; + colorB = p3; + colorA = 1.0f; + } + + public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + IntBuffer p9) { + /* + * int pp2 = 0; switch(p3) { default: case GL_RGBA: pp2 = _wGL_RGBA; break; case + * GL_BGRA: pp2 = _wGL_BGRA; break; } int pp3 = 0; switch(p7) { default: case + * GL_RGBA: pp3 = _wGL_RGBA; break; case GL_BGRA: pp3 = _wGL_BGRA; break; } + */ + bytesUploaded += p9.remaining() * 4; + _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGBA8, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); + } + + public static final void glTexImage2D_2(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + IntBuffer p9) { + bytesUploaded += p9.remaining() * 4; + _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGB8, p4, p5, p6, _wGL_RGB, _wGL_UNSIGNED_BYTE, p9); + } + + public static final void glTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + IntBuffer p9) { + int pp1 = 0; + switch (p1) { + default: + case GL_TEXTURE_2D: + pp1 = _wGL_TEXTURE_2D; + break; + // case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; + } + /* + * int pp3 = 0; switch(p7) { default: case GL_RGBA: pp3 = _wGL_RGBA; break; case + * GL_BGRA: pp3 = _wGL_BGRA; break; } + */ + bytesUploaded += p9.remaining() * 4; + _wglTexSubImage2D(pp1, p2, p3, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); + } + + public static final void glDeleteTextures(int p1) { + _wglDeleteTextures(texObjects.free(p1)); + } + + public static final void glPolygonOffset(float p1, float p2) { + _wglPolygonOffset(p1, p2); + } + + public static final void glCallLists(IntBuffer p1) { + while (p1.hasRemaining()) { + glCallList(p1.get()); + } + } + + public static final void glEnableVertexAttrib(int p1) { + switch (p1) { + case GL_COLOR_ARRAY: + enableColorArray = true; + break; + case GL_NORMAL_ARRAY: + enableNormalArray = true; + break; + case GL_TEXTURE_COORD_ARRAY: + enableTex0Array = true; + break; + default: + break; + } + } + + public static final void glDisableVertexAttrib(int p1) { + switch (p1) { + case GL_COLOR_ARRAY: + enableColorArray = false; + break; + case GL_NORMAL_ARRAY: + enableNormalArray = false; + break; + case GL_TEXTURE_COORD_ARRAY: + enableTex0Array = false; + break; + default: + break; + } + } + + private static final int getShaderModeFlag0() { + int mode = 0; + mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); + mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0)); + mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0)); + return mode; + } + + private static final int getShaderModeFlag1() { + int mode = 0; + mode = (mode | ((enableColorMaterial && enableLighting) ? FixedFunctionShader.LIGHTING : 0)); + mode = (mode | (fogEnabled ? FixedFunctionShader.FOG : 0)); + mode = (mode | (enableAlphaTest ? FixedFunctionShader.ALPHATEST : 0)); + mode = (mode | (enableTexture2D ? FixedFunctionShader.UNIT0 : 0)); + return mode; + } + + private static final int getShaderModeFlag() { + int mode = 0; + mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); + mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0)); + mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0)); + mode = (mode | ((enableColorMaterial && enableLighting) ? FixedFunctionShader.LIGHTING : 0)); + mode = (mode | (fogEnabled ? FixedFunctionShader.FOG : 0)); + mode = (mode | (enableAlphaTest ? FixedFunctionShader.ALPHATEST : 0)); + mode = (mode | (enableTexture2D ? FixedFunctionShader.UNIT0 : 0)); + return mode; + } + + private static FixedFunctionShader shader = null; + + private static final void bindTheShader() { + bindTheShader(getShaderModeFlag()); + } + + private static final void bindTheShader(int mode) { + FixedFunctionShader s = shader = FixedFunctionShader.instance(mode); + s.useProgram(); + if (enableAlphaTest) { + s.setAlphaTest(alphaThresh); + } + s.setColor(colorR, colorG, colorB, colorA); + if (fogEnabled) { + s.setFogMode((fogPremultiply ? 2 : 0) + fogMode); + s.setFogColor(fogColorR, fogColorG, fogColorB, fogColorA); + s.setFogDensity(fogDensity); + s.setFogStartEnd(fogStart, fogEnd); + } + s.setModelMatrix(matModelV[matModelPointer]); + s.setProjectionMatrix(matProjV[matProjPointer]); + s.setTextureMatrix(matTexV[matTexPointer]); + if (enableColorMaterial && enableLighting) { + s.setNormal(normalX, normalY, normalZ); + s.setLightPositions(lightPos0vec, lightPos1vec); + } + s.setTex0Coords(tex0X, tex0Y); + } + + private static Object blankUploadArray = _wCreateLowLevelIntBuffer(525000); + + public static final void glDrawArrays(int p1, int p2, int p3, Object buffer) { + if (isCompilingDisplayList) { + if (p1 == GL_QUADS) { + if (compilingDisplayList.shaderMode == -1) { + compilingDisplayList.shaderMode = getShaderModeFlag0(); + } else { + if (compilingDisplayList.shaderMode != getShaderModeFlag0()) { + System.err.println("vertex format inconsistent in display list"); + } + } + compilingDisplayList.listLength += p3; + _wAppendLowLevelBuffer(buffer); + } else { + System.err.println("only GL_QUADS supported in a display list"); + } + } else { + bytesUploaded += _wArrayByteLength(buffer); + vertexDrawn += p3; + + bindTheShader(); + + _wglBindVertexArray0(shader.genericArray); + _wglBindBuffer(_wGL_ARRAY_BUFFER, shader.genericBuffer); + if (!shader.bufferIsInitialized) { + shader.bufferIsInitialized = true; + _wglBufferData(_wGL_ARRAY_BUFFER, blankUploadArray, _wGL_DYNAMIC_DRAW); + } + _wglBufferSubData(_wGL_ARRAY_BUFFER, 0, buffer); + + if (p1 == GL_QUADS) { + _wglDrawQuadArrays(p2, p3); + triangleDrawn += p3 / 2; + } else { + int drawMode = 0; + switch (p1) { + default: + case GL_TRIANGLES: + drawMode = _wGL_TRIANGLES; + triangleDrawn += p3 / 3; + break; + case GL_TRIANGLE_STRIP: + drawMode = _wGL_TRIANGLE_STRIP; + triangleDrawn += p3 - 2; + break; + case GL_TRIANGLE_FAN: + drawMode = _wGL_TRIANGLE_FAN; + triangleDrawn += p3 - 2; + break; + case GL_LINE_STRIP: + drawMode = _wGL_LINE_STRIP; + triangleDrawn += p3 - 1; + break; + case GL_LINES: + drawMode = _wGL_LINES; + triangleDrawn += p3 / 2; + break; + } + _wglDrawArrays(drawMode, p2, p3); + } + + shader.unuseProgram(); + + } + } + + private static final void _wglDrawQuadArrays(int p2, int p3) { + if (quadsToTrianglesBuffer == null) { + 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; + int v3 = i * 4 + 2; + int v4 = i * 4 + 3; + upload.put(v1 | (v2 << 16)); + upload.put(v4 | (v2 << 16)); + upload.put(v3 | (v4 << 16)); + } + upload.flip(); + quadsToTrianglesBuffer = _wglCreateBuffer(); + _wglBindBuffer(_wGL_ELEMENT_ARRAY_BUFFER, quadsToTrianglesBuffer); + _wglBufferData0(_wGL_ELEMENT_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); + } + if (!currentArray.isQuadBufferBound) { + currentArray.isQuadBufferBound = true; + _wglBindBuffer(_wGL_ELEMENT_ARRAY_BUFFER, quadsToTrianglesBuffer); + } + _wglDrawElements(_wGL_TRIANGLES, p3 * 6 / 4, _wGL_UNSIGNED_SHORT, p2 * 6 / 4); + } + + private static BufferArrayGL occlusion_vao = null; + private static BufferGL occlusion_vbo = null; + private static ProgramGL occlusion_program = null; + private static UniformGL occlusion_matrix_m = null; + private static UniformGL occlusion_matrix_p = null; + + private static final void initializeOcclusionObjects() { + occlusion_vao = _wglCreateVertexArray(); + occlusion_vbo = _wglCreateBuffer(); + + 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, + 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }; + for (int i = 0; i < verts.length; i++) { + upload.put(Float.floatToRawIntBits(verts[i])); + } + upload.flip(); + + _wglBindVertexArray(occlusion_vao); + _wglBindBuffer(_wGL_ARRAY_BUFFER, occlusion_vbo); + _wglBufferData0(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); + _wglEnableVertexAttribArray(0); + _wglVertexAttribPointer(0, 3, _wGL_FLOAT, false, 12, 0); + + ShaderGL vert = _wglCreateShader(_wGL_VERTEX_SHADER); + ShaderGL frag = _wglCreateShader(_wGL_FRAGMENT_SHADER); + + String src = fileContents("/glsl/occl.glsl"); + _wglShaderSource(vert, _wgetShaderHeader() + "\n#define CC_VERT\n" + src); + _wglShaderSource(frag, _wgetShaderHeader() + "\n#define CC_FRAG\n" + src); + + _wglCompileShader(vert); + if (!_wglGetShaderCompiled(vert)) + System.err.println(("\n" + _wglGetShaderInfoLog(vert)).replace("\n", "\n[/glsl/occl.glsl][VERT] ") + "\n"); + + _wglCompileShader(frag); + if (!_wglGetShaderCompiled(frag)) + System.err.println(("\n" + _wglGetShaderInfoLog(frag)).replace("\n", "\n[/glsl/occl.glsl][FRAG] ") + "\n"); + + occlusion_program = _wglCreateProgram(); + + _wglAttachShader(occlusion_program, vert); + _wglAttachShader(occlusion_program, frag); + _wglLinkProgram(occlusion_program); + _wglDetachShader(occlusion_program, vert); + _wglDetachShader(occlusion_program, frag); + _wglDeleteShader(vert); + _wglDeleteShader(frag); + + if (!_wglGetProgramLinked(occlusion_program)) + System.err.println( + ("\n\n" + _wglGetProgramInfoLog(occlusion_program)).replace("\n", "\n[/glsl/occl.glsl][LINKER] ")); + + _wglUseProgram(occlusion_program); + occlusion_matrix_m = _wglGetUniformLocation(occlusion_program, "matrix_m"); + occlusion_matrix_p = _wglGetUniformLocation(occlusion_program, "matrix_p"); + + } + + private static final GLObjectMap queryObjs = new GLObjectMap(256); + + public static final int glCreateQuery() { + return queryObjs.register(_wglCreateQuery()); + } + + public static final void glBeginQuery(int obj) { + _wglBeginQuery(_wGL_ANY_SAMPLES_PASSED, queryObjs.get(obj)); + } + + public static final void glDeleteQuery(int obj) { + _wglDeleteQuery(queryObjs.free(obj)); + } + + private static final Matrix4f cachedOcclusionP = (Matrix4f) (new Matrix4f()).setZero(); + private static float[] occlusionModel = new float[16]; + private static float[] occlusionProj = new float[16]; + + public static final void glBindOcclusionBB() { + if (occlusion_vao == null) + initializeOcclusionObjects(); + _wglUseProgram(occlusion_program); + _wglBindVertexArray(occlusion_vao); + if (!cachedOcclusionP.equals(matProjV[matProjPointer])) { + cachedOcclusionP.load(matProjV[matProjPointer]); + cachedOcclusionP.store(occlusionProj); + _wglUniformMat4fv(occlusion_matrix_p, occlusionProj); + } + } + + public static final void glEndOcclusionBB() { + + } + + public static final void glDrawOcclusionBB(float posX, float posY, float posZ, float sizeX, float sizeY, + float sizeZ) { + glPushMatrix(); + glTranslatef(posX - sizeX * 0.01f, posY - sizeY * 0.01f, posZ - sizeZ * 0.01f); + glScalef(sizeX * 1.02f, sizeY * 1.02f, sizeZ * 1.02f); + matModelV[matModelPointer].store(occlusionModel); + _wglUniformMat4fv(occlusion_matrix_m, occlusionModel); + _wglDrawArrays(_wGL_TRIANGLES, 0, 36); + glPopMatrix(); + + } + + public static final void glEndQuery() { + _wglEndQuery(_wGL_ANY_SAMPLES_PASSED); + } + + public static final boolean glGetQueryResult(int obj) { + QueryGL q = queryObjs.get(obj); + return _wglGetQueryObjecti(q, _wGL_QUERY_RESULT) > 0; + } + + public static final boolean glGetQueryResultAvailable(int obj) { + QueryGL q = queryObjs.get(obj); + return _wglGetQueryObjecti(q, _wGL_QUERY_RESULT_AVAILABLE) > 0; + } + + public static final int glGenTextures() { + return texObjects.register(_wglGenTextures()); + } + + public static final void glTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + ByteBuffer p9) { + int pp1 = 0; + switch (p1) { + default: + case GL_TEXTURE_2D: + pp1 = _wGL_TEXTURE_2D; + break; + // case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; + } + /* + * int pp3 = 0; switch(p7) { default: case GL_RGBA: pp3 = _wGL_RGBA; break; case + * GL_BGRA: pp3 = _wGL_BGRA; break; } + */ + bytesUploaded += p9.remaining(); + _wglTexSubImage2D(pp1, p2, p3, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); + } + + public static final void glFogi(int p1, int p2) { + if (p1 == GL_FOG_MODE) { + switch (p2) { + default: + case GL_LINEAR: + fogMode = 1; + break; + case GL_EXP: + fogMode = 2; + break; + } + } + } + + public static final void glFogf(int p1, float p2) { + switch (p1) { + case GL_FOG_START: + fogStart = p2; + break; + case GL_FOG_END: + fogEnd = p2; + break; + case GL_FOG_DENSITY: + fogDensity = p2; + break; + default: + break; + } + } + + public static final void glFog(int p1, FloatBuffer p2) { + if (p1 == GL_FOG_COLOR) { + fogColorR = p2.get(); + fogColorG = p2.get(); + fogColorB = p2.get(); + fogColorA = p2.get(); + } + } + + public static final void glDeleteLists(int p1, int p2) { + for (int i = 0; i < p2; i++) { + DisplayList d = displayListsInitialized.remove(p1 + i); + if (d != null) { + _wglDeleteVertexArray(d.glarray); + _wglDeleteBuffer(d.glbuffer); + } + displayLists.remove(p1 + i); + } + } + + public static final void glMultiTexCoord2f(int p1, float p2, float p3) { + tex0X = p2; + tex0Y = p3; + } + + private static Matrix4f unprojA = new Matrix4f(); + private static Matrix4f unprojB = new Matrix4f(); + private static Vector4f unprojC = new Vector4f(); + + public static final void gluUnProject(float p1, float p2, float p3, FloatBuffer p4, FloatBuffer p5, int[] p6, + FloatBuffer p7) { + unprojA.load(p4); + unprojB.load(p5); + Matrix4f.mul(unprojA, unprojB, unprojB); + unprojB.invert(); + unprojC.set(((p1 - (float) p6[0]) / (float) p6[2]) * 2f - 1f, ((p2 - (float) p6[1]) / (float) p6[3]) * 2f - 1f, + p3, 1.0f); + Matrix4f.transform(unprojB, unprojC, unprojC); + p7.put(unprojC.x / unprojC.w); + p7.put(unprojC.y / unprojC.w); + p7.put(unprojC.z / unprojC.w); + } + + public static final void gluPerspective(float fovy, float aspect, float zNear, float zFar) { + Matrix4f res = getMatrix(); + float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f); + res.m00 = cotangent / aspect; + res.m01 = 0.0f; + res.m02 = 0.0f; + res.m03 = 0.0f; + res.m10 = 0.0f; + res.m11 = cotangent; + res.m12 = 0.0f; + res.m13 = 0.0f; + res.m20 = 0.0f; + res.m21 = 0.0f; + res.m22 = (zFar + zNear) / (zFar - zNear); + res.m23 = -1.0f; + res.m30 = 0.0f; + res.m31 = 0.0f; + res.m32 = 2.0f * zFar * zNear / (zFar - zNear); + res.m33 = 0.0f; + } + + public static final void gluPerspectiveFlat(float fovy, float aspect, float zNear, float zFar) { + Matrix4f res = getMatrix(); + float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f); + res.m00 = cotangent / aspect; + res.m01 = 0.0f; + res.m02 = 0.0f; + res.m03 = 0.0f; + res.m10 = 0.0f; + res.m11 = cotangent; + res.m12 = 0.0f; + res.m13 = 0.0f; + res.m20 = 0.0f; + res.m21 = 0.0f; + res.m22 = ((zFar + zNear) / (zFar - zNear)) * 0.001f; + res.m23 = -1.0f; + res.m30 = 0.0f; + res.m31 = 0.0f; + res.m32 = 2.0f * zFar * zNear / (zFar - zNear); + res.m33 = 0.0f; + } + + public static final String gluErrorString(int p1) { + switch (p1) { + case GL_INVALID_ENUM: + return "GL_INVALID_ENUM"; + case GL_INVALID_VALUE: + return "GL_INVALID_VALUE"; + case GL_INVALID_OPERATION: + return "GL_INVALID_OPERATION"; + case GL_OUT_OF_MEMORY: + return "GL_OUT_OF_MEMORY"; + case GL_CONTEXT_LOST_WEBGL: + return "CONTEXT_LOST_WEBGL"; + default: + return "Unknown Error"; + } + } + + private static long lastBandwidthReset = 0l; + private static int lastBandwidth = 0; + + public static final int getBitsPerSecond() { + if (System.currentTimeMillis() - lastBandwidthReset > 1000) { + lastBandwidthReset = System.currentTimeMillis(); + lastBandwidth = bytesUploaded * 8; + bytesUploaded = 0; + } + return lastBandwidth; + } + + public static final int getVertexesPerSecond() { + int ret = vertexDrawn; + vertexDrawn = 0; + return ret; + } + + public static final int getTrianglesPerSecond() { + int ret = triangleDrawn; + triangleDrawn = 0; + return ret; + } + +} \ No newline at end of file diff --git a/src/teavm/java/util/IProgressUpdate.java b/src/teavm/java/util/IProgressUpdate.java new file mode 100644 index 0000000..4ca8572 --- /dev/null +++ b/src/teavm/java/util/IProgressUpdate.java @@ -0,0 +1,9 @@ +package util; + +public interface IProgressUpdate { + void displayProgressMessage(String var1); + + void displayLoadingString(String var1); + + void setLoadingProgress(int var1); +}