Added holograms to TileMasterRitualStone and TileAltar (#810)

* Added holograms to TileMasterRitualStone and TileAltar
-Right click with either Ritual Diviner or (name pending) Sanguine Sanctum to show up the hologram
-Ritual hologram disappears once ritual is activated
-Altar hologram disappears once altar reaches specified tier
-Fixed the Sigil of Holding configs
-Someone still needs to add in a recipe for the Sigil of Holding
-Disabled the Sanguine Sanctum right-click effect for now
-Kept the hologram from holding the Ritual Diviner in hand
-Someone needs to fix the lighting for the ritual hologram!

* Getters and formatting changes

* Re-implement commented out feature

* Moved the rendering completely to client-side

Have the Sanguine Book work again

Make it actually work

Tidy things up

* Cycles through tier when right clicked

* Re put onItemUse

* Add IAltarReader to ItemSigilHolding
This commit is contained in:
Arcaratus 2016-06-21 21:20:49 -04:00 committed by Nick Ignoffo
parent ebe428a89b
commit 6a2c30834e
10 changed files with 340 additions and 50 deletions

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.util.Utils;
import WayofTime.bloodmagic.util.handler.event.ClientHandler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
@ -73,7 +74,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (addRuneToRitual(stack, world, pos, player))
if (trySetDisplayedRitual(stack, world, pos) && addRuneToRitual(stack, world, pos, player))
{
if (world.isRemote)
{
@ -89,7 +90,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
/**
* Adds a single rune to the ritual.
*
*
* @param stack
* - The Ritual Diviner stack
* @param world
@ -98,7 +99,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
* - Block Position of the MRS.
* @param player
* - The Player attempting to place the ritual
*
*
* @return - True if a rune was successfully added
*/
public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player)
@ -145,7 +146,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
} else
{
return false; // TODO: Possibly replace the block with a
// ritual stone
// ritual stone
}
}
}
@ -154,6 +155,25 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
return false;
}
public boolean trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos)
{
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileMasterRitualStone)
{
Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(itemStack));
TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tile;
if (ritual != null)
{
EnumFacing direction = getDirection(itemStack);
return ClientHandler.setRitualHolo(masterRitualStone, ritual, direction, true);
}
}
return true;
}
// TODO: Make this work for any IRitualStone
public boolean consumeStone(ItemStack stack, World world, EntityPlayer player)
{
@ -357,7 +377,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
public void notifyDirectionChange(EnumFacing direction, EntityPlayer player)
{
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentDirection", direction.getName()));
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentDirection", Utils.toFancyCasing(direction.getName())));
}
public void setDirection(ItemStack stack, EnumFacing direction)
@ -393,7 +413,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
/**
* Cycles the selected ritual to the next available ritual that is enabled.
*
*
* @param stack
* - The ItemStack of the ritual diviner
* @param player
@ -446,7 +466,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
/**
* Does the same as cycleRitual but instead cycles backwards.
*
*
* @param stack
* @param player
*/

View file

@ -2,18 +2,26 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
import WayofTime.bloodmagic.api.iface.IDocumentedBlock;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.tile.TileAltar;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
@ -24,8 +32,10 @@ import org.apache.commons.lang3.tuple.Pair;
import java.util.Collections;
import java.util.List;
public class ItemSanguineBook extends Item implements IVariantProvider
public class ItemSanguineBook extends Item implements IVariantProvider, IAltarManipulator
{
private EnumAltarTier currentDisplayedTier = EnumAltarTier.ONE;
public ItemSanguineBook()
{
setUnlocalizedName(Constants.Mod.MODID + ".sanguineBook");
@ -40,26 +50,69 @@ public class ItemSanguineBook extends Item implements IVariantProvider
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
IBlockState hitState = world.getBlockState(pos);
if (player.isSneaking() && hitState.getBlock() instanceof IDocumentedBlock)
if (player.isSneaking())
{
IDocumentedBlock documentedBlock = (IDocumentedBlock) hitState.getBlock();
List<ITextComponent> docs = documentedBlock.getDocumentation(player, world, pos, hitState);
if (!docs.isEmpty())
if (hitState.getBlock() instanceof IDocumentedBlock)
{
ChatUtil.sendNoSpam(player, docs.toArray(new ITextComponent[docs.size()]));
return EnumActionResult.SUCCESS;
trySetDisplayedTier(world, pos);
IDocumentedBlock documentedBlock = (IDocumentedBlock) hitState.getBlock();
List<ITextComponent> docs = documentedBlock.getDocumentation(player, world, pos, hitState);
if (!docs.isEmpty())
{
ChatUtil.sendNoSpam(player, docs.toArray(new ITextComponent[docs.size()]));
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
}
}
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (world.isRemote)
return super.onItemRightClick(stack, world, player, hand);
stack = NBTHelper.checkNBT(stack);
RayTraceResult rayTrace = rayTrace(world, player, false);
if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY)
{
if (stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1)
stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0);
else
stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1);
currentDisplayedTier = EnumAltarTier.values()[stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)];
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.setTier", NumeralHelper.toRoman(stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1)));
return super.onItemRightClick(stack, world, player, hand);
}
return super.onItemRightClick(stack, world, player, hand);
}
public boolean trySetDisplayedTier(World world, BlockPos pos)
{
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileAltar)
{
if (currentDisplayedTier != EnumAltarTier.ONE)
return !((TileAltar) tile).setCurrentTierDisplayed(currentDisplayedTier);
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
stack = NBTHelper.checkNBT(stack);
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.book.shifting"));
tooltip.add(TextFormatting.OBFUSCATED + "~ILikeTehNutsAndICannotLie");
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1));
}
// IVariantProvider

View file

@ -2,8 +2,8 @@ package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.item.inventory.InventoryHolding;
import WayofTime.bloodmagic.util.handler.BMKeyBinding;
@ -29,7 +29,7 @@ import org.apache.commons.lang3.tuple.Pair;
import java.util.Collections;
import java.util.List;
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader
{
public static int inventorySize;
@ -284,31 +284,34 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable
{
initModeTag(itemStack);
int index;
int currentIndex = getCurrentItemOrdinal(itemStack);
ItemStack currentItemStack = getItemStackInSlot(itemStack, currentIndex);
if (currentItemStack == null)
return;
if (mode < 0)
int index = mode;
if (mode == 120 || mode == -120)
{
index = next(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack == null)
int currentIndex = getCurrentItemOrdinal(itemStack);
ItemStack currentItemStack = getItemStackInSlot(itemStack, currentIndex);
if (currentItemStack == null)
return;
if (mode < 0)
{
index = next(index);
index = next(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack == null)
{
index = next(index);
currentItemStack = getItemStackInSlot(itemStack, index);
}
}
}
else
{
index = prev(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack == null)
else
{
index = prev(index);
index = prev(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack == null)
{
index = prev(index);
currentItemStack = getItemStackInSlot(itemStack, index);
}
}
}