Skip to content

Commit

Permalink
Added support for armor stands & armor
Browse files Browse the repository at this point in the history
  • Loading branch information
DavixDevelop committed Apr 30, 2024
1 parent 5c9b49f commit b49b5e9
Show file tree
Hide file tree
Showing 534 changed files with 3,005 additions and 517 deletions.
13 changes: 8 additions & 5 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
- [0.8](https://github.com/DavixDevelop/schem2obj/releases/tag/v0.8)
- Added support for armor stands & armor
- Added improved glass shader in `MCImportCleanUp_Blender.py` script
- [0.7](https://github.com/DavixDevelop/schem2obj/releases/tag/v0.7)
- Dropped `alpha` tag
- Added new optional parameter `-biome <biome_id>`
- Added support for following Blocks:
- Wall
- Fence Gate
- Dropped `alpha` tag
- Added new optional parameter `-biome <biome_id>`
- Added support for following Blocks:
- Wall
- Fence Gate
- [0.6](https://github.com/DavixDevelop/schem2obj/releases/tag/v0.6-alpha)
- Memory optimized generating and converting of blocks, to enable converting larger schematics
- The exported OBJ file (if the optional parameter `-allBlocks` isn't set), now consists of only one object,
Expand Down
757 changes: 539 additions & 218 deletions MCImportCleanUp_Blender.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ All basic blocks (that are only basic cubes), and builtin blocks (ex, water, ban
- Paintings
- Boats (All variants)
- Item Frames (Including holding items (all supported blocks & entities))
- Armor Stand & Armor

### Supported resource packs
For now, only resource packs that use the SEUS or Vanilla format are supported. Beside using the textures the resource pack includes,
Expand Down
Binary file modified Schem2Obj_Banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'com.davixdevelop.schem2obj.SchemeToObj'

group 'com.davixdevelop'
version '0.7.' + ('git rev-list --count HEAD'.execute().text.trim())
version '0.8.' + ('git rev-list --count HEAD'.execute().text.trim())
archivesBaseName = "schem2obj"

compileJava {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/davixdevelop/schem2obj/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static void setConstants(){
EntityFolderFilter.add("zombie");
EntityFolderFilter.add("chest");
EntityFolderFilter.add("boat");
EntityFolderFilter.add("armorstand");

SupportedEntities.add("minecart");
SupportedEntities.add("bed");
Expand All @@ -61,6 +62,7 @@ public static void setConstants(){
SupportedEntities.add("painting");
SupportedEntities.add("boat");
SupportedEntities.add("item_frame");
SupportedEntities.add("armor_stand");

BANNER_COLORS.put(0, new IntegerString("black", 1644825));
BANNER_COLORS.put(1, new IntegerString("red",10040115));
Expand Down Expand Up @@ -152,6 +154,7 @@ public static void setConstants(){
public static int CONSTANT_BIOME_ID = 1;

public static int SNOW_COLOR = 16316922;
public static int DEFAULT_LEATHER_COLOR = 10511680;

public static int SWAMPLAND_PURPLE_OVERLAY = 10716067;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public BiomeCollection(){

//Get tge input stream of biomes.json
//biomes.json was generated using ExtractBlocks (https://github.com/DavixDevelop/ExtractBlocks)
InputStream biomesStream = this.getClass().getClassLoader().getResourceAsStream("assets/minecraft/biomes.json");
InputStream biomesStream = this.getClass().getClassLoader().getResourceAsStream("assets/schem2obj/biomes.json");

if(biomesStream != null){
//Get reader for input stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,13 @@ else if(rawAngle instanceof String){
fixedDisplay.scale = new Double[]{rawFixedDisplay.scale[0], rawFixedDisplay.scale[2], rawFixedDisplay.scale[1]};
}

model = new BlockModel(modelName, rawModel.parent, rawModel.ambientOcclusion, new BlockTextures(particle, textureVariables),cubeElements, fixedDisplay);
String parentModel = rawModel.parent;
//Check if parent model path includes the namespace, ex. "minecraft:", and remove it
if(parentModel != null && parentModel.contains(":"))
parentModel = parentModel.substring(parentModel.indexOf(":") + 1);


model = new BlockModel(modelName, parentModel, rawModel.ambientOcclusion, new BlockTextures(particle, textureVariables),cubeElements, fixedDisplay);
return model;
}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/davixdevelop/schem2obj/cubemodels/CubeModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,20 @@ public void fromCubes(String name, Boolean uvLock, ArrayVector.MatrixRotation ro
}
}


/**
* Create the cube model from the name and a map of texture variables
* @param name The name of the cube model
* @param modelsMaterials A map of texture variables and the material it's set to, ex key: #north, value: block/dirt
*/
public void fromName(String name, HashMap<String,String> modelsMaterials){
setName(name);

//Set the materials the cubes to the cube model
materials = new HashedStringList();
for(String textureVariable : modelsMaterials.keySet())
materials.put(modelsMaterials.get(textureVariable));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import com.davixdevelop.schem2obj.cubemodels.entity.*;
import com.davixdevelop.schem2obj.cubemodels.entitytile.*;
import com.davixdevelop.schem2obj.cubemodels.item.ItemCubeModel;
import com.davixdevelop.schem2obj.cubemodels.item.armor.ArmorBootsCubeModel;
import com.davixdevelop.schem2obj.cubemodels.item.armor.ArmorChestplateCubeModel;
import com.davixdevelop.schem2obj.cubemodels.item.armor.ArmorHelmetCubeModel;
import com.davixdevelop.schem2obj.cubemodels.item.armor.ArmorLeggingsCubeModel;
import com.davixdevelop.schem2obj.namespace.Namespace;
import com.davixdevelop.schem2obj.resourceloader.ResourceLoader;
import com.davixdevelop.schem2obj.schematic.EntityValues;
Expand Down Expand Up @@ -91,18 +95,12 @@ public ICubeModel fromNamespace(Namespace namespace){
}
}

public ICubeModel getItemModel(EntityValues item, Namespace itemHolderNamespace){
boolean itemUsesBlockAsIcon = false;

public Namespace getNamespaceFromItem(EntityValues item){
//Get namespace of item
String itemResource = item.getString("id");
String itemResourcePath = itemResource.substring(itemResource.indexOf(":") + 1);
Namespace namespace = Constants.NAMESPACE_MAPPING.getNamespace(itemResource);

//If namespace is null, the item uses the icon in textures/items as the item model
if(namespace == null)
itemUsesBlockAsIcon = true;
else{
if(namespace != null){
namespace.setPosition(new Integer[]{0,0,0});

Set<String> tagKeys = new LinkedHashSet<>();
Expand Down Expand Up @@ -173,6 +171,27 @@ public ICubeModel getItemModel(EntityValues item, Namespace itemHolderNamespace)
namespace.setCustomData(entityValues);
}

return namespace;
}

/**
* Get the item model from the Item nbt tag
* @param item The nbt tag of the Item
* @param itemHolderNamespace The namespace of the object that holds the Item
* @return The model of the Item
*/
public ICubeModel getItemModel(EntityValues item, Namespace itemHolderNamespace){
boolean itemUsesBlockAsIcon = false;

//Get namespace of item
String itemResource = item.getString("id");
String itemResourcePath = itemResource.substring(itemResource.indexOf(":") + 1);
Namespace namespace = getNamespaceFromItem(item);

//If namespace is null, the item uses the icon in textures/items as the item model
if(namespace == null)
itemUsesBlockAsIcon = true;


ICubeModel itemCubeModel = null;
Map<String, Object> key = new LinkedHashMap<>();
Expand All @@ -186,17 +205,8 @@ public ICubeModel getItemModel(EntityValues item, Namespace itemHolderNamespace)

Object itemKey = !key.isEmpty() ? key : itemResource;

/*if(itemGenerationQueue.contains(itemKey)){
while (true){
if(!itemGenerationQueue.contains(itemKey))
break;
}
}else
itemGenerationQueue.add(itemKey);*/


if(itemModels.containsKey(itemKey)){
//itemGenerationQueue.remove(itemKey);
return itemModels.get(itemKey).duplicate();
}else{
String item_resource = null;
Expand Down Expand Up @@ -286,6 +296,8 @@ public static ICubeModel getType(Namespace blockNamespace){
return new BoatCubeModel();
case "item_frame":
return new ItemFrameCubeModel();
case "armor_stand":
return new ArmorStandModel();
}

if (blockNamespace.getResource().contains("slab") && !blockNamespace.getResource().contains("double"))
Expand Down Expand Up @@ -315,6 +327,18 @@ public static ICubeModel getType(Namespace blockNamespace){
if(blockNamespace.getResource().contains("fence_gate"))
return new FenceGateCubeModel();

if(blockNamespace.getType().contains("_helmet"))
return new ArmorHelmetCubeModel();

if(blockNamespace.getType().contains("_chestplate"))
return new ArmorChestplateCubeModel();

if(blockNamespace.getType().contains("_leggings"))
return new ArmorLeggingsCubeModel();

if(blockNamespace.getType().contains("_boots"))
return new ArmorBootsCubeModel();


switch (blockNamespace.getType()) {
case "grass":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
Expand Down Expand Up @@ -103,15 +102,21 @@ public static void generateOrGetMaterial(String materialPath, Namespace namespac

String diffuseTexturePath = null;

if(materialPath.startsWith("blocks") || materialPath.startsWith("painting") || materialPath.startsWith("items") || (materialPath.startsWith("entity") && !materialPath.contains("-"))) {
if(materialPath.startsWith("blocks") || materialPath.startsWith("painting") || materialPath.startsWith("items") || materialPath.startsWith("models") || (materialPath.startsWith("entity") && !materialPath.contains("-"))) {
diffuseTexturePath = materialPath;
}else if(materialPath.startsWith("entity") && materialPath.contains("-")){
String materialName = textureName(materialPath);
//If material path contains a -, it means the texture for that material is in a subfolder with the name of the entity
//Ex: black-bed -> diffuseTextureFile = entity/bed/black
diffuseTexturePath = String.format("entity/%s/%s", materialName.substring(materialName.indexOf('-') + 1), materialName.substring(0, materialName.indexOf('-')));
}else{
diffuseTexturePath = materialPath;
}

//Check if texture path contains the namespace, ex. ":minecraft", and remove it
if(diffuseTexturePath != null && diffuseTexturePath.contains(":"))
diffuseTexturePath = diffuseTexturePath.substring(diffuseTexturePath.indexOf(":") + 1);

String diffusePath = ResourceLoader.getResourcePath("textures", diffuseTexturePath,"png");

ResourcePack.Format materialFormat = ResourceLoader.getFormat(diffusePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author DavixDevelop
*/
public class RedstoneWireCubeModel extends CubeModel implements IAdjacentCheck {
static AdjacentBlockState ADJACENT_REDSTONE_WIRE_STATES = new AdjacentBlockState("assets/minecraft/redstone_wire_states.json");
static AdjacentBlockState ADJACENT_REDSTONE_WIRE_STATES = new AdjacentBlockState("assets/schem2obj/redstone_wire_states.json");
static Set<String> MODIFIED_REDSTONE_WIRE_MATERIALS = new HashSet<>();

private String power;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @author DavixDevelop
*/
public class StairsCubeModel extends BlockCubeModel implements IAdjacentCheck {
public static AdjacentBlockState ADJACENT_STAIRS_STATES = new AdjacentBlockState("assets/minecraft/stairs_states.json");
public static AdjacentBlockState ADJACENT_STAIRS_STATES = new AdjacentBlockState("assets/schem2obj/stairs_states.json");

private String half;
private String facing;
Expand Down
Loading

0 comments on commit b49b5e9

Please sign in to comment.