├── .github └── workflows │ └── wheels.yml ├── .gitignore ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── map.png ├── mc ├── InputStream.py ├── JavaUtils.pxd ├── JavaUtils.pyx ├── Resources.py ├── __init__.py ├── lib │ ├── soft_oal_32.dll │ └── soft_oal_64.dll ├── net │ ├── __init__.py │ └── minecraft │ │ ├── __init__.py │ │ ├── client │ │ ├── ChatLine.py │ │ ├── GameSettings.py │ │ ├── GuiMainTitle.py │ │ ├── KeyBinding.py │ │ ├── LoadingScreenRenderer.py │ │ ├── Minecraft.py │ │ ├── OpenGlCapsChecker.py │ │ ├── PlayerLoader.py │ │ ├── RenderHelper.py │ │ ├── Session.py │ │ ├── ThreadDownloadSkin.py │ │ ├── Timer.py │ │ ├── __init__.py │ │ ├── controller │ │ │ ├── PlayerController.py │ │ │ ├── PlayerControllerCreative.py │ │ │ ├── PlayerControllerSP.py │ │ │ └── __init__.py │ │ ├── effect │ │ │ ├── EffectRenderer.py │ │ │ ├── EntityBubbleFX.py │ │ │ ├── EntityDiggingFX.py │ │ │ ├── EntityExplodeFX.py │ │ │ ├── EntityFX.pxd │ │ │ ├── EntityFX.pyx │ │ │ ├── EntityFlameFX.py │ │ │ ├── EntityLavaFX.py │ │ │ ├── EntityRainFX.py │ │ │ ├── EntitySmokeFX.py │ │ │ └── __init__.py │ │ ├── gui │ │ │ ├── FontRenderer.pxd │ │ │ ├── FontRenderer.pyx │ │ │ ├── Gui.py │ │ │ ├── GuiButton.py │ │ │ ├── GuiControls.py │ │ │ ├── GuiErrorScreen.py │ │ │ ├── GuiGameOver.py │ │ │ ├── GuiIngame.py │ │ │ ├── GuiIngameMenu.py │ │ │ ├── GuiLevelDialog.py │ │ │ ├── GuiLoadLevel.py │ │ │ ├── GuiNameLevel.py │ │ │ ├── GuiNewLevel.py │ │ │ ├── GuiOptions.py │ │ │ ├── GuiSaveLevel.py │ │ │ ├── GuiScreen.py │ │ │ ├── GuiSmallButton.py │ │ │ ├── ScaledResolution.py │ │ │ ├── __init__.py │ │ │ └── container │ │ │ │ ├── GuiChest.py │ │ │ │ ├── GuiContainer.py │ │ │ │ ├── GuiCrafting.py │ │ │ │ ├── GuiInventory.py │ │ │ │ ├── InventoryCraftResult.py │ │ │ │ ├── InventoryCrafting.py │ │ │ │ ├── Slot.py │ │ │ │ ├── SlotCrafting.py │ │ │ │ └── __init__.py │ │ ├── model │ │ │ ├── ModelBase.py │ │ │ ├── ModelBiped.py │ │ │ ├── ModelRenderer.py │ │ │ ├── PositionTextureVertex.py │ │ │ ├── TexturedQuad.py │ │ │ └── __init__.py │ │ ├── player │ │ │ ├── EntityPlayerInput.py │ │ │ ├── EntityPlayerSP.py │ │ │ ├── MovementInput.py │ │ │ ├── MovementInputFromOptions.py │ │ │ └── __init__.py │ │ ├── render │ │ │ ├── EntityRenderer.py │ │ │ ├── EntitySorter.py │ │ │ ├── Frustum.pxd │ │ │ ├── Frustum.pyx │ │ │ ├── ItemRenderer.py │ │ │ ├── RenderBlocks.pxd │ │ │ ├── RenderBlocks.pyx │ │ │ ├── RenderEngine.py │ │ │ ├── RenderGlobal.pxd │ │ │ ├── RenderGlobal.pyx │ │ │ ├── RenderSorter.py │ │ │ ├── Tessellator.pxd │ │ │ ├── Tessellator.pyx │ │ │ ├── WorldRenderer.pxd │ │ │ ├── WorldRenderer.pyx │ │ │ ├── __init__.py │ │ │ ├── entity │ │ │ │ ├── Render.py │ │ │ │ ├── RenderArrow.py │ │ │ │ ├── RenderEntity.py │ │ │ │ ├── RenderItem.py │ │ │ │ ├── RenderLiving.py │ │ │ │ ├── RenderManager.py │ │ │ │ ├── RenderTNTPrimed.py │ │ │ │ └── __init__.py │ │ │ └── texture │ │ │ │ ├── TextureFX.pxd │ │ │ │ ├── TextureFX.pyx │ │ │ │ ├── TextureFlamesFX.pyx │ │ │ │ ├── TextureGearsFX.pyx │ │ │ │ ├── TextureLavaFX.pyx │ │ │ │ ├── TextureWaterFX.pyx │ │ │ │ ├── TextureWaterFlowFX.pyx │ │ │ │ └── __init__.py │ │ └── sound │ │ │ ├── SoundManager.py │ │ │ ├── SoundPool.py │ │ │ ├── SoundPoolEntry.py │ │ │ └── __init__.py │ │ └── game │ │ ├── Inventory.py │ │ ├── InventoryLargeChest.py │ │ ├── __init__.py │ │ ├── entity │ │ ├── AILiving.pxd │ │ ├── AILiving.pyx │ │ ├── Entity.pxd │ │ ├── Entity.pyx │ │ ├── EntityLiving.pxd │ │ ├── EntityLiving.pyx │ │ ├── __init__.py │ │ ├── misc │ │ │ ├── EntityItem.py │ │ │ ├── EntityTNTPrimed.py │ │ │ └── __init__.py │ │ ├── player │ │ │ ├── EntityPlayer.py │ │ │ ├── InventoryPlayer.py │ │ │ └── __init__.py │ │ └── projectile │ │ │ ├── EntityArrow.py │ │ │ └── __init__.py │ │ ├── item │ │ ├── Item.py │ │ ├── ItemAxe.py │ │ ├── ItemBlock.py │ │ ├── ItemBow.py │ │ ├── ItemFlintAndSteel.py │ │ ├── ItemFood.py │ │ ├── ItemPickaxe.py │ │ ├── ItemSoup.py │ │ ├── ItemSpade.py │ │ ├── ItemStack.py │ │ ├── ItemSword.py │ │ ├── ItemTool.py │ │ ├── Items.py │ │ ├── __init__.py │ │ └── recipe │ │ │ ├── CraftingManager.py │ │ │ ├── RecipeSorter.py │ │ │ ├── RecipesBlocks.py │ │ │ ├── RecipesBowl.py │ │ │ ├── RecipesIngots.py │ │ │ ├── RecipesTools.py │ │ │ ├── RecipesWeapons.py │ │ │ ├── ShapedRecipes.py │ │ │ └── __init__.py │ │ ├── level │ │ ├── EntityMap.pxd │ │ ├── EntityMap.pyx │ │ ├── EntityMapSlot.pxd │ │ ├── EntityMapSlot.pyx │ │ ├── LevelLoader.py │ │ ├── MobSpawner.py │ │ ├── World.pxd │ │ ├── World.pyx │ │ ├── __init__.py │ │ ├── block │ │ │ ├── Block.pxd │ │ │ ├── Block.pyx │ │ │ ├── BlockBookshelf.py │ │ │ ├── BlockChest.py │ │ │ ├── BlockContainer.py │ │ │ ├── BlockDirt.py │ │ │ ├── BlockFire.pyx │ │ │ ├── BlockFlower.py │ │ │ ├── BlockFlowing.pxd │ │ │ ├── BlockFlowing.pyx │ │ │ ├── BlockFluid.pxd │ │ │ ├── BlockFluid.pyx │ │ │ ├── BlockGears.py │ │ │ ├── BlockGlass.py │ │ │ ├── BlockGrass.py │ │ │ ├── BlockLeaves.py │ │ │ ├── BlockLeavesBase.py │ │ │ ├── BlockLog.py │ │ │ ├── BlockMushroom.py │ │ │ ├── BlockOre.py │ │ │ ├── BlockOreBlock.py │ │ │ ├── BlockSand.py │ │ │ ├── BlockSapling.py │ │ │ ├── BlockSource.py │ │ │ ├── BlockSponge.py │ │ │ ├── BlockStationary.py │ │ │ ├── BlockStep.py │ │ │ ├── BlockStone.py │ │ │ ├── BlockTNT.py │ │ │ ├── BlockTorch.py │ │ │ ├── BlockWorkbench.py │ │ │ ├── Blocks.py │ │ │ ├── StepSound.py │ │ │ ├── __init__.py │ │ │ └── tileentity │ │ │ │ ├── TileEntity.py │ │ │ │ ├── TileEntityChest.py │ │ │ │ └── __init__.py │ │ ├── generator │ │ │ ├── LevelGenerator.pyx │ │ │ ├── __init__.py │ │ │ └── noise │ │ │ │ ├── NoiseGeneratorDistort.pxd │ │ │ │ ├── NoiseGeneratorDistort.pyx │ │ │ │ ├── NoiseGeneratorOctaves.pxd │ │ │ │ ├── NoiseGeneratorOctaves.pyx │ │ │ │ ├── NoiseGeneratorPerlin.pxd │ │ │ │ ├── NoiseGeneratorPerlin.pyx │ │ │ │ └── __init__.py │ │ └── material │ │ │ ├── Material.py │ │ │ └── __init__.py │ │ └── physics │ │ ├── AxisAlignedBB.pxd │ │ ├── AxisAlignedBB.pyx │ │ ├── MovingObjectPosition.py │ │ ├── Vec3D.py │ │ └── __init__.py └── resources │ ├── icon │ └── minecraft.png │ ├── music │ ├── calm1.ogg │ ├── calm2.ogg │ └── calm3.ogg │ ├── newsound │ └── random │ │ ├── bow.ogg │ │ ├── click.ogg │ │ ├── explode.ogg │ │ ├── explode1.ogg │ │ ├── explode2.ogg │ │ ├── explode3.ogg │ │ ├── explode4.ogg │ │ ├── fizz.ogg │ │ ├── fuse.ogg │ │ ├── hurt.ogg │ │ ├── pop.ogg │ │ └── splash.ogg │ ├── sound │ └── step │ │ ├── grass1.ogg │ │ ├── grass2.ogg │ │ ├── grass3.ogg │ │ ├── grass4.ogg │ │ ├── gravel1.ogg │ │ ├── gravel2.ogg │ │ ├── gravel3.ogg │ │ ├── gravel4.ogg │ │ ├── stone1.ogg │ │ ├── stone2.ogg │ │ ├── stone3.ogg │ │ ├── stone4.ogg │ │ ├── wood1.ogg │ │ ├── wood2.ogg │ │ ├── wood3.ogg │ │ └── wood4.ogg │ └── texture │ ├── armor │ ├── chain.png │ └── plate.png │ ├── char.png │ ├── clouds.png │ ├── cube-nes.png │ ├── default.gif │ ├── default.png │ ├── dirt.png │ ├── grass.png │ ├── gui │ ├── container.png │ ├── crafting.png │ ├── gui.png │ ├── icons.png │ ├── inventory.png │ ├── items.png │ └── logo.png │ ├── item │ ├── arrows.png │ └── sign.png │ ├── mcexport.png │ ├── mcexport2.png │ ├── mcexport3.png │ ├── misc │ ├── gear.png │ └── gearmiddle.png │ ├── mob │ ├── creeper.png │ ├── pig.png │ ├── sheep.png │ ├── sheep_fur.png │ ├── skeleton.png │ ├── spider.png │ └── zombie.png │ ├── particles.png │ ├── rain.png │ ├── rock.png │ ├── shadow.png │ ├── terrain.png │ └── water.png ├── pyproject.toml ├── requirements.txt ├── screenshot.png └── setup.py /.github/workflows/wheels.yml: -------------------------------------------------------------------------------- 1 | name: Build and upload to PyPI 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | push: 7 | branches: 8 | - master 9 | release: 10 | types: 11 | - published 12 | 13 | jobs: 14 | build_wheels: 15 | name: Build wheels on ${{ matrix.os }} 16 | runs-on: ${{ matrix.os }} 17 | strategy: 18 | matrix: 19 | os: [ubuntu-latest, windows-latest, macos-13, macos-14] 20 | 21 | steps: 22 | - uses: actions/checkout@v4 23 | 24 | - name: Build wheels 25 | uses: pypa/cibuildwheel@v2.17.0 26 | 27 | - uses: actions/upload-artifact@v4 28 | with: 29 | name: dist-${{ matrix.os }} 30 | path: ./wheelhouse/*.whl 31 | 32 | build_sdist: 33 | name: Build source distribution 34 | runs-on: ubuntu-latest 35 | steps: 36 | - uses: actions/checkout@v4 37 | 38 | - name: Build sdist 39 | run: pipx run build --sdist 40 | 41 | - uses: actions/upload-artifact@v4 42 | with: 43 | name: dist-${{ matrix.os }} 44 | path: dist/*.tar.gz 45 | 46 | upload_pypi: 47 | needs: [build_wheels, build_sdist] 48 | runs-on: ubuntu-latest 49 | environment: pypi 50 | permissions: 51 | id-token: write 52 | if: github.event_name == 'release' && github.event.action == 'published' 53 | steps: 54 | - uses: actions/download-artifact@v4 55 | with: 56 | pattern: dist-* 57 | merge-multiple: true 58 | path: dist 59 | 60 | - uses: pypa/gh-action-pypi-publish@release/v1 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | build 3 | minecraft_python.egg-info 4 | *.pyc 5 | *.pyd 6 | *.dat 7 | *.bat 8 | !start server.bat 9 | *.log 10 | *.html 11 | *.prof 12 | *.c 13 | *.h 14 | .DS_Store 15 | *.so 16 | *.mclevel 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2023 pythonengineer 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include pyproject.toml 3 | include setup.py 4 | include Makefile 5 | include requirements.txt 6 | include screenshot.png 7 | include mc/resources/icon/minecraft.png 8 | graft mc/resources/icon 9 | include LICENSE 10 | include README.md 11 | 12 | recursive-include mc *.pyx *.pxd *.ogg *.dll 13 | recursive-exclude mc/resources/texture * 14 | recursive-exclude * *.pyc 15 | recursive-exclude * *.pyd 16 | recursive-exclude * *.gif 17 | recursive-exclude * *.html 18 | recursive-exclude * *.c 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build dist redist install install-from-source clean uninstall 2 | 3 | build: 4 | CYTHONIZE=1 ./setup.py build 5 | 6 | dist: 7 | CYTHONIZE=1 ./setup.py sdist bdist_wheel 8 | 9 | redist: clean dist 10 | 11 | install: 12 | CYTHONIZE=1 pip install . 13 | 14 | install-from-source: dist 15 | pip install dist/minecraft-python-0.31.20100131.tar.gz 16 | 17 | clean: 18 | $(RM) -r build dist src/*.egg-info 19 | find . -name __pycache__ -exec rm -r {} + 20 | 21 | uninstall: 22 | pip uninstall minecraft-python 23 | -------------------------------------------------------------------------------- /map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/map.png -------------------------------------------------------------------------------- /mc/JavaUtils.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | cpdef unsigned long long getMillis() 6 | cdef double signum(double val) 7 | cdef unsigned int floatToRawIntBits(float x) 8 | 9 | cdef class Random: 10 | 11 | cdef: 12 | long long __seed 13 | double __nextNextGaussian 14 | bint __haveNextNextGaussian 15 | 16 | cdef int _next(self, int bits) 17 | cpdef int nextInt(self, int limit=?) 18 | cpdef float nextFloat(self) 19 | cdef double nextDouble(self) 20 | cpdef double nextGaussian(self) 21 | 22 | cpdef double random() 23 | 24 | cdef class Bits: 25 | 26 | cdef long makeLong(self, unsigned char b7, unsigned char b6, unsigned char b5, 27 | unsigned char b4, unsigned char b3, unsigned char b2, 28 | unsigned char b1, unsigned char b0) 29 | cdef int makeInt(self, unsigned char b3, unsigned char b2, 30 | unsigned char b1, unsigned char b0) 31 | cdef short makeShort(self, unsigned char b1, unsigned char b0) 32 | 33 | cpdef enum ByteOrder: 34 | BIG_ENDIAN = 0 35 | LITTLE_ENDIAN = 1 36 | 37 | cdef class Buffer(Bits): 38 | 39 | cdef: 40 | int _position 41 | int _limit 42 | int _capacity 43 | bint _order 44 | 45 | cpdef long getLong(self) 46 | cpdef int getInt(self) 47 | cpdef short getShort(self) 48 | cpdef double getDouble(self) 49 | cpdef float getFloat(self) 50 | 51 | cpdef order(self, bint order) 52 | cpdef flip(self) 53 | cpdef limit(self, int limit) 54 | cpdef position(self, int position=?) 55 | cpdef remaining(self) 56 | 57 | cpdef clear(self) 58 | cpdef capacity(self) 59 | cpdef compact(self) 60 | 61 | cdef int __nextIndex(self, int nb=?) 62 | cdef int nextGetIndex(self, int nb=?) 63 | cdef int nextPutIndex(self, int nb=?) 64 | 65 | cdef int checkIndex(self, int i) 66 | cdef bint checkBounds(self, int off, int length, int size) 67 | 68 | @cython.final 69 | cdef class ByteBuffer(Buffer): 70 | cdef: 71 | unsigned char[:] __array 72 | object __dataPtr 73 | 74 | cpdef inline put(self, unsigned char value) 75 | cpdef inline unsigned char get(self) 76 | cpdef inline unsigned char getAt(self, int idx) 77 | cdef inline __getDataPtr(self) 78 | 79 | @cython.final 80 | cdef class IntBuffer(Buffer): 81 | cdef: 82 | int[:] __array 83 | object __dataPtr 84 | 85 | cpdef inline put(self, int value) 86 | cdef putInts(self, int[:] src, int offset, int length) 87 | cpdef inline int get(self) 88 | cpdef inline int getAt(self, int idx) 89 | cdef inline __getDataPtr(self) 90 | 91 | @cython.final 92 | cdef class FloatBuffer(Buffer): 93 | cdef: 94 | float[:] __array 95 | object __dataPtr 96 | 97 | cpdef inline put(self, float value) 98 | cdef putFloats(self, float* src, int offset, int length) 99 | cpdef inline float get(self) 100 | cpdef inline float getAt(self, int idx) 101 | cdef getFloats(self, float*, int size) 102 | cdef inline __getDataPtr(self) 103 | -------------------------------------------------------------------------------- /mc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/__init__.py -------------------------------------------------------------------------------- /mc/lib/soft_oal_32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/lib/soft_oal_32.dll -------------------------------------------------------------------------------- /mc/lib/soft_oal_64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/lib/soft_oal_64.dll -------------------------------------------------------------------------------- /mc/net/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/ChatLine.py: -------------------------------------------------------------------------------- 1 | class ChatLine: 2 | 3 | def __init__(self): 4 | self.updateCounter = 0 5 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/KeyBinding.py: -------------------------------------------------------------------------------- 1 | class KeyBinding: 2 | 3 | def __init__(self, keyDescription, keyCode): 4 | self.keyDescription = keyDescription 5 | self.keyCode = keyCode 6 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/OpenGlCapsChecker.py: -------------------------------------------------------------------------------- 1 | class OpenGlCapsChecker: 2 | cap = False 3 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/PlayerLoader.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.player.EntityPlayerSP import EntityPlayerSP 2 | from mc.net.minecraft.game.level.LevelLoader import LevelLoader 3 | 4 | class PlayerLoader(LevelLoader): 5 | 6 | def __init__(self, minecraft, loadingScreen): 7 | super().__init__(loadingScreen) 8 | self.__minecraft = minecraft 9 | 10 | def _loadEntity(self, world, entityId): 11 | if entityId == 'LocalPlayer': 12 | return EntityPlayerSP(self.__minecraft, world) 13 | else: 14 | super()._loadEntity(world, entityId) 15 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/RenderHelper.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.physics.Vec3D import Vec3D 2 | from mc.JavaUtils import BufferUtils 3 | from pyglet import gl 4 | 5 | class RenderHelper: 6 | __colorBuffer = BufferUtils.createFloatBuffer(16) 7 | 8 | @staticmethod 9 | def disableStandardItemLighting(): 10 | gl.glDisable(gl.GL_LIGHTING) 11 | gl.glDisable(gl.GL_LIGHT0) 12 | gl.glDisable(gl.GL_LIGHT1) 13 | gl.glDisable(gl.GL_COLOR_MATERIAL) 14 | 15 | @staticmethod 16 | def enableStandardItemLighting(): 17 | gl.glEnable(gl.GL_LIGHTING) 18 | gl.glEnable(gl.GL_LIGHT0) 19 | gl.glEnable(gl.GL_LIGHT1) 20 | gl.glEnable(gl.GL_COLOR_MATERIAL) 21 | gl.glColorMaterial(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT_AND_DIFFUSE) 22 | x = 0.4 23 | y = 0.6 24 | z = 0.8 25 | gl.glLightModelf(gl.GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0) 26 | vec = Vec3D(0.4, 1.0, -0.2) 27 | RenderHelper.__setColorBuffer(vec.xCoord, vec.yCoord, vec.zCoord, 28 | 0.0).glLightfv(gl.GL_LIGHT0, gl.GL_POSITION) 29 | RenderHelper.__setColorBuffer(y, y, y, 1.0).glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE) 30 | RenderHelper.__setColorBuffer(0.0, 0.0, 0.0, 1.0).glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT) 31 | RenderHelper.__setColorBuffer(z, z, z, 1.0).glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR) 32 | vec = Vec3D(-0.4, 1.0, 0.2) 33 | RenderHelper.__setColorBuffer(vec.xCoord, vec.yCoord, vec.zCoord, 34 | 0.0).glLightfv(gl.GL_LIGHT1, gl.GL_POSITION) 35 | RenderHelper.__setColorBuffer(0.6, 0.6, 0.6, 1.0).glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE) 36 | RenderHelper.__setColorBuffer(0.0, 0.0, 0.0, 1.0).glLightfv(gl.GL_LIGHT1, gl.GL_AMBIENT) 37 | RenderHelper.__setColorBuffer(0.8, 0.8, 0.8, 1.0).glLightfv(gl.GL_LIGHT1, gl.GL_SPECULAR) 38 | gl.glShadeModel(gl.GL_SMOOTH) 39 | RenderHelper.__setColorBuffer(x, x, x, 1.0).glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT) 40 | 41 | @staticmethod 42 | def __setColorBuffer(a, b, c, d): 43 | RenderHelper.__colorBuffer.clear() 44 | RenderHelper.__colorBuffer.put(a).put(b).put(c).put(d) 45 | RenderHelper.__colorBuffer.flip() 46 | return RenderHelper.__colorBuffer 47 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/Session.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Blocks import blocks 2 | 3 | class Session: 4 | registeredBlocksList = (blocks.stone, blocks.cobblestone, blocks.brick, blocks.dirt, 5 | blocks.planks, blocks.wood, blocks.leaves, blocks.torch, 6 | blocks.stairSingle, blocks.glass, blocks.cobblestoneMossy, 7 | blocks.sapling, blocks.plantYellow, blocks.plantRed, 8 | blocks.mushroomBrown, blocks.mushroomRed, blocks.sand, 9 | blocks.gravel, blocks.sponge, blocks.clothRed, 10 | blocks.clothOrange, blocks.clothYellow, blocks.clothChartreuse, 11 | blocks.clothGreen, blocks.clothSpringGreen, blocks.clothCyan, 12 | blocks.clothCapri, blocks.clothUltramarine, blocks.clothViolet, 13 | blocks.clothPurple, blocks.clothMagenta, blocks.clothRose, 14 | blocks.clothDarkGray, blocks.clothGray, blocks.clothWhite, 15 | blocks.oreCoal, blocks.oreIron, blocks.oreGold, blocks.blockSteel, 16 | blocks.blockGold, blocks.bookShelf, blocks.tnt, blocks.obsidian) 17 | print(len(registeredBlocksList)) 18 | 19 | def __init__(self, username, sessionId): 20 | self.username = username 21 | self.sessionId = sessionId 22 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/ThreadDownloadSkin.py: -------------------------------------------------------------------------------- 1 | from threading import Thread 2 | from base64 import b64decode 3 | from io import BytesIO 4 | from PIL import Image 5 | 6 | import urllib.request 7 | import json 8 | 9 | def getTextureInfo(properties): 10 | for prop in properties: 11 | if prop['name'] == 'textures': 12 | return json.loads(b64decode(prop['value'], validate=True).decode('utf-8')) 13 | 14 | class ThreadDownloadSkin(Thread): 15 | 16 | def __init__(self, mc): 17 | super().__init__() 18 | self.__mc = mc 19 | 20 | def run(self): 21 | if not self.__mc.session: 22 | return 23 | 24 | username = self.__mc.session.username 25 | if not username: 26 | return 27 | 28 | try: 29 | with urllib.request.urlopen(f'https://api.mojang.com/users/profiles/minecraft/{username}') as r: 30 | if r.code != 200: 31 | return 32 | 33 | userId = json.loads(r.read().decode(r.info().get_param('charset') or 'utf-8'))['id'] 34 | 35 | with urllib.request.urlopen(f'https://sessionserver.mojang.com/session/minecraft/profile/{userId}') as r: 36 | if r.code != 200: 37 | return 38 | 39 | userInfo = json.loads(r.read().decode(r.info().get_param('charset') or 'utf-8')) 40 | 41 | textureInfo = getTextureInfo(userInfo['properties']) 42 | if not textureInfo: 43 | return 44 | 45 | try: 46 | skinUrl = textureInfo['textures']['SKIN']['url'] 47 | except: 48 | return 49 | 50 | with urllib.request.urlopen(skinUrl) as r: 51 | if r.code != 200: 52 | return 53 | except: 54 | pass 55 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/Timer.py: -------------------------------------------------------------------------------- 1 | from mc.JavaUtils import getMillis 2 | 3 | import time 4 | 5 | class Timer: 6 | NS_PER_SECOND = 1000000 7 | MAX_TICKS_PER_UPDATE = 10 8 | __lastHRTime = 0.0 9 | elapsedTicks = 0 10 | renderPartialTicks = 0.0 11 | __timerSpeed = 1.0 12 | __elapsedPartialTicks = 0.0 13 | __timeSyncAdjustment = 1.0 14 | 15 | def __init__(self, ticksPerSecond): 16 | self.ticksPerSecond = 20.0 17 | self.__lastSyncSysClock = getMillis() 18 | self.__lastSyncHRClock = time.time_ns() // Timer.NS_PER_SECOND 19 | 20 | def updateTimer(self): 21 | now = getMillis() 22 | passedMs = now - self.__lastSyncSysClock 23 | timeRate = time.time_ns() // Timer.NS_PER_SECOND 24 | if passedMs > 1000: 25 | syncDelta = timeRate - self.__lastSyncHRClock 26 | adjust = passedMs / syncDelta 27 | self.__timeSyncAdjustment += (adjust - self.__timeSyncAdjustment) * 0.2 28 | self.__lastSyncSysClock = now 29 | self.__lastSyncHRClock = timeRate 30 | elif passedMs < 0: 31 | self.__lastSyncSysClock = now 32 | self.__lastSyncHRClock = timeRate 33 | 34 | hrTime = timeRate / 1000.0 35 | adjust = (hrTime - self.__lastHRTime) * self.__timeSyncAdjustment 36 | self.__lastHRTime = hrTime 37 | if adjust < 0.0: 38 | adjust = 0.0 39 | elif adjust > 1.0: 40 | adjust = 1.0 41 | 42 | self.__elapsedPartialTicks += adjust * self.__timerSpeed * self.ticksPerSecond 43 | self.elapsedTicks = int(self.__elapsedPartialTicks) 44 | if self.elapsedTicks > Timer.MAX_TICKS_PER_UPDATE: 45 | self.elapsedTicks = Timer.MAX_TICKS_PER_UPDATE 46 | 47 | self.__elapsedPartialTicks -= self.elapsedTicks 48 | self.renderPartialTicks = self.__elapsedPartialTicks 49 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/__init__.py: -------------------------------------------------------------------------------- 1 | class MinecraftError(Exception): 2 | pass 3 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/controller/PlayerController.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityDiggingFX import EntityDiggingFX 2 | from mc.net.minecraft.game.level.block.Blocks import blocks 3 | 4 | class PlayerController: 5 | 6 | def __init__(self, mc): 7 | self._mc = mc 8 | self.isInTestMode = False 9 | 10 | def onWorldChange(self, world): 11 | pass 12 | 13 | def clickBlock(self, x, y, z): 14 | self.sendBlockRemoved(x, y, z) 15 | 16 | def sendBlockRemoved(self, x, y, z): 17 | self._mc.effectRenderer.addBlockDestroyEffects(x, y, z) 18 | block = blocks.blocksList[self._mc.theWorld.getBlockId(x, y, z)] 19 | change = self._mc.theWorld.setBlockWithNotify(x, y, z, 0) 20 | if block and change: 21 | speed = (block.stepSound.soundVolume + 1.0) / 2.0 22 | self._mc.sndManager.playSound( 23 | f'step.{block.stepSound.soundDir}', x + 0.5, y + 0.5, z + 0.5, 24 | speed, block.stepSound.soundPitch * 0.8 25 | ) 26 | block.onBlockDestroyedByPlayer(self._mc.theWorld, x, y, z) 27 | 28 | return change 29 | 30 | def sendBlockRemoving(self, x, y, z, sideHit): 31 | pass 32 | 33 | def resetBlockRemoving(self): 34 | pass 35 | 36 | def setPartialTime(self, damageTime): 37 | pass 38 | 39 | def getBlockReachDistance(self): 40 | return 5.0 41 | 42 | def flipPlayer(self, player): 43 | pass 44 | 45 | def onUpdate(self): 46 | pass 47 | 48 | def shouldDrawHUD(self): 49 | return True 50 | 51 | def onRespawn(self, player): 52 | pass 53 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/controller/PlayerControllerCreative.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.Session import Session 2 | from mc.net.minecraft.client.controller.PlayerController import PlayerController 3 | from mc.net.minecraft.game.level.MobSpawner import MobSpawner 4 | from mc.net.minecraft.game.level.block.Blocks import blocks 5 | from mc.net.minecraft.game.item.ItemStack import ItemStack 6 | 7 | class PlayerControllerCreative(PlayerController): 8 | 9 | def onRespawn(self, player): 10 | for i in range(9): 11 | if player.inventory.mainInventory[i] is None: 12 | player.inventory.mainInventory[i] = ItemStack(blocks.blocksList[Session.registeredBlocksList[i].blockID]) 13 | else: 14 | player.inventory.mainInventory[i].stackSize = 1 15 | 16 | def shouldDrawHUD(self): 17 | return False 18 | 19 | def onWorldChange(self, world): 20 | super().onWorldChange(world) 21 | world.survivalWorld = False 22 | 23 | self.__mobSpawner = MobSpawner(world) 24 | size = world.width * world.length * world.height // 64 // 64 // 64 25 | for i in range(size): 26 | self.__mobSpawner.spawnMob(size, world.playerEntity, None) 27 | 28 | def onUpdate(self): 29 | self.__mobSpawner.spawnMobs() 30 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/controller/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/controller/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntityBubbleFX.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityFX import EntityFX 2 | from mc.net.minecraft.game.level.material.Material import Material 3 | from mc.JavaUtils import random 4 | 5 | class EntityBubbleFX(EntityFX): 6 | 7 | def __init__(self, world, x, y, z, xr, yr, zr): 8 | super().__init__(world, x, y, z, xr, yr, zr) 9 | self._particleRed = 1.0 10 | self._particleGreen = 1.0 11 | self._particleBlue = 1.0 12 | self._particleTextureIndex = 32 13 | self.setSize(0.02, 0.02) 14 | self._particleScale *= self._rand.nextFloat() * 0.6 + 0.2 15 | self._motionX1 = xr * 0.2 + (random() * 2.0 - 1.0) * 0.02 16 | self._motionY1 = yr * 0.2 + (random() * 2.0 - 1.0) * 0.02 17 | self._motionZ1 = zr * 0.2 + (random() * 2.0 - 1.0) * 0.02 18 | self._particleMaxAge = int(8.0 / (random() * 0.8 + 0.2)) 19 | 20 | def onEntityUpdate(self): 21 | self.prevPosX = self.posX 22 | self.prevPosY = self.posY 23 | self.prevPosZ = self.posZ 24 | self._motionY1 += 0.002 25 | self.moveEntity(self._motionX1, self._motionY1, self._motionZ1) 26 | self._motionX1 *= 0.85 27 | self._motionY1 *= 0.85 28 | self._motionZ1 *= 0.85 29 | if self._worldObj.getBlockMaterial(int(self.posX), int(self.posY), 30 | int(self.posZ)) != Material.water: 31 | self.setEntityDead() 32 | 33 | self._particleMaxAge -= 1 34 | if self._particleMaxAge + 1 <= 0: 35 | self.setEntityDead() 36 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntityDiggingFX.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityFX import EntityFX 2 | 3 | class EntityDiggingFX(EntityFX): 4 | 5 | def __init__(self, world, x, y, z, xr, yr, zr, block): 6 | super().__init__(world, x, y, z, xr, yr, zr) 7 | self._particleTextureIndex = block.blockIndexInTexture 8 | self._particleGravity = block.blockParticleGravity 9 | self._particleRed = self._particleGreen = self._particleBlue = 0.6 10 | self._particleScale /= 2.0 11 | 12 | def getFXLayer(self): 13 | return 1 14 | 15 | def renderParticle(self, t, a, xa, ya, za, xa2, ya2): 16 | u0 = ((self._particleTextureIndex % 16) + self._particleTextureJitterX / 4.0) / 16.0 17 | u1 = u0 + 0.999 / 64.0 18 | v0 = ((self._particleTextureIndex // 16) + self._particleTextureJitterY / 4.0) / 16.0 19 | v1 = v0 + 0.999 / 64.0 20 | r = 0.1 * self._particleScale 21 | x = self.prevPosX + (self.posX - self.prevPosX) * a 22 | y = self.prevPosY + (self.posY - self.prevPosY) * a 23 | z = self.prevPosZ + (self.posZ - self.prevPosZ) * a 24 | br = self.getBrightness(a) 25 | t.setColorOpaque_F(br * self._particleRed, br * self._particleGreen, br * self._particleBlue) 26 | t.addVertexWithUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - ya2 * r, u0, v1) 27 | t.addVertexWithUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + ya2 * r, u0, v0) 28 | t.addVertexWithUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + ya2 * r, u1, v0) 29 | t.addVertexWithUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - ya2 * r, u1, v1) 30 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntityExplodeFX.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityFX import EntityFX 2 | from mc.JavaUtils import random 3 | 4 | class EntityExplodeFX(EntityFX): 5 | 6 | def __init__(self, world, x, y, z, xr, yr, zr): 7 | super().__init__(world, x, y, z, xr, yr, zr) 8 | self._motionX1 = xr + (random() * 2.0 - 1.0) * 0.05 9 | self._motionY1 = yr + (random() * 2.0 - 1.0) * 0.05 10 | self._motionZ1 = zr + (random() * 2.0 - 1.0) * 0.05 11 | self._particleRed = self._rand.nextFloat() * 0.3 + 0.7 12 | self._particleGreen = self._particleRed 13 | self._particleBlue = self._particleRed 14 | self._particleScale = self._rand.nextFloat() * self._rand.nextFloat() * 6.0 + 1.0 15 | self._particleMaxAge = int(16.0 / (self._rand.nextFloat() * 0.8 + 0.2)) 16 | 17 | def renderParticle(self, t, a, xa, ya, za, xa2, ya2): 18 | super().renderParticle(t, a, xa, ya, za, xa2, ya2) 19 | 20 | def onEntityUpdate(self): 21 | self.prevPosX = self.posX 22 | self.prevPosY = self.posY 23 | self.prevPosZ = self.posZ 24 | self._particleAge += 1 25 | if self._particleAge - 1 >= self._particleMaxAge: 26 | self.setEntityDead() 27 | 28 | self._particleTextureIndex = 7 - (self._particleAge << 3) // self._particleMaxAge 29 | self._motionY1 += 0.004 30 | self.moveEntity(self._motionX1, self._motionY1, self._motionZ1) 31 | self._motionX1 *= 0.9 32 | self._motionY1 *= 0.9 33 | self._motionZ1 *= 0.9 34 | if self.onGround: 35 | self._motionX1 *= 0.7 36 | self._motionZ1 *= 0.7 37 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntityFX.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.client.render.Tessellator cimport Tessellator 4 | from mc.net.minecraft.game.entity.Entity cimport Entity 5 | 6 | cdef class EntityFX(Entity): 7 | 8 | cdef: 9 | public int _particleTextureIndex 10 | public float _particleGravity 11 | public float _particleRed 12 | public float _particleGreen 13 | public float _particleBlue 14 | public float _motionX1 15 | public float _motionY1 16 | public float _motionZ1 17 | public float _particleTextureJitterX 18 | public float _particleTextureJitterY 19 | public float _particleScale 20 | public int _particleMaxAge 21 | public int _particleAge 22 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntityFlameFX.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityFX import EntityFX 2 | from mc.JavaUtils import random 3 | 4 | class EntityFlameFX(EntityFX): 5 | 6 | def __init__(self, world, x, y, z): 7 | super().__init__(world, x, y, z, 0.0, 0.0, 0.0) 8 | self._motionX1 *= 0.01 9 | self._motionY1 *= 0.01 10 | self._motionZ1 *= 0.01 11 | self._rand.nextFloat() 12 | self._rand.nextFloat() 13 | self._rand.nextFloat() 14 | self._rand.nextFloat() 15 | self._rand.nextFloat() 16 | self._rand.nextFloat() 17 | self.__flameScale = self._particleScale 18 | self._particleRed = self._particleGreen = self._particleBlue = 1.0 19 | self._particleMaxAge = int(8.0 / (random() * 0.8 + 0.2)) + 4 20 | self.noClip = True 21 | self._particleTextureIndex = 48 22 | 23 | def renderParticle(self, t, a, xa, ya, za, xa2, ya2): 24 | age = (self._particleAge + a) / self._particleMaxAge 25 | self._particleScale = self.__flameScale * (1.0 - age * age * 0.5) 26 | super().renderParticle(t, a, xa, ya, za, xa2, ya2) 27 | 28 | def getBrightness(self, a): 29 | age = min(max((self._particleAge + a) / self._particleMaxAge, 0.0), 1.0) 30 | return super().getBrightness(a) * age + (1.0 - age) 31 | 32 | def onEntityUpdate(self): 33 | self.prevPosX = self.posX 34 | self.prevPosY = self.posY 35 | self.prevPosZ = self.posZ 36 | self._particleAge += 1 37 | if self._particleAge - 1 >= self._particleMaxAge: 38 | self.setEntityDead() 39 | 40 | self.moveEntity(self._motionX1, self._motionY1, self._motionZ1) 41 | self._motionX1 *= 0.96 42 | self._motionY1 *= 0.96 43 | self._motionZ1 *= 0.96 44 | if self.onGround: 45 | self._motionX1 *= 0.7 46 | self._motionZ1 *= 0.7 47 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntityLavaFX.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityFX import EntityFX 2 | from mc.JavaUtils import random 3 | 4 | class EntityLavaFX(EntityFX): 5 | 6 | def __init__(self, world, x, y, z): 7 | super().__init__(world, x, y, z, 0.0, 0.0, 0.0) 8 | self._motionX1 *= 0.8 9 | self._motionY1 *= 0.8 10 | self._motionZ1 *= 0.8 11 | self._motionY1 = self._rand.nextFloat() * 0.4 + 0.05 12 | self._particleRed = self._particleGreen = self._particleBlue = 1.0 13 | self._particleScale *= self._rand.nextFloat() * 2.0 + 0.2 14 | self.__lavaScale = self._particleScale 15 | self._particleMaxAge = int(16.0 / (random() * 0.8 + 0.2)) 16 | self.noClip = False 17 | self._particleTextureIndex = 49 18 | 19 | def getBrightness(self, a): 20 | return 1.0 21 | 22 | def renderParticle(self, t, a, xa, ya, za, xa2, ya2): 23 | age = (self._particleAge + a) / self._particleMaxAge 24 | self._particleScale = self.__lavaScale * (1.0 - age * age) 25 | super().renderParticle(t, a, xa, ya, za, xa2, ya2) 26 | 27 | def onEntityUpdate(self): 28 | self.prevPosX = self.posX 29 | self.prevPosY = self.posY 30 | self.prevPosZ = self.posZ 31 | self._particleAge += 1 32 | if self._particleAge - 1 >= self._particleMaxAge: 33 | self.setEntityDead() 34 | 35 | age = self._particleAge / self._particleMaxAge 36 | if self._rand.nextFloat() > age: 37 | self._worldObj.spawnParticle( 38 | 'smoke', self.posX, self.posY, self.posZ, 39 | self._motionX1, self._motionY1, self._motionZ1 40 | ) 41 | 42 | self._motionY1 -= 0.03 43 | self.moveEntity(self._motionX1, self._motionY1, self._motionZ1) 44 | self._motionX1 *= 0.999 45 | self._motionY1 *= 0.999 46 | self._motionZ1 *= 0.999 47 | if self.onGround: 48 | self._motionX1 *= 0.7 49 | self._motionZ1 *= 0.7 50 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntityRainFX.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityFX import EntityFX 2 | from mc.JavaUtils import random 3 | 4 | class EntityRainFX(EntityFX): 5 | 6 | def __init__(self, world, x, y, z): 7 | super().__init__(world, x, y, z, 0.0, 0.0, 0.0) 8 | self._motionX1 *= 0.3 9 | self._motionY1 = random() * 0.2 + 0.1 10 | self._motionZ1 *= 0.3 11 | self._particleRed = 1.0 12 | self._particleGreen = 1.0 13 | self._particleBlue = 1.0 14 | self._particleTextureIndex = 16 15 | self.setSize(0.01, 0.01) 16 | self._particleMaxAge = int(8.0 / (random() * 0.8 + 0.2)) 17 | 18 | def renderParticle(self, t, a, xa, ya, za, xa2, ya2): 19 | super().renderParticle(t, a, xa, ya, za, xa2, ya2) 20 | 21 | def onEntityUpdate(self): 22 | self.prevPosX = self.posX 23 | self.prevPosY = self.posY 24 | self.prevPosZ = self.posZ 25 | self._motionY1 = self._motionY1 - 0.06 26 | self.moveEntity(self._motionX1, self._motionY1, self._motionZ1) 27 | self._motionX1 *= 0.98 28 | self._motionY1 *= 0.98 29 | self._motionZ1 *= 0.98 30 | self._particleMaxAge -= 1 31 | if self._particleMaxAge + 1 <= 0: 32 | self.setEntityDead() 33 | 34 | if self.onGround: 35 | if random() < 0.5: 36 | self.setEntityDead() 37 | 38 | self._motionX1 *= 0.7 39 | self._motionZ1 *= 0.7 40 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/EntitySmokeFX.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.effect.EntityFX import EntityFX 2 | from mc.JavaUtils import random 3 | 4 | class EntitySmokeFX(EntityFX): 5 | 6 | def __init__(self, world, x, y, z): 7 | super().__init__(world, x, y, z, 0.0, 0.0, 0.0) 8 | self._motionX1 *= 0.1 9 | self._motionY1 *= 0.1 10 | self._motionZ1 *= 0.1 11 | self._particleRed = random() * 0.3 12 | self._particleGreen = self._particleRed 13 | self._particleBlue = self._particleRed 14 | self._particleScale *= 12.0 / 16.0 15 | self._particleMaxAge = int(8.0 / (random() * 0.8 + 0.2)) 16 | self.noClip = True 17 | 18 | def renderParticle(self, t, a, xa, ya, za, xa2, ya2): 19 | super().renderParticle(t, a, xa, ya, za, xa2, ya2) 20 | 21 | def onEntityUpdate(self): 22 | self.prevPosX = self.posX 23 | self.prevPosY = self.posY 24 | self.prevPosZ = self.posZ 25 | self._particleAge += 1 26 | if self._particleAge - 1 >= self._particleMaxAge: 27 | self.setEntityDead() 28 | 29 | self._particleTextureIndex = 7 - (self._particleAge << 3) // self._particleMaxAge 30 | self._motionY1 = float(self._motionY1 + 0.004) 31 | self.moveEntity(self._motionX1, self._motionY1, self._motionZ1) 32 | self._motionX1 *= 0.96 33 | self._motionY1 *= 0.96 34 | self._motionZ1 *= 0.96 35 | if self.onGround: 36 | self._motionX1 *= 0.7 37 | self._motionZ1 *= 0.7 38 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/effect/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/effect/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/FontRenderer.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | @cython.final 6 | cdef class FontRenderer: 7 | 8 | cdef: 9 | object __options 10 | int[256] __charWidth 11 | int __fontTextureName 12 | 13 | cdef __renderString(self, str string, int x, int y, int color, bint darken=?) 14 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/Gui.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.render.Tessellator import tessellator 2 | from pyglet import gl 3 | 4 | class Gui: 5 | _zLevel = 0.0 6 | 7 | @staticmethod 8 | def _drawRect(x0, y0, x1, y1, col): 9 | a = ((col % 0x100000000) >> 24) / 255.0 10 | r = (col >> 16 & 255) / 255.0 11 | g = (col >> 8 & 255) / 255.0 12 | b = (col & 255) / 255.0 13 | t = tessellator 14 | gl.glEnable(gl.GL_BLEND) 15 | gl.glDisable(gl.GL_TEXTURE_2D) 16 | gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) 17 | gl.glColor4f(r, g, b, a) 18 | t.startDrawingQuads() 19 | t.addVertex(x0, y1, 0.0) 20 | t.addVertex(x1, y1, 0.0) 21 | t.addVertex(x1, y0, 0.0) 22 | t.addVertex(x0, y0, 0.0) 23 | t.draw() 24 | gl.glEnable(gl.GL_TEXTURE_2D) 25 | gl.glDisable(gl.GL_BLEND) 26 | 27 | @staticmethod 28 | def _drawGradientRect(x0, y0, x1, y1, col1, col2): 29 | f10 = ((col1 % 0x100000000) >> 24) / 255.0 30 | f11 = (col1 >> 16 & 255) / 255.0 31 | f6 = (col1 >> 8 & 255) / 255.0 32 | f12 = (col1 & 255) / 255.0 33 | f7 = ((col2 % 0x100000000) >> 24) / 255.0 34 | f8 = (col2 >> 16 & 255) / 255.0 35 | f9 = (col2 >> 8 & 255) / 255.0 36 | f13 = (col2 & 255) / 255.0 37 | gl.glDisable(gl.GL_TEXTURE_2D) 38 | gl.glEnable(gl.GL_BLEND) 39 | gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) 40 | gl.glBegin(gl.GL_QUADS) 41 | gl.glColor4f(f11, f6, f12, f10) 42 | gl.glVertex2f(x1, y0) 43 | gl.glVertex2f(x0, y0) 44 | gl.glColor4f(f8, f9, f13, f7) 45 | gl.glVertex2f(x0, y1) 46 | gl.glVertex2f(x1, y1) 47 | gl.glEnd() 48 | gl.glDisable(gl.GL_BLEND) 49 | gl.glEnable(gl.GL_TEXTURE_2D) 50 | 51 | @staticmethod 52 | def drawCenteredString(font, string, x, y, color): 53 | font.drawStringWithShadow(string, x - font.getStringWidth(string) // 2, y, color) 54 | 55 | @staticmethod 56 | def drawString(font, string, x, y, color): 57 | font.drawStringWithShadow(string, x, y, color) 58 | 59 | def drawTexturedModalRect(self, x, y, xOffset, yOffset, w, h): 60 | f = 0.00390625 61 | t = tessellator 62 | t.startDrawingQuads() 63 | t.addVertexWithUV(x, y + h, self._zLevel, xOffset * f, (yOffset + h) * f) 64 | t.addVertexWithUV(x + w, y + h, self._zLevel, (xOffset + w) * f, (yOffset + h) * f) 65 | t.addVertexWithUV(x + w, y, self._zLevel, (xOffset + w) * f, yOffset * f) 66 | t.addVertexWithUV(x, y, self._zLevel, xOffset * f, yOffset * f) 67 | t.draw() 68 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiButton.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.Gui import Gui 2 | from pyglet import gl 3 | 4 | class GuiButton(Gui): 5 | 6 | def __init__(self, id_, x, y, width, height=None, string=None): 7 | if height is None: 8 | string = width 9 | width = 200 10 | height = 20 11 | 12 | self.id = id_ 13 | self.__width = width 14 | self.__height = 20 15 | self.__x = x 16 | self.__y = y 17 | self.displayString = string 18 | self.enabled = True 19 | self.visible = True 20 | 21 | def drawButton(self, mc, xMouse, yMouse): 22 | if not self.visible: 23 | return 24 | 25 | gl.glBindTexture(gl.GL_TEXTURE_2D, mc.renderEngine.getTexture('gui/gui.png')) 26 | gl.glColor4f(1.0, 1.0, 1.0, 1.0) 27 | onButton = True if xMouse >= self.__x and yMouse >= self.__y and \ 28 | xMouse < self.__x + self.__width and \ 29 | yMouse < self.__y + self.__height else False 30 | adjust = 1 31 | if not self.enabled: 32 | adjust = 0 33 | elif onButton: 34 | adjust = 2 35 | 36 | self.drawTexturedModalRect(self.__x, self.__y, 0, 46 + adjust * 20, 37 | self.__width / 2, self.__height) 38 | self.drawTexturedModalRect(self.__x + self.__width / 2, self.__y, 39 | 200 - self.__width / 2, 46 + adjust * 20, 40 | self.__width / 2, self.__height) 41 | if not self.enabled: 42 | self.drawCenteredString(mc.fontRenderer, self.displayString, 43 | self.__x + self.__width // 2, 44 | self.__y + (self.__height - 8) // 2, -6250336) 45 | elif onButton: 46 | self.drawCenteredString(mc.fontRenderer, self.displayString, 47 | self.__x + self.__width // 2, 48 | self.__y + (self.__height - 8) // 2, 0xFFFFA0) 49 | else: 50 | self.drawCenteredString(mc.fontRenderer, self.displayString, 51 | self.__x + self.__width // 2, 52 | self.__y + (self.__height - 8) // 2, 0xE0E0E0) 53 | 54 | def mousePressed(self, xm, ym): 55 | return self.enabled and xm >= self.__x and ym >= self.__y and \ 56 | xm < self.__x + self.__width and ym < self.__y + self.__height 57 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiControls.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiSmallButton import GuiSmallButton 2 | from mc.net.minecraft.client.gui.GuiScreen import GuiScreen 3 | from mc.net.minecraft.client.gui.GuiButton import GuiButton 4 | 5 | class GuiControls(GuiScreen): 6 | __screenTitle = 'Controls' 7 | __buttonId = -1 8 | 9 | def __init__(self, screen, options): 10 | self.__parentScreen = screen 11 | self.__options = options 12 | 13 | def initGui(self): 14 | for i, binding in enumerate(self.__options.keyBindings): 15 | self._controlList.append(GuiSmallButton(i, self.width // 2 - 155 + i % 2 * 160, 16 | self.height // 6 + 24 * (i >> 1), 17 | self.__options.setKeyBindingString(i))) 18 | 19 | self._controlList.append(GuiButton(200, self.width // 2 - 100, 20 | self.height // 6 + 168, 'Done')) 21 | 22 | def _actionPerformed(self, button): 23 | for i, binding in enumerate(self.__options.keyBindings): 24 | self._controlList[i].displayString = self.__options.setKeyBindingString(i) 25 | 26 | if button.id == 200: 27 | self.mc.displayGuiScreen(self.__parentScreen) 28 | else: 29 | self.__buttonId = button.id 30 | button.displayString = '> ' + self.__options.setKeyBindingString(button.id) + ' <' 31 | 32 | def _keyTyped(self, key, char, motion): 33 | if self.__buttonId >= 0 and key: 34 | self.__options.setKeyBinding(self.__buttonId, key) 35 | self._controlList[self.__buttonId].displayString = self.__options.setKeyBindingString(self.__buttonId) 36 | self.__buttonId = -1 37 | else: 38 | super()._keyTyped(key, char, motion) 39 | 40 | def drawScreen(self, xm, ym): 41 | self._drawGradientRect(0, 0, self.width, self.height, 1610941696, -1607454624) 42 | self.drawCenteredString(self._fontRenderer, self.__screenTitle, self.width // 2, 20, 16777215) 43 | super().drawScreen(xm, ym) 44 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiErrorScreen.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiScreen import GuiScreen 2 | 3 | class GuiErrorScreen(GuiScreen): 4 | 5 | def __init__(self, title, text): 6 | self.__title = title 7 | self.__text = text 8 | 9 | def drawScreen(self, xm, ym): 10 | self._drawGradientRect(0, 0, self.width, self.height, -12574688, -11530224) 11 | self.drawCenteredString(self._fontRenderer, self.__title, self.width // 2, 90, 0xFFFFFF) 12 | self.drawCenteredString(self._fontRenderer, self.__text, self.width // 2, 110, 0xFFFFFF) 13 | super().drawScreen(xm, ym) 14 | 15 | def _keyTyped(self, key, char, motion): 16 | pass 17 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiGameOver.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiLoadLevel import GuiLoadLevel 2 | from mc.net.minecraft.client.gui.GuiNewLevel import GuiNewLevel 3 | from mc.net.minecraft.client.gui.GuiOptions import GuiOptions 4 | from mc.net.minecraft.client.gui.GuiScreen import GuiScreen 5 | from mc.net.minecraft.client.gui.GuiButton import GuiButton 6 | from pyglet import gl 7 | 8 | class GuiGameOver(GuiScreen): 9 | 10 | def initGui(self): 11 | self._controlList.clear() 12 | self._controlList.append(GuiButton(1, self.width // 2 - 100, self.height // 4 + 72, 13 | 'Generate new world...')) 14 | self._controlList.append(GuiButton(2, self.width // 2 - 100, self.height // 4 + 96, 15 | 'Load world..')) 16 | if not self.mc.session: 17 | self._controlList[2].enabled = False 18 | 19 | def _keyTyped(self, key, char, motion): 20 | pass 21 | 22 | def _actionPerformed(self, button): 23 | if button.id == 0: 24 | self.mc.displayGuiScreen(GuiOptions(self, self.mc.options)) 25 | elif button.id == 1: 26 | self.mc.displayGuiScreen(GuiNewLevel(self)) 27 | elif button.id == 2 and self.mc.session: 28 | self.mc.displayGuiScreen(GuiLoadLevel(self)) 29 | 30 | def drawScreen(self, xm, ym): 31 | self._drawGradientRect(0, 0, self.width, self.height, 0x60500000, -1602211792) 32 | gl.glPushMatrix() 33 | gl.glScalef(2.0, 2.0, 2.0) 34 | self.drawCenteredString(self._fontRenderer, 'Game over!', self.width // 2 // 2, 30, 0xFFFFFF) 35 | gl.glPopMatrix() 36 | self.drawCenteredString(self._fontRenderer, 'Score: &e' + str(self.mc.thePlayer.getScore()), 37 | self.width // 2, 100, 0xFFFFFF) 38 | super().drawScreen(xm, ym) 39 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiIngameMenu.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiScreen import GuiScreen 2 | from mc.net.minecraft.client.gui.GuiOptions import GuiOptions 3 | from mc.net.minecraft.client.gui.GuiNewLevel import GuiNewLevel 4 | from mc.net.minecraft.client.gui.GuiSaveLevel import GuiSaveLevel 5 | from mc.net.minecraft.client.gui.GuiLoadLevel import GuiLoadLevel 6 | from mc.net.minecraft.client.gui.GuiButton import GuiButton 7 | from pyglet import window 8 | 9 | class GuiIngameMenu(GuiScreen): 10 | 11 | def initGui(self): 12 | self._controlList.clear() 13 | self._controlList.append(GuiButton(0, self.width // 2 - 100, 14 | self.height // 4, 'Options...')) 15 | self._controlList.append(GuiButton(1, self.width // 2 - 100, 16 | self.height // 4 + 24, 'Generate new world...')) 17 | self._controlList.append(GuiButton(2, self.width // 2 - 100, 18 | self.height // 4 + 48, 'Save world..')) 19 | self._controlList.append(GuiButton(3, self.width // 2 - 100, 20 | self.height // 4 + 72, 'Load world..')) 21 | self._controlList.append(GuiButton(4, self.width // 2 - 100, 22 | self.height // 4 + 120, 'Back to game')) 23 | if not self.mc.session: 24 | self._controlList[2].enabled = False 25 | self._controlList[3].enabled = False 26 | 27 | def _actionPerformed(self, button): 28 | if button.id == 0: 29 | self.mc.displayGuiScreen(GuiOptions(self, self.mc.options)) 30 | elif button.id == 1: 31 | self.mc.displayGuiScreen(GuiNewLevel(self)) 32 | elif button.id == 2 and self.mc.session: 33 | self.mc.displayGuiScreen(GuiSaveLevel(self)) 34 | elif button.id == 3 and self.mc.session: 35 | self.mc.displayGuiScreen(GuiLoadLevel(self)) 36 | elif button.id == 4: 37 | self.mc.displayGuiScreen(None) 38 | self.mc.grabMouse() 39 | 40 | def drawScreen(self, xm, ym): 41 | self._drawGradientRect(0, 0, self.width, self.height, 1610941696, -1607454624) 42 | self.drawCenteredString(self._fontRenderer, 'Game menu', self.width // 2, 40, 0xFFFFFF) 43 | super().drawScreen(xm, ym) 44 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiLevelDialog.py: -------------------------------------------------------------------------------- 1 | try: 2 | import wx 3 | except: 4 | import tkinter as tk 5 | from tkinter.filedialog import askopenfilename, asksaveasfilename 6 | 7 | import os 8 | 9 | class GuiLevelDialog: 10 | 11 | def __init__(self, loadLevel): 12 | self.__screen = loadLevel 13 | 14 | def run(self): 15 | from mc.net.minecraft.client.gui.GuiSaveLevel import GuiSaveLevel 16 | saves = os.path.join(self.__screen.mc.mcDataDir, 'saves') 17 | if not os.path.exists(saves): 18 | os.mkdir(saves) 19 | 20 | isLoad = not isinstance(self.__screen, GuiSaveLevel) 21 | try: 22 | title = 'Load level' if isLoad else 'Save level' 23 | style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST if isLoad else wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT 24 | app = wx.App(False) 25 | with wx.FileDialog(None, title, saves, wildcard='MCLEVEL files (*.mclevel)|*.mclevel', 26 | style=style) as fileDialog: 27 | fileDialog.CenterOnParent() 28 | fileDialog.SetWindowStyleFlag(wx.STAY_ON_TOP) 29 | if fileDialog.ShowModal() == wx.ID_CANCEL: 30 | return 31 | 32 | self.__screen.setFile(fileDialog.GetPath()) 33 | wx.GetApp().ExitMainLoop() 34 | except NameError: 35 | root = tk.Tk() 36 | root.wm_attributes('-topmost', True) 37 | root.withdraw() 38 | try: 39 | fileChooser = askopenfilename if isLoad else asksaveasfilename 40 | file = fileChooser(initialdir=saves, 41 | filetypes=[('Minecraft levels', '*.mclevel')]) 42 | if file: 43 | self.__screen.setFile(file) 44 | finally: 45 | root.quit() 46 | root.destroy() 47 | finally: 48 | self.__screen.setFrozen(False) 49 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiNameLevel.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiScreen import GuiScreen 2 | from mc.net.minecraft.client.gui.GuiButton import GuiButton 3 | from pyglet import window 4 | 5 | class GuiNameLevel(GuiScreen): 6 | 7 | def __init__(self, screen, name, slot): 8 | self.__parent = screen 9 | self.__name = name 10 | if self.__name == '-': 11 | self.__name = '' 12 | self.__id = slot 13 | self.__title = 'Enter level name:' 14 | self.__counter = 0 15 | 16 | def initGui(self): 17 | self._controlList.clear() 18 | self._controlList.append(GuiButton(0, self.width // 2 - 100, self.height // 4 + 120, 'Save')) 19 | self._controlList.append(GuiButton(1, self.width // 2 - 100, self.height // 4 + 144, 'Cancel')) 20 | self._controlList[0].enabled = len(self.__name.strip()) > 1 21 | 22 | def updateScreen(self): 23 | self.__counter += 1 24 | 25 | def _actionPerformed(self, button): 26 | if button.enabled: 27 | if button.id == 0 and len(self.__name.strip()) > 1: 28 | self.__name.strip() 29 | self.mc.displayGuiScreen(None) 30 | self.mc.grabMouse() 31 | elif button.id == 1: 32 | self.mc.displayGuiScreen(self.__parent) 33 | 34 | def _keyTyped(self, key, char, motion): 35 | if motion == window.key.MOTION_BACKSPACE and len(self.__name) > 0: 36 | self.__name = self.__name[:-1] 37 | elif char: 38 | if char in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_\'*!"#%/()=+?[]{}<>' and len(self.__name) < 64: 39 | self.__name += char 40 | 41 | self._controlList[0].enabled = len(self.__name.strip()) > 1 42 | 43 | def drawScreen(self, xm, ym): 44 | self._drawGradientRect(0, 0, self.width, self.height, 1610941696, -1607454624) 45 | self.drawCenteredString(self._fontRenderer, self.__title, self.width / 2, 40, 0xFFFFFF) 46 | w = self.width // 2 - 100 47 | h = self.height // 2 - 10 48 | self._drawRect(w - 1, h - 1, w + 200 + 1, h + 20 + 1, -6250336) 49 | self._drawRect(w, h, w + 200, h + 20, -16777216) 50 | self.drawString( 51 | self._fontRenderer, 52 | self.__name + ('_' if self.__counter // 6 % 2 == 0 else ''), 53 | w + 4, h + 6, 14737632 54 | ) 55 | super().drawScreen(xm, ym) 56 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiOptions.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiScreen import GuiScreen 2 | from mc.net.minecraft.client.gui.GuiButton import GuiButton 3 | from mc.net.minecraft.client.gui.GuiSmallButton import GuiSmallButton 4 | from mc.net.minecraft.client.gui.GuiControls import GuiControls 5 | 6 | class GuiOptions(GuiScreen): 7 | __screenTitle = 'Options' 8 | 9 | def __init__(self, screen, options): 10 | self.__parentScreen = screen 11 | self.__options = options 12 | 13 | def initGui(self): 14 | for i in range(self.__options.numberOfOptions): 15 | self._controlList.append(GuiSmallButton(i, self.width // 2 - 155 + i % 2 * 160, 16 | self.height // 6 + 24 * (i >> 1), 17 | self.__options.getOptionDisplayString(i))) 18 | 19 | self._controlList.append(GuiButton(100, self.width // 2 - 100, 20 | self.height // 6 + 120 + 12, 'Controls...')) 21 | self._controlList.append(GuiButton(200, self.width // 2 - 100, 22 | self.height // 6 + 168, 'Done')) 23 | 24 | def _actionPerformed(self, button): 25 | if button.enabled: 26 | if button.id < 100: 27 | self.__options.setOptionValue(button.id, 1) 28 | button.displayString = self.__options.getOptionDisplayString(button.id) 29 | elif button.id == 100: 30 | self.mc.displayGuiScreen(GuiControls(self, self.__options)) 31 | elif button.id == 200: 32 | self.mc.displayGuiScreen(self.__parentScreen) 33 | 34 | def drawScreen(self, xm, ym): 35 | self._drawGradientRect(0, 0, self.width, self.height, 1610941696, -1607454624) 36 | self.drawCenteredString(self._fontRenderer, self.__screenTitle, 37 | self.width / 2, 20, 16777215) 38 | super().drawScreen(xm, ym) 39 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiSaveLevel.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiLoadLevel import GuiLoadLevel 2 | from mc.net.minecraft.client.gui.GuiNameLevel import GuiNameLevel 3 | from mc.net.minecraft.client.PlayerLoader import PlayerLoader 4 | 5 | import traceback 6 | 7 | class GuiSaveLevel(GuiLoadLevel): 8 | 9 | def __init__(self, screen): 10 | super().__init__(screen) 11 | self._title = 'Save level' 12 | 13 | def initGui(self): 14 | super().initGui() 15 | self._controlList[5].displayString = 'Save file...' 16 | 17 | def _setLevels(self, levels): 18 | for i in range(5): 19 | self._controlList[i].displayString = levels[i] 20 | self._controlList[i].visible = True 21 | 22 | self._controlList[5].visible = True 23 | 24 | def _openFile(self, file): 25 | try: 26 | PlayerLoader(self.mc, self.mc.loadingScreen).save(self.mc.theWorld, file) 27 | except Exception as e: 28 | print(traceback.format_exc()) 29 | 30 | def _openLevel(self, i): 31 | self.mc.displayGuiScreen(GuiNameLevel(self, self._controlList[i].displayString, i)) 32 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiScreen.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.Gui import Gui 2 | from mc.net.minecraft.client.render.Tessellator import tessellator 3 | from pyglet import window, gl 4 | 5 | class GuiScreen(Gui): 6 | allowUserInput = False 7 | 8 | def drawScreen(self, xMouse, yMouse): 9 | for button in self._controlList: 10 | button.drawButton(self.mc, xMouse, yMouse) 11 | 12 | def _keyTyped(self, key, char, motion): 13 | if key == window.key.ESCAPE: 14 | self.mc.displayGuiScreen(None) 15 | self.mc.grabMouse() 16 | 17 | def _mouseClicked(self, xm, ym, button): 18 | if button == window.mouse.LEFT: 19 | for button in self._controlList: 20 | if button.mousePressed(xm, ym): 21 | self.mc.sndManager.playSoundFX('random.click', 1.0, 1.0) 22 | self._actionPerformed(button) 23 | 24 | def _actionPerformed(self, button): 25 | pass 26 | 27 | def setWorldAndResolution(self, minecraft, width, height): 28 | self.mc = minecraft 29 | self._fontRenderer = minecraft.fontRenderer 30 | self.width = width 31 | self.height = height 32 | self._controlList = [] 33 | self.initGui() 34 | 35 | def initGui(self): 36 | pass 37 | 38 | def handleMouseInput(self, button): 39 | xm = self.mc.mouseX * self.width // self.mc.width 40 | ym = self.height - self.mc.mouseY * self.height // self.mc.height - 1 41 | self._mouseClicked(xm, ym, button) 42 | 43 | def handleKeyboardEvent(self, key=None, char=None, motion=None): 44 | if key == window.key.F11: 45 | self.mc.toggleFullscreen() 46 | return 47 | 48 | self._keyTyped(key, char, motion) 49 | 50 | def updateScreen(self): 51 | pass 52 | 53 | def onGuiClosed(self): 54 | pass 55 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/GuiSmallButton.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.GuiButton import GuiButton 2 | 3 | class GuiSmallButton(GuiButton): 4 | 5 | def __init__(self, id_, x, y, msg): 6 | super().__init__(id_, x, y, 150, 20, msg) 7 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/ScaledResolution.py: -------------------------------------------------------------------------------- 1 | class ScaledResolution: 2 | 3 | def __init__(self, width, height): 4 | self.__scaledWidth = width 5 | self.__scaledHeight = height 6 | scale = 1 7 | while self.__scaledWidth // (scale + 1) >= 320 and \ 8 | self.__scaledHeight // (scale + 1) >= 240: 9 | scale += 1 10 | 11 | self.__scaledWidth //= scale 12 | self.__scaledHeight //= scale 13 | 14 | def getScaledWidth(self): 15 | return self.__scaledWidth 16 | 17 | def getScaledHeight(self): 18 | return self.__scaledHeight 19 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/gui/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/GuiChest.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.container.GuiContainer import GuiContainer 2 | from mc.net.minecraft.client.gui.container.Slot import Slot 3 | from pyglet import gl 4 | 5 | class GuiChest(GuiContainer): 6 | 7 | def __init__(self, upperChestInventory, lowerChestInventory): 8 | super().__init__() 9 | self.__upperChestInventory = upperChestInventory 10 | self.__lowerChestInventory = lowerChestInventory 11 | self.allowUserInput = False 12 | self.__inventoryRows = lowerChestInventory.getSizeInventory() // 9 13 | self.ySize = 114 + self.__inventoryRows * 18 14 | yOffset = (self.__inventoryRows - 4) * 18 15 | for row in range(self.__inventoryRows): 16 | for col in range(9): 17 | self._inventorySlots.append(Slot(self, lowerChestInventory, col + row * 9, 18 | 8 + col * 18, 18 + row * 18)) 19 | 20 | for row in range(3): 21 | for col in range(9): 22 | self._inventorySlots.append(Slot(self, upperChestInventory, col + (row + 1) * 9, 23 | 8 + col * 18, 103 + row * 18 + yOffset)) 24 | 25 | for row in range(9): 26 | self._inventorySlots.append(Slot(self, upperChestInventory, row, 27 | 8 + row * 18, yOffset + 161)) 28 | 29 | def _drawGuiContainerForegroundLayer(self): 30 | self._fontRenderer.drawString(self.__lowerChestInventory.getInvName(), 31 | 8, 6, 4210752) 32 | self._fontRenderer.drawString(self.__upperChestInventory.getInvName(), 33 | 8, self.ySize - 96 + 2, 4210752) 34 | 35 | def _drawGuiContainerBackgroundLayer(self): 36 | tex = self.mc.renderEngine.getTexture('gui/container.png') 37 | gl.glColor4f(1.0, 1.0, 1.0, 1.0) 38 | gl.glBindTexture(gl.GL_TEXTURE_2D, tex) 39 | x = (self.width - self.xSize) // 2 40 | y = (self.height - self.ySize) // 2 41 | self.drawTexturedModalRect(x, y, 0, 0, self.xSize, 42 | self.__inventoryRows * 18 + 17) 43 | self.drawTexturedModalRect(x, y + self.__inventoryRows * 18 + 17, 0, 44 | 126, self.xSize, 96) 45 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/GuiCrafting.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.recipe.CraftingManager import CraftingManager 2 | from mc.net.minecraft.client.gui.container.InventoryCraftResult import InventoryCraftResult 3 | from mc.net.minecraft.client.gui.container.InventoryCrafting import InventoryCrafting 4 | from mc.net.minecraft.client.gui.container.GuiContainer import GuiContainer 5 | from mc.net.minecraft.client.gui.container.SlotCrafting import SlotCrafting 6 | from mc.net.minecraft.client.gui.container.Slot import Slot 7 | from pyglet import gl 8 | 9 | class GuiCrafting(GuiContainer): 10 | 11 | def __init__(self, player): 12 | super().__init__() 13 | self.__inventoryCrafting = InventoryCrafting(self, 3, 3) 14 | self.__iInventory = InventoryCraftResult() 15 | self._inventorySlots.append(SlotCrafting( 16 | self, self.__inventoryCrafting, self.__iInventory, 0, 124, 35 17 | )) 18 | for row in range(3): 19 | for col in range(3): 20 | self._inventorySlots.append(Slot(self, self.__inventoryCrafting, col + row * 3, 21 | 30 + col * 18, 17 + row * 18)) 22 | 23 | for row in range(3): 24 | for col in range(9): 25 | self._inventorySlots.append(Slot(self, player, col + (row + 1) * 9, 26 | 8 + col * 18, 84 + row * 18)) 27 | 28 | for row in range(9): 29 | self._inventorySlots.append(Slot(self, player, row, 8 + row * 18, 142)) 30 | 31 | def onGuiClosed(self): 32 | super().onGuiClosed() 33 | for slot in range(9): 34 | stack = self.__inventoryCrafting.getStackInSlot(slot) 35 | if stack: 36 | self.mc.thePlayer.dropPlayerItemWithRandomChoice(stack) 37 | 38 | def guiCraftingItemsCheck(self): 39 | items = [0] * 9 40 | for row in range(3): 41 | for col in range(3): 42 | slot = row + col * 3 43 | stack = self.__inventoryCrafting.getStackInSlot(slot) 44 | if stack: 45 | items[slot] = stack.itemID 46 | else: 47 | items[slot] = -1 48 | 49 | self.__iInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(items)) 50 | 51 | def _drawGuiContainerForegroundLayer(self): 52 | self._fontRenderer.drawString('Crafting', 28, 6, 4210752) 53 | self._fontRenderer.drawString('Inventory', 8, self.ySize - 96 + 2, 4210752) 54 | 55 | def _drawGuiContainerBackgroundLayer(self): 56 | tex = self.mc.renderEngine.getTexture('gui/crafting.png') 57 | gl.glColor4f(1.0, 1.0, 1.0, 1.0) 58 | gl.glBindTexture(gl.GL_TEXTURE_2D, tex) 59 | x = (self.width - self.xSize) // 2 60 | y = (self.height - self.ySize) // 2 61 | self.drawTexturedModalRect(x, y, 0, 0, self.xSize, self.ySize) 62 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/GuiInventory.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.container.InventoryCraftResult import InventoryCraftResult 2 | from mc.net.minecraft.client.gui.container.InventoryCrafting import InventoryCrafting 3 | from mc.net.minecraft.client.gui.container.GuiContainer import GuiContainer 4 | from mc.net.minecraft.client.gui.container.Slot import Slot 5 | from mc.net.minecraft.client.gui.container.SlotCrafting import SlotCrafting 6 | from mc.net.minecraft.game.item.recipe.CraftingManager import CraftingManager 7 | from pyglet import gl 8 | 9 | class GuiInventory(GuiContainer): 10 | 11 | def __init__(self, inventory): 12 | super().__init__() 13 | self.__inventoryCrafting = InventoryCrafting(self, 2, 2) 14 | self.__craftResult = InventoryCraftResult() 15 | 16 | self.allowUserInput = True 17 | 18 | self._inventorySlots.append(SlotCrafting( 19 | self, self.__inventoryCrafting, self.__craftResult, 0, 144, 36 20 | )) 21 | for row in range(2): 22 | for col in range(2): 23 | self._inventorySlots.append(Slot( 24 | self, self.__inventoryCrafting, col + (row << 1), 25 | 88 + col * 18, 26 + row * 18 26 | )) 27 | 28 | for armorSlots in range(4): 29 | self._inventorySlots.append(Slot( 30 | self, inventory, inventory.getSizeInventory() - 1 - armorSlots, 31 | 8, 8 + armorSlots * 18 32 | )) 33 | 34 | for row in range(3): 35 | for col in range(9): 36 | self._inventorySlots.append(Slot( 37 | self, inventory, col + (row + 1) * 9, 38 | 8 + col * 18, 84 + row * 18 39 | )) 40 | 41 | for barSlots in range(9): 42 | self._inventorySlots.append(Slot(self, inventory, barSlots, 43 | 8 + barSlots * 18, 142)) 44 | 45 | def onGuiClosed(self): 46 | super().onGuiClosed() 47 | for i in range(self.__inventoryCrafting.getSizeInventory()): 48 | stack = self.__inventoryCrafting.getStackInSlot(i) 49 | if stack: 50 | self.mc.thePlayer.dropPlayerItemWithRandomChoice(stack) 51 | 52 | def guiCraftingItemsCheck(self): 53 | items = [0] * 9 54 | for row in range(3): 55 | for col in range(3): 56 | slot = -1 57 | if row < 2 and col < 2: 58 | stack = self.__inventoryCrafting.getStackInSlot(row + (col << 1)) 59 | if stack: 60 | slot = stack.itemID 61 | 62 | items[row + col * 3] = slot 63 | 64 | self.__craftResult.setInventorySlotContents( 65 | 0, CraftingManager.getInstance().findMatchingRecipe(items) 66 | ) 67 | 68 | def _drawGuiContainerForegroundLayer(self): 69 | self._fontRenderer.drawString('Crafting', 86, 16, 4210752) 70 | 71 | def _drawGuiContainerBackgroundLayer(self): 72 | tex = self.mc.renderEngine.getTexture('gui/inventory.png') 73 | gl.glColor4f(1.0, 1.0, 1.0, 1.0) 74 | gl.glBindTexture(gl.GL_TEXTURE_2D, tex) 75 | w = (self.width - self.xSize) // 2 76 | h = (self.height - self.ySize) // 2 77 | self.drawTexturedModalRect(w, h, 0, 0, self.xSize, self.ySize) 78 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/InventoryCraftResult.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.Inventory import Inventory 2 | 3 | class InventoryCraftResult(Inventory): 4 | STACK_LIMIT = 64 5 | 6 | def __init__(self): 7 | self.__stackResult = [None] 8 | 9 | def getSizeInventory(self): 10 | return 1 11 | 12 | def getStackInSlot(self, slot): 13 | return self.__stackResult[slot] 14 | 15 | def getInvName(self): 16 | return 'Result' 17 | 18 | def decrStackSize(self, slot, size): 19 | if self.__stackResult[slot]: 20 | stack = self.__stackResult[slot] 21 | self.__stackResult[slot] = None 22 | return stack 23 | else: 24 | return None 25 | 26 | def setInventorySlotContents(self, slot, stack): 27 | self.__stackResult[slot] = stack 28 | 29 | def getInventoryStackLimit(self): 30 | return InventoryCraftResult.STACK_LIMIT 31 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/InventoryCrafting.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.Inventory import Inventory 2 | 3 | class InventoryCrafting(Inventory): 4 | STACK_LIMIT = 64 5 | 6 | def __init__(self, eventHandler, width, height): 7 | self.__inventoryWidth = width * height 8 | self.__stackList = [None] * self.__inventoryWidth 9 | self.__eventHandler = eventHandler 10 | 11 | def getSizeInventory(self): 12 | return self.__inventoryWidth 13 | 14 | def getStackInSlot(self, slot): 15 | return self.__stackList[slot] 16 | 17 | def getInvName(self): 18 | return 'Crafting' 19 | 20 | def decrStackSize(self, slot, size): 21 | if not self.__stackList[slot]: 22 | return None 23 | 24 | if self.__stackList[slot].stackSize <= size: 25 | stack = self.__stackList[slot] 26 | self.__stackList[slot] = None 27 | self.__eventHandler.guiCraftingItemsCheck() 28 | return stack 29 | else: 30 | stack = self.__stackList[slot].splitStack(size) 31 | if self.__stackList[slot].stackSize == 0: 32 | self.__stackList[slot] = None 33 | 34 | self.__eventHandler.guiCraftingItemsCheck() 35 | return stack 36 | 37 | def setInventorySlotContents(self, slot, stack): 38 | self.__stackList[slot] = stack 39 | self.__eventHandler.guiCraftingItemsCheck() 40 | 41 | def getInventoryStackLimit(self): 42 | return InventoryCrafting.STACK_LIMIT 43 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/Slot.py: -------------------------------------------------------------------------------- 1 | class Slot: 2 | 3 | def __init__(self, guiHandler, inventory, slotIndex, xPos, yPos): 4 | self.__guiHandler = guiHandler 5 | self.inventory = inventory 6 | self.slotIndex = slotIndex 7 | self.xDisplayPosition = xPos 8 | self.yDisplayPosition = yPos 9 | 10 | def getIsMouseOverSlot(self, x, y): 11 | w = (self.__guiHandler.width - self.__guiHandler.xSize) // 2 12 | h = (self.__guiHandler.height - self.__guiHandler.ySize) // 2 13 | x -= w 14 | y -= h 15 | return x >= self.xDisplayPosition - 1 and \ 16 | x < self.xDisplayPosition + 16 + 1 and \ 17 | y >= self.yDisplayPosition - 1 and \ 18 | y < self.yDisplayPosition + 16 + 1 19 | 20 | def onPickupFromSlot(self): 21 | pass 22 | 23 | def isItemValid(self): 24 | return True 25 | 26 | def putStack(self, stack): 27 | self.inventory.setInventorySlotContents(self.slotIndex, stack) 28 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/SlotCrafting.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.gui.container.Slot import Slot 2 | 3 | class SlotCrafting(Slot): 4 | 5 | def __init__(self, guiHandler, inventory, craftResult, slotIndex, xPos, yPos): 6 | super().__init__(guiHandler, craftResult, 0, xPos, yPos) 7 | self.__craftMatrix = inventory 8 | 9 | def isItemValid(self): 10 | return False 11 | 12 | def onPickupFromSlot(self): 13 | for slot in range(self.__craftMatrix.getSizeInventory()): 14 | if self.__craftMatrix.getStackInSlot(slot): 15 | self.__craftMatrix.decrStackSize(slot, 1) 16 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/gui/container/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/gui/container/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/model/ModelBase.py: -------------------------------------------------------------------------------- 1 | class ModelBase: 2 | 3 | def render(self, x, y, z, xRot, yRot, zRot): 4 | pass 5 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/model/ModelBiped.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.model.ModelBase import ModelBase 2 | from mc.net.minecraft.client.model.ModelRenderer import ModelRenderer 3 | 4 | import math 5 | 6 | class ModelBiped(ModelBase): 7 | 8 | def __init__(self, translation=0.0): 9 | self.bipedHead = ModelRenderer(0, 0) 10 | self.bipedHead.addBox(-4.0, -8.0, -4.0, 8, 8, 8, 0.0) 11 | self.bipedHeadWear = ModelRenderer(32, 0) 12 | self.bipedHeadWear.addBox(-4.0, -8.0, -4.0, 8, 8, 8, 0.5) 13 | self.bipedBody = ModelRenderer(16, 16) 14 | self.bipedBody.addBox(-4.0, 0.0, -2.0, 8, 12, 4, 0.0) 15 | self.bipedRightArm = ModelRenderer(40, 16) 16 | self.bipedRightArm.addBox(-3.0, -2.0, -2.0, 4, 12, 4, 0.0) 17 | self.bipedRightArm.setRotationPoint(-5.0, 2.0, 0.0) 18 | self.bipedLeftArm = ModelRenderer(40, 16) 19 | self.bipedLeftArm.mirror = True 20 | self.bipedLeftArm.addBox(-1.0, -2.0, -2.0, 4, 12, 4, 0.0) 21 | self.bipedLeftArm.setRotationPoint(5.0, 2.0, 0.0) 22 | self.bipedRightLeg = ModelRenderer(0, 16) 23 | self.bipedRightLeg.addBox(-2.0, 0.0, -2.0, 4, 12, 4, 0.0) 24 | self.bipedRightLeg.setRotationPoint(-2.0, 12.0, 0.0) 25 | self.bipedLeftLeg = ModelRenderer(0, 16) 26 | self.bipedLeftLeg.mirror = True 27 | self.bipedLeftLeg.addBox(-2.0, 0.0, -2.0, 4, 12, 4, 0.0) 28 | self.bipedLeftLeg.setRotationPoint(2.0, 12.0, 0.0) 29 | 30 | def render(self, x, y, z, xRot, yRot, zRot): 31 | zRot = yRot 32 | yRot = xRot 33 | xRot = 0.0 34 | self.bipedHead.rotateAngleY = yRot / (180.0 / math.pi) 35 | self.bipedHead.rotateAngleX = zRot / (180.0 / math.pi) 36 | self.bipedRightArm.rotateAngleX = math.cos(x * 0.6662 + math.pi) * 2.0 * y 37 | self.bipedRightArm.rotateAngleZ = (math.cos(x * 0.2312) + 1.0) * y 38 | self.bipedLeftArm.rotateAngleX = math.cos(x * 0.6662) * 2.0 * y 39 | self.bipedLeftArm.rotateAngleZ = (math.cos(x * 0.2812) - 1.0) * y 40 | self.bipedRightLeg.rotateAngleX = math.cos(x * 0.6662) * 1.4 * y 41 | self.bipedLeftLeg.rotateAngleX = math.cos(x * 0.6662 + math.pi) * 1.4 * y 42 | self.bipedRightArm.rotateAngleZ += math.cos(xRot * 0.09) * 0.05 + 0.05 43 | self.bipedLeftArm.rotateAngleZ -= math.cos(xRot * 0.09) * 0.05 + 0.05 44 | self.bipedRightArm.rotateAngleX += math.sin(xRot * 0.067) * 0.05 45 | self.bipedLeftArm.rotateAngleX -= math.sin(xRot * 0.067) * 0.05 46 | self.bipedHead.render(1.0) 47 | self.bipedBody.render(1.0) 48 | self.bipedRightArm.render(1.0) 49 | self.bipedLeftArm.render(1.0) 50 | self.bipedRightLeg.render(1.0) 51 | self.bipedLeftLeg.render(1.0) 52 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/model/PositionTextureVertex.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.physics.Vec3D import Vec3D 2 | 3 | class PositionTextureVertex: 4 | 5 | @staticmethod 6 | def fromPos(x, y, z, u, v): 7 | return PositionTextureVertex(None, x, y, z, u, v) 8 | 9 | def __init__(self, obj, x=0.0, y=0.0, z=0.0, u=0.0, v=0.0): 10 | if isinstance(obj, Vec3D): 11 | self.vector3D = obj 12 | elif isinstance(obj, PositionTextureVertex): 13 | self.vector3D = obj.vector3D 14 | else: 15 | self.vector3D = Vec3D(x, y, z) 16 | 17 | self.texturePositionX = u 18 | self.texturePositionY = v 19 | 20 | def setTexturePosition(self, u, v): 21 | return PositionTextureVertex(self, u=u, v=v) 22 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/model/TexturedQuad.py: -------------------------------------------------------------------------------- 1 | class TexturedQuad: 2 | 3 | def __init__(self, vertices, u0=None, v0=None, u1=None, v1=None): 4 | self.vertexPositions = vertices 5 | if isinstance(u0, int): 6 | vertices[0] = vertices[0].setTexturePosition(u1 / 64.0 - 0.0015625, 7 | v0 / 32.0 + 0.003125) 8 | vertices[1] = vertices[1].setTexturePosition(u0 / 64.0 + 0.0015625, 9 | v0 / 32.0 + 0.003125) 10 | vertices[2] = vertices[2].setTexturePosition(u0 / 64.0 + 0.0015625, 11 | v1 / 32.0 - 0.003125) 12 | vertices[3] = vertices[3].setTexturePosition(u1 / 64.0 - 0.0015625, 13 | v1 / 32.0 - 0.003125) 14 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/model/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/player/EntityPlayerInput.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.entity.AILiving import AILiving 2 | 3 | class EntityPlayerInput(AILiving): 4 | 5 | def __init__(self, player): 6 | super().__init__() 7 | self.__player = player 8 | 9 | def updatePlayerActionState(self): 10 | self._moveStrafing = self.__player.movementInput.moveStrafe 11 | self._moveForward = self.__player.movementInput.moveForward 12 | self._isJumping = self.__player.movementInput.jump 13 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/player/EntityPlayerSP.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.player.EntityPlayerInput import EntityPlayerInput 2 | from mc.net.minecraft.client.gui.container.GuiCrafting import GuiCrafting 3 | from mc.net.minecraft.client.gui.container.GuiChest import GuiChest 4 | from mc.net.minecraft.game.entity.player.EntityPlayer import EntityPlayer 5 | from mc.net.minecraft.game.item.ItemStack import ItemStack 6 | from nbtlib.tag import Compound, List, Byte, Int 7 | 8 | class EntityPlayerSP(EntityPlayer): 9 | 10 | def __init__(self, mc, world): 11 | super().__init__(world) 12 | self.__mc = mc 13 | self.movementInput = None 14 | self._entityAI = EntityPlayerInput(self) 15 | 16 | def onLivingUpdate(self): 17 | self.movementInput.updatePlayerMoveState() 18 | super().onLivingUpdate() 19 | 20 | def _writeEntityToNBT(self, compound): 21 | compound['Score'] = Int(self._getScore) 22 | invList = List[Compound]() 23 | for slot in range(len(self.inventory.mainInventory)): 24 | if self.inventory.mainInventory[slot]: 25 | comp = Compound({'Slot': Byte(slot)}) 26 | self.inventory.mainInventory[slot].writeToNBT(comp) 27 | invList.append(comp) 28 | 29 | compound['Inventory'] = invList 30 | 31 | def _readEntityFromNBT(self, compound): 32 | self._getScore = compound['Score'].real 33 | invList = compound['Inventory'] 34 | self.inventory.mainInventory = [None] * 64 35 | for comp in invList: 36 | self.inventory.mainInventory[comp['Slot'].real & 255] = ItemStack(comp) 37 | 38 | def _getEntityString(self): 39 | return 'LocalPlayer' 40 | 41 | def displayGUIChest(self, inventory): 42 | self.__mc.displayGuiScreen(GuiChest(self.inventory, inventory)) 43 | 44 | def displayWorkbenchGUI(self): 45 | self.__mc.displayGuiScreen(GuiCrafting(self.inventory)) 46 | 47 | def displayGUIInventory(self): 48 | self.inventory.setInventorySlotContents(self.inventory.currentItem, None) 49 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/player/MovementInput.py: -------------------------------------------------------------------------------- 1 | class MovementInput: 2 | moveStrafe = 0.0 3 | moveForward = 0.0 4 | jump = False 5 | 6 | def updatePlayerMoveState(self): 7 | pass 8 | 9 | def resetKeyState(self): 10 | pass 11 | 12 | def checkKeyForMovementInput(self, symbol, state): 13 | pass 14 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/player/MovementInputFromOptions.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.player.MovementInput import MovementInput 2 | from pyglet import window 3 | 4 | class MovementInputFromOptions(MovementInput): 5 | 6 | def __init__(self, options): 7 | self.__options = options 8 | self.__keys = [False] * 10 9 | 10 | def checkKeyForMovementInput(self, symbol, state): 11 | id_ = -1 12 | if symbol == self.__options.keyBindForward.keyCode: id_ = 0 13 | if symbol == self.__options.keyBindBack.keyCode: id_ = 1 14 | if symbol == self.__options.keyBindLeft.keyCode: id_ = 2 15 | if symbol == self.__options.keyBindRight.keyCode: id_ = 3 16 | if symbol == self.__options.keyBindJump.keyCode: id_ = 4 17 | if id_ >= 0: 18 | self.__keys[id_] = state 19 | 20 | def resetKeyState(self): 21 | for i in range(10): 22 | self.__keys[i] = False 23 | 24 | def updatePlayerMoveState(self): 25 | self.moveStrafe = 0.0 26 | self.moveForward = 0.0 27 | if self.__keys[0]: self.moveForward -= 1.0 28 | if self.__keys[1]: self.moveForward += 1.0 29 | if self.__keys[2]: self.moveStrafe -= 1.0 30 | if self.__keys[3]: self.moveStrafe += 1.0 31 | 32 | self.jump = self.__keys[4] 33 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/player/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/player/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/EntitySorter.py: -------------------------------------------------------------------------------- 1 | class EntitySorter: 2 | 3 | def __init__(self, player): 4 | self.__player = player 5 | 6 | def compare(self, chunk1, chunk2): 7 | return -1 if chunk1.distanceToEntitySquared(self.__player) < chunk2.distanceToEntitySquared(self.__player) else 1 8 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/Frustum.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.JavaUtils cimport FloatBuffer 4 | 5 | cdef class Frustum: 6 | 7 | cdef: 8 | int _right 9 | int _left 10 | int _bottom 11 | int _top 12 | int _back 13 | int _front 14 | int _a 15 | int _b 16 | int _c 17 | int _d 18 | 19 | FloatBuffer __projectionMatrixBuffer 20 | FloatBuffer __modelviewMatrixBuffer 21 | FloatBuffer __clippingMatrixBuffer 22 | 23 | float[16] __projectionMatrix 24 | float[16] __modelviewMatrix 25 | float[16] __clippingMatrix 26 | 27 | float[6][4] __frustum 28 | 29 | cdef __normalize(self, int side) 30 | cdef bint isBoundingBoxFullyInFrustum(self, float x0, float y0, float z0, 31 | float x1, float y1, float z1) 32 | cdef bint isBoundingBoxInFrustum(self, float x0, float y0, float z0, 33 | float x1, float y1, float z1) 34 | cdef bint isVisible(self, aabb) 35 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/RenderBlocks.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | from mc.net.minecraft.client.render.Tessellator cimport Tessellator 6 | from mc.net.minecraft.game.level.block.Block cimport Block 7 | from mc.net.minecraft.game.level.World cimport World 8 | 9 | @cython.final 10 | cdef class RenderBlocks: 11 | 12 | cdef: 13 | Tessellator __tessellator 14 | World __blockAccess 15 | int __overrideBlockTexture 16 | bint __flipTexture 17 | 18 | cdef bint renderBlockByRenderType(self, Block block, int x, int y, int z) 19 | cdef __renderBlockFire(self, Block block, int x, int y, int z) 20 | cdef __renderBlockGear(self, Block block, int x, int y, int z) 21 | cdef __renderBlockTorch(self, Block block, float x, float y, float z, 22 | float xOffset, float zOffset) 23 | cdef __renderBlockPlant(self, Block block, float x, float y, float z) 24 | cdef float __shouldSideBeRendered(self, int x, int y, int z) 25 | cdef __renderBlockBottom(self, Block block, float x, float y, float z, int tex) 26 | cdef __renderBlockTop(self, Block block, float x, float y, float z, int tex) 27 | cdef __renderBlockNorth(self, Block block, int x, int y, int z, int tex) 28 | cdef __renderBlockSouth(self, Block block, int x, int y, int z, int tex) 29 | cdef __renderBlockWest(self, Block block, int x, int y, int z, int tex) 30 | cdef __renderBlockEast(self, Block block, int x, int y, int z, int tex) 31 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/RenderGlobal.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | from mc.net.minecraft.game.level.World cimport World 6 | from mc.net.minecraft.client.render.RenderBlocks cimport RenderBlocks 7 | from mc.net.minecraft.client.render.Tessellator cimport Tessellator 8 | from mc.JavaUtils cimport IntBuffer 9 | 10 | @cython.final 11 | cdef class RenderGlobal: 12 | 13 | cdef: 14 | object __mc 15 | object __renderEngine 16 | World __worldObj 17 | IntBuffer __renderIntBuffer 18 | Tessellator __t 19 | 20 | list __worldRenderersToUpdate 21 | list __sortedWorldRenderers 22 | list __worldRenderers 23 | 24 | RenderBlocks __globalRenderBlocks 25 | public object renderManager 26 | 27 | int[50000] __chunkBuffer 28 | int __cloudOffsetX 29 | float __prevSortX 30 | float __prevSortY 31 | float __prevSortZ 32 | 33 | public float damagePartialTime 34 | 35 | int __glGenList 36 | int __glRenderListBase 37 | 38 | int __renderChunksWide 39 | int __renderChunksTall 40 | int __renderChunksDeep 41 | 42 | cdef __markBlocksForUpdate(self, int x0, int y0, int z0, int x1, int y1, int z1) 43 | cdef markBlockAndNeighborsNeedsUpdate(self, int x, int y, int z) 44 | cdef markBlockRangeNeedsUpdate(self, int x0, int y0, int z0, 45 | int x1, int y1, int z1) 46 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/RenderSorter.py: -------------------------------------------------------------------------------- 1 | class RenderSorter: 2 | 3 | def __init__(self, player): 4 | self.__player = player 5 | 6 | def compare(self, chunk1, chunk2): 7 | if chunk1.isInFrustum and not chunk2.isInFrustum: 8 | return 1 9 | elif (not chunk2.isInFrustum or chunk1.isInFrustum) and \ 10 | chunk1.distanceToEntitySquared(self.__player) < chunk2.distanceToEntitySquared(self.__player): 11 | return 1 12 | else: 13 | return -1 14 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/Tessellator.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | from mc.JavaUtils cimport IntBuffer 6 | 7 | @cython.final 8 | cdef class Tessellator: 9 | 10 | cdef: 11 | int max_ints 12 | 13 | IntBuffer __byteBuffer 14 | int[:] __rawBuffer 15 | 16 | int __vertexCount 17 | 18 | float __textureU 19 | float __textureV 20 | 21 | int __color 22 | 23 | bint __hasColor 24 | bint __hasTexture 25 | 26 | int __colors 27 | int __addedVertices 28 | int __rawBufferIndex 29 | 30 | bint __drawMode 31 | 32 | cpdef void draw(self) 33 | cdef void __reset(self) 34 | cpdef void startDrawingQuads(self) 35 | cpdef inline void setColorOpaque_F(self, float r, float g, float b) 36 | cdef inline void __setColorOpaque(self, int r, int g, int b) 37 | cpdef void addVertexWithUV(self, float x, float y, float z, float u, float v) 38 | cpdef void addVertex(self, float x, float y, float z) 39 | cpdef inline void setColorOpaque_I(self, int c) 40 | cpdef inline void disableColor(self) 41 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/WorldRenderer.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | from mc.net.minecraft.client.render.Frustum cimport Frustum 6 | from mc.net.minecraft.client.render.Tessellator cimport Tessellator 7 | from mc.net.minecraft.client.render.RenderBlocks cimport RenderBlocks 8 | from mc.net.minecraft.game.level.block.Block cimport Block 9 | from mc.net.minecraft.game.level.World cimport World 10 | from mc.net.minecraft.game.physics.AxisAlignedBB cimport AxisAlignedBB 11 | 12 | @cython.final 13 | cdef class WorldRenderer: 14 | 15 | cdef: 16 | World __worldObj 17 | Tessellator __t 18 | RenderBlocks __renderBlocks 19 | AxisAlignedBB __rendererBoundingBox 20 | 21 | int __glRenderList 22 | 23 | int __posX 24 | int __posY 25 | int __posZ 26 | 27 | int __sizeWidth 28 | int __sizeHeight 29 | int __sizeDepth 30 | 31 | int __posXPlus 32 | int __posYPlus 33 | int __posZPlus 34 | 35 | bint[2] __skipRenderPass 36 | public bint isInFrustum 37 | public bint needsUpdate 38 | 39 | cdef updateRenderer(self) 40 | cpdef float distanceToEntitySquared(self, player) 41 | cdef __setDontDraw(self) 42 | cdef getGLCallListForPass(self, int* chunkBuffer, int startingIndex, int renderPass) 43 | cdef updateInFrustum(self, Frustum frustum) 44 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/render/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/entity/RenderArrow.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.render.Tessellator import tessellator 2 | from mc.net.minecraft.client.render.entity.Render import Render 3 | from pyglet import gl 4 | 5 | import math 6 | 7 | class RenderArrow(Render): 8 | 9 | def doRender(self, entity, xd, yd, zd, yaw, a): 10 | self._loadTexture('item/arrows.png') 11 | gl.glPushMatrix() 12 | gl.glTranslatef(xd, yd, zd) 13 | gl.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * a - 90.0, 0.0, 1.0, 0.0) 14 | gl.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * a, 0.0, 0.0, 1.0) 15 | t = tessellator 16 | gl.glEnable(gl.GL_NORMALIZE) 17 | arrowShake = entity.arrowShake - a 18 | if arrowShake > 0.0: 19 | arrowShake = -math.sin(arrowShake * 3.0) * arrowShake 20 | gl.glRotatef(arrowShake, 0.0, 0.0, 1.0) 21 | 22 | gl.glRotatef(45.0, 1.0, 0.0, 0.0) 23 | gl.glScalef(0.05625, 0.05625, 0.05625) 24 | gl.glTranslatef(-4.0, 0.0, 0.0) 25 | gl.glNormal3f(0.05625, 0.0, 0.0) 26 | t.startDrawingQuads() 27 | t.addVertexWithUV(-7.0, -2.0, -2.0, 0.0, 0.15625) 28 | t.addVertexWithUV(-7.0, -2.0, 2.0, 0.15625, 0.15625) 29 | t.addVertexWithUV(-7.0, 2.0, 2.0, 0.15625, 5.0 / 16.0) 30 | t.addVertexWithUV(-7.0, 2.0, -2.0, 0.0, 5.0 / 16.0) 31 | t.draw() 32 | gl.glNormal3f(-0.05625, 0.0, 0.0) 33 | t.startDrawingQuads() 34 | t.addVertexWithUV(-7.0, 2.0, -2.0, 0.0, 0.15625) 35 | t.addVertexWithUV(-7.0, 2.0, 2.0, 0.15625, 0.15625) 36 | t.addVertexWithUV(-7.0, -2.0, 2.0, 0.15625, 5.0 / 16.0) 37 | t.addVertexWithUV(-7.0, -2.0, -2.0, 0.0, 5.0 / 16.0) 38 | t.draw() 39 | 40 | for i in range(4): 41 | gl.glRotatef(90.0, 1.0, 0.0, 0.0) 42 | gl.glNormal3f(0.0, 0.0, 0.05625) 43 | t.addVertexWithUV(-8.0, -2.0, 0.0, 0.0, 0.0) 44 | t.addVertexWithUV(8.0, -2.0, 0.0, 0.5, 0.0) 45 | t.addVertexWithUV(8.0, 2.0, 0.0, 0.5, 0.15625) 46 | t.addVertexWithUV(-8.0, 2.0, 0.0, 0.0, 0.15625) 47 | t.draw() 48 | 49 | gl.glDisable(gl.GL_NORMALIZE) 50 | gl.glPopMatrix() 51 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/entity/RenderEntity.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.render.Tessellator import tessellator 2 | from mc.net.minecraft.client.render.entity.Render import Render 3 | from pyglet import gl 4 | 5 | class RenderEntity(Render): 6 | 7 | def doRender(self, entity, xd, yd, zd, yaw, a): 8 | gl.glPushMatrix() 9 | gl.glTranslatef(xd - entity.lastTickPosX, yd - entity.lastTickPosY, 10 | zd - entity.lastTickPosZ) 11 | Render.renderOffsetAABB(entity.boundingBox) 12 | gl.glPopMatrix() 13 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/entity/RenderLiving.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.render.entity.Render import Render 2 | from mc.net.minecraft.client.model.ModelBiped import ModelBiped 3 | from pyglet import gl 4 | 5 | import math 6 | 7 | class RenderLiving(Render): 8 | 9 | def __init__(self): 10 | self.__mainModel = ModelBiped() 11 | self._shadowSize = 0.5 12 | 13 | def doRender(self, entity, xd, yd, zd, yaw, a): 14 | gl.glPushMatrix() 15 | try: 16 | renderYaw = entity.prevRenderYawOffset + (entity.renderYawOffset - entity.prevRenderYawOffset) * a 17 | rotationYaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * a 18 | rotationPitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * a 19 | gl.glTranslatef(xd, yd, zd) 20 | self._loadTexture(entity.texture) 21 | gl.glRotatef(180.0 - renderYaw, 0.0, 1.0, 0.0) 22 | if entity.deathTime > 0: 23 | fall = (entity.deathTime + a - 1.0) / 20.0 * 1.6 24 | fall = min(math.sqrt(fall), 1.0) 25 | gl.glRotatef(fall * 90.0, 1.0, 0.0, 0.0) 26 | 27 | gl.glScalef(-(1.0 / 16.0), -(1.0 / 16.0), 1.0 / 16.0) 28 | gl.glTranslatef(0.0, -24.0, 0.0) 29 | gl.glEnable(gl.GL_NORMALIZE) 30 | y = entity.moveStrafing + (entity.moveForward - entity.moveStrafing) * a 31 | x = entity.randomYawVelocity - entity.moveForward * (1.0 - a) 32 | y = min(y, 1.0) 33 | self.__mainModel.render(x, y, 0.0, rotationYaw - renderYaw, 34 | rotationPitch, 1.0) 35 | if entity.hurtTime > 0 or entity.deathTime > 0: 36 | gl.glDisable(gl.GL_TEXTURE_2D) 37 | gl.glColor4f(1.0, 0.0, 0.0, 0.5) 38 | gl.glEnable(gl.GL_BLEND) 39 | gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) 40 | self.__mainModel.render(x, y, 0.0, rotationYaw - renderYaw, 41 | rotationPitch, 1.0) 42 | gl.glDisable(gl.GL_BLEND) 43 | gl.glEnable(gl.GL_TEXTURE_2D) 44 | 45 | gl.glDisable(gl.GL_NORMALIZE) 46 | except Exception as e: 47 | print(str(e)) 48 | 49 | gl.glPopMatrix() 50 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/entity/RenderManager.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.render.Tessellator import tessellator 2 | from mc.net.minecraft.client.render.entity.RenderEntity import RenderEntity 3 | from mc.net.minecraft.client.render.entity.RenderArrow import RenderArrow 4 | from mc.net.minecraft.client.render.entity.RenderLiving import RenderLiving 5 | from mc.net.minecraft.client.render.entity.RenderItem import RenderItem 6 | from mc.net.minecraft.client.render.entity.RenderTNTPrimed import RenderTNTPrimed 7 | from mc.net.minecraft.game.entity.Entity import Entity 8 | from mc.net.minecraft.game.entity.EntityLiving import EntityLiving 9 | from mc.net.minecraft.game.entity.misc.EntityItem import EntityItem 10 | from mc.net.minecraft.game.entity.misc.EntityTNTPrimed import EntityTNTPrimed 11 | from mc.net.minecraft.game.entity.projectile.EntityArrow import EntityArrow 12 | from mc.net.minecraft.game.level.block.Blocks import blocks 13 | from pyglet import gl 14 | 15 | class RenderManager: 16 | 17 | def __init__(self): 18 | self.worldObj = None 19 | self.renderEngine = None 20 | self.playerViewY = 0.0 21 | self.__entityRenderMap = {} 22 | self.__entityRenderMap[Entity] = RenderEntity() 23 | self.__entityRenderMap[EntityArrow] = RenderArrow() 24 | self.__entityRenderMap[EntityLiving] = RenderLiving() 25 | self.__entityRenderMap[EntityItem] = RenderItem() 26 | self.__entityRenderMap[EntityTNTPrimed] = RenderTNTPrimed() 27 | for render in self.__entityRenderMap.values(): 28 | render.setRenderManager(self) 29 | 30 | def renderEntity(self, entity, a): 31 | xd = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * a 32 | yd = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * a 33 | zd = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * a 34 | light = self.worldObj.getBlockLightValue( 35 | int(xd), 36 | int(yd + entity.getShadowSize()), 37 | int(zd) 38 | ) 39 | yaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * a 40 | gl.glColor3f(light, light, light) 41 | self.renderEntityWithPosYaw(entity, xd, yd, zd, yaw, a) 42 | 43 | def renderEntityWithPosYaw(self, entity, xd, yd, zd, yaw, a): 44 | render = self.__entityRenderMap.get(entity.__class__) 45 | if not render and entity.__class__ != Entity: 46 | render = self.__entityRenderMap.get(entity.__class__.__bases__[0]) 47 | self.__entityRenderMap[entity.__class__] = render 48 | 49 | if render: 50 | render.doRender(entity, xd, yd, zd, yaw, a) 51 | render.renderShadow(entity, xd, yd, zd, a) 52 | 53 | def changeWorld(self, world): 54 | self.worldObj = world 55 | 56 | def setPlayerViewY(self, a): 57 | p = self.worldObj.getPlayerEntity() 58 | self.playerViewY = p.prevRotationYaw + (p.rotationYaw - p.prevRotationYaw) * a 59 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/entity/RenderTNTPrimed.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.render.Tessellator import tessellator 2 | from mc.net.minecraft.client.render.entity.Render import Render 3 | from mc.net.minecraft.client.render.RenderBlocks import RenderBlocks 4 | from mc.net.minecraft.game.level.block.Blocks import blocks 5 | from pyglet import gl 6 | 7 | class RenderTNTPrimed(Render): 8 | __blockRenderer = RenderBlocks(tessellator) 9 | 10 | def doRender(self, entity, xd, yd, zd, yaw, a): 11 | gl.glPushMatrix() 12 | gl.glTranslatef(xd, yd, zd) 13 | if entity.fuse - a + 1.0 < 10.0: 14 | scale = 1.0 - (entity.fuse - a + 1.0) / 10.0 15 | scale = min(max(scale, 0.0), 1.0) 16 | scale *= scale 17 | scale *= scale 18 | scale = 1.0 + scale * 0.3 19 | gl.glScalef(scale, scale, scale) 20 | 21 | alpha = (1.0 - (entity.fuse - a + 1.0) / 100.0) * 0.8 22 | 23 | self._loadTexture('terrain.png') 24 | self.__blockRenderer.renderBlockOnInventory(blocks.tnt) 25 | if entity.fuse // 5 % 2 == 0: 26 | gl.glDisable(gl.GL_TEXTURE_2D) 27 | gl.glDisable(gl.GL_LIGHTING) 28 | gl.glEnable(gl.GL_BLEND) 29 | gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_DST_ALPHA) 30 | gl.glColor4f(1.0, 1.0, 1.0, alpha) 31 | self.__blockRenderer.renderBlockOnInventory(blocks.tnt) 32 | gl.glColor4f(1.0, 1.0, 1.0, 1.0) 33 | gl.glDisable(gl.GL_BLEND) 34 | gl.glEnable(gl.GL_LIGHTING) 35 | gl.glEnable(gl.GL_TEXTURE_2D) 36 | 37 | gl.glPopMatrix() 38 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/entity/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/render/entity/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/TextureFX.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cdef class TextureFX: 4 | 5 | cdef: 6 | public int iconIndex 7 | public list imageData 8 | public bint anaglyphEnabled 9 | public int textureId 10 | 11 | cpdef onTick(self) 12 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/TextureFX.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cdef class TextureFX: 4 | 5 | def __init__(self, tex): 6 | self.iconIndex = tex 7 | self.imageData = [0] * 1024 8 | self.anaglyphEnabled = False 9 | self.textureId = 0 10 | 11 | cpdef onTick(self): 12 | pass 13 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/TextureFlamesFX.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | # cython: cdivision=True, boundscheck=False, wraparound=False, nonecheck=False 3 | 4 | from libc.string cimport memcpy 5 | 6 | from mc.net.minecraft.client.render.texture.TextureFX cimport TextureFX 7 | from mc.net.minecraft.game.level.block.Blocks import blocks 8 | from mc.JavaUtils cimport random 9 | 10 | cdef class TextureFlamesFX(TextureFX): 11 | 12 | cdef: 13 | float __currentFireFrame[320] 14 | float __lastFireFrame[320] 15 | 16 | def __init__(self, idx): 17 | TextureFX.__init__(self, blocks.fire.blockIndexInTexture + (idx << 4)) 18 | for i in range(256): 19 | self.__currentFireFrame[i] = 0.0 20 | self.__lastFireFrame[i] = 0.0 21 | 22 | cpdef onTick(self): 23 | cdef int x, z, i, xx, zz, pixel, r, g, b, a, nr 24 | cdef float color 25 | cdef float frame[320] 26 | 27 | for x in range(16): 28 | for z in range(20): 29 | i = 18 30 | color = self.__currentFireFrame[x + ((z + 1) % 20 << 4)] * 18.0 31 | 32 | for xx in range(x - 1, x + 2): 33 | for zz in range(z, z + 2): 34 | if xx >= 0 and zz >= 0 and xx < 16 and zz < 20: 35 | color += self.__currentFireFrame[xx + (zz << 4)] 36 | 37 | i += 1 38 | 39 | self.__lastFireFrame[x + (z << 4)] = color / (i * 1.06) 40 | if z >= 19: 41 | self.__lastFireFrame[x + (z << 4)] = random() * random() * \ 42 | random() * 4.0 + \ 43 | random() * 0.1 + 0.2 44 | 45 | memcpy(frame, self.__lastFireFrame, sizeof(self.__lastFireFrame)) 46 | self.__lastFireFrame = self.__currentFireFrame 47 | self.__currentFireFrame = frame 48 | 49 | for pixel in range(256): 50 | color = self.__currentFireFrame[pixel] * 1.8 51 | if color > 1.0: 52 | color = 1.0 53 | 54 | if color < 0.0: 55 | color = 0.0 56 | 57 | r = (color * 155.0 + 100.0) 58 | g = (color * color * 255.0) 59 | b = (color * color * color * color * color * color * color * color * color * color * 255.0) 60 | a = 0 if color < 0.5 else 255 61 | if self.anaglyphEnabled: 62 | nr = (r * 30 + g * 59 + b * 11) // 100 63 | g = (r * 30 + g * 70) // 100 64 | b = (r * 30 + b * 70) // 100 65 | r = nr 66 | 67 | self.imageData[pixel << 2] = r 68 | self.imageData[(pixel << 2) + 1] = g 69 | self.imageData[(pixel << 2) + 2] = b 70 | self.imageData[(pixel << 2) + 3] = a 71 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/TextureGearsFX.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | # cython: cdivision=True, boundscheck=False, wraparound=False, nonecheck=False 3 | 4 | from libc.math cimport sin, cos, pi 5 | 6 | from mc.net.minecraft.client.render.texture.TextureFX cimport TextureFX 7 | from mc.net.minecraft.game.level.block.Blocks import blocks 8 | from mc.JavaUtils cimport random 9 | from mc import Resources 10 | 11 | cdef class TextureGearsFX(TextureFX): 12 | 13 | cdef: 14 | int __gearRotation 15 | int __gearColor[1024] 16 | int __gearMiddleColor[1024] 17 | int __gearRotationDir 18 | 19 | def __init__(self, idx): 20 | TextureFX.__init__(self, blocks.cog.blockIndexInTexture + idx) 21 | self.__gearRotationDir = (idx << 1) - 1 22 | self.__gearRotation = 2 23 | 24 | color = Resources.textures['misc/gear.png'][2] 25 | for i in range(len(color)): 26 | self.__gearColor[i] = color[i] 27 | 28 | color = Resources.textures['misc/gearmiddle.png'][2] 29 | for i in range(len(color)): 30 | self.__gearMiddleColor[i] = color[i] 31 | 32 | cpdef onTick(self): 33 | cdef int pixelX, pixelY, texX, texY, color, midColor, r, g, b, a, pixel 34 | cdef float x, y, gearX, gearY, gearXT, gearYT 35 | 36 | self.__gearRotation += self.__gearRotationDir & 63 37 | x = sin(self.__gearRotation / 64.0 * pi * 2.0) 38 | y = cos(self.__gearRotation / 64.0 * pi * 2.0) 39 | 40 | for pixelX in range(16): 41 | for pixelY in range(16): 42 | gearX = (pixelX / 15.0 - 0.5) * 31.0 43 | gearY = (pixelY / 15.0 - 0.5) * 31.0 44 | gearXT = y * gearX - x * gearY 45 | gearYT = y * gearY + x * gearX 46 | texX = (gearXT + 16.0) 47 | texY = (gearYT + 16.0) 48 | color = 0 49 | if texX >= 0 and texY >= 0 and texX < 32 and texY < 32: 50 | color = self.__gearColor[texX + (texY << 5)] 51 | midColor = self.__gearMiddleColor[pixelX + (pixelY << 4)] 52 | if ((midColor % 0x100000000) >> 24) > 128: 53 | color = midColor 54 | 55 | r = (color >> 16 & 255) 56 | g = (color >> 8 & 255) 57 | b = (color & 255) 58 | a = 255 if ((color % 0x100000000) >> 24) > 128 else 0 59 | pixel = pixelX + (pixelY << 4) 60 | self.imageData[pixel << 2] = r 61 | self.imageData[(pixel << 2) + 1] = g 62 | self.imageData[(pixel << 2) + 2] = b 63 | self.imageData[(pixel << 2) + 3] = a 64 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/TextureLavaFX.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | # cython: cdivision=True, boundscheck=False, wraparound=False, nonecheck=False 3 | 4 | from libc.string cimport memcpy 5 | from libc.math cimport sin, pi 6 | 7 | from mc.net.minecraft.client.render.texture.TextureFX cimport TextureFX 8 | from mc.net.minecraft.game.level.block.Blocks import blocks 9 | from mc.JavaUtils cimport random 10 | 11 | cdef class TextureLavaFX(TextureFX): 12 | 13 | cdef: 14 | float __red[256] 15 | float __green[256] 16 | float __blue[256] 17 | float __alpha[256] 18 | 19 | def __init__(self): 20 | TextureFX.__init__(self, blocks.lavaMoving.blockIndexInTexture) 21 | for i in range(256): 22 | self.__red[i] = 0.0 23 | self.__green[i] = 0.0 24 | self.__blue[i] = 0.0 25 | self.__alpha[i] = 0.0 26 | 27 | cpdef onTick(self): 28 | cdef int x, z, y0, y1, xx, zz, pixel, r, g, b, nr 29 | cdef float color 30 | cdef float red[256] 31 | 32 | for x in range(16): 33 | for z in range(16): 34 | color = 0.0 35 | y0 = (sin(z * pi * 2.0 / 16.0) * 1.2) 36 | y1 = (sin(x * pi * 2.0 / 16.0) * 1.2) 37 | 38 | for xx in range(x - 1, x + 2): 39 | for zz in range(z - 1, z + 2): 40 | color += self.__red[(xx + y0 & 15) + ((zz + y1 & 15) << 4)] 41 | 42 | self.__green[x + (z << 4)] = color / 10.0 + (self.__blue[(x & 15) + \ 43 | ((z & 15) << 4)] + \ 44 | self.__blue[(x + 1 & 15) + ((z & 15) << 4)] + \ 45 | self.__blue[(x + 1 & 15) + ((z + 1 & 15) << 4)] + \ 46 | self.__blue[(x & 15) + ((z + 1 & 15) << 4)]) / 4.0 * 0.8 47 | self.__blue[x + (z << 4)] += self.__alpha[x + (z << 4)] * 0.01 48 | if self.__blue[x + (z << 4)] < 0.0: 49 | self.__blue[x + (z << 4)] = 0.0 50 | 51 | self.__alpha[x + (z << 4)] -= 0.06 52 | if random() < 0.005: 53 | self.__alpha[x + (z << 4)] = 1.5 54 | 55 | memcpy(red, self.__green, sizeof(self.__green)) 56 | self.__green = self.__red 57 | self.__red = red 58 | 59 | for pixel in range(256): 60 | color = self.__red[pixel] * 2.0 61 | if color > 1.0: 62 | color = 1.0 63 | 64 | if color < 0.0: 65 | color = 0.0 66 | 67 | r = (color * 100.0 + 155.0) 68 | g = (color * color * 255.0) 69 | b = (color * color * color * color * 128.0) 70 | if self.anaglyphEnabled: 71 | nr = (r * 30 + g * 59 + b * 11) // 100 72 | g = (r * 30 + g * 70) // 100 73 | b = (r * 30 + b * 70) // 100 74 | r = nr 75 | 76 | self.imageData[pixel << 2] = r 77 | self.imageData[(pixel << 2) + 1] = g 78 | self.imageData[(pixel << 2) + 2] = b 79 | self.imageData[(pixel << 2) + 3] = -1 80 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/TextureWaterFX.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | # cython: cdivision=True, boundscheck=False, wraparound=False, nonecheck=False 3 | 4 | from libc.string cimport memcpy 5 | 6 | from mc.net.minecraft.client.render.texture.TextureFX cimport TextureFX 7 | from mc.net.minecraft.game.level.block.Blocks import blocks 8 | from mc.JavaUtils cimport random 9 | 10 | cdef class TextureWaterFX(TextureFX): 11 | 12 | cdef: 13 | float __red[256] 14 | float __green[256] 15 | float __blue[256] 16 | float __alpha[256] 17 | int __tickCounter 18 | 19 | def __init__(self): 20 | TextureFX.__init__(self, blocks.waterMoving.blockIndexInTexture) 21 | for i in range(256): 22 | self.__red[i] = 0.0 23 | self.__green[i] = 0.0 24 | self.__blue[i] = 0.0 25 | self.__alpha[i] = 0.0 26 | 27 | self.__tickCounter = 0 28 | 29 | cpdef onTick(self): 30 | cdef int x, z, y, pixel, r, g, b, a, nr 31 | cdef float color 32 | cdef float red[256] 33 | 34 | self.__tickCounter += 1 35 | 36 | for x in range(16): 37 | for z in range(16): 38 | color = 0.0 39 | for y in range(x - 1, x + 2): 40 | color += self.__red[(y & 15) + ((z & 15) << 4)] 41 | 42 | self.__green[x + (z << 4)] = color / 3.3 + self.__blue[x + (z << 4)] * 0.8 43 | 44 | for x in range(16): 45 | for z in range(16): 46 | self.__blue[x + (z << 4)] += self.__alpha[x + (z << 4)] * 0.05 47 | if self.__blue[x + (z << 4)] < 0.0: 48 | self.__blue[x + (z << 4)] = 0.0 49 | 50 | self.__alpha[x + (z << 4)] -= 0.1 51 | if random() < 0.05: 52 | self.__alpha[x + (z << 4)] = 0.5 53 | 54 | memcpy(red, self.__green, sizeof(self.__green)) 55 | self.__green = self.__red 56 | self.__red = red 57 | 58 | for pixel in range(256): 59 | color = self.__red[pixel] 60 | if color > 1.0: 61 | color = 1.0 62 | 63 | if color < 0.0: 64 | color = 0.0 65 | 66 | color *= color 67 | r = (32.0 + color * 32.0) 68 | g = (50.0 + color * 64.0) 69 | b = 255 70 | a = (146.0 + color * 50.0) 71 | if self.anaglyphEnabled: 72 | nr = (r * 30 + g * 59 + 2805) // 100 73 | g = (r * 30 + g * 70) // 100 74 | b = (r * 30 + 17850) // 100 75 | r = nr 76 | 77 | self.imageData[pixel << 2] = r 78 | self.imageData[(pixel << 2) + 1] = g 79 | self.imageData[(pixel << 2) + 2] = b 80 | self.imageData[(pixel << 2) + 3] = a 81 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/TextureWaterFlowFX.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | # cython: cdivision=True, boundscheck=False, wraparound=False, nonecheck=False 3 | 4 | from libc.string cimport memcpy 5 | 6 | from mc.net.minecraft.client.render.texture.TextureFX cimport TextureFX 7 | from mc.net.minecraft.game.level.block.Blocks import blocks 8 | from mc.JavaUtils cimport random 9 | 10 | cdef class TextureWaterFlowFX(TextureFX): 11 | 12 | cdef: 13 | float __red[256] 14 | float __green[256] 15 | float __blue[256] 16 | float __alpha[256] 17 | int __tickCounter 18 | 19 | def __init__(self): 20 | TextureFX.__init__(self, blocks.waterMoving.blockIndexInTexture + 32) 21 | for i in range(256): 22 | self.__red[i] = 0.0 23 | self.__green[i] = 0.0 24 | self.__blue[i] = 0.0 25 | self.__alpha[i] = 0.0 26 | 27 | self.__tickCounter = 0 28 | 29 | cpdef onTick(self): 30 | cdef int x, z, y, r, g, b, a, nr 31 | cdef float color 32 | cdef float red[256] 33 | 34 | self.__tickCounter += 1 35 | 36 | for x in range(16): 37 | for z in range(16): 38 | color = 0.0 39 | for y in range(z - 2, z + 1): 40 | color += self.__red[(x & 15) + ((y & 15) << 4)] 41 | 42 | self.__green[x + (z << 4)] = color / 3.2 + self.__blue[x + (z << 4)] * 0.8 43 | 44 | for x in range(16): 45 | for z in range(16): 46 | self.__blue[x + (z << 4)] += self.__alpha[x + (z << 4)] * 0.05 47 | if self.__blue[x + (z << 4)] < 0.0: 48 | self.__blue[x + (z << 4)] = 0.0 49 | 50 | self.__alpha[x + (z << 4)] -= 0.3 51 | if random() < 0.2: 52 | self.__alpha[x + (z << 4)] = 0.5 53 | 54 | memcpy(red, self.__green, sizeof(self.__green)) 55 | self.__green = self.__red 56 | self.__red = red 57 | 58 | for pixel in range(256): 59 | color = self.__red[pixel] 60 | if color > 1.0: 61 | color = 1.0 62 | 63 | if color < 0.0: 64 | color = 0.0 65 | 66 | color *= color 67 | r = (32.0 + color * 32.0) 68 | g = (50.0 + color * 64.0) 69 | b = 255 70 | a = (146.0 + color * 50.0) 71 | if self.anaglyphEnabled: 72 | nr = (r * 30 + g * 59 + 2805) // 100 73 | g = (r * 30 + g * 70) // 100 74 | b = (r * 30 + 17850) // 100 75 | r = nr 76 | 77 | self.imageData[pixel << 2] = r 78 | self.imageData[(pixel << 2) + 1] = g 79 | self.imageData[(pixel << 2) + 2] = b 80 | self.imageData[(pixel << 2) + 3] = a 81 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/render/texture/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/render/texture/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/client/sound/SoundPool.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.client.sound.SoundPoolEntry import SoundPoolEntry 2 | from mc.JavaUtils import Random 3 | 4 | class SoundPool: 5 | 6 | def __init__(self): 7 | self.__rand = Random() 8 | self.__nameToSoundPoolEntriesMapping = {} 9 | self.numberOfSoundPoolEntries = 0 10 | 11 | def addSound(self, soundUrl, file): 12 | try: 13 | sound = soundUrl[0:-4].replace('/', '.') 14 | while sound[-1].isdigit(): 15 | sound = sound[0:-1] 16 | 17 | if sound not in self.__nameToSoundPoolEntriesMapping: 18 | self.__nameToSoundPoolEntriesMapping[sound] = [] 19 | 20 | entry = SoundPoolEntry(soundUrl, file) 21 | self.__nameToSoundPoolEntriesMapping[sound].append(entry) 22 | self.numberOfSoundPoolEntries += 1 23 | return entry 24 | except Exception as e: 25 | raise RuntimeError(e) 26 | 27 | def getRandomSoundFromSoundPool(self, name): 28 | entries = self.__nameToSoundPoolEntriesMapping.get(name) 29 | return entries[self.__rand.nextInt(len(entries))] if entries else None 30 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/sound/SoundPoolEntry.py: -------------------------------------------------------------------------------- 1 | from pyglet import media 2 | 3 | class SoundPoolEntry: 4 | 5 | def __init__(self, name, url): 6 | self.soundName = name 7 | self.soundUrl = url 8 | self.stream = media.load(url, streaming=False) 9 | -------------------------------------------------------------------------------- /mc/net/minecraft/client/sound/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/client/sound/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/Inventory.py: -------------------------------------------------------------------------------- 1 | class Inventory: 2 | 3 | def getSizeInventory(self): 4 | return 0 5 | 6 | def getStackInSlot(self, slot): 7 | return None 8 | 9 | def decrStackSize(self, slot, size): 10 | return None 11 | 12 | def setInventorySlotContents(self, slot, stack): 13 | pass 14 | 15 | def getInvName(self): 16 | return '' 17 | 18 | def getInventoryStackLimit(self): 19 | return 0 20 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/InventoryLargeChest.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.Inventory import Inventory 2 | 3 | class InventoryLargeChest(Inventory): 4 | 5 | def __init__(self, name, upperChest, lowerChest): 6 | self.__name = name 7 | self.__upperChest = upperChest 8 | self.__lowerChest = lowerChest 9 | 10 | def getSizeInventory(self): 11 | return self.__upperChest.getSizeInventory() + \ 12 | self.__lowerChest.getSizeInventory() 13 | 14 | def getInvName(self): 15 | return self.__name 16 | 17 | def getStackInSlot(self, slot): 18 | if slot >= self.__upperChest.getSizeInventory(): 19 | return self.__lowerChest.getStackInSlot( 20 | slot - self.__upperChest.getSizeInventory() 21 | ) 22 | else: 23 | return self.__upperChest.getStackInSlot(slot) 24 | 25 | def decrStackSize(self, slot, size): 26 | if slot >= self.__upperChest.getSizeInventory(): 27 | return self.__lowerChest.decrStackSize(slot - self.__upperChest.getSizeInventory(), size) 28 | else: 29 | return self.__upperChest.decrStackSize(slot, size) 30 | 31 | def setInventorySlotContents(self, slot, stack): 32 | if slot >= self.__upperChest.getSizeInventory(): 33 | self.__lowerChest.setInventorySlotContents( 34 | slot - self.__upperChest.getSizeInventory(), stack 35 | ) 36 | else: 37 | self.__upperChest.setInventorySlotContents(slot, stack) 38 | 39 | def getInventoryStackLimit(self): 40 | return self.__upperChest.getInventoryStackLimit() 41 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/AILiving.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.entity.Entity cimport Entity 4 | from mc.net.minecraft.game.entity.EntityLiving cimport EntityLiving 5 | from mc.net.minecraft.game.level.World cimport World 6 | from mc.JavaUtils cimport Random 7 | 8 | cdef class AILiving: 9 | 10 | cdef: 11 | Random __rand 12 | public float _moveStrafing 13 | public float _moveForward 14 | float __randomYawVelocity 15 | EntityLiving __entityLiving 16 | public bint _isJumping 17 | int __fire 18 | float __moveSpeed 19 | int __entityAge 20 | Entity __playerToAttack 21 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/Entity.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.physics.AxisAlignedBB cimport AxisAlignedBB 4 | from mc.net.minecraft.game.level.World cimport World 5 | from mc.JavaUtils cimport Random 6 | 7 | cdef class Entity: 8 | 9 | cdef: 10 | public float posX 11 | public float posY 12 | public float posZ 13 | public float prevPosX 14 | public float prevPosY 15 | public float prevPosZ 16 | public float motionX 17 | public float motionY 18 | public float motionZ 19 | public float rotationYaw 20 | public float rotationPitch 21 | public float prevRotationYaw 22 | public float prevRotationPitch 23 | 24 | public bint preventEntitySpawning 25 | public World _worldObj 26 | public AxisAlignedBB boundingBox 27 | public bint onGround 28 | public bint isCollidedHorizontally 29 | bint __surfaceCollision 30 | public bint isDead 31 | 32 | public float yOffset 33 | public float width 34 | public float height 35 | 36 | public float prevDistanceWalkedModified 37 | public float distanceWalkedModified 38 | public bint _canTriggerWalking 39 | float __fallDistance 40 | int __nextStepDistance 41 | 42 | public float lastTickPosX 43 | public float lastTickPosY 44 | public float lastTickPosZ 45 | 46 | float __ySize 47 | public float stepHeight 48 | public bint noClip 49 | float __entityCollisionReduction 50 | public Random _rand 51 | public int ticksExisted 52 | 53 | public int fireResistance 54 | public int fire 55 | public int _maxAir 56 | bint __inWater 57 | public int heartsLife 58 | public int air 59 | 60 | cdef bint isOffsetPositionInLiquid(self, float xa, float ya, float za) 61 | cpdef moveEntity(self, float x, float y, float z) 62 | cdef _fall(self, float distance) 63 | cpdef bint handleWaterMovement(self) 64 | cdef bint handleLavaMovement(self) 65 | cpdef moveFlying(self, float xa, float za, float speed) 66 | cpdef float getBrightness(self, float a) 67 | cdef applyEntityCollision(self, entity) 68 | cdef bint shouldRenderAtSqrDistance(self, float d) 69 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/EntityLiving.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.entity.Entity cimport Entity 4 | from mc.net.minecraft.game.entity.AILiving cimport AILiving 5 | 6 | cdef class EntityLiving(Entity): 7 | 8 | cdef: 9 | public int heartsHalvesLife 10 | public float renderYawOffset 11 | public float prevRenderYawOffset 12 | float __prevRotationYawHead 13 | float __rotationYawHead 14 | public str texture 15 | public int health 16 | public int prevHealth 17 | public int hurtTime 18 | public int maxHurtTime 19 | public float attackedAtYaw 20 | public int deathTime 21 | int __attackTime 22 | public float prevCameraPitch 23 | public float cameraPitch 24 | public AILiving _entityAI 25 | public float moveStrafing 26 | public float moveForward 27 | public float randomYawVelocity 28 | 29 | cdef _fall(self, float d) 30 | cdef travel(self, float x, float z) 31 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/entity/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/misc/EntityTNTPrimed.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.entity.Entity import Entity 2 | from mc.JavaUtils import random 3 | 4 | from nbtlib.tag import Byte 5 | 6 | import math 7 | 8 | class EntityTNTPrimed(Entity): 9 | 10 | def __init__(self, world, x, y, z): 11 | super().__init__(world) 12 | self.preventEntitySpawning = True 13 | self.setSize(0.98, 0.98) 14 | self.yOffset = self.height / 2.0 15 | self.setPosition(x, y, z) 16 | r = random() * math.pi * 2.0 17 | self.motionX = -math.sin(r * math.pi / 180.0) * 0.02 18 | self.motionY = 0.2 19 | self.motionZ = -math.cos(r * math.pi / 180.0) * 0.02 20 | self._canTriggerWalking = False 21 | self.fuse = 80 22 | self.prevPosX = x 23 | self.prevPosY = y 24 | self.prevPosZ = z 25 | 26 | def canBeCollidedWith(self): 27 | return not self.isDead 28 | 29 | def onEntityUpdate(self): 30 | self.prevPosX = self.posX 31 | self.prevPosY = self.posY 32 | self.prevPosZ = self.posZ 33 | self.motionY -= 0.04 34 | self.moveEntity(self.motionX, self.motionY, self.motionZ) 35 | self.motionX *= 0.98 36 | self.motionY *= 0.98 37 | self.motionZ *= 0.98 38 | if self.onGround: 39 | self.motionX *= 0.7 40 | self.motionZ *= 0.7 41 | self.motionY *= -0.5 42 | 43 | if self.fuse <= 0: 44 | self._worldObj.playSoundAtEntity( 45 | self, 'random.explode', 4.0, 46 | (1.0 + (self._rand.nextFloat() - self._rand.nextFloat()) * 0.2) * 0.7 47 | ) 48 | self.setEntityDead() 49 | self._worldObj.createExplosion( 50 | None, self.posX, self.posY, self.posZ, 4.0 51 | ) 52 | else: 53 | self._worldObj.spawnParticle( 54 | 'smoke', self.posX, self.posY + 0.5, self.posZ, 0.0, 0.0, 0.0 55 | ) 56 | 57 | self.fuse -= 1 58 | 59 | def _writeEntityToNBT(self, compound): 60 | compound['Fuse'] = Byte(self.fuse) 61 | 62 | def _readEntityFromNBT(self, compound): 63 | self.fuse = compound['Fuse'].real 64 | 65 | def _getEntityString(self): 66 | return 'PrimedTnt' 67 | 68 | def getShadowSize(self): 69 | return 0.0 70 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/misc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/entity/misc/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/player/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/entity/player/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/entity/projectile/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/entity/projectile/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/Item.py: -------------------------------------------------------------------------------- 1 | from mc.JavaUtils import Random 2 | 3 | class Item: 4 | TOTAL_STACK_SIZE = 100 5 | MAX_DAMAGE = 32 6 | _rand = Random() 7 | 8 | def __init__(self, items, itemId): 9 | self.items = items 10 | self.shiftedIndex = itemId + 256 11 | items.itemsList[itemId + 256] = self 12 | self._maxStackSize = Item.TOTAL_STACK_SIZE 13 | self._maxDamage = Item.MAX_DAMAGE 14 | 15 | def setIconIndex(self, iconIndex): 16 | self._iconIndex = iconIndex 17 | return self 18 | 19 | def getIconIndex(self): 20 | return self._iconIndex 21 | 22 | def onItemUse(self, stack, world, x, y, z, sideHit): 23 | pass 24 | 25 | def getStrVsBlock(self, block): 26 | return 1.0 27 | 28 | def onItemRightClick(self, stack, world, player): 29 | return stack 30 | 31 | def getItemStackLimit(self): 32 | return self._maxStackSize 33 | 34 | def onPlaced(self, world, x, y, z): 35 | return False 36 | 37 | def getMaxDamage(self): 38 | return self._maxDamage 39 | 40 | def hitEntity(self, stack): 41 | pass 42 | 43 | def onBlockDestroyed(self, stack): 44 | pass 45 | 46 | def getItemDamage(self): 47 | return 1 48 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemAxe.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.ItemTool import ItemTool 2 | from mc.net.minecraft.game.level.block.Blocks import blocks 3 | 4 | class ItemAxe(ItemTool): 5 | __blocksEffectiveAgainst = (blocks.planks, blocks.bookShelf, 6 | blocks.wood, blocks.chest) 7 | 8 | def __init__(self, items, itemId, damage): 9 | super().__init__(items, itemId, damage, self.__blocksEffectiveAgainst) 10 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemBlock.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Blocks import blocks 2 | from mc.net.minecraft.game.item.Item import Item 3 | 4 | class ItemBlock(Item): 5 | 6 | def __init__(self, items, itemId): 7 | super().__init__(items, itemId) 8 | self.__blockID = itemId + 256 9 | self.setIconIndex(blocks.blocksList[itemId + 256].getBlockTexture(2)) 10 | 11 | def onItemUse(self, stack, world, x, y, z, sideHit): 12 | if sideHit == 0: y -= 1 13 | if sideHit == 1: y += 1 14 | if sideHit == 2: z -= 1 15 | if sideHit == 3: z += 1 16 | if sideHit == 4: x -= 1 17 | if sideHit == 5: x += 1 18 | 19 | if not stack.stackSize: 20 | return 21 | 22 | if x <= 0 or y <= 0 or z <= 0 or x >= world.width - 1 or y >= world.height - 1 or z >= world.length - 1: 23 | return 24 | 25 | block = blocks.blocksList[world.getBlockId(x, y, z)] 26 | if self.__blockID <= 0 or block and block != blocks.waterMoving and \ 27 | block != blocks.waterStill and block != blocks.lavaMoving and \ 28 | block != blocks.lavaStill and block != blocks.fire: 29 | return 30 | 31 | block = blocks.blocksList[self.__blockID] 32 | aabb = block.getCollisionBoundingBoxFromPool(x, y, z) 33 | if not world.checkIfAABBIsClear(aabb) or not block.canPlaceBlockAt(world, x, y, z): 34 | return 35 | 36 | world.setBlockWithNotify(x, y, z, self.__blockID) 37 | x += 0.5 38 | y += 0.5 39 | z += 0.5 40 | name = 'step.' + block.stepSound.soundDir 41 | volume = (block.stepSound.soundVolume + 1.0) / 2.0 42 | world.playSoundEffect(x, y, z, name, volume, block.stepSound.soundPitch * 0.8) 43 | stack.stackSize -= 1 44 | 45 | def onPlaced(self, world, x, y, z): 46 | return blocks.blocksList[self.__blockID].onBlockPlaced(world, x, y, z) 47 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemBow.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.entity.projectile.EntityArrow import EntityArrow 2 | from mc.net.minecraft.game.item.Item import Item 3 | 4 | class ItemBow(Item): 5 | 6 | def __init__(self, items, itemId): 7 | super().__init__(items, 5) 8 | self._maxStackSize = 1 9 | 10 | def onItemRightClick(self, stack, world, player): 11 | if player.inventory.consumeInventoryItem(self.items.arrow.shiftedIndex): 12 | world.playSoundAtEntity( 13 | player, 'random.bow', 1.0, 14 | 1.0 / (self._rand.nextFloat() * 0.4 + 0.8) 15 | ) 16 | world.spawnEntityInWorld(EntityArrow(world, player)) 17 | 18 | return stack 19 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemFlintAndSteel.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Blocks import blocks 2 | from mc.net.minecraft.game.item.Item import Item 3 | 4 | class ItemFlintAndSteel(Item): 5 | 6 | def __init__(self, items, itemId): 7 | super().__init__(items, 3) 8 | self._maxStackSize = 1 9 | self._maxDamage = 64 10 | 11 | def onItemUse(self, stack, world, x, y, z, sideHit): 12 | if sideHit == 0: y -= 1 13 | if sideHit == 1: y += 1 14 | if sideHit == 2: z -= 1 15 | if sideHit == 3: z += 1 16 | if sideHit == 4: x -= 1 17 | if sideHit == 5: x += 1 18 | 19 | if x <= 0 or y <= 0 or z <= 0 or x >= world.width - 1 or y >= world.height - 1 or z >= world.length - 1: 20 | return 21 | 22 | blockId = world.getBlockId(x, y, z) 23 | if blockId == 0: 24 | world.setBlockWithNotify(x, y, z, blocks.fire.blockID) 25 | 26 | stack.damageItem(1) 27 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemFood.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.Item import Item 2 | 3 | class ItemFood(Item): 4 | 5 | def __init__(self, items, itemId, healAmount): 6 | super().__init__(items, itemId) 7 | self.__healAmount = healAmount 8 | self._maxStackSize = 1 9 | 10 | def onItemRightClick(self, stack, world, player): 11 | stack.stackSize -= 1 12 | if player.health > 0: 13 | player.health += self.__healAmount 14 | if player.health > player.HEALTH: 15 | player.health = player.HEALTH 16 | 17 | player.heartsLife = player.heartsHalvesLife // 2 18 | 19 | return stack 20 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemPickaxe.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.ItemTool import ItemTool 2 | from mc.net.minecraft.game.level.block.Blocks import blocks 3 | 4 | class ItemPickaxe(ItemTool): 5 | __blocksEffectiveAgainst = (blocks.cobblestone, blocks.stairDouble, blocks.stairSingle, 6 | blocks.stone, blocks.cobblestoneMossy, blocks.oreIron, 7 | blocks.blockSteel, blocks.oreCoal, blocks.blockGold, 8 | blocks.oreGold, blocks.oreDiamond, blocks.blockDiamond) 9 | 10 | def __init__(self, items, itemId, damage): 11 | super().__init__(items, itemId, damage, self.__blocksEffectiveAgainst) 12 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemSoup.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.ItemFood import ItemFood 2 | 3 | class ItemSoup(ItemFood): 4 | 5 | def __init__(self, items, itemId, healAmount): 6 | super().__init__(items, 26, 8) 7 | 8 | def onItemRightClick(self, stack, world, player): 9 | from mc.net.minecraft.game.item.ItemStack import ItemStack 10 | super().onItemRightClick(stack, world, player) 11 | return ItemStack(self.items.bowlEmpty) 12 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemSpade.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.ItemTool import ItemTool 2 | from mc.net.minecraft.game.level.block.Blocks import blocks 3 | 4 | class ItemSpade(ItemTool): 5 | __blocksEffectiveAgainst = (blocks.grass, blocks.dirt, blocks.sand, blocks.gravel) 6 | 7 | def __init__(self, items, itemId, damage): 8 | super().__init__(items, itemId, damage, self.__blocksEffectiveAgainst) 9 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemStack.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.Items import items 2 | 3 | from nbtlib.tag import Compound, Short, Byte 4 | 5 | class ItemStack: 6 | 7 | def __init__(self, obj, stackSize=1, damage=0): 8 | self.stackSize = stackSize 9 | self.itemDamage = damage 10 | self.animationsToGo = 0 11 | if hasattr(obj, 'blockID'): 12 | self.itemID = obj.blockID 13 | elif isinstance(obj, int): 14 | self.itemID = obj 15 | elif isinstance(obj, Compound): 16 | compound = obj 17 | self.itemID = compound['id'].real 18 | self.stackSize = compound['Count'].real 19 | self.itemDamage = compound['Damage'].real 20 | elif hasattr(obj, 'shiftedIndex'): 21 | self.itemID = obj.shiftedIndex 22 | 23 | def splitStack(self, portion): 24 | self.stackSize -= portion 25 | return ItemStack(self.itemID, portion, self.itemDamage) 26 | 27 | def getItem(self): 28 | return items.itemsList[self.itemID] 29 | 30 | def writeToNBT(self, compound): 31 | compound['id'] = Short(self.itemID) 32 | compound['Count'] = Byte(self.stackSize) 33 | compound['Damage'] = Short(self.itemDamage) 34 | return compound 35 | 36 | def isItemStackDamageable(self): 37 | return items.itemsList[self.itemID].getMaxDamage() 38 | 39 | def damageItem(self, damage): 40 | self.itemDamage += damage 41 | if self.itemDamage > self.isItemStackDamageable(): 42 | self.stackSize = max(0, self.stackSize - 1) 43 | self.itemDamage = 0 44 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemSword.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.Item import Item 2 | 3 | class ItemSword(Item): 4 | 5 | def __init__(self, items, itemId, damage): 6 | super().__init__(items, itemId) 7 | self._maxStackSize = 1 8 | self._maxDamage = 32 << damage 9 | self.__weaponDamage = 4 * (damage + 1) 10 | 11 | def getStrVsBlock(self, block): 12 | return 1.5 13 | 14 | def hitEntity(self, stack): 15 | stack.damageItem(1) 16 | 17 | def onBlockDestroyed(self, stack): 18 | stack.damageItem(2) 19 | 20 | def getItemDamage(self): 21 | return self.__weaponDamage 22 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/ItemTool.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.Item import Item 2 | 3 | class ItemTool(Item): 4 | 5 | def __init__(self, items, itemId, damage, affectedBlocks): 6 | super().__init__(items, itemId) 7 | self.__blocksEffectiveAgainst = affectedBlocks 8 | self._maxStackSize = 1 9 | self._maxDamage = 32 << damage 10 | self.__efficiencyOnProperMaterial = damage + 1 << 1 11 | 12 | def getStrVsBlock(self, block): 13 | for b in self.__blocksEffectiveAgainst: 14 | if b == block: 15 | return self.__efficiencyOnProperMaterial 16 | 17 | return 1.0 18 | 19 | def hitEntity(self, stack): 20 | stack.damageItem(2) 21 | 22 | def onBlockDestroyed(self, stack): 23 | stack.damageItem(1) 24 | 25 | def getItemDamage(self): 26 | return 0 27 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/Items.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.ItemFlintAndSteel import ItemFlintAndSteel 2 | from mc.net.minecraft.game.item.ItemPickaxe import ItemPickaxe 3 | from mc.net.minecraft.game.item.ItemSword import ItemSword 4 | from mc.net.minecraft.game.item.ItemSpade import ItemSpade 5 | from mc.net.minecraft.game.item.ItemSoup import ItemSoup 6 | from mc.net.minecraft.game.item.ItemBlock import ItemBlock 7 | from mc.net.minecraft.game.item.ItemFood import ItemFood 8 | from mc.net.minecraft.game.item.ItemAxe import ItemAxe 9 | from mc.net.minecraft.game.item.ItemBow import ItemBow 10 | from mc.net.minecraft.game.item.Item import Item 11 | from mc.net.minecraft.game.level.block.Blocks import blocks 12 | 13 | class Items: 14 | 15 | def __init__(self): 16 | self.itemsList = [None] * 1024 17 | 18 | self.shovel = ItemSpade(self, 0, 2).setIconIndex(82) 19 | self.pickaxeSteel = ItemPickaxe(self, 1, 2).setIconIndex(98) 20 | self.axeSteel = ItemAxe(self, 2, 2).setIconIndex(114) 21 | 22 | self.flintSteel = ItemFlintAndSteel(self, 3).setIconIndex(5) 23 | 24 | apple = ItemFood(self, 4, 4).setIconIndex(4) 25 | 26 | self.bow = ItemBow(self, 5).setIconIndex(21) 27 | 28 | self.arrow = Item(self, 6).setIconIndex(37) 29 | self.coal = Item(self, 7).setIconIndex(7) 30 | self.diamond = Item(self, 8).setIconIndex(55) 31 | self.ingotIron = Item(self, 9).setIconIndex(23) 32 | self.ingotGold = Item(self, 10).setIconIndex(39) 33 | 34 | self.swordSteel = ItemSword(self, 11, 2).setIconIndex(66) 35 | self.swordWood = ItemSword(self, 12, 0).setIconIndex(64) 36 | self.shovelWood = ItemSpade(self, 13, 0).setIconIndex(80) 37 | self.pickaxeWood = ItemPickaxe(self, 14, 0).setIconIndex(96) 38 | self.axeWood = ItemAxe(self, 15, 0).setIconIndex(112) 39 | 40 | self.swordStone = ItemSword(self, 16, 1).setIconIndex(65) 41 | self.shovelStone = ItemSpade(self, 17, 1).setIconIndex(81) 42 | self.pickaxeStone = ItemPickaxe(self, 18, 1).setIconIndex(97) 43 | self.axeStone = ItemAxe(self, 19, 1).setIconIndex(113) 44 | 45 | self.swordDiamond = ItemSword(self, 20, 3).setIconIndex(67) 46 | self.shovelDiamond = ItemSpade(self, 21, 3).setIconIndex(83) 47 | self.pickaxeDiamond = ItemPickaxe(self, 22, 3).setIconIndex(99) 48 | self.axeDiamond = ItemAxe(self, 23, 3).setIconIndex(115) 49 | 50 | self.stick = Item(self, 24).setIconIndex(53) 51 | 52 | self.bowlEmpty = Item(self, 25).setIconIndex(71) 53 | self.bowlSoup = ItemSoup(self, 26, 8).setIconIndex(72) 54 | 55 | self.swordGold = ItemSword(self, 27, 0).setIconIndex(68) 56 | self.shovelGold = ItemSpade(self, 28, 0).setIconIndex(84) 57 | self.pickaxeGold = ItemPickaxe(self, 29, 0).setIconIndex(100) 58 | self.axeGold = ItemAxe(self, 30, 0).setIconIndex(116) 59 | 60 | self.silk = Item(self, 31).setIconIndex(8) 61 | self.feather = Item(self, 32).setIconIndex(24) 62 | 63 | self.gunpowder = Item(self, 33).setIconIndex(40) 64 | 65 | for i in range(256): 66 | if blocks.blocksList[i]: 67 | self.itemsList[i] = ItemBlock(self, i - 256) 68 | 69 | items = Items() 70 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/item/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/RecipeSorter.py: -------------------------------------------------------------------------------- 1 | class RecipeSorter: 2 | 3 | def __init__(self, craftingManager): 4 | pass 5 | 6 | def compare(self, recipe1, recipe2): 7 | if recipe2.getSize() < recipe1.getSize(): 8 | return -1 9 | elif recipe2.getSize() > recipe2.getSize(): 10 | return 1 11 | else: 12 | return 0 13 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/RecipesBlocks.py: -------------------------------------------------------------------------------- 1 | class RecipesBlocks: 2 | pass 3 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/RecipesBowl.py: -------------------------------------------------------------------------------- 1 | class RecipesBowl: 2 | pass 3 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/RecipesIngots.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.Items import items 2 | from mc.net.minecraft.game.item.ItemStack import ItemStack 3 | from mc.net.minecraft.game.level.block.Blocks import blocks 4 | 5 | class RecipesIngots: 6 | __recipeItems = ( 7 | (blocks.blockGold, items.ingotGold), 8 | (blocks.blockSteel, items.ingotIron), 9 | (blocks.blockDiamond, items.diamond) 10 | ) 11 | 12 | def addRecipes(self, craftingManager): 13 | for block, item in RecipesIngots.__recipeItems: 14 | craftingManager.addRecipe(ItemStack(block), ['###', '###', '###', ord('#'), item]) 15 | craftingManager.addRecipe(ItemStack(item, 9), ['#', ord('#'), block]) 16 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/RecipesTools.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.Items import items 2 | from mc.net.minecraft.game.item.ItemStack import ItemStack 3 | from mc.net.minecraft.game.level.block.Blocks import blocks 4 | 5 | class RecipesTools: 6 | __recipePatterns = (('XXX', ' # ', ' # '), ('X', '#', '#'), ('XX', 'X#', ' #')) 7 | __recipeItems = ( 8 | (blocks.planks, blocks.cobblestone, items.ingotIron, items.diamond, items.ingotGold), 9 | (items.pickaxeWood, items.pickaxeStone, items.pickaxeSteel, items.pickaxeDiamond, items.pickaxeGold), 10 | (items.shovelWood, items.shovelStone, items.shovel, items.shovelDiamond, items.shovelGold), 11 | (items.axeWood, items.axeStone, items.axeSteel, items.axeDiamond, items.axeGold) 12 | ) 13 | 14 | def addRecipes(self, craftingManager): 15 | for toolIdx, toolItem in enumerate(self.__recipeItems[0]): 16 | for toolType in range(len(self.__recipeItems) - 1): 17 | toolResult = self.__recipeItems[toolType + 1][toolIdx] 18 | craftingManager.addRecipe( 19 | ItemStack(toolResult), 20 | [self.__recipePatterns[toolType][0], self.__recipePatterns[toolType][1], 21 | self.__recipePatterns[toolType][2], ord('#'), items.stick, 22 | ord('X'), toolItem] 23 | ) 24 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/RecipesWeapons.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.Items import items 2 | from mc.net.minecraft.game.item.ItemStack import ItemStack 3 | from mc.net.minecraft.game.level.block.Blocks import blocks 4 | 5 | class RecipesWeapons: 6 | __recipePatterns = (('X', 'X', '#'),) 7 | __recipeItems = ( 8 | (blocks.planks, blocks.cobblestone, items.ingotIron, items.diamond, items.ingotGold), 9 | (items.swordWood, items.swordStone, items.swordSteel, items.swordDiamond, items.swordGold) 10 | ) 11 | 12 | def addRecipes(self, craftingManager): 13 | for toolIdx, toolItem in enumerate(self.__recipeItems[0]): 14 | for toolType in range(len(self.__recipeItems) - 1): 15 | toolResult = self.__recipeItems[toolType + 1][toolIdx] 16 | craftingManager.addRecipe( 17 | ItemStack(toolResult), 18 | [self.__recipePatterns[toolType][0], self.__recipePatterns[toolType][1], 19 | self.__recipePatterns[toolType][2], ord('#'), items.stick, 20 | ord('X'), toolItem] 21 | ) 22 | 23 | craftingManager.addRecipe( 24 | ItemStack(items.bow, 1), 25 | (' #X', '# X', ' #X', ord('X'), 26 | items.silk, ord('#'), items.stick) 27 | ) 28 | craftingManager.addRecipe( 29 | ItemStack(items.arrow, 4), 30 | ('X', '#', 'Y', ord('Y'), items.feather, ord('X'), 31 | items.ingotIron, ord('#'), items.stick) 32 | ) 33 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/ShapedRecipes.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.item.ItemStack import ItemStack 2 | 3 | class ShapedRecipes: 4 | 5 | def __init__(self, width, height, items, output): 6 | self.__recipeWidth = width 7 | self.__recipeHeight = height 8 | self.__recipeItems = items 9 | self.__recipeOutput = output 10 | 11 | def matches(self, items): 12 | for x in range(3 - self.__recipeWidth + 1): 13 | for y in range(3 - self.__recipeHeight + 1): 14 | if self.__matches(items, x, y, True): 15 | return True 16 | if self.__matches(items, x, y, False): 17 | return True 18 | 19 | return False 20 | 21 | def __matches(self, items, x, y, small): 22 | for xSlot in range(3): 23 | for ySlot in range(3): 24 | row = xSlot - x 25 | col = ySlot - y 26 | idx = -1 27 | if row >= 0 and col >= 0 and \ 28 | row < self.__recipeWidth and col < self.__recipeHeight: 29 | if small: 30 | idx = self.__recipeItems[self.__recipeWidth - row - 1 + col * self.__recipeWidth] 31 | else: 32 | idx = self.__recipeItems[row + col * self.__recipeWidth] 33 | 34 | if items[xSlot + ySlot * 3] != idx: 35 | return False 36 | 37 | return True 38 | 39 | def getCraftingResult(self): 40 | return ItemStack(self.__recipeOutput.itemID, self.__recipeOutput.stackSize) 41 | 42 | def getSize(self): 43 | return self.__recipeWidth * self.__recipeHeight 44 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/item/recipe/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/item/recipe/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/EntityMap.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | from mc.net.minecraft.game.entity.Entity cimport Entity 6 | from mc.net.minecraft.game.physics.AxisAlignedBB cimport AxisAlignedBB 7 | from mc.net.minecraft.game.level.EntityMapSlot cimport EntityMapSlot 8 | 9 | @cython.final 10 | cdef class EntityMap: 11 | 12 | cdef: 13 | public int width 14 | public int depth 15 | public int height 16 | 17 | EntityMapSlot __slot 18 | EntityMapSlot __slot2 19 | 20 | public list entityGrid 21 | public list all 22 | list __tmp 23 | 24 | cdef insert(self, Entity entity) 25 | cdef remove(self, Entity entity) 26 | cdef list getEntities(self, Entity oEntity, float x0, float y0, float z0, 27 | float x1, float y1, float z1) 28 | cdef list __addEntities(self, Entity oEntity, float x0, float y0, float z0, 29 | float x1, float y1, float z1, list l) 30 | cpdef list getEntitiesWithinAABBExcludingEntity(self, Entity entity, AxisAlignedBB aabb) 31 | cdef updateEntities(self) 32 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/EntityMapSlot.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | from mc.net.minecraft.game.level.EntityMap cimport EntityMap 6 | 7 | @cython.final 8 | cdef class EntityMapSlot: 9 | 10 | cdef: 11 | public int posX 12 | public int posY 13 | public int posZ 14 | EntityMap __entityMap 15 | 16 | cdef EntityMapSlot init(self, float x, float y, float z) 17 | cdef add(self, entity) 18 | cdef remove(self, entity) 19 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/EntityMapSlot.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cdef class EntityMapSlot: 4 | 5 | def __init__(self, entityMap): 6 | self.posX = 0 7 | self.posY = 0 8 | self.posZ = 0 9 | self.__entityMap = entityMap 10 | 11 | cdef EntityMapSlot init(self, float x, float y, float z): 12 | self.posX = (x // 16) 13 | self.posY = (y // 16) 14 | self.posZ = (z // 16) 15 | if self.posX < 0: 16 | self.posX = 0 17 | if self.posY < 0: 18 | self.posY = 0 19 | if self.posZ < 0: 20 | self.posZ = 0 21 | 22 | if self.posX >= self.__entityMap.width: 23 | self.posX = self.__entityMap.width - 1 24 | if self.posY >= self.__entityMap.depth: 25 | self.posY = self.__entityMap.depth - 1 26 | if self.posZ >= self.__entityMap.height: 27 | self.posZ = self.__entityMap.height - 1 28 | 29 | return self 30 | 31 | cdef add(self, entity): 32 | if self.posX >= 0 and self.posY >= 0 and self.posZ >= 0: 33 | self.__entityMap.entityGrid[(self.posZ * self.__entityMap.depth + self.posY) * \ 34 | self.__entityMap.width + self.posX].append(entity) 35 | 36 | cdef remove(self, entity): 37 | if self.posX >= 0 and self.posY >= 0 and self.posZ >= 0: 38 | try: 39 | self.__entityMap.entityGrid[(self.posZ * self.__entityMap.depth + self.posY) * \ 40 | self.__entityMap.width + self.posX].remove(entity) 41 | except: 42 | pass 43 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/level/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/Block.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.level.World cimport World 4 | from mc.JavaUtils cimport Random 5 | 6 | cdef class Block: 7 | 8 | cdef: 9 | public object blocks 10 | public int blockIndexInTexture 11 | public int blockID 12 | public object stepSound 13 | public float blockParticleGravity 14 | public float _hardness 15 | public float _resistance 16 | 17 | public float minX 18 | public float minY 19 | public float minZ 20 | public float maxX 21 | public float maxY 22 | public float maxZ 23 | 24 | cpdef bint renderAsNormalBlock(self) 25 | cpdef int getRenderType(self) 26 | cdef float getBlockBrightness(self, World world, int x, int y, int z) 27 | cpdef bint shouldSideBeRendered(self, World world, int x, int y, int z, int layer) 28 | cpdef int getBlockTextureFromSideAndMetadata(self, World world, int x, int y, int z, int layer) 29 | cpdef int getBlockTexture(self, int face) 30 | cpdef bint isOpaqueCube(self) 31 | cpdef bint isCollidable(self) 32 | cpdef void updateTick(self, World world, int x, int y, int z, Random random) except * 33 | cpdef void randomDisplayTick(self, World world, int x, int y, int z, Random random) except * 34 | cpdef int getBlockMaterial(self) 35 | cpdef void onNeighborBlockChange(self, World world, int x, int y, int z, int blockType) except * 36 | cdef int tickRate(self) 37 | cpdef int quantityDropped(self, Random random) 38 | cpdef int idDropped(self) 39 | cdef dropBlockAsItemWithChance(self, World world, int x, int y, int z, float chance) 40 | cdef float getExplosionResistance(self) 41 | cdef collisionRayTrace(self, World world, int x, int y, int z, v0, v1) 42 | cdef bint __isVecInsideYZBounds(self, vec) 43 | cdef bint __isVecInsideXZBounds(self, vec) 44 | cdef bint __isVecInsideXYBounds(self, vec) 45 | cdef int getRenderBlockPass(self) 46 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockBookshelf.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockBookshelf(Block): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, 47, 35) 7 | 8 | def getBlockTexture(self, face): 9 | return 4 if face <= 1 else self.blockIndexInTexture 10 | 11 | def quantityDropped(self, random): 12 | return 0 13 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockContainer.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockContainer(Block): 4 | 5 | def __init__(self, blocks, blockId): 6 | super().__init__(blocks, blockId) 7 | 8 | def onBlockAdded(self, world, x, y, z): 9 | super().onBlockAdded(world, x, y, z) 10 | world.setBlockTileEntity(x, y, z, self._getBlockEntity()) 11 | 12 | def onBlockRemoval(self, world, x, y, z): 13 | super().onBlockRemoval(world, x, y, z) 14 | world.removeBlockTileEntity(x, y, z) 15 | 16 | def _getBlockEntity(self): 17 | return None 18 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockDirt.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockDirt(Block): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, 3, 2) 7 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockFlower.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockFlower(Block): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, blockId, tex) 7 | self.blockIndexInTexture = tex 8 | self._setTickOnLoad(True) 9 | self._setBlockBounds(0.3, 0.0, 0.3, 0.7, 0.6, 0.7) 10 | 11 | def updateTick(self, world, x, y, z, random): 12 | below = world.getBlockId(x, y - 1, z) 13 | if not world.isHalfLit(x, y, z) or \ 14 | (below != self.blocks.dirt.blockID and below != self.blocks.grass.blockID): 15 | world.setBlockWithNotify(x, y, z, 0) 16 | 17 | def getCollisionBoundingBoxFromPool(self, x, y, z): 18 | return None 19 | 20 | def isOpaqueCube(self): 21 | return False 22 | 23 | def renderAsNormalBlock(self): 24 | return False 25 | 26 | def getRenderType(self): 27 | return 1 28 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockFlowing.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.level.block.BlockFluid cimport BlockFluid 4 | from mc.net.minecraft.game.level.World cimport World 5 | from mc.JavaUtils cimport Random 6 | 7 | cdef class BlockFlowing(BlockFluid): 8 | 9 | cdef: 10 | int __material 11 | int __stillId 12 | int __movingId 13 | Random __random 14 | int[4] __flowArray 15 | 16 | cpdef void updateTick(self, World world, int x, int y, int z, Random random) except * 17 | cdef bint update(self, World world, int x, int y, int z, int _) 18 | cdef bint __liquidSpread(self, World world, int x0, int y0, int z0, 19 | int x1, int y1, int z1) 20 | cdef bint __flow(self, World world, int x0, int y0, int z0, 21 | int x1, int y1, int z1) 22 | cpdef bint shouldSideBeRendered(self, World world, int x, int y, int z, int layer) 23 | cpdef bint isCollidable(self) 24 | cpdef bint isOpaqueCube(self) 25 | cpdef int getBlockMaterial(self) 26 | cpdef void onNeighborBlockChange(self, World world, int x, int y, int z, int blockType) except * 27 | cdef int tickRate(self) 28 | cdef dropBlockAsItemWithChance(self, World world, int x, int y, int z, float chance) 29 | cpdef int quantityDropped(self, Random random) 30 | cdef int getRenderBlockPass(self) 31 | cdef bint __extinguishFireLava(self, World world, int x, int y, int z) 32 | cdef bint __fireSpread(self, World world, int x, int y, int z) 33 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockFluid.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.level.block.Block cimport Block 4 | from mc.net.minecraft.game.level.World cimport World 5 | from mc.JavaUtils cimport Random 6 | 7 | cdef class BlockFluid(Block): 8 | 9 | cdef: 10 | public int _material 11 | public int _stillId 12 | public int _movingId 13 | 14 | cpdef int getBlockTexture(self, int face) 15 | cpdef bint renderAsNormalBlock(self) 16 | cpdef void updateTick(self, World world, int x, int y, int z, Random random) except * 17 | cdef bint update(self, World world, int x, int y, int z, int _) 18 | cpdef bint _canFlow(self, World world, int x, int y, int z) 19 | cdef bint __extinguishFireLava(self, World world, int x, int y, int z) 20 | cdef bint __flow(self, World world, int x, int y, int z) 21 | cdef float getBlockBrightness(self, World world, int x, int y, int z) 22 | cpdef bint shouldSideBeRendered(self, World world, int x, int y, int z, int layer) 23 | cpdef bint isCollidable(self) 24 | cpdef bint isOpaqueCube(self) 25 | cpdef int getBlockMaterial(self) 26 | cpdef void onNeighborBlockChange(self, World world, int x, int y, int z, int blockType) except * 27 | cdef int tickRate(self) 28 | cdef dropBlockAsItemWithChance(self, World world, int x, int y, int z, float chance) 29 | cpdef int quantityDropped(self, Random random) 30 | cdef int getRenderBlockPass(self) 31 | cpdef void randomDisplayTick(self, World world, int x, int y, int z, Random random) except * 32 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockGears.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockGears(Block): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, 55, 62) 7 | 8 | def getCollisionBoundingBoxFromPool(self, x, y, z): 9 | return None 10 | 11 | def isOpaqueCube(self): 12 | return False 13 | 14 | def renderAsNormalBlock(self): 15 | return False 16 | 17 | def getRenderType(self): 18 | return 5 19 | 20 | def quantityDropped(self, random): 21 | return 1 22 | 23 | def isCollidable(self): 24 | return False 25 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockGlass.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockGlass(Block): 4 | 5 | def __init__(self, blocks, blockId, tex, _): 6 | super().__init__(blocks, 20, 49) 7 | self.__renderThrough = False 8 | 9 | def isOpaqueCube(self): 10 | return False 11 | 12 | def shouldSideBeRendered(self, world, x, y, z, layer): 13 | block = world.getBlockId(x, y, z) 14 | if not self.__renderThrough and block == self.blockID: 15 | return False 16 | else: 17 | return super().shouldSideBeRendered(world, x, y, z, layer) 18 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockGrass.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | from mc.net.minecraft.game.level.material.Material import Material 3 | 4 | class BlockGrass(Block): 5 | 6 | def __init__(self, blocks, blockId): 7 | super().__init__(blocks, 2) 8 | self.blockIndexInTexture = 3 9 | self._setTickOnLoad(True) 10 | 11 | def getBlockTexture(self, face): 12 | if face == 1: return 0 13 | if face == 0: return 2 14 | return 3 15 | 16 | def updateTick(self, world, x, y, z, random): 17 | if not world.isHalfLit(x, y + 1, z) and world.getBlockMaterial(x, y + 1, z) == Material.air: 18 | if random.nextInt(4) == 0: 19 | world.setBlockWithNotify(x, y, z, self.blocks.dirt.blockID) 20 | else: 21 | xt = x + random.nextInt(3) - 1 22 | yt = y + random.nextInt(5) - 3 23 | zt = z + random.nextInt(3) - 1 24 | if world.getBlockId(xt, yt, zt) == self.blocks.dirt.blockID and \ 25 | world.isHalfLit(xt, yt + 1, zt) and \ 26 | world.getBlockMaterial(x, y + 1, z) == Material.air: 27 | world.setBlockWithNotify(xt, yt, zt, self.blocks.grass.blockID) 28 | 29 | def idDropped(self): 30 | return self.blocks.dirt.idDropped() 31 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockLeaves.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.BlockLeavesBase import BlockLeavesBase 2 | 3 | class BlockLeaves(BlockLeavesBase): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, 18, 22, True) 7 | 8 | def quantityDropped(self, random): 9 | if random.nextInt(6) == 0: 10 | return 1 11 | else: 12 | return 0 13 | 14 | def idDropped(self): 15 | return self.blocks.sapling.blockID 16 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockLeavesBase.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockLeavesBase(Block): 4 | 5 | def __init__(self, blocks, blockId, tex, _): 6 | super().__init__(blocks, blockId, tex) 7 | self.__renderThrough = True 8 | 9 | def isOpaqueCube(self): 10 | return False 11 | 12 | def shouldSideBeRendered(self, world, x, y, z, layer): 13 | if not self.__renderThrough and world.getBlockId(x, y, z) == self.blockID: 14 | return False 15 | else: 16 | return super().shouldSideBeRendered(world, x, y, z, layer) 17 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockLog.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockLog(Block): 4 | 5 | def __init__(self, blocks, blockId): 6 | super().__init__(blocks, 17) 7 | self.blockIndexInTexture = 20 8 | 9 | def quantityDropped(self, random): 10 | return random.nextInt(3) + 3 11 | 12 | def idDropped(self): 13 | return self.blocks.planks.blockID 14 | 15 | def getBlockTexture(self, face): 16 | return 21 if face == 1 else (21 if face == 0 else 20) 17 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockMushroom.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.BlockFlower import BlockFlower 2 | 3 | class BlockMushroom(BlockFlower): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, blockId, tex) 7 | self._setBlockBounds(0.3, 0.0, 0.3, 0.7, 0.4, 0.7) 8 | 9 | def updateTick(self, world, x, y, z, random): 10 | below = world.getBlockId(x, y - 1, z) 11 | if not world.isFullyLit(x, y, z) or not self.blocks.opaqueCubeLookup[below]: 12 | world.setBlockWithNotify(x, y, z, 0) 13 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockOre.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | from mc.JavaUtils import Random 3 | 4 | class BlockOre(Block): 5 | 6 | def __init__(self, blocks, blockId, tex): 7 | super().__init__(blocks, blockId, tex) 8 | self.__rand = Random() 9 | 10 | def idDropped(self): 11 | from mc.net.minecraft.game.item.Items import items 12 | if self.blockID == self.blocks.oreCoal.blockID: 13 | return items.coal.shiftedIndex 14 | elif self.blockID == self.blocks.oreDiamond.blockID: 15 | return items.diamond.shiftedIndex 16 | else: 17 | return self.blockID 18 | 19 | def quantityDropped(self, random): 20 | return 1 if self.idDropped() == self.blockID else random.nextInt(3) + 1 21 | 22 | def onBlockPlaced(self, world, x, y, z): 23 | from mc.net.minecraft.game.entity.misc.EntityItem import EntityItem 24 | from mc.net.minecraft.game.item.Items import items 25 | from mc.net.minecraft.game.item.ItemStack import ItemStack 26 | itemId = 0 27 | if self.blockID == self.blocks.oreCoal.blockID: 28 | itemId = items.coal.shiftedIndex 29 | elif self.blockID == self.blocks.oreDiamond.blockID: 30 | itemId = items.diamond.shiftedIndex 31 | elif self.blockID == self.blocks.oreIron.blockID: 32 | itemId = items.ingotIron.shiftedIndex 33 | elif self.blockID == self.blocks.oreGold.blockID: 34 | itemId = items.ingotGold.shiftedIndex 35 | 36 | drops = self.__rand.nextInt(3) + 1 37 | for i in range(drops): 38 | if world.rand.nextFloat() <= 1.0: 39 | itemX = world.rand.nextFloat() * 0.7 + 0.15 40 | itemY = world.rand.nextFloat() * 0.7 + 0.15 41 | itemZ = world.rand.nextFloat() * 0.7 + 0.15 42 | item = EntityItem(world, x + itemX, y + itemY, z + itemZ, 43 | ItemStack(itemId)) 44 | item.delayBeforeCanPickup = 10 45 | world.spawnEntityInWorld(item) 46 | 47 | return True 48 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockOreBlock.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockOreBlock(Block): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, blockId, tex) 7 | 8 | def getBlockTexture(self, face): 9 | if face == 1: 10 | return self.blockIndexInTexture - 16 11 | elif face == 0: 12 | return self.blockIndexInTexture + 16 13 | else: 14 | return self.blockIndexInTexture 15 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockSand.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | from mc.net.minecraft.game.level.material.Material import Material 3 | 4 | class BlockSand(Block): 5 | 6 | def onNeighborBlockChange(self, world, x, y, z, blockType): 7 | newY = y 8 | while True: 9 | blockId = world.getBlockId(x, newY - 1, z) 10 | if blockId == 0: 11 | stop = True 12 | elif blockId == self.blocks.fire.blockID: 13 | stop = True 14 | else: 15 | material = self.blocks.blocksList[blockId].getBlockMaterial() 16 | stop = True if material == Material.water else material == Material.lava 17 | 18 | if not stop or newY < 0: 19 | if newY < 0: 20 | world.setTileNoUpdate(x, y, z, 0) 21 | 22 | if newY != y: 23 | blockId = world.getBlockId(x, newY, z) 24 | if blockId > 0 and self.blocks.blocksList[blockId].getBlockMaterial() != Material.air: 25 | world.setTileNoUpdate(x, newY, z, 0) 26 | 27 | world.swap(x, y, z, x, newY, z) 28 | 29 | return 30 | 31 | newY -= 1 32 | if world.getBlockId(x, newY, z) == self.blocks.fire.blockID: 33 | world.setBlock(x, newY, z, 0) 34 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockSapling.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.BlockFlower import BlockFlower 2 | 3 | class BlockSapling(BlockFlower): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, 6, 15) 7 | self._setBlockBounds(10.0 * 0.01, 0.0, 10.0 * 0.01, 0.9, 0.8, 0.9) 8 | 9 | def updateTick(self, world, x, y, z, random): 10 | below = world.getBlockId(x, y - 1, z) 11 | if world.isHalfLit(x, y, z) and (below == self.blocks.dirt.blockID or \ 12 | below == self.blocks.grass.blockID): 13 | if random.nextInt(5) == 0: 14 | world.setTileNoUpdate(x, y, z, 0) 15 | if not world.growTrees(x, y, z): 16 | world.setTileNoUpdate(x, y, z, self.blockID) 17 | else: 18 | world.setBlockWithNotify(x, y, z, 0) 19 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockSource.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockSource(Block): 4 | 5 | def __init__(self, blocks, blockId, fluid): 6 | super().__init__(blocks, blockId, blocks.blocksList[fluid].blockIndexInTexture) 7 | self.__fluid = fluid 8 | self._setTickOnLoad(True) 9 | 10 | def onBlockAdded(self, world, x, y, z): 11 | super().onBlockAdded(world, x, y, z) 12 | if world.getBlockId(x - 1, y, z) == 0: 13 | world.setBlockWithNotify(x - 1, y, z, self.__fluid) 14 | if world.getBlockId(x + 1, y, z) == 0: 15 | world.setBlockWithNotify(x + 1, y, z, self.__fluid) 16 | if world.getBlockId(x, y, z - 1) == 0: 17 | world.setBlockWithNotify(x, y, z - 1, self.__fluid) 18 | if world.getBlockId(x, y, z + 1) == 0: 19 | world.setBlockWithNotify(x, y, z + 1, self.__fluid) 20 | 21 | def updateTick(self, world, x, y, z, random): 22 | super().updateTick(world, x, y, z, random) 23 | if world.getBlockId(x - 1, y, z) == 0: 24 | world.setBlockWithNotify(x - 1, y, z, self.__fluid) 25 | if world.getBlockId(x + 1, y, z) == 0: 26 | world.setBlockWithNotify(x + 1, y, z, self.__fluid) 27 | if world.getBlockId(x, y, z - 1) == 0: 28 | world.setBlockWithNotify(x, y, z - 1, self.__fluid) 29 | if world.getBlockId(x, y, z + 1) == 0: 30 | world.setBlockWithNotify(x, y, z + 1, self.__fluid) 31 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockSponge.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockSponge(Block): 4 | 5 | def __init__(self, blocks, blockId): 6 | super().__init__(blocks, 19) 7 | self.blockIndexInTexture = 48 8 | 9 | def onBlockAdded(self, world, x, y, z): 10 | for xx in range(x - 2, x + 3): 11 | for yy in range(y - 2, y + 3): 12 | for zz in range(z - 2, z + 3): 13 | if world.isWater(xx, yy, zz): 14 | world.setBlock(xx, yy, zz, 0) 15 | 16 | def onBlockRemoval(self, world, x, y, z): 17 | for xx in range(x - 2, x + 3): 18 | for yy in range(y - 2, y + 3): 19 | for zz in range(z - 2, z + 3): 20 | world.notifyBlocksOfNeighborChange(xx, yy, zz, 21 | world.getBlockId(xx, yy, zz)) 22 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockStationary.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.BlockFluid import BlockFluid 2 | from mc.net.minecraft.game.level.material.Material import Material 3 | 4 | class BlockStationary(BlockFluid): 5 | 6 | def __init__(self, blocks, blockId, material): 7 | super().__init__(blocks, blockId, material) 8 | self._movingId = blockId - 1 9 | self._stillId = blockId 10 | self._setTickOnLoad(False) 11 | 12 | def updateTick(self, world, x, y, z, random): 13 | pass 14 | 15 | def onNeighborBlockChange(self, world, x, y, z, blockType): 16 | hasAirNeighbor = False 17 | if not hasAirNeighbor and self._canFlow(world, x, y - 1, z): 18 | hasAirNeighbor = True 19 | if not hasAirNeighbor and self._canFlow(world, x - 1, y, z): 20 | hasAirNeighbor = True 21 | if not hasAirNeighbor and self._canFlow(world, x + 1, y, z): 22 | hasAirNeighbor = True 23 | if not hasAirNeighbor and self._canFlow(world, x, y, z - 1): 24 | hasAirNeighbor = True 25 | if not hasAirNeighbor and self._canFlow(world, x, y, z + 1): 26 | hasAirNeighbor = True 27 | 28 | if blockType != 0: 29 | material = self.blocks.blocksList[blockType].getBlockMaterial() 30 | if self._material == Material.water and material == Material.lava or \ 31 | material == Material.water and self._material == Material.lava: 32 | world.setBlockWithNotify(x, y, z, self.blocks.stone.blockID) 33 | return 34 | 35 | if self.blocks.fire.getChanceOfNeighborsEncouragingFire(blockType): 36 | hasAirNeighbor = True 37 | 38 | if hasAirNeighbor: 39 | world.setTileNoUpdate(x, y, z, self._movingId) 40 | world.scheduleBlockUpdate(x, y, z, self._movingId) 41 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockStep.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockStep(Block): 4 | 5 | def __init__(self, blocks, blockId, half): 6 | self.__blockType = half 7 | super().__init__(blocks, blockId, 6) 8 | if not self.__blockType: 9 | self._setBlockBounds(0.0, 0.0, 0.0, 1.0, 0.5, 1.0) 10 | 11 | def getBlockTexture(self, face): 12 | return 6 if face <= 1 else 5 13 | 14 | def isOpaqueCube(self): 15 | return self.__blockType 16 | 17 | def onNeighborBlockChange(self, world, x, y, z, blockType): 18 | if self == self.blocks.stairSingle: 19 | pass 20 | 21 | def onBlockAdded(self, world, x, y, z): 22 | if self != self.blocks.stairSingle: 23 | super().onBlockAdded(world, x, y, z) 24 | 25 | if world.getBlockId(x, y - 1, z) == self.blocks.stairSingle.blockID: 26 | world.setBlockWithNotify(x, y, z, 0) 27 | world.setBlockWithNotify(x, y - 1, z, self.blocks.stairDouble.blockID) 28 | 29 | def idDropped(self): 30 | return self.blocks.stairSingle.blockID 31 | 32 | def renderAsNormalBlock(self): 33 | return self.__blockType 34 | 35 | def shouldSideBeRendered(self, world, x, y, z, layer): 36 | if layer == 1: 37 | return True 38 | elif not super().shouldSideBeRendered(world, x, y, z, layer): 39 | return False 40 | elif layer == 0: 41 | return True 42 | else: 43 | return world.getBlockId(x, y, z) != self.blockID 44 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockStone.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockStone(Block): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, blockId, tex) 7 | 8 | def idDropped(self): 9 | return self.blocks.cobblestone.blockID 10 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockTNT.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | from mc.net.minecraft.game.entity.misc.EntityTNTPrimed import EntityTNTPrimed 3 | 4 | class BlockTNT(Block): 5 | 6 | def __init__(self, blocks, blockId, tex): 7 | super().__init__(blocks, 46, 8) 8 | 9 | def getBlockTexture(self, face): 10 | if face == 0: 11 | return self.blockIndexInTexture + 2 12 | elif face == 1: 13 | return self.blockIndexInTexture + 1 14 | else: 15 | return self.blockIndexInTexture 16 | 17 | def quantityDropped(self, random): 18 | return 0 19 | 20 | def onBlockDestroyedByExplosion(self, world, x, y, z): 21 | entity = EntityTNTPrimed(world, x + 0.5, y + 0.5, z + 0.5) 22 | entity.fuse = world.rand.nextInt(entity.fuse // 4) + entity.fuse // 8 23 | world.spawnEntityInWorld(entity) 24 | 25 | def onBlockDestroyedByPlayer(self, world, x, y, z): 26 | entity = EntityTNTPrimed(world, x + 0.5, y + 0.5, z + 0.5) 27 | world.spawnEntityInWorld(entity) 28 | world.playSoundAtEntity(entity, 'random.fuse', 1.0, 1.0) 29 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockTorch.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockTorch(Block): 4 | 5 | def __init__(self, blocks, blockId, tex): 6 | super().__init__(blocks, 50, 80) 7 | 8 | def getCollisionBoundingBoxFromPool(self, x, y, z): 9 | return None 10 | 11 | def isOpaqueCube(self): 12 | return False 13 | 14 | def renderAsNormalBlock(self): 15 | return False 16 | 17 | def getRenderType(self): 18 | return 2 19 | 20 | def collisionRayTrace(self, world, x, y, z, v0, v1): 21 | if world.isBlockNormalCube(x - 1, y, z): 22 | self._setBlockBounds(0.0, 0.2, 0.35, 0.3, 0.8, 0.65) 23 | elif world.isBlockNormalCube(x + 1, y, z): 24 | self._setBlockBounds(0.7, 0.2, 0.35, 1.0, 0.8, 0.65) 25 | elif world.isBlockNormalCube(x, y, z - 1): 26 | self._setBlockBounds(0.35, 0.2, 0.0, 0.65, 0.8, 0.3) 27 | elif world.isBlockNormalCube(x, y, z + 1): 28 | self._setBlockBounds(0.35, 0.2, 0.7, 0.65, 0.8, 1.0) 29 | else: 30 | self._setBlockBounds(0.4, 0.0, 0.4, 0.6, 0.6, 0.6) 31 | 32 | return super().collisionRayTrace(world, x, y, z, v0, v1) 33 | 34 | def randomDisplayTick(self, world, x, y, z, random): 35 | posX = x + 0.5 36 | posY = y + 0.7 37 | posZ = z + 0.5 38 | if world.isBlockNormalCube(x - 1, y, z): 39 | world.spawnParticle('smoke', posX - 0.27, posY + 0.22, posZ, 0.0, 0.0, 0.0) 40 | world.spawnParticle('flame', posX - 0.27, posY + 0.22, posZ, 0.0, 0.0, 0.0) 41 | elif world.isBlockNormalCube(x + 1, y, z): 42 | world.spawnParticle('smoke', posX + 0.27, posY + 0.22, posZ, 0.0, 0.0, 0.0) 43 | world.spawnParticle('flame', posX + 0.27, posY + 0.22, posZ, 0.0, 0.0, 0.0) 44 | elif world.isBlockNormalCube(x, y, z - 1): 45 | world.spawnParticle('smoke', posX, posY + 0.22, posZ - 0.27, 0.0, 0.0, 0.0) 46 | world.spawnParticle('flame', posX, posY + 0.22, posZ - 0.27, 0.0, 0.0, 0.0) 47 | elif world.isBlockNormalCube(x, y, z + 1): 48 | world.spawnParticle('smoke', posX, posY + 0.22, posZ + 0.27, 0.0, 0.0, 0.0) 49 | world.spawnParticle('flame', posX, posY + 0.22, posZ + 0.27, 0.0, 0.0, 0.0) 50 | else: 51 | world.spawnParticle('smoke', posX, posY, posZ, 0.0, 0.0, 0.0) 52 | world.spawnParticle('flame', posX, posY, posZ, 0.0, 0.0, 0.0) 53 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/BlockWorkbench.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.Block import Block 2 | 3 | class BlockWorkbench(Block): 4 | 5 | def __init__(self, blocks, blockId): 6 | super().__init__(blocks, 58) 7 | self.blockIndexInTexture = 59 8 | 9 | def getBlockTexture(self, face): 10 | if face == 1: 11 | return self.blockIndexInTexture - 16 12 | elif face == 0: 13 | return self.blocks.planks.getBlockTexture(0) 14 | elif face != 2 and face != 4: 15 | return self.blockIndexInTexture 16 | else: 17 | return self.blockIndexInTexture + 1 18 | 19 | def blockActivated(self, world, x, y, z, player): 20 | player.displayWorkbenchGUI() 21 | return True 22 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/StepSound.py: -------------------------------------------------------------------------------- 1 | class StepSound: 2 | 3 | def __init__(self, name, volume, pitch): 4 | self.soundDir = name 5 | self.soundVolume = 1.0 6 | self.soundPitch = pitch 7 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/level/block/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/tileentity/TileEntity.py: -------------------------------------------------------------------------------- 1 | class TileEntity: 2 | 3 | def readFromNBT(self, compound): 4 | pass 5 | 6 | def writeToNBT(self, compound): 7 | pass 8 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/tileentity/TileEntityChest.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.level.block.tileentity.TileEntity import TileEntity 2 | from mc.net.minecraft.game.item.ItemStack import ItemStack 3 | from mc.net.minecraft.game.Inventory import Inventory 4 | 5 | from nbtlib.tag import Compound, String, Byte, List 6 | 7 | class TileEntityChest(TileEntity, Inventory): 8 | CHEST_STACK_LIMIT = 64 9 | 10 | def __init__(self): 11 | self.__chestContents = [None] * 36 12 | 13 | def getSizeInventory(self): 14 | return 27 15 | 16 | def getStackInSlot(self, slot): 17 | return self.__chestContents[slot] 18 | 19 | def decrStackSize(self, slot, size): 20 | if not self.__chestContents[slot]: 21 | return None 22 | 23 | if self.__chestContents[slot].stackSize <= size: 24 | stack = self.__chestContents[slot] 25 | self.__chestContents[slot] = None 26 | return stack 27 | else: 28 | stack = self.__chestContents[slot].splitStack(size) 29 | if self.__chestContents[slot].stackSize == 0: 30 | self.__chestContents[slot] = None 31 | 32 | return stack 33 | 34 | def setInventorySlotContents(self, slot, stack): 35 | self.__chestContents[slot] = stack 36 | if stack: 37 | stack.stackSize = min(stack.stackSize, TileEntityChest.CHEST_STACK_LIMIT) 38 | 39 | def getInvName(self): 40 | return 'Chest' 41 | 42 | def readFromNBT(self, compound): 43 | tagList = compound['Items'] 44 | self.__chestContents = [None] * 64 45 | for tag in tagList: 46 | slot = tag['Slot'].real & 255 47 | self.__chestContents[slot] = ItemStack(tag) 48 | 49 | def writeToNBT(self, compound): 50 | compound['id'] = String('Chest') 51 | tagList = List[Compound]() 52 | for i in range(len(self.__chestContents)): 53 | if self.__chestContents[i]: 54 | comp = Compound({'Slot': Byte(i)}) 55 | self.__chestContents[i].writeToNBT(comp) 56 | tagList.append(comp) 57 | 58 | compound['Items'] = tagList 59 | 60 | def getInventoryStackLimit(self): 61 | return TileEntityChest.CHEST_STACK_LIMIT 62 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/block/tileentity/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/level/block/tileentity/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/level/generator/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.level.generator.noise.NoiseGeneratorOctaves cimport NoiseGeneratorOctaves 4 | 5 | cdef class NoiseGeneratorDistort: 6 | 7 | cdef: 8 | NoiseGeneratorOctaves __source 9 | NoiseGeneratorOctaves __distort 10 | 11 | cdef double generateNoise(self, double x, double y) 12 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/noise/NoiseGeneratorDistort.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cdef class NoiseGeneratorDistort: 4 | 5 | def __init__(self, NoiseGeneratorOctaves source, NoiseGeneratorOctaves distort): 6 | self.__source = source 7 | self.__distort = distort 8 | 9 | cdef double generateNoise(self, double x, double y): 10 | return self.__source.generateNoise(x + self.__distort.generateNoise(x, y), y) 11 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cdef class NoiseGeneratorOctaves: 4 | 5 | cdef: 6 | list __generatorCollection 7 | int __octaves 8 | 9 | cdef double generateNoise(self, double x, double y) 10 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/noise/NoiseGeneratorOctaves.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from mc.net.minecraft.game.level.generator.noise.NoiseGeneratorPerlin cimport NoiseGeneratorPerlin 4 | from mc.JavaUtils cimport Random 5 | 6 | cdef class NoiseGeneratorOctaves: 7 | 8 | def __init__(self, Random random, int octaves): 9 | cdef int i 10 | self.__octaves = octaves 11 | self.__generatorCollection = [None] * octaves 12 | for i in range(octaves): 13 | self.__generatorCollection[i] = NoiseGeneratorPerlin(random) 14 | 15 | cdef double generateNoise(self, double x, double y): 16 | cdef double value, power 17 | cdef int i 18 | cdef NoiseGeneratorPerlin noiseLevel 19 | 20 | value = 0.0 21 | power = 1.0 22 | 23 | for i in range(self.__octaves): 24 | noiseLevel = self.__generatorCollection[i] 25 | value += noiseLevel.generateNoise(x / power, y / power) * power 26 | power *= 2.0 27 | 28 | return value 29 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cdef class NoiseGeneratorPerlin: 4 | 5 | cdef: 6 | int __permutations[512] 7 | 8 | @staticmethod 9 | cdef double __generateNoise(double t) 10 | @staticmethod 11 | cdef double __lerp(double d0, double d2, double d4) 12 | @staticmethod 13 | cdef double __grad(int hash, double x, double y, double z) 14 | cdef double generateNoise(self, double x, double y) 15 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/noise/NoiseGeneratorPerlin.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | from libc.math cimport floor 4 | 5 | from mc.JavaUtils cimport Random 6 | 7 | cdef class NoiseGeneratorPerlin: 8 | 9 | def __init__(self, Random random): 10 | cdef int i, j, tmp 11 | 12 | for i in range(256): 13 | self.__permutations[i] = i 14 | 15 | for i in range(256): 16 | j = random.nextInt(256 - i) + i 17 | tmp = self.__permutations[i] 18 | self.__permutations[i] = self.__permutations[j] 19 | self.__permutations[j] = tmp 20 | self.__permutations[i + 256] = self.__permutations[i] 21 | 22 | @staticmethod 23 | cdef double __generateNoise(double t): 24 | return t * t * t * (t * (t * 6.0 - 15.0) + 10.0) 25 | 26 | @staticmethod 27 | cdef double __lerp(double d0, double d2, double d4): 28 | return d2 + d0 * (d4 - d2) 29 | 30 | @staticmethod 31 | cdef double __grad(int hash, double x, double y, double z): 32 | cdef double d8, d10 33 | 34 | hash &= 0xF 35 | d8 = x if hash < 8 else y 36 | d10 = y if hash < 4 else (z if hash != 12 and hash != 14 else x) 37 | return (d8 if (hash & 1) == 0 else -d8) + (d10 if (hash & 2) == 0 else -d10) 38 | 39 | cdef double generateNoise(self, double x, double y): 40 | cdef int X, Y, Z, A, AA, AB, B, BA, BB 41 | cdef double z, u, v, w 42 | 43 | X = floor(x) & 0xFF 44 | Y = floor(y) & 0xFF 45 | Z = floor(0.0) & 0xFF 46 | 47 | x -= floor(x) 48 | y -= floor(y) 49 | z = floor(0.0) 50 | 51 | u = NoiseGeneratorPerlin.__generateNoise(x) 52 | v = NoiseGeneratorPerlin.__generateNoise(y) 53 | w = NoiseGeneratorPerlin.__generateNoise(z) 54 | 55 | A = self.__permutations[X] + Y 56 | AA = self.__permutations[A] + Z 57 | AB = self.__permutations[A + 1] + Z 58 | B = self.__permutations[X + 1] + Y 59 | BA = self.__permutations[B] + Z 60 | BB = self.__permutations[B + 1] + Z 61 | 62 | return NoiseGeneratorPerlin.__lerp(w, 63 | NoiseGeneratorPerlin.__lerp(v, 64 | NoiseGeneratorPerlin.__lerp(u, 65 | NoiseGeneratorPerlin.__grad(self.__permutations[AA], x, y, z), 66 | NoiseGeneratorPerlin.__grad(self.__permutations[BA], x - 1.0, y, z)), 67 | NoiseGeneratorPerlin.__lerp(u, 68 | NoiseGeneratorPerlin.__grad(self.__permutations[AB], x, y - 1.0, z), 69 | NoiseGeneratorPerlin.__grad(self.__permutations[BB], x - 1.0, y - 1.0, z))), 70 | NoiseGeneratorPerlin.__lerp(v, 71 | NoiseGeneratorPerlin.__lerp(u, 72 | NoiseGeneratorPerlin.__grad(self.__permutations[AA + 1], x, y, z - 1.0), 73 | NoiseGeneratorPerlin.__grad(self.__permutations[BA + 1], x - 1.0, y, z - 1.0)), 74 | NoiseGeneratorPerlin.__lerp(u, 75 | NoiseGeneratorPerlin.__grad(self.__permutations[AB + 1], x, y - 1.0, z - 1.0), 76 | NoiseGeneratorPerlin.__grad(self.__permutations[BB + 1], x - 1.0, y - 1.0, z - 1.0)))) 77 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/generator/noise/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/level/generator/noise/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/material/Material.py: -------------------------------------------------------------------------------- 1 | from enum import IntEnum 2 | 3 | class Material(IntEnum): 4 | air = 0 5 | water = 1 6 | lava = 2 7 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/level/material/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/level/material/__init__.py -------------------------------------------------------------------------------- /mc/net/minecraft/game/physics/AxisAlignedBB.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=3 2 | 3 | cimport cython 4 | 5 | @cython.final 6 | cdef class AxisAlignedBB: 7 | 8 | cdef: 9 | float __epsilon 10 | 11 | public float minX 12 | public float minY 13 | public float minZ 14 | public float maxX 15 | public float maxY 16 | public float maxZ 17 | 18 | cpdef AxisAlignedBB addCoord(self, float xa, float ya, float za) 19 | cdef float calculateXOffset(self, AxisAlignedBB c, float xa) 20 | cdef float calculateYOffset(self, AxisAlignedBB c, float ya) 21 | cdef float calculateZOffset(self, AxisAlignedBB c, float za) 22 | cpdef void offset(self, float xa, float ya, float za) 23 | cdef AxisAlignedBB copy(self) 24 | cpdef calculateIntercept(self, vec1, vec2) 25 | cdef bint __isVecInYZ(self, xa) 26 | cdef bint __isVecInXZ(self, ya) 27 | cdef bint __isVecInXY(self, za) 28 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/physics/MovingObjectPosition.py: -------------------------------------------------------------------------------- 1 | from mc.net.minecraft.game.physics.Vec3D import Vec3D 2 | 3 | class MovingObjectPosition: 4 | 5 | def __init__(self, x, y=None, z=None, sideHit=None, hitVec=None): 6 | if y is None: 7 | entity = x 8 | self.typeOfHit = 1 9 | self.entityHit = entity 10 | self.blockX = 0 11 | self.blockY = 0 12 | self.blockZ = 0 13 | self.sideHit = 0 14 | self.hitVec = None 15 | else: 16 | self.typeOfHit = 0 17 | self.blockX = x 18 | self.blockY = y 19 | self.blockZ = z 20 | self.sideHit = sideHit 21 | self.hitVec = Vec3D(hitVec.xCoord, hitVec.yCoord, hitVec.zCoord) 22 | self.entityHit = None 23 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/physics/Vec3D.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | class Vec3D: 4 | 5 | def __init__(self, x, y, z): 6 | self.xCoord = x 7 | self.yCoord = y 8 | self.zCoord = z 9 | 10 | def subtract(self, vec): 11 | return Vec3D(self.xCoord - vec.xCoord, self.yCoord - vec.yCoord, 12 | self.zCoord - vec.zCoord) 13 | 14 | def normalize(self): 15 | length = math.sqrt(self.xCoord * self.xCoord + \ 16 | self.yCoord * self.yCoord + \ 17 | self.zCoord * self.zCoord) 18 | return Vec3D(self.xCoord / length, self.yCoord / length, 19 | self.zCoord / length) 20 | 21 | def addVector(self, x, y, z): 22 | return Vec3D(self.xCoord + x, self.yCoord + y, self.zCoord + z) 23 | 24 | def distanceTo(self, vec): 25 | xd = vec.xCoord - self.xCoord 26 | yd = vec.yCoord - self.yCoord 27 | zd = vec.zCoord - self.zCoord 28 | return math.sqrt(xd * xd + yd * yd + zd * zd) 29 | 30 | def squaredDistanceTo(self, vec): 31 | xd = vec.xCoord - self.xCoord 32 | yd = vec.yCoord - self.yCoord 33 | zd = vec.zCoord - self.zCoord 34 | return xd * xd + yd * yd + zd * zd 35 | 36 | def getIntermediateWithXValue(self, vec, xa): 37 | xd = vec.xCoord - self.xCoord 38 | yd = vec.yCoord - self.yCoord 39 | zd = vec.zCoord - self.zCoord 40 | if xd * xd < 1.0E-7: 41 | return 42 | 43 | xa = (xa - self.xCoord) / xd 44 | if xa >= 0.0 and xa <= 1.0: 45 | return Vec3D(self.xCoord + xd * xa, self.yCoord + yd * xa, 46 | self.zCoord + zd * xa) 47 | 48 | def getIntermediateWithYValue(self, vec, ya): 49 | xd = vec.xCoord - self.xCoord 50 | yd = vec.yCoord - self.yCoord 51 | zd = vec.zCoord - self.zCoord 52 | if yd * yd < 1.0E-7: 53 | return 54 | 55 | ya = (ya - self.yCoord) / yd 56 | if ya >= 0.0 and ya <= 1.0: 57 | return Vec3D(self.xCoord + xd * ya, self.yCoord + yd * ya, 58 | self.zCoord + zd * ya) 59 | 60 | def getIntermediateWithZValue(self, vec, za): 61 | xd = vec.xCoord - self.xCoord 62 | yd = vec.yCoord - self.yCoord 63 | zd = vec.zCoord - self.zCoord 64 | if zd * zd < 1.0E-7: 65 | return 66 | 67 | za = (za - self.zCoord) / zd 68 | if za >= 0.0 and za <= 1.0: 69 | return Vec3D(self.xCoord + xd * za, self.yCoord + yd * za, 70 | self.zCoord + zd * za) 71 | 72 | def toString(self): 73 | return '(' + self.xCoord + ', ' + self.yCoord + ', ' + self.zCoord + ')' 74 | -------------------------------------------------------------------------------- /mc/net/minecraft/game/physics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/net/minecraft/game/physics/__init__.py -------------------------------------------------------------------------------- /mc/resources/icon/minecraft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/icon/minecraft.png -------------------------------------------------------------------------------- /mc/resources/music/calm1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/music/calm1.ogg -------------------------------------------------------------------------------- /mc/resources/music/calm2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/music/calm2.ogg -------------------------------------------------------------------------------- /mc/resources/music/calm3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/music/calm3.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/bow.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/bow.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/click.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/click.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/explode.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/explode.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/explode1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/explode1.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/explode2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/explode2.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/explode3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/explode3.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/explode4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/explode4.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/fizz.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/fizz.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/fuse.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/fuse.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/hurt.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/hurt.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/pop.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/pop.ogg -------------------------------------------------------------------------------- /mc/resources/newsound/random/splash.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/newsound/random/splash.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/grass1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/grass1.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/grass2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/grass2.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/grass3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/grass3.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/grass4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/grass4.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/gravel1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/gravel1.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/gravel2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/gravel2.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/gravel3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/gravel3.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/gravel4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/gravel4.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/stone1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/stone1.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/stone2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/stone2.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/stone3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/stone3.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/stone4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/stone4.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/wood1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/wood1.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/wood2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/wood2.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/wood3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/wood3.ogg -------------------------------------------------------------------------------- /mc/resources/sound/step/wood4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/sound/step/wood4.ogg -------------------------------------------------------------------------------- /mc/resources/texture/armor/chain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/armor/chain.png -------------------------------------------------------------------------------- /mc/resources/texture/armor/plate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/armor/plate.png -------------------------------------------------------------------------------- /mc/resources/texture/char.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/char.png -------------------------------------------------------------------------------- /mc/resources/texture/clouds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/clouds.png -------------------------------------------------------------------------------- /mc/resources/texture/cube-nes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/cube-nes.png -------------------------------------------------------------------------------- /mc/resources/texture/default.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/default.gif -------------------------------------------------------------------------------- /mc/resources/texture/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/default.png -------------------------------------------------------------------------------- /mc/resources/texture/dirt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/dirt.png -------------------------------------------------------------------------------- /mc/resources/texture/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/grass.png -------------------------------------------------------------------------------- /mc/resources/texture/gui/container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/gui/container.png -------------------------------------------------------------------------------- /mc/resources/texture/gui/crafting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/gui/crafting.png -------------------------------------------------------------------------------- /mc/resources/texture/gui/gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/gui/gui.png -------------------------------------------------------------------------------- /mc/resources/texture/gui/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/gui/icons.png -------------------------------------------------------------------------------- /mc/resources/texture/gui/inventory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/gui/inventory.png -------------------------------------------------------------------------------- /mc/resources/texture/gui/items.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/gui/items.png -------------------------------------------------------------------------------- /mc/resources/texture/gui/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/gui/logo.png -------------------------------------------------------------------------------- /mc/resources/texture/item/arrows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/item/arrows.png -------------------------------------------------------------------------------- /mc/resources/texture/item/sign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/item/sign.png -------------------------------------------------------------------------------- /mc/resources/texture/mcexport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mcexport.png -------------------------------------------------------------------------------- /mc/resources/texture/mcexport2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mcexport2.png -------------------------------------------------------------------------------- /mc/resources/texture/mcexport3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mcexport3.png -------------------------------------------------------------------------------- /mc/resources/texture/misc/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/misc/gear.png -------------------------------------------------------------------------------- /mc/resources/texture/misc/gearmiddle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/misc/gearmiddle.png -------------------------------------------------------------------------------- /mc/resources/texture/mob/creeper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mob/creeper.png -------------------------------------------------------------------------------- /mc/resources/texture/mob/pig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mob/pig.png -------------------------------------------------------------------------------- /mc/resources/texture/mob/sheep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mob/sheep.png -------------------------------------------------------------------------------- /mc/resources/texture/mob/sheep_fur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mob/sheep_fur.png -------------------------------------------------------------------------------- /mc/resources/texture/mob/skeleton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mob/skeleton.png -------------------------------------------------------------------------------- /mc/resources/texture/mob/spider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mob/spider.png -------------------------------------------------------------------------------- /mc/resources/texture/mob/zombie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/mob/zombie.png -------------------------------------------------------------------------------- /mc/resources/texture/particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/particles.png -------------------------------------------------------------------------------- /mc/resources/texture/rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/rain.png -------------------------------------------------------------------------------- /mc/resources/texture/rock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/rock.png -------------------------------------------------------------------------------- /mc/resources/texture/shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/shadow.png -------------------------------------------------------------------------------- /mc/resources/texture/terrain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/terrain.png -------------------------------------------------------------------------------- /mc/resources/texture/water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/mc/resources/texture/water.png -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools", 4 | "wheel", 5 | "cython>=3.0.8", 6 | "numpy>=1.26.0", 7 | ] 8 | build-backend = "setuptools.build_meta" 9 | 10 | [tool.cibuildwheel] 11 | skip = "pp*" 12 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pillow>=8.2.0 2 | pyglet>=1.5.29,<2.0.0 3 | cython>=3.0.8 4 | numpy>=1.26.0 5 | pyogg>=0.6.14a1 6 | wxPython>=4.2.1 7 | nbtlib>=2.0.4 8 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pythonengineer/minecraft-python/aa71f70e07f962056bd3f723293ed81929b6f1e6/screenshot.png --------------------------------------------------------------------------------