diff --git a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java index 4afa594e..e7085209 100644 --- a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java +++ b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java @@ -16,10 +16,13 @@ import WayofTime.bloodmagic.item.routing.ItemNodeRouter; import WayofTime.bloodmagic.item.routing.ItemRouterFilter; import WayofTime.bloodmagic.item.sigil.*; import WayofTime.bloodmagic.item.soul.*; +import WayofTime.bloodmagic.item.types.AlchemicTypes; import WayofTime.bloodmagic.item.types.ComponentTypes; import WayofTime.bloodmagic.item.types.ShardType; + import com.google.common.collect.Lists; import com.google.common.collect.Sets; + import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -43,7 +46,8 @@ import java.util.Set; @Mod.EventBusSubscriber(modid = BloodMagic.MODID) @GameRegistry.ObjectHolder(BloodMagic.MODID) @SuppressWarnings("unchecked") -public class RegistrarBloodMagicItems { +public class RegistrarBloodMagicItems +{ public static final Item BLOOD_ORB = Items.AIR; public static final Item ACTIVATION_CRYSTAL = Items.AIR; @@ -117,6 +121,7 @@ public class RegistrarBloodMagicItems { public static final Item POINTS_UPGRADE = Items.AIR; public static final Item DEMON_WILL_GAUGE = Items.AIR; public static final Item POTION_FLASK = Items.AIR; + public static final Item ALCHEMIC_VIAL = Items.AIR; public static Item.ToolMaterial BOUND_TOOL_MATERIAL = EnumHelper.addToolMaterial("bound", 4, 1, 10, 8, 50); public static Item.ToolMaterial SOUL_TOOL_MATERIAL = EnumHelper.addToolMaterial("demonic", 4, 520, 7, 8, 50); @@ -124,10 +129,12 @@ public class RegistrarBloodMagicItems { public static List items; @SubscribeEvent - public static void registerItems(RegistryEvent.Register event) { + public static void registerItems(RegistryEvent.Register event) + { items = Lists.newArrayList(); - RegistrarBloodMagicBlocks.blocks.stream().filter(block -> block instanceof IBMBlock && ((IBMBlock) block).getItem() != null).forEach(block -> { + RegistrarBloodMagicBlocks.blocks.stream().filter(block -> block instanceof IBMBlock && ((IBMBlock) block).getItem() != null).forEach(block -> + { IBMBlock bmBlock = (IBMBlock) block; items.add(bmBlock.getItem().setRegistryName(block.getRegistryName())); }); @@ -204,23 +211,27 @@ public class RegistrarBloodMagicItems { new ItemSanguineBook().setRegistryName("sanguine_book"), new ItemLivingArmourPointsUpgrade().setRegistryName("points_upgrade"), new ItemDemonWillGauge().setRegistryName("demon_will_gauge"), - new ItemPotionFlask().setRegistryName("potion_flask") - )); + new ItemPotionFlask().setRegistryName("potion_flask"), + new ItemEnumColour.Variant<>(AlchemicTypes.class, "alchemicVial").setRegistryName("alchemic_vial") + )); event.getRegistry().registerAll(items.toArray(new Item[0])); } @SideOnly(Side.CLIENT) @SubscribeEvent - public static void registerRenders(ModelRegistryEvent event) { - items.stream().filter(i -> i instanceof IVariantProvider).forEach(i -> { + public static void registerRenders(ModelRegistryEvent event) + { + items.stream().filter(i -> i instanceof IVariantProvider).forEach(i -> + { Int2ObjectMap variants = new Int2ObjectOpenHashMap<>(); ((IVariantProvider) i).gatherVariants(variants); for (Int2ObjectMap.Entry variant : variants.int2ObjectEntrySet()) ModelLoader.setCustomModelResourceLocation(i, variant.getIntKey(), new ModelResourceLocation(i.getRegistryName(), variant.getValue())); }); - items.stream().filter(i -> i instanceof IMeshProvider).forEach(i -> { + items.stream().filter(i -> i instanceof IMeshProvider).forEach(i -> + { IMeshProvider mesh = (IMeshProvider) i; ResourceLocation loc = mesh.getCustomLocation(); if (loc == null) @@ -234,7 +245,8 @@ public class RegistrarBloodMagicItems { ModelLoader.setCustomMeshDefinition(i, mesh.getMeshDefinition()); }); - RegistrarBloodMagicBlocks.blocks.stream().filter(b -> b instanceof IVariantProvider).forEach(b -> { + RegistrarBloodMagicBlocks.blocks.stream().filter(b -> b instanceof IVariantProvider).forEach(b -> + { Int2ObjectMap variants = new Int2ObjectOpenHashMap<>(); ((IVariantProvider) b).gatherVariants(variants); for (Int2ObjectMap.Entry variant : variants.int2ObjectEntrySet()) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemEnumColour.java b/src/main/java/WayofTime/bloodmagic/item/ItemEnumColour.java new file mode 100644 index 00000000..bb99c6a9 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/item/ItemEnumColour.java @@ -0,0 +1,67 @@ +package WayofTime.bloodmagic.item; + +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.item.types.ISubItem; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.MathHelper; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class ItemEnumColour & ISubItem> extends Item +{ + //Copy of @ItemEnum, except all variants use the same textures with different colouring + protected final T[] types; + + public ItemEnumColour(Class enumClass, String baseName) + { + super(); + + this.types = enumClass.getEnumConstants(); + + setUnlocalizedName(BloodMagic.MODID + "." + baseName); + setHasSubtypes(types.length > 1); + setCreativeTab(BloodMagic.TAB_BM); + } + + @Override + public String getUnlocalizedName(ItemStack stack) + { + return super.getUnlocalizedName(stack) + "." + getItemType(stack).getInternalName(); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(CreativeTabs tab, NonNullList subItems) + { + if (!isInCreativeTab(tab)) + return; + + for (T type : types) + subItems.add(new ItemStack(this, 1, type.ordinal())); + } + + public T getItemType(ItemStack stack) + { + return types[MathHelper.clamp(stack.getItemDamage(), 0, types.length)]; + } + + public static class Variant & ISubItem> extends ItemEnum implements IVariantProvider + { + + public Variant(Class enumClass, String baseName) + { + super(enumClass, baseName); + } + + @Override + public void gatherVariants(Int2ObjectMap variants) + { + variants.put(0, "type=normal"); + } + } +} diff --git a/src/main/java/WayofTime/bloodmagic/item/types/AlchemicTypes.java b/src/main/java/WayofTime/bloodmagic/item/types/AlchemicTypes.java new file mode 100644 index 00000000..35498ea0 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/item/types/AlchemicTypes.java @@ -0,0 +1,59 @@ +package WayofTime.bloodmagic.item.types; + +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nonnull; +import java.util.Locale; + +public enum AlchemicTypes implements ISubItem +{ + BASE(0x2e35ff); + + final int potionColour; + + AlchemicTypes(int colour1) + { + potionColour = colour1; + } + + @Nonnull + @Override + public String getInternalName() + { + return name().toLowerCase(Locale.ROOT); + } + + @Nonnull + @Override + public ItemStack getStack() + { + return getStack(1); + } + + @Nonnull + @Override + public ItemStack getStack(int count) + { + return new ItemStack(RegistrarBloodMagicItems.ALCHEMIC_VIAL, count, ordinal()); + } + + public int getColourForLayer(int layer) + { + if (layer == 0) + { + return potionColour; + } + return -1; + } + + public static int getColourForLayer(int variant, int layer) + { + if (variant >= AlchemicTypes.values().length) + { + return -1; + } + + return AlchemicTypes.values()[variant].getColourForLayer(layer); + } +} diff --git a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java index 1f8ff251..b6cc9e64 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java @@ -13,12 +13,15 @@ import WayofTime.bloodmagic.entity.projectile.EntityBloodLight; import WayofTime.bloodmagic.entity.projectile.EntityMeteor; import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare; +import WayofTime.bloodmagic.item.types.AlchemicTypes; import WayofTime.bloodmagic.soul.DemonWillHolder; import WayofTime.bloodmagic.tile.*; import WayofTime.bloodmagic.tile.routing.TileRoutingNode; import WayofTime.bloodmagic.util.BMLog; import WayofTime.bloodmagic.util.Constants; + import com.google.common.collect.ImmutableMap; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; @@ -37,18 +40,22 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import java.awt.Color; import java.util.Map; -public class ClientProxy extends CommonProxy { +public class ClientProxy extends CommonProxy +{ public static DemonWillHolder currentAura = new DemonWillHolder(); @Override - public void preInit() { + public void preInit() + { super.preInit(); OBJLoader.INSTANCE.addDomain(BloodMagic.MODID); - ClientRegistry.bindTileEntitySpecialRenderer(TileInversionPillar.class, new AnimationTESR() { + ClientRegistry.bindTileEntitySpecialRenderer(TileInversionPillar.class, new AnimationTESR() + { @Override - public void handleEvents(TileInversionPillar chest, float time, Iterable pastEvents) { + public void handleEvents(TileInversionPillar chest, float time, Iterable pastEvents) + { chest.handleEvents(time, pastEvents); } }); @@ -66,7 +73,8 @@ public class ClientProxy extends CommonProxy { } @Override - public void registerRenderers() { + public void registerRenderers() + { RenderingRegistry.registerEntityRenderingHandler(EntitySoulSnare.class, new SoulSnareRenderFactory()); RenderingRegistry.registerEntityRenderingHandler(EntitySentientArrow.class, new SentientArrowRenderFactory()); RenderingRegistry.registerEntityRenderingHandler(EntityBloodLight.class, new BloodLightRenderFactory()); @@ -82,19 +90,24 @@ public class ClientProxy extends CommonProxy { } @Override - public void init() { + public void init() + { super.init(); - Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> { - try { + Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> + { + try + { if (stack.hasTagCompound() && stack.getTagCompound().hasKey(Constants.NBT.COLOR)) if (tintIndex == 1) return Color.decode(stack.getTagCompound().getString(Constants.NBT.COLOR)).getRGB(); - } catch (NumberFormatException e) { + } catch (NumberFormatException e) + { return -1; } return -1; }, RegistrarBloodMagicItems.SIGIL_HOLDING); - Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> { + Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> + { if (tintIndex != 0 && tintIndex != 2) return -1; @@ -103,29 +116,43 @@ public class ClientProxy extends CommonProxy { return PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromStack(stack)); }, RegistrarBloodMagicItems.POTION_FLASK); + Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> + { +// if (tintIndex != 0 && tintIndex != 2) +// return -1; + + int variant = stack.getMetadata(); + + return AlchemicTypes.getColourForLayer(variant, tintIndex); + }, RegistrarBloodMagicItems.ALCHEMIC_VIAL); addElytraLayer(); } @Override - public void postInit() { + public void postInit() + { Elements.createHUDElements(); } - private void addElytraLayer() { + private void addElytraLayer() + { RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); - try { + try + { Map skinMap = ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, renderManager, "skinMap", "field_178636_l"); skinMap.get("default").addLayer(new LayerBloodElytra(skinMap.get("default"))); skinMap.get("slim").addLayer(new LayerBloodElytra(skinMap.get("slim"))); BMLog.DEBUG.info("Elytra layer added"); - } catch (Exception e) { + } catch (Exception e) + { BMLog.DEBUG.error("Failed to set custom Elytra Layer for Elytra Living Armour Upgrade: {}", e.getMessage()); } } @Override - public IAnimationStateMachine load(ResourceLocation location, ImmutableMap parameters) { + public IAnimationStateMachine load(ResourceLocation location, ImmutableMap parameters) + { return ModelLoaderRegistry.loadASM(location, parameters); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java index 1def76f5..2b454edb 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java @@ -215,7 +215,8 @@ public class RitualEllipsoid extends Ritual // } @Override - public void gatherComponents(Consumer components) { + public void gatherComponents(Consumer components) + { addCornerRunes(components, 1, 0, EnumRuneType.WATER); addCornerRunes(components, 1, 1, EnumRuneType.WATER); } diff --git a/src/main/resources/assets/bloodmagic/blockstates/alchemic_vial.json b/src/main/resources/assets/bloodmagic/blockstates/alchemic_vial.json new file mode 100644 index 00000000..74f8af30 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/alchemic_vial.json @@ -0,0 +1,18 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "normal": { + "textures": { + "layer0": "bloodmagic:items/Alchemic_Liquid", + "layer1": "bloodmagic:items/Alchemic_Vial", + "layer2": "bloodmagic:items/Alchemic_Ribbon" + } + } + } + } +} diff --git a/src/main/resources/assets/bloodmagic/textures/items/alchemic_liquid.png b/src/main/resources/assets/bloodmagic/textures/items/alchemic_liquid.png new file mode 100644 index 00000000..4930364f Binary files /dev/null and b/src/main/resources/assets/bloodmagic/textures/items/alchemic_liquid.png differ diff --git a/src/main/resources/assets/bloodmagic/textures/items/alchemic_ribbon.png b/src/main/resources/assets/bloodmagic/textures/items/alchemic_ribbon.png new file mode 100644 index 00000000..7a497e46 Binary files /dev/null and b/src/main/resources/assets/bloodmagic/textures/items/alchemic_ribbon.png differ diff --git a/src/main/resources/assets/bloodmagic/textures/items/alchemic_vial.png b/src/main/resources/assets/bloodmagic/textures/items/alchemic_vial.png new file mode 100644 index 00000000..3062b21d Binary files /dev/null and b/src/main/resources/assets/bloodmagic/textures/items/alchemic_vial.png differ