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
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.altar;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -82,6 +83,9 @@ public class BloodAltar implements IFluidHandler
|
|||
private AltarRecipe recipe;
|
||||
private ItemStack result;
|
||||
|
||||
@Getter
|
||||
private EnumAltarTier currentTierDisplayed = EnumAltarTier.ONE;
|
||||
|
||||
public BloodAltar(TileAltar tileAltar)
|
||||
{
|
||||
this.tileAltar = tileAltar;
|
||||
|
@ -287,6 +291,7 @@ public class BloodAltar implements IFluidHandler
|
|||
chargingFrequency = tagCompound.getInteger(Constants.NBT.ALTAR_CHARGE_FREQUENCY);
|
||||
totalCharge = tagCompound.getInteger(Constants.NBT.ALTAR_TOTAL_CHARGE);
|
||||
maxCharge = tagCompound.getInteger(Constants.NBT.ALTAR_MAX_CHARGE);
|
||||
currentTierDisplayed = Enums.getIfPresent(EnumAltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED)).or(EnumAltarTier.ONE);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
|
@ -330,6 +335,7 @@ public class BloodAltar implements IFluidHandler
|
|||
tagCompound.setInteger(Constants.NBT.ALTAR_CHARGE_FREQUENCY, chargingFrequency);
|
||||
tagCompound.setInteger(Constants.NBT.ALTAR_TOTAL_CHARGE, totalCharge);
|
||||
tagCompound.setInteger(Constants.NBT.ALTAR_MAX_CHARGE, maxCharge);
|
||||
tagCompound.setString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED, currentTierDisplayed.name());
|
||||
}
|
||||
|
||||
public void startCycle()
|
||||
|
@ -549,6 +555,9 @@ public class BloodAltar implements IFluidHandler
|
|||
|
||||
upgrade = BloodAltar.getUpgrades(tileAltar.getWorld(), tileAltar.getPos(), tier);
|
||||
|
||||
if (tier.equals(currentTierDisplayed))
|
||||
currentTierDisplayed = EnumAltarTier.ONE;
|
||||
|
||||
if (tier.equals(EnumAltarTier.ONE))
|
||||
{
|
||||
upgrade = null;
|
||||
|
@ -717,6 +726,15 @@ public class BloodAltar implements IFluidHandler
|
|||
return bufferCapacity;
|
||||
}
|
||||
|
||||
public boolean setCurrentTierDisplayed(EnumAltarTier altarTier)
|
||||
{
|
||||
if (currentTierDisplayed == altarTier)
|
||||
return false;
|
||||
else
|
||||
currentTierDisplayed = altarTier;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addToDemonBloodDuration(int dur)
|
||||
{
|
||||
this.demonBloodDuration += dur;
|
||||
|
|
|
@ -68,6 +68,7 @@ public class Constants
|
|||
public static final String ALTAR_MAX_CHARGE = "maxCharge";
|
||||
public static final String ALTAR_CHARGE_RATE = "chargeRate";
|
||||
public static final String ALTAR_CHARGE_FREQUENCY = "chargeFrequency";
|
||||
public static final String ALTAR_CURRENT_TIER_DISPLAYED = "currentTierDisplayed";
|
||||
|
||||
public static final String ALTARMAKER_CURRENT_TIER = "currentTier";
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import WayofTime.bloodmagic.altar.BloodAltar;
|
|||
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IDocumentedBlock;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package WayofTime.bloodmagic.client.render;
|
||||
|
||||
import WayofTime.bloodmagic.api.altar.AltarComponent;
|
||||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
||||
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
@ -12,9 +16,11 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderAltar extends TileEntitySpecialRenderer<TileAltar>
|
||||
{
|
||||
|
@ -35,6 +41,11 @@ public class RenderAltar extends TileEntitySpecialRenderer<TileAltar>
|
|||
this.renderFluid(getWorld(), level);
|
||||
this.renderItem(tileAltar.getWorld(), inputStack, partialTicks);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
if (tileAltar.getCurrentTierDisplayed() != EnumAltarTier.ONE)
|
||||
{
|
||||
renderHologram(tileAltar, tileAltar.getCurrentTierDisplayed(), partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFluid(World world, float fluidLevel)
|
||||
|
@ -109,4 +120,63 @@ public class RenderAltar extends TileEntitySpecialRenderer<TileAltar>
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void renderHologram(TileAltar altar, EnumAltarTier tier, float partialTicks)
|
||||
{
|
||||
EntityPlayerSP player = mc.thePlayer;
|
||||
World world = player.worldObj;
|
||||
|
||||
if (tier == EnumAltarTier.ONE)
|
||||
return;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.color(1F, 1F, 1F, 0.6125F);
|
||||
|
||||
BlockPos vec3, vX;
|
||||
vec3 = altar.getPos();
|
||||
double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
for (AltarComponent altarComponent : tier.getAltarComponents())
|
||||
{
|
||||
vX = vec3.add(altarComponent.getOffset());
|
||||
double minX = vX.getX() - posX;
|
||||
double minY = vX.getY() - posY;
|
||||
double minZ = vX.getZ() - posZ;
|
||||
|
||||
if (!world.getBlockState(vX).isOpaqueCube())
|
||||
{
|
||||
TextureAtlasSprite texture = null;
|
||||
|
||||
switch (altarComponent.getComponent())
|
||||
{
|
||||
case BLOODRUNE:
|
||||
texture = ClientHandler.blankBloodRune;
|
||||
break;
|
||||
case NOTAIR:
|
||||
texture = ClientHandler.stoneBrick;
|
||||
break;
|
||||
case GLOWSTONE:
|
||||
texture = ClientHandler.glowstone;
|
||||
break;
|
||||
case BLOODSTONE:
|
||||
texture = ClientHandler.bloodStoneBrick;
|
||||
break;
|
||||
case BEACON:
|
||||
texture = ClientHandler.beacon;
|
||||
break;
|
||||
case CRYSTAL:
|
||||
texture = ClientHandler.crystalCluster;
|
||||
break;
|
||||
}
|
||||
|
||||
RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ, world);
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
if (hitState.getBlock() instanceof IDocumentedBlock)
|
||||
{
|
||||
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 EnumActionResult.SUCCESS;
|
||||
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
|
||||
|
|
|
@ -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,7 +284,9 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable
|
|||
{
|
||||
initModeTag(itemStack);
|
||||
|
||||
int index;
|
||||
int index = mode;
|
||||
if (mode == 120 || mode == -120)
|
||||
{
|
||||
int currentIndex = getCurrentItemOrdinal(itemStack);
|
||||
ItemStack currentItemStack = getItemStackInSlot(itemStack, currentIndex);
|
||||
if (currentItemStack == null)
|
||||
|
@ -311,6 +313,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable
|
|||
currentItemStack = getItemStackInSlot(itemStack, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, index);
|
||||
}
|
||||
|
|
|
@ -224,4 +224,14 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
|
|||
{
|
||||
return bloodAltar.getChargingFrequency();
|
||||
}
|
||||
|
||||
public EnumAltarTier getCurrentTierDisplayed()
|
||||
{
|
||||
return bloodAltar.getCurrentTierDisplayed();
|
||||
}
|
||||
|
||||
public boolean setCurrentTierDisplayed(EnumAltarTier altarTier)
|
||||
{
|
||||
return bloodAltar.setCurrentTierDisplayed(altarTier);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package WayofTime.bloodmagic.tile;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
@ -131,6 +132,7 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
|||
String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
// crystalOwner = PlayerHelper.getUUIDFromPlayer(activator).toString(); //Temporary patch job
|
||||
|
||||
ClientHandler.setRitualHolo(null, null, EnumFacing.NORTH, false);
|
||||
if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null)
|
||||
{
|
||||
if (activationCrystal.getItem() instanceof ItemActivationCrystal)
|
||||
|
@ -303,7 +305,6 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
|||
@Override
|
||||
public World getWorldObj()
|
||||
{
|
||||
|
||||
return getWorld();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -35,9 +36,7 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.client.hud.HUDElement;
|
||||
|
@ -56,18 +55,30 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class ClientHandler
|
||||
{
|
||||
public TextureAtlasSprite ritualStoneBlank;
|
||||
public TextureAtlasSprite ritualStoneWater;
|
||||
public TextureAtlasSprite ritualStoneFire;
|
||||
public TextureAtlasSprite ritualStoneEarth;
|
||||
public TextureAtlasSprite ritualStoneAir;
|
||||
public TextureAtlasSprite ritualStoneDawn;
|
||||
public TextureAtlasSprite ritualStoneDusk;
|
||||
public static TextureAtlasSprite ritualStoneBlank;
|
||||
public static TextureAtlasSprite ritualStoneWater;
|
||||
public static TextureAtlasSprite ritualStoneFire;
|
||||
public static TextureAtlasSprite ritualStoneEarth;
|
||||
public static TextureAtlasSprite ritualStoneAir;
|
||||
public static TextureAtlasSprite ritualStoneDawn;
|
||||
public static TextureAtlasSprite ritualStoneDusk;
|
||||
|
||||
public static TextureAtlasSprite blankBloodRune;
|
||||
public static TextureAtlasSprite stoneBrick;
|
||||
public static TextureAtlasSprite glowstone;
|
||||
public static TextureAtlasSprite bloodStoneBrick;
|
||||
public static TextureAtlasSprite beacon;
|
||||
public static TextureAtlasSprite crystalCluster;
|
||||
|
||||
public static Minecraft minecraft = Minecraft.getMinecraft();
|
||||
public static final List<BMKeyBinding> keyBindings = new ArrayList<BMKeyBinding>();
|
||||
public static final List<HUDElement> hudElements = new ArrayList<HUDElement>();
|
||||
|
||||
private static TileMasterRitualStone mrsHoloTile;
|
||||
private static Ritual mrsHoloRitual;
|
||||
private static EnumFacing mrsHoloDirection;
|
||||
private static boolean mrsHoloDisplay;
|
||||
|
||||
public static final BMKeyBinding keyOpenSigilHolding = new BMKeyBinding("openSigilHolding", Keyboard.KEY_H, BMKeyBinding.Key.OPEN_SIGIL_HOLDING);
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -104,6 +115,13 @@ public class ClientHandler
|
|||
ritualStoneAir = forName(event.getMap(), "AirRitualStone", BLOCKS);
|
||||
ritualStoneDawn = forName(event.getMap(), "LightRitualStone", BLOCKS);
|
||||
ritualStoneDusk = forName(event.getMap(), "DuskRitualStone", BLOCKS);
|
||||
|
||||
blankBloodRune = forName(event.getMap(), "BlankRune", BLOCKS);
|
||||
stoneBrick = event.getMap().registerSprite(new ResourceLocation("minecraft:blocks/stonebrick"));
|
||||
glowstone = event.getMap().registerSprite(new ResourceLocation("minecraft:blocks/glowstone"));
|
||||
bloodStoneBrick = forName(event.getMap(), "BloodStoneBrick", BLOCKS);
|
||||
beacon = event.getMap().registerSprite(new ResourceLocation("minecraft:blocks/beacon"));
|
||||
crystalCluster = forName(event.getMap(), "ShardCluster", BLOCKS);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -112,12 +130,27 @@ public class ClientHandler
|
|||
EntityPlayerSP player = minecraft.thePlayer;
|
||||
World world = player.worldObj;
|
||||
|
||||
if (mrsHoloTile != null)
|
||||
{
|
||||
if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone)
|
||||
{
|
||||
if (mrsHoloDisplay)
|
||||
renderRitualStones(mrsHoloTile, event.getPartialTicks());
|
||||
else
|
||||
ClientHandler.setRitualHolo(null, null, EnumFacing.NORTH, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClientHandler.setRitualHolo(null, null, EnumFacing.NORTH, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (minecraft.objectMouseOver == null || minecraft.objectMouseOver.typeOfHit != RayTraceResult.Type.BLOCK)
|
||||
return;
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(minecraft.objectMouseOver.getBlockPos());
|
||||
|
||||
if (tileEntity instanceof IMasterRitualStone && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
|
||||
if (tileEntity instanceof TileMasterRitualStone && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner && !mrsHoloDisplay)
|
||||
renderRitualStones(player, event.getPartialTicks());
|
||||
|
||||
if (tileEntity instanceof TileMasterRitualStone && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemRitualReader)
|
||||
|
@ -170,7 +203,7 @@ public class ClientHandler
|
|||
private void cycleSigil(ItemStack stack, EntityPlayer player, int dWheel)
|
||||
{
|
||||
int mode = dWheel;
|
||||
if (ConfigHandler.sigilHoldingSkipsEmptySlots)
|
||||
if (!ConfigHandler.sigilHoldingSkipsEmptySlots)
|
||||
{
|
||||
mode = ItemSigilHolding.getCurrentItemOrdinal(stack);
|
||||
mode = dWheel < 0 ? ItemSigilHolding.next(mode) : ItemSigilHolding.prev(mode);
|
||||
|
@ -217,15 +250,17 @@ public class ClientHandler
|
|||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.color(1F, 1F, 1F, 0.6125F);
|
||||
|
||||
BlockPos vec3 = new BlockPos(minecraft.objectMouseOver.getBlockPos().getX(), minecraft.objectMouseOver.getBlockPos().getY(), minecraft.objectMouseOver.getBlockPos().getZ());
|
||||
BlockPos vec3, vX;
|
||||
vec3 = minecraft.objectMouseOver.getBlockPos();
|
||||
double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
for (RitualComponent ritualComponent : ritual.getComponents())
|
||||
{
|
||||
BlockPos vX = vec3.add(new BlockPos(ritualComponent.getX(direction), ritualComponent.getY(), ritualComponent.getZ(direction)));
|
||||
vX = vec3.add(ritualComponent.getOffset(direction));
|
||||
double minX = vX.getX() - posX;
|
||||
double minY = vX.getY() - posY;
|
||||
double minZ = vX.getZ() - posZ;
|
||||
|
@ -266,6 +301,84 @@ public class ClientHandler
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks)
|
||||
{
|
||||
EntityPlayerSP player = minecraft.thePlayer;
|
||||
World world = player.worldObj;
|
||||
EnumFacing direction = mrsHoloDirection;
|
||||
Ritual ritual = mrsHoloRitual;
|
||||
|
||||
if (ritual == null)
|
||||
return;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.color(1F, 1F, 1F, 0.5F);
|
||||
|
||||
BlockPos vec3, vX;
|
||||
vec3 = masterRitualStone.getPos();
|
||||
double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
for (RitualComponent ritualComponent : ritual.getComponents())
|
||||
{
|
||||
vX = vec3.add(ritualComponent.getOffset(direction));
|
||||
double minX = vX.getX() - posX;
|
||||
double minY = vX.getY() - posY;
|
||||
double minZ = vX.getZ() - posZ;
|
||||
|
||||
if (!world.getBlockState(vX).isOpaqueCube())
|
||||
{
|
||||
TextureAtlasSprite texture = null;
|
||||
|
||||
switch (ritualComponent.getRuneType())
|
||||
{
|
||||
case BLANK:
|
||||
texture = ritualStoneBlank;
|
||||
break;
|
||||
case WATER:
|
||||
texture = ritualStoneWater;
|
||||
break;
|
||||
case FIRE:
|
||||
texture = ritualStoneFire;
|
||||
break;
|
||||
case EARTH:
|
||||
texture = ritualStoneEarth;
|
||||
break;
|
||||
case AIR:
|
||||
texture = ritualStoneAir;
|
||||
break;
|
||||
case DAWN:
|
||||
texture = ritualStoneDawn;
|
||||
break;
|
||||
case DUSK:
|
||||
texture = ritualStoneDusk;
|
||||
break;
|
||||
}
|
||||
|
||||
RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ, world);
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static boolean setRitualHolo(TileMasterRitualStone masterRitualStone, Ritual ritual, EnumFacing direction, boolean displayed)
|
||||
{
|
||||
mrsHoloDisplay = displayed;
|
||||
if (mrsHoloTile != masterRitualStone || mrsHoloRitual != ritual || mrsHoloDirection != direction)
|
||||
{
|
||||
mrsHoloTile = masterRitualStone;
|
||||
mrsHoloRitual = ritual;
|
||||
mrsHoloDirection = direction;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void renderHotbarItem(int x, int y, float partialTicks, EntityPlayer player, @Nullable ItemStack stack)
|
||||
{
|
||||
if (stack != null)
|
||||
|
|
Loading…
Reference in a new issue