mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Improve Wood Model Loader
This commit is contained in:
1 parent
736e6c5fa2
commit
09ea20729d
2 files changed
+30
-21
No files matched your search
@@ -3,6 +3,14 @@ package forestry.arboriculture;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodItemMeshDefinition;
|
||||
@@ -11,13 +19,7 @@ import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.arboriculture.models.WoodModelLoader;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class WoodHelper {
|
||||
|
||||
@@ -86,7 +88,12 @@ public class WoodHelper {
|
||||
if (woodType instanceof EnumVanillaWoodType) {
|
||||
return new ModelResourceLocation("minecraft:" + woodType + "_" + blockKind, "inventory");
|
||||
} else {
|
||||
return ModelManager.getInstance().getModelLocation(blockKind + "/" + woodType);
|
||||
String modID = Constants.MOD_ID;
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if(block != null){
|
||||
modID = block.getRegistryName().getResourceDomain();
|
||||
}
|
||||
return new ModelResourceLocation(modID + ":" + blockKind + "/" + woodType, "inventory");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package forestry.arboriculture.blocks;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodStateMapper;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.models.WoodModelLoader;
|
||||
import forestry.core.config.Constants;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
@@ -20,9 +14,17 @@ import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodStateMapper;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.models.WoodModelLoader;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class WoodTypeStateMapper extends StateMapperBase implements IWoodStateMapper {
|
||||
private final IWoodTyped woodTyped;
|
||||
@@ -70,14 +72,14 @@ public class WoodTypeStateMapper extends StateMapperBase implements IWoodStateMa
|
||||
Block block = state.getBlock();
|
||||
int meta = block.getMetaFromState(state);
|
||||
IWoodType woodType = woodTyped.getWoodType(meta);
|
||||
if (woodType instanceof EnumForestryWoodType) {
|
||||
if (woodType instanceof EnumVanillaWoodType) {
|
||||
return getVanillaModelResourceLocation(block, woodType, properties);
|
||||
} else {
|
||||
if (WoodModelLoader.INSTANCE.isEnabled) {
|
||||
return getForestryModelResourceLocation(woodType, properties);
|
||||
return getModelResourceLocation(woodType, properties, block.getRegistryName().getResourceDomain());
|
||||
} else {
|
||||
return getDefaultModelResourceLocation(state);
|
||||
}
|
||||
} else {
|
||||
return getVanillaModelResourceLocation(block, woodType, properties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,10 +102,10 @@ public class WoodTypeStateMapper extends StateMapperBase implements IWoodStateMa
|
||||
return new ModelResourceLocation(Constants.MOD_ID + ':' + resourceLocation, propertyString);
|
||||
}
|
||||
|
||||
private ModelResourceLocation getForestryModelResourceLocation(IWoodType woodType, Map<IProperty<?>, Comparable<?>> properties) {
|
||||
private ModelResourceLocation getModelResourceLocation(IWoodType woodType, Map<IProperty<?>, Comparable<?>> properties, String modID) {
|
||||
String resourceLocation = "arboriculture/" + blockPath + '/' + woodType;
|
||||
String propertyString = this.getPropertyString(properties);
|
||||
return new ModelResourceLocation(Constants.MOD_ID + ':' + resourceLocation, propertyString);
|
||||
return new ModelResourceLocation(modID + ':' + resourceLocation, propertyString);
|
||||
}
|
||||
|
||||
private ModelResourceLocation getVanillaModelResourceLocation(Block block, IWoodType woodType, Map<IProperty<?>, Comparable<?>> properties) {
|
||||
|
||||
Reference in new issue
Block a user