fix item sprites
This commit is contained in:
parent
1ef1b4ae30
commit
5c0e71f80c
10 changed files with 43 additions and 209 deletions
|
@ -1,33 +1,23 @@
|
|||
package client.renderer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import client.renderer.blockmodel.IBakedModel;
|
||||
import client.renderer.blockmodel.ModelManager;
|
||||
import client.renderer.texture.TextureAtlasSprite;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.init.ItemRegistry;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.ItemMeshDefinition;
|
||||
|
||||
public class ItemModelMesher
|
||||
{
|
||||
// private final Map<Integer, ResourceLocation> simpleShapes = Maps.<Integer, ResourceLocation>newHashMap();
|
||||
private final Map<Integer, IBakedModel> simpleShapesCache = Maps.<Integer, IBakedModel>newHashMap();
|
||||
private final Map<Item, ItemMeshDefinition> shapers = Maps.<Item, ItemMeshDefinition>newHashMap();
|
||||
private final ModelManager modelManager;
|
||||
|
||||
public ItemModelMesher(ModelManager modelManager)
|
||||
{
|
||||
this.modelManager = modelManager;
|
||||
for(Item item : ItemRegistry.REGISTRY) {
|
||||
ItemMeshDefinition mesher = item.getMesher();
|
||||
if(mesher != null)
|
||||
this.shapers.put(item, mesher);
|
||||
}
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getParticleIcon(Item item)
|
||||
|
@ -40,16 +30,6 @@ public class ItemModelMesher
|
|||
Item item = stack.getItem();
|
||||
IBakedModel ibakedmodel = this.simpleShapesCache.get(this.getIndex(item));
|
||||
|
||||
if (ibakedmodel == null)
|
||||
{
|
||||
ItemMeshDefinition itemmeshdefinition = this.shapers.get(item);
|
||||
|
||||
if (itemmeshdefinition != null)
|
||||
{
|
||||
ibakedmodel = this.modelManager.getModel(itemmeshdefinition.getModelLocation(stack));
|
||||
}
|
||||
}
|
||||
|
||||
if (ibakedmodel == null)
|
||||
{
|
||||
ibakedmodel = this.modelManager.getMissingModel();
|
||||
|
@ -110,22 +90,10 @@ public class ItemModelMesher
|
|||
public void rebuildCache()
|
||||
{
|
||||
this.simpleShapesCache.clear();
|
||||
List<ItemStack> stacks = Lists.newArrayList();
|
||||
for(Item item : ItemRegistry.REGISTRY) {
|
||||
if(this.shapers.containsKey(item))
|
||||
continue;
|
||||
item.getRenderItems(item, stacks);
|
||||
for(ItemStack stack : stacks) {
|
||||
this.simpleShapesCache.put(this.getIndex(item),
|
||||
this.modelManager.getModel("item/" +
|
||||
ItemRegistry.getNameFromItem(item).toString() + '#' + "inventory"));
|
||||
}
|
||||
stacks.clear();
|
||||
this.simpleShapesCache.put(this.getIndex(item),
|
||||
this.modelManager.getModel("item/" +
|
||||
ItemRegistry.getNameFromItem(item).toString() + '#' + "inventory"));
|
||||
}
|
||||
|
||||
// for (Entry<Integer, ResourceLocation> entry : this.simpleShapes.entrySet())
|
||||
// {
|
||||
// this.simpleShapesCache.put(entry.getKey(), this.modelManager.getModel((ResourceLocation)entry.getValue()));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,6 @@ public abstract class ModelBakery
|
|||
// variants.add(res);
|
||||
|
||||
// RenderRegistry.registerVariants(variantNames);
|
||||
List<ItemStack> stacks = Lists.newArrayList();
|
||||
for (Item item : ItemRegistry.REGISTRY)
|
||||
{
|
||||
// List<Integer> list = variantNames.get(item);
|
||||
|
@ -142,13 +141,17 @@ public abstract class ModelBakery
|
|||
// list = Collections.<Integer>singletonList(0);
|
||||
// for(Integer s : list)
|
||||
// {
|
||||
item.getRenderItems(item, stacks);
|
||||
for(ItemStack stack : stacks) {
|
||||
String resourcelocation = "item/" + ItemRegistry.getNameFromItem(item).toString() + '#' + "inventory";
|
||||
models.put(resourcelocation, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item).toString()));
|
||||
itemLocations.add(resourcelocation);
|
||||
}
|
||||
stacks.clear();
|
||||
String loc = "item/" + ItemRegistry.getNameFromItem(item) + '#' + "inventory";
|
||||
models.put(loc, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item)));
|
||||
itemLocations.add(loc);
|
||||
String[] extra = item.getRenderItems();
|
||||
if(extra != null) {
|
||||
for(String sprite : extra) {
|
||||
loc = "item/" + sprite + '#' + "inventory";
|
||||
models.put(loc, (ModelBlock)ModelBlock.PROVIDER.getModel(item.getTransform(), sprite));
|
||||
itemLocations.add(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Set<String> set = Sets.<String>newHashSet();
|
||||
|
|
|
@ -226,34 +226,9 @@ public class RenderItem
|
|||
{
|
||||
EntityNPC entityplayer = (EntityNPC)entityToRenderFor;
|
||||
Item item = stack.getItem();
|
||||
String modelresourcelocation = null;
|
||||
|
||||
if (item == Items.fishing_rod && entityplayer.fishEntity != null)
|
||||
{
|
||||
modelresourcelocation = "item/fishing_rod_cast" + '#' + "inventory";
|
||||
}
|
||||
else if (item == Items.bow && entityplayer.getItemInUse() != null)
|
||||
{
|
||||
int i = stack.getMaxItemUseDuration() - entityplayer.getItemInUseCount();
|
||||
|
||||
if (i >= 18)
|
||||
{
|
||||
modelresourcelocation = "item/bow_pulling_3" + '#' + "inventory";
|
||||
}
|
||||
else if (i > 13)
|
||||
{
|
||||
modelresourcelocation = "item/bow_pulling_2" + '#' + "inventory";
|
||||
}
|
||||
else if (i > 0)
|
||||
{
|
||||
modelresourcelocation = "item/bow_pulling_1" + '#' + "inventory";
|
||||
}
|
||||
}
|
||||
|
||||
if (modelresourcelocation != null)
|
||||
{
|
||||
ibakedmodel = this.itemModelMesher.getModelManager().getModel(modelresourcelocation);
|
||||
}
|
||||
String sprite = item == null ? null : item.getSprite(entityplayer, stack);
|
||||
if(sprite != null)
|
||||
ibakedmodel = this.itemModelMesher.getModelManager().getModel("item/" + sprite + '#' + "inventory");
|
||||
}
|
||||
|
||||
this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue