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:
parent
ebe428a89b
commit
6a2c30834e
10 changed files with 340 additions and 50 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue