use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class BlockAltar method breakBlock.
@Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TileAltar)
((TileAltar) tile).dropItems();
super.breakBlock(world, blockPos, blockState);
}
use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class BlockAltar method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
TileAltar altar = (TileAltar) world.getTileEntity(pos);
if (altar == null || player.isSneaking())
return false;
ItemStack playerItem = player.getHeldItem(hand);
if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) {
playerItem.getItem().onItemRightClick(world, player, hand);
return true;
}
if (Utils.insertItemToTile(altar, player))
altar.startCycle();
else
altar.setActive();
world.notifyBlockUpdate(pos, state, state, 3);
return true;
}
use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class DataProviderBloodAltar method getNBTData.
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
TileAltar altar = (TileAltar) te;
boolean hasSigil = false;
boolean hasSeer = false;
switch(ConfigHandler.compat.wailaAltarDisplayMode) {
case ALWAYS:
{
hasSigil = hasSeer = true;
break;
}
case SIGIL_HELD:
{
hasSeer = holdingSeerSigil(player);
hasSigil = hasSeer || holdingDivinationSigil(player);
break;
}
case SIGIL_CONTAINED:
{
hasSeer = hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_SEER), player);
hasSigil = hasSeer || hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_DIVINATION), player);
break;
}
}
if (!hasSeer && !hasSigil)
return tag;
NBTTagCompound altarData = new NBTTagCompound();
altarData.setInteger("tier", altar.getTier().toInt());
altarData.setInteger("capacity", altar.getCapacity());
altarData.setInteger("stored", altar.getCurrentBlood());
if (hasSeer) {
altarData.setInteger("progress", (int) (((double) altar.getProgress() / (double) altar.getLiquidRequired() * 100) / altar.getStackInSlot(0).getCount()));
altarData.setInteger("charge", altar.getTotalCharge());
}
tag.setTag("altar", altarData);
return tag;
}
use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class AltarUtil method getTier.
@Nonnull
public static AltarTier getTier(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (!(tile instanceof TileAltar))
return AltarTier.ONE;
AltarTier lastCheck = AltarTier.ONE;
for (AltarTier tier : AltarTier.values()) {
for (AltarComponent component : tier.getAltarComponents()) {
BlockPos componentPos = pos.add(component.getOffset());
IBlockState worldState = world.getBlockState(componentPos);
if (worldState.getBlock() instanceof IAltarComponent)
if (((IAltarComponent) worldState.getBlock()).getType(world, worldState, componentPos) == component.getComponent())
continue;
if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR && !worldState.getMaterial().isLiquid())
continue;
List<IBlockState> validStates = BloodMagicAPI.INSTANCE.getComponentStates(component.getComponent());
if (!validStates.contains(worldState))
return lastCheck;
}
lastCheck = tier;
}
return lastCheck;
}
use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class ItemSacrificialDagger method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (PlayerHelper.isFakePlayer(player))
return super.onItemRightClick(world, player, hand);
if (this.canUseForSacrifice(stack)) {
player.setActiveHand(hand);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
int lpAdded = ConfigHandler.values.sacrificialDaggerConversion * 2;
RayTraceResult rayTrace = rayTrace(world, player, false);
if (rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
if (tile != null && tile instanceof TileAltar && stack.getItemDamage() == 1)
lpAdded = ((TileAltar) tile).getCapacity();
}
if (!player.capabilities.isCreativeMode) {
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2, lpAdded);
if (MinecraftForge.EVENT_BUS.post(evt))
return super.onItemRightClick(world, player, hand);
if (evt.shouldDrainHealth) {
player.hurtResistantTime = 0;
player.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 0.001F);
player.setHealth(Math.max(player.getHealth() - 2, 0.0001f));
if (player.getHealth() <= 0.001f) {
player.onDeath(DamageSourceBloodMagic.INSTANCE);
player.setHealth(0);
}
// player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 2.0F);
}
if (!evt.shouldFillAltar)
return super.onItemRightClick(world, player, hand);
lpAdded = evt.lpAdded;
}
double posX = player.posX;
double posY = player.posY;
double posZ = player.posZ;
world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
for (int l = 0; l < 8; ++l) world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), 0, 0, 0);
if (!world.isRemote && PlayerHelper.isFakePlayer(player))
return super.onItemRightClick(world, player, hand);
// TODO - Check if SoulFray is active
PlayerSacrificeHelper.findAndFillAltar(world, player, lpAdded, false);
return super.onItemRightClick(world, player, hand);
}
Aggregations