Fixed the model perspective of the biome radar

This commit is contained in:
Adubbz 2015-12-16 10:21:01 +11:00
parent 2fb6414141
commit fb592e3aaf
4 changed files with 103 additions and 97 deletions

View File

@ -107,72 +107,78 @@ artifacts {
uploadArchives {
dependsOn 'build'
repositories.mavenDeployer {
if ("$System.env.maven_username" != "null" && "$System.env.maven_password" != "null") {
repositories {
if (project.hasProperty("filesmaven")) {
logger.info('Publishing to files server')
mavenDeployer {
configuration = configurations.deployJars
repository(url: "http://files.minecraftforge.net/maven/manage/upload") {
authentication(userName: 'console_script', password: 'dc6d48ca20a474beeac280a9a16a926e')
repository(url: project.filesmaven.url) {
authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key)
}
// This is just the pom data for the maven repo
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'Biomes O Plenty'
url 'https://github.com/Glitchfiend/BiomesOPlenty'
scm {
url 'https://github.com/Glitchfiend/BiomesOPlenty'
connection 'scm:git:git://github.com/Glitchfiend/BiomesOPlenty.git'
developerConnection 'scm:git:git@github.com:Glitchfiend/BiomesOPlenty.git'
}
issueManagement {
system 'github'
url 'https://github.com/Glitchfiend/BiomesOPlenty/issues'
}
licenses {
license {
name 'Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International Public License'
url 'http://creativecommons.org/licenses/by-nc-nd/4.0/'
distribution 'repo'
}
}
developers {
developer {
id 'Adubbz'
name 'Adubbz'
roles { role 'developer' }
}
developer {
id 'Amnet'
name 'Amnet'
roles { role 'developer' }
}
developer {
id 'Forstride'
name 'Forstride'
roles { role 'developer' }
}
developer {
id 'ted80'
name 'ted80'
roles { role 'developer' }
}
}
}
}
}
} else {
logger.info('Publishing to repo folder')
pom.version = "${project.minecraft.version}-${project.version}"
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
}
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'Biomes O Plenty'
url 'https://github.com/Glitchfiend/BiomesOPlenty'
scm {
url 'https://github.com/Glitchfiend/BiomesOPlenty'
connection 'scm:git:git://github.com/Glitchfiend/BiomesOPlenty.git'
developerConnection 'scm:git:git@github.com:Glitchfiend/BiomesOPlenty.git'
}
issueManagement {
system 'github'
url 'https://github.com/Glitchfiend/BiomesOPlenty/issues'
}
licenses {
license {
name 'Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International Public License'
url 'http://creativecommons.org/licenses/by-nc-nd/4.0/'
distribution 'repo'
}
}
developers {
developer {
id 'Adubbz'
name 'Adubbz'
roles { role 'developer' }
}
developer {
id 'Amnet'
name 'Amnet'
roles { role 'developer' }
}
developer {
id 'Forstride'
name 'Forstride'
roles { role 'developer' }
}
developer {
id 'ted80'
name 'ted80'
roles { role 'developer' }
}
}
mavenDeployer {
pom.version = "${project.minecraft.version}-${project.version}"
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
}
}
}

View File

@ -8,6 +8,7 @@
package biomesoplenty.client.handler;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -17,15 +18,17 @@ import biomesoplenty.client.util.TextureUtils;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.SimpleBakedModel;
import net.minecraft.util.IRegistry;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class ModelBakeHandler
{
public static final ModelResourceLocation BIOME_FINDER = new ModelResourceLocation("biomesoplenty:biome_finder", "inventory");
public static final ModelResourceLocation BIOME_FINDER_LOC = new ModelResourceLocation("biomesoplenty:item/biome_finder", "inventory");
public static final ModelResourceLocation BIOME_FINDER_REG_LOC = new ModelResourceLocation("biomesoplenty:biome_finder", "inventory");
public static List<String> fluidsToTextureStitch = new ArrayList<String>();
@ -45,11 +48,16 @@ public class ModelBakeHandler
}
@SubscribeEvent
public void onModelBake(ModelBakeEvent event)
public void onModelBake(ModelBakeEvent event) throws IOException
{
IRegistry modelRegistry = event.modelRegistry;
IBakedModel biomeFinderModel = (IBakedModel)modelRegistry.getObject(BIOME_FINDER);
modelRegistry.putObject(BIOME_FINDER, new ModelBiomeFinder(biomeFinderModel, biomeFinderFrames));
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.modelRegistry;
ModelLoader modelLoader = event.modelLoader;
//NOTE: If there are issues with this in the future, it may be useful to investigate ItemLayerModel
//Get the existing model defined by the json file
IModel biomeFinderModel = modelLoader.getModel(BIOME_FINDER_LOC);
//Replace the existing model with our new flexible one
modelRegistry.putObject(BIOME_FINDER_REG_LOC, new ModelBiomeFinder(biomeFinderModel, biomeFinderFrames));
}
}

View File

@ -18,18 +18,17 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.client.model.IFlexibleBakedModel;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ISmartItemModel;
public class ModelBiomeFinder extends IFlexibleBakedModel.Wrapper implements ISmartItemModel
{
private IBakedModel[] frames;
private IBakedModel defaultModel;
public ModelBiomeFinder(IBakedModel defaultModel, TextureAtlasSprite[] frameTextures)
public ModelBiomeFinder(IModel defaultModel, TextureAtlasSprite[] frameTextures)
{
super(defaultModel, DefaultVertexFormats.ITEM);
this.defaultModel = defaultModel;
super(null, DefaultVertexFormats.ITEM);
this.frames = ModelUtils.generateModelsForTextures(defaultModel, frameTextures);
}
@ -37,7 +36,7 @@ public class ModelBiomeFinder extends IFlexibleBakedModel.Wrapper implements ISm
public IBakedModel handleItemState(ItemStack stack)
{
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
if (player == null) {return this.defaultModel;}
if (player == null) {return this.frames[0];}
NBTTagCompound nbt = stack.getTagCompound();
if (nbt != null && nbt.hasKey("biomeIDToFind"))

View File

@ -8,43 +8,36 @@
package biomesoplenty.client.util;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Function;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.SimpleBakedModel;
import net.minecraft.util.EnumFacing;
import com.google.common.collect.Lists;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
public class ModelUtils
{
public static IBakedModel[] generateModelsForTextures(IBakedModel model, TextureAtlasSprite[] textures)
public static IBakedModel[] generateModelsForTextures(IModel model, TextureAtlasSprite[] textures)
{
IBakedModel[] output = new IBakedModel[textures.length];
for (int i = 0; i < output.length; i++)
{
TextureAtlasSprite texture = textures[i];
SimpleBakedModel.Builder builder = new SimpleBakedModel.Builder(model, texture);
final TextureAtlasSprite texture = textures[i];
//Defines how TextureAtlasSprites are obtained whilst baking
Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
{
public TextureAtlasSprite apply(ResourceLocation location)
{
return texture;
}
};
builder.setTexture(texture);
output[i] = builder.makeBakedModel();
output[i] = model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter);
}
return output;
}
public static List createFaceLists()
{
List list = new ArrayList(EnumFacing.values().length);
for (int i = 0; i < EnumFacing.values().length; i++)
{
list.add(i, Lists.newLinkedList());
}
return list;
}
}