Holding sigil can provide it's own mesh provider now

This commit is contained in:
Nicholas Ignoffo 2018-03-07 19:55:32 -08:00
parent 554993ea79
commit fefeaf26af
2 changed files with 20 additions and 10 deletions

View file

@ -240,14 +240,5 @@ public class RegistrarBloodMagicItems {
for (Int2ObjectMap.Entry<String> variant : variants.int2ObjectEntrySet())
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(b), variant.getIntKey(), new ModelResourceLocation(b.getRegistryName(), variant.getValue()));
});
final ResourceLocation holdingLoc = SIGIL_HOLDING.getRegistryName();
ModelLoader.setCustomMeshDefinition(SIGIL_HOLDING, stack -> {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("color"))
return new ModelResourceLocation(holdingLoc, "type=color");
return new ModelResourceLocation(holdingLoc, "type=normal");
});
ModelLoader.registerItemVariants(SIGIL_HOLDING, new ModelResourceLocation(holdingLoc, "type=normal"));
ModelLoader.registerItemVariants(SIGIL_HOLDING, new ModelResourceLocation(holdingLoc, "type=color"));
}
}

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.key.IKeybindable;
import WayofTime.bloodmagic.client.key.KeyBindings;
import WayofTime.bloodmagic.iface.IAltarReader;
@ -12,6 +13,8 @@ import WayofTime.bloodmagic.util.helper.NBTHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper;
import WayofTime.bloodmagic.util.helper.TextHelper;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@ -27,8 +30,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.function.Consumer;
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding {
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding, IMeshProvider {
public static final int inventorySize = 5;
public ItemSigilHolding() {
@ -166,7 +170,22 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
@Override
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
// No-op - Just here to stop the super from running since we're using a mesh provider
}
@Override
public ItemMeshDefinition getMeshDefinition() {
return stack -> {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("color"))
return new ModelResourceLocation(getRegistryName(), "type=color");
return new ModelResourceLocation(getRegistryName(), "type=normal");
};
}
@Override
public void gatherVariants(Consumer<String> variants) {
variants.accept("type=normal");
variants.accept("type=color");
}
public static int next(int mode) {