Add IGuideLinked for ritual controller

This commit is contained in:
Nicholas Ignoffo 2016-06-05 16:29:36 -07:00
parent 75f8bd0bda
commit 8edf42a5cb
7 changed files with 64 additions and 19 deletions

View file

@ -11,4 +11,4 @@ jei_version=3.4.0.204
waila_version=1.7.0-B3
thaumcraft_version=5.1.5
baubles_version=1.1.3.0
guideapi_version=2.0.0-35
guideapi_version=2.0.0-37

View file

@ -3,6 +3,8 @@ package WayofTime.bloodmagic.block;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
import amerifrance.guideapi.api.IGuideLinked;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
@ -11,10 +13,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@ -32,7 +36,10 @@ import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
import WayofTime.bloodmagic.util.ChatUtil;
public class BlockRitualController extends BlockStringContainer implements IVariantProvider
import javax.annotation.Nullable;
@Optional.Interface(modid = "guideapi", iface = "amerifrance.guideapi.api.IGuideLinked")
public class BlockRitualController extends BlockStringContainer implements IVariantProvider, IGuideLinked
{
public static final String[] names = { "master", "imperfect" };
@ -109,6 +116,8 @@ public class BlockRitualController extends BlockStringContainer implements IVari
return meta == 0 ? (new TileMasterRitualStone()) : (new TileImperfectRitualStone());
}
// IVariantProvider
@Override
public List<Pair<Integer, String>> getVariants()
{
@ -117,4 +126,27 @@ public class BlockRitualController extends BlockStringContainer implements IVari
ret.add(new ImmutablePair<Integer, String>(i, "type=" + names[i]));
return ret;
}
// IGuideLinked
@Override
@Nullable
public ResourceLocation getLinkedEntry(World world, BlockPos pos, EntityPlayer player, ItemStack stack)
{
IBlockState state = world.getBlockState(pos);
if (state.getValue(getStringProp()).equals(names[0]))
{
TileMasterRitualStone mrs = (TileMasterRitualStone) world.getTileEntity(pos);
if (mrs == null || mrs.getCurrentRitual() == null)
return null;
else
return new ResourceLocation("bloodmagic", "ritual_" + mrs.getCurrentRitual().getName());
} else if (state.getValue(getStringProp()).equals(names[1]))
{
ImperfectRitual imperfectRitual = ImperfectRitualRegistry.getRitualForBlock(BlockStack.getStackFromPos(world, pos.up()));
if (imperfectRitual != null)
return new ResourceLocation("bloodmagic", "ritual_" + imperfectRitual.getName());
}
return null;
}
}

View file

@ -4,13 +4,14 @@ import WayofTime.bloodmagic.api.Constants;
import amerifrance.guideapi.api.impl.abstraction.EntryAbstract;
import net.minecraft.util.ResourceLocation;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class CategoryAlchemy {
public static Map<ResourceLocation, EntryAbstract> buildCategory() {
Map<ResourceLocation, EntryAbstract> entries = new HashMap<ResourceLocation, EntryAbstract>();
public class CategoryAlchemy
{
public static Map<ResourceLocation, EntryAbstract> buildCategory()
{
Map<ResourceLocation, EntryAbstract> entries = new LinkedHashMap<ResourceLocation, EntryAbstract>();
String keyBase = Constants.Mod.DOMAIN + "alchemy_";

View file

@ -4,13 +4,14 @@ import WayofTime.bloodmagic.api.Constants;
import amerifrance.guideapi.api.impl.abstraction.EntryAbstract;
import net.minecraft.util.ResourceLocation;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class CategoryArchitect {
public class CategoryArchitect
{
public static Map<ResourceLocation, EntryAbstract> buildCategory() {
Map<ResourceLocation, EntryAbstract> entries = new HashMap<ResourceLocation, EntryAbstract>();
Map<ResourceLocation, EntryAbstract> entries = new LinkedHashMap<ResourceLocation, EntryAbstract>();
String keyBase = Constants.Mod.DOMAIN + "architect_";

View file

@ -1,8 +1,10 @@
package WayofTime.bloodmagic.compat.guideapi.book;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
import WayofTime.bloodmagic.api.registry.RitualRegistry;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
import WayofTime.bloodmagic.compat.guideapi.entry.EntryText;
import WayofTime.bloodmagic.util.helper.TextHelper;
import amerifrance.guideapi.api.IPage;
@ -12,16 +14,15 @@ import amerifrance.guideapi.page.PageImage;
import net.minecraft.util.ResourceLocation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class CategoryRitual
{
public static Map<ResourceLocation, EntryAbstract> buildCategory()
{
Map<ResourceLocation, EntryAbstract> entries = new HashMap<ResourceLocation, EntryAbstract>();
Map<ResourceLocation, EntryAbstract> entries = new LinkedHashMap<ResourceLocation, EntryAbstract>();
String keyBase = Constants.Mod.DOMAIN + "ritual_";
for (Ritual ritual : RitualRegistry.getRituals())
@ -32,6 +33,14 @@ public class CategoryRitual
entries.put(new ResourceLocation(keyBase + ritual.getName()), new EntryText(ritualPages, TextHelper.localize(ritual.getUnlocalizedName()), true));
}
for (ImperfectRitual imperfectRitual : ImperfectRitualRegistry.getRituals())
{
List<IPage> ritualPages = new ArrayList<IPage>();
ritualPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(imperfectRitual.getUnlocalizedName() + ".info")));
ritualPages.add(new PageImage(new ResourceLocation("bloodmagicguide", "textures/guide/" + imperfectRitual.getName() + ".png")));
entries.put(new ResourceLocation(keyBase + imperfectRitual.getName()), new EntryText(ritualPages, TextHelper.localize(imperfectRitual.getUnlocalizedName()), true));
}
return entries;
}
}

View file

@ -5,12 +5,14 @@ import amerifrance.guideapi.api.impl.abstraction.EntryAbstract;
import net.minecraft.util.ResourceLocation;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class CategorySpell {
public static Map<ResourceLocation, EntryAbstract> buildCategory() {
Map<ResourceLocation, EntryAbstract> entries = new HashMap<ResourceLocation, EntryAbstract>();
public class CategorySpell
{
public static Map<ResourceLocation, EntryAbstract> buildCategory()
{
Map<ResourceLocation, EntryAbstract> entries = new LinkedHashMap<ResourceLocation, EntryAbstract>();
String keyBase = Constants.Mod.DOMAIN + "spell_";

View file

@ -32,7 +32,7 @@ public class OrbRecipeRenderer implements IRecipeRenderer
@Override
public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) {
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(GuideMod.GUITEXLOC + "recipe_elements.png"));
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("gudieapi", "textures/gui/recipe_elements.png"));
guiBase.drawTexturedModalRect(guiLeft + 42, guiTop + 53, 0, 0, 105, 65);
guiBase.drawCenteredString(fontRenderer, TextHelper.localize("text.recipe.shapedOrb"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0);