Skip to content

Commit

Permalink
Animated Textures WIP, added lazy_biome_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspirata committed Jun 6, 2024
1 parent 9c6e8d4 commit 417599b
Show file tree
Hide file tree
Showing 8,442 changed files with 91,767 additions and 217 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added Animated Textures Test.blend
Binary file not shown.
3 changes: 3 additions & 0 deletions Mcblend Source/Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from bpy.types import PropertyGroup

main_directory = os.path.dirname(os.path.realpath(__file__))
resource_packs_directory = os.path.join(main_directory, "Resource Packs")
materials_file_path = os.path.join(main_directory, "Materials", "Materials.blend")
materials_folder = os.path.join(main_directory, "Materials")
optimization_folder = os.path.join(main_directory, "Optimization")
Expand Down Expand Up @@ -245,6 +246,8 @@

SSS_Materials = ["leaves", "grass", "tulip", "oxeye_daisy", "dandelion", "poppy", "blue_orchid", "torchflower", "lily_of_the_valley", "cornflower", "allium", "azure bluet"]

Biome_Fix_Materials = ["leaves", "grass", "water"]

Metal = ["iron", "gold", "copper", "diamond", "netherite", "minecart", "lantern", "chain", "anvil", "clock", "cauldron", "spyglass", "rail"]

Reflective = ["glass", "ender", "amethyst", "water", "emerald"]
Expand Down
117 changes: 61 additions & 56 deletions Mcblend Source/MCB_API.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from .Data import *

def InitOnStart():

if "resource_packs" not in bpy.context.scene:
bpy.context.scene["resource_packs"] = {}
update_default_pack()

items = bpy.context.scene.assetsproperties.asset_items
items.clear()
for category, assets in Assets.items():
for key in assets.keys():
item = items.add()
item.name = key

def Absolute_Solver(error_code="None", data=None, err=None, error_name=None, description=None):

def GetASText(error_code, text, data=None):
Expand Down Expand Up @@ -39,17 +52,55 @@ def GetConnectedSocketTo(input, tag, material=None):
if link.to_socket.name == input_socket.name:
return link.from_socket

def InitOnStart():
def get_resource_packs(debug=None):
if debug is not None:
print(f"Resource Packs: {bpy.context.scene['resource_packs']}")

return bpy.context.scene["resource_packs"]

def set_resource_packs(resource_packs, debug=None):
bpy.context.scene["resource_packs"] = resource_packs

if debug is not None:
print(f"Resource Packs: {bpy.context.scene['resource_packs']}")

def update_default_pack(debug=None):
resource_packs = bpy.context.scene["resource_packs"]

default_pack = "Minecraft 1.20.6"
default_path = os.path.join(resource_packs_directory, "Minecraft 1.20.6")
resource_packs[default_pack] = {"path": (default_path), "enabled": True}

if "resource_packs" not in bpy.context.scene:
bpy.context.scene["resource_packs"] = {}
if debug is not None:
print(f"Default Pack: {default_pack} stored in {default_path}")

items = bpy.context.scene.assetsproperties.asset_items
items.clear()
for category, assets in Assets.items():
for key in assets.keys():
item = items.add()
item.name = key
def find_image(image_name, root_folder):
# Check in the directory
for dirpath, _, filenames in os.walk(root_folder):
if image_name in filenames:
return os.path.join(dirpath, image_name)

# Check in zip files within the directory
for dirpath, _, files in os.walk(root_folder):
for file in files:
if file.endswith('.zip'):
with zipfile.ZipFile(os.path.join(dirpath, file), 'r') as zip_ref:
for zip_info in zip_ref.infolist():
if os.path.basename(zip_info.filename) == image_name:
extract_path = os.path.join(main_directory, 'Resource Packs', os.path.splitext(file)[0])
extracted_file_path = zip_ref.extract(zip_info, extract_path)
return extracted_file_path

# Check if root folder is a zip file
if root_folder.endswith('.zip'):
with zipfile.ZipFile(root_folder, 'r') as zip_ref:
for zip_info in zip_ref.infolist():
if os.path.basename(zip_info.filename) == image_name:
extract_path = os.path.join(main_directory, 'Resource Packs', os.path.splitext(os.path.basename(root_folder))[0])
extracted_file_path = zip_ref.extract(zip_info, extract_path)
return extracted_file_path

return None

def blender_version(blender_version, debug=None):

Expand Down Expand Up @@ -97,50 +148,4 @@ def blender_version(blender_version, debug=None):
elif operator == '==':
return bpy.app.version == version
else:
return False

def get_resource_packs(scene, debug=None):
if debug is not None:
print(f"Resource Packs: {scene['resource_packs']}")

return scene["resource_packs"]

def set_resource_packs(scene, resource_packs, debug=None):
scene["resource_packs"] = resource_packs

if debug is not None:
print(f"Resource Packs: {scene['resource_packs']}")

def update_default_pack(scene, debug=None):
resource_packs = scene["resource_packs"]

default_pack = "Minecraft 1.20.1"
default_path = r"C:\Users\const\OneDrive\Документы\GitHub\Mcblend\Minecraft Assets"
resource_packs[default_pack] = {"path": default_path, "enabled": True}

if debug is not None:
print(f"Default Pack: {resource_packs[default_pack]}")

def find_image(image_name, root_folder):
# Check in the directory
for dirpath, _, filenames in os.walk(root_folder):
if image_name in filenames:
return os.path.join(dirpath, image_name)

# Check in zip files within the directory
for root, _, files in os.walk(root_folder):
for file in files:
if file.endswith('.zip'):
with zipfile.ZipFile(os.path.join(root, file), 'r') as zip_ref:
for zip_info in zip_ref.infolist():
if os.path.basename(zip_info.filename) == image_name:
return zip_ref.extract(zip_info, os.path.join(root_folder, 'temp'))

# Check if root folder is a zip file
if root_folder.endswith('.zip'):
with zipfile.ZipFile(root_folder, 'r') as zip_ref:
for zip_info in zip_ref.infolist():
if os.path.basename(zip_info.filename) == image_name:
return zip_ref.extract(zip_info, os.path.join(os.path.dirname(root_folder), 'temp'))

return None
return False
Binary file modified Mcblend Source/Materials/Materials.blend
Binary file not shown.
Loading

0 comments on commit 417599b

Please sign in to comment.