From 502d50162868b53ebedf9aa7d840d2de5f65f235 Mon Sep 17 00:00:00 2001 From: steev Date: Wed, 25 Oct 2023 07:33:09 +0200 Subject: [PATCH 1/2] added wall and roof class --- README.md | 2 -- wall.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) delete mode 100644 README.md create mode 100644 wall.py diff --git a/README.md b/README.md deleted file mode 100644 index c40db15..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# pyblock-exporer - diff --git a/wall.py b/wall.py new file mode 100644 index 0000000..7df3e03 --- /dev/null +++ b/wall.py @@ -0,0 +1,29 @@ +from pyblockworld import World + +class Wall: + __length:int + __width:int + __height:int + __rotated:bool + __x:float + __y:float + __z:float + __world:World + __block:str + + def __init__(self, x:float, y:float, z:float, block:str, world:World, length=10, width=10, height=5, rotated=False): + self.__width = width + self.__length = length + self.__height = height + self.__x = x + self.__y = y - 1 + self.__z = z + self.__world = world + self.__rotated = rotated + self.__block = block + + def build(self): + if self.__rotated: + self.__world.setBlocks(self.__x, self.__y, self.__z, self.__x + self.__width, self.__y + self.__height, self.__z, self.__block) + else: + self.__world.setBlocks(self.__x, self.__y, self.__z, self.__x, self.__y + self.__height, self.__z + self.__length, self.__block) -- 2.47.2 From 3cf248e4253da0e39ab2420c454810c4a8696ace Mon Sep 17 00:00:00 2001 From: steev Date: Mon, 30 Oct 2023 13:34:01 +0100 Subject: [PATCH 2/2] added wallwithwindow --- .idea/.gitignore | 8 ++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/misc.xml | 7 ++++ .idea/modules.xml | 8 ++++ .idea/pythonProject.iml | 10 +++++ .idea/vcs.xml | 6 +++ WallWithDoor.py | 22 +++++++++++ WallWithWindow.py | 37 +++++++++++++++++++ main.py | 28 ++++++++++++++ roof.py | 37 +++++++++++++++++++ wall.py | 22 +++++++++++ 11 files changed, 191 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/pythonProject.iml create mode 100644 .idea/vcs.xml create mode 100644 WallWithDoor.py create mode 100644 WallWithWindow.py create mode 100644 main.py create mode 100644 roof.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7eb8ee6 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e15ec35 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/pythonProject.iml b/.idea/pythonProject.iml new file mode 100644 index 0000000..aee9ef2 --- /dev/null +++ b/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WallWithDoor.py b/WallWithDoor.py new file mode 100644 index 0000000..e7d3deb --- /dev/null +++ b/WallWithDoor.py @@ -0,0 +1,22 @@ +from pyblockworld import World +from wall import Wall +class WallWithDoor(Wall): + __windowBlock:str + def __init__(self, x:float, y:float, z:float, block:str, window:str, world:World, width:int=10, height:int=5, rotated:bool=False): + super().__init__(x, y, z, block, world, width, height, rotated) + self.__windowBlock = window + + def build(self): + super().build() + x = super().getX() + y = super().getY() + 2 + z = super().getZ() / 2 + + super().getWorld().setBlocks( + x, + y, + z, + x, + y + 2, + z, + self.__windowBlock) diff --git a/WallWithWindow.py b/WallWithWindow.py new file mode 100644 index 0000000..d72a9f8 --- /dev/null +++ b/WallWithWindow.py @@ -0,0 +1,37 @@ +from pyblockworld import World +from wall import Wall +class WallWithWindow(Wall): + __windowBlock:str + def __init__(self, x:float, y:float, z:float, block:str, window:str, world:World, width:int=10, height:int=5): + super().__init__(x, y, z, block, world, width, height) + self.__windowBlock = window + + def build(self): + super().build() + + if super().getLength() < 6: + x = super().getX() + y = super().getY() + 2 + z = super().getZ() + 2 + + super().getWorld().setBlocks( + x, + y, + z, + x, + y + 1, + z + 2, + self.__windowBlock) + else: + x = super().getX() + y = super().getY() + 2 + z = super().getZ() + 3 + + super().getWorld().setBlocks( + x, + y, + z, + x, + y + (super().getHeight()-4), + z + (super().getLength()-(super().getLength()/2)), + self.__windowBlock) diff --git a/main.py b/main.py new file mode 100644 index 0000000..092314f --- /dev/null +++ b/main.py @@ -0,0 +1,28 @@ +from pyblockworld import World + +import WallWithDoor +import wall +import WallWithWindow +import roof + +# Nun werden beim Drücken der Taste ein paar Blöcke platziert. +def b_key_pressed(world: World): + x, y, z = world.player_position() + + wall1 = wall.Wall(x=x, y=y, z=z, world=world, block="default:brick") + wall2 = wall.Wall(x=x, y=y, z=z, world=world, rotated=True, block="default:brick") + wall3 = WallWithWindow.WallWithWindow(x=x+10, y=y, z=z, block="default:brick", window="default:grass", world=world) + roof1 = roof.Roof(x, y + 5, z, "default:brick", world) + + print("wall1 constructed") + wall1.build() + print("wall2 constructed") + wall2.build() + print("wall3 constructed") + wall3.build() + print("wall4 constructed") + roof1.build() + +world = World() +world.build_key_pressed = b_key_pressed +world.run() \ No newline at end of file diff --git a/roof.py b/roof.py new file mode 100644 index 0000000..ce4f5f9 --- /dev/null +++ b/roof.py @@ -0,0 +1,37 @@ +from pyblockworld import World + +class Roof: + __width:int + __height:int + __x:float + __y:float + __z:float + __world:World + __block:str + + def __init__(self, x:float, y:float, z:float, block:str, world:World, height=10, width=10): + self.__x = x + self.__y = y + self.__z = z + self.__width = width + self.__height = height + self.__world = world + self.__block = block + + def build(self): + self.__world.setBlocks(self.__x, self.__y, self.__z, self.__x + self.__width, self.__y, self.__z + self.__height, self.__block) + + def getWidth(self): + return self.__width + + def getHeight(self): + return self.__height + + def getX(self): + return self.__x + + def getY(self): + return self.__y + + def getZ(self): + return self.__z \ No newline at end of file diff --git a/wall.py b/wall.py index 7df3e03..5493ad4 100644 --- a/wall.py +++ b/wall.py @@ -27,3 +27,25 @@ class Wall: self.__world.setBlocks(self.__x, self.__y, self.__z, self.__x + self.__width, self.__y + self.__height, self.__z, self.__block) else: self.__world.setBlocks(self.__x, self.__y, self.__z, self.__x, self.__y + self.__height, self.__z + self.__length, self.__block) + + def getWidth(self): + return self.__width + + def getHeight(self): + return self.__height + + def getLength(self): + return self.__length + + def getWorld(self): + return self.__world + + def getX(self): + return self.__x + def getY(self): + return self.__y + def getZ(self): + return self.__z + + def getRotated(self): + return self.__rotated \ No newline at end of file -- 2.47.2