use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class BlockAltar method getComparatorInputOverride.
@Override
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
if (world.isRemote)
return 0;
TileEntity tile = world.getTileEntity(pos);
if (tile != null && tile instanceof TileAltar) {
TileAltar altar = (TileAltar) tile;
ItemStack orbStack = altar.getStackInSlot(0);
if (world.getBlockState(pos.down()).getBlock() instanceof BlockDecorative) {
if (orbStack.getItem() instanceof IBloodOrb && orbStack.getItem() instanceof IBindable) {
BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack);
Binding binding = ((IBindable) orbStack.getItem()).getBinding(orbStack);
if (orb != null && binding != null) {
SoulNetwork soulNetwork = NetworkHelper.getSoulNetwork(binding);
int maxEssence = orb.getCapacity();
int currentEssence = soulNetwork.getCurrentEssence();
int level = currentEssence * 15 / maxEssence;
return Math.min(15, level) % 16;
}
}
} else {
int maxEssence = altar.getCapacity();
int currentEssence = altar.getCurrentBlood();
int level = currentEssence * 15 / maxEssence;
return Math.min(15, level) % 16;
}
}
return 0;
}
use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class Elements method createHUDElements.
public static void createHUDElements() {
new HUDElementHolding();
new HUDElementDemonWillAura();
// Blood Altar with Divination Sigil
new HUDElementCornerTile.DivinedView<TileAltar>(TileAltar.class, true) {
@Override
protected void addInformation(List<Pair<Sprite, Function<TileAltar, String>>> information) {
// Current tier
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), altar -> NumeralHelper.toRoman(altar.getTier().toInt())));
// Stored/Capacity
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity())));
}
};
// Blood Altar with Seers Sigil
new HUDElementCornerTile.DivinedView<TileAltar>(TileAltar.class, false) {
@Override
protected void addInformation(List<Pair<Sprite, Function<TileAltar, String>>> information) {
// Current tier
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), altar -> NumeralHelper.toRoman(altar.getTier().toInt())));
// Stored/Capacity
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity())));
// Crafting progress/Crafting requirement
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 32, 46, 16, 16), altar -> {
if (!altar.isActive())
// FIXME localize
return "Inactive";
int progress = altar.getProgress();
int totalLiquidRequired = altar.getLiquidRequired() * altar.getStackInSlot(0).getCount();
return String.format("%d/%d", progress, totalLiquidRequired);
}));
// Consumption rate
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 48, 46, 16, 16), altar -> String.valueOf((int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1)))));
// Total charge
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 64, 46, 16, 16), altar -> String.valueOf(altar.getTotalCharge())));
}
};
// Incense Altar
new HUDElementCornerTile.DivinedView<TileIncenseAltar>(TileIncenseAltar.class, true) {
@Override
protected void addInformation(List<Pair<Sprite, Function<TileIncenseAltar, String>>> information) {
// Current tranquility
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 80, 46, 16, 16), incense -> String.valueOf((int) ((100D * (int) (100 * incense.tranquility)) / 100D))));
// Sacrifice bonus
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 96, 46, 16, 16), incense -> String.valueOf((int) (100 * incense.incenseAddition))));
}
};
// Inversion Pillar
new HUDElementCornerTile.DivinedView<TileInversionPillar>(TileInversionPillar.class, true) {
@Override
protected void addInformation(List<Pair<Sprite, Function<TileInversionPillar, String>>> information) {
// Current inversion
information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 112, 46, 16, 16), pillar -> String.valueOf(((int) (10 * pillar.getCurrentInversion())) / 10D)));
}
};
}
use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.
the class RitualWellOfSuffering method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
BlockPos pos = masterRitualStone.getBlockPos();
int maxEffects = currentEssence / getRefreshCost();
int totalEffects = 0;
BlockPos altarPos = pos.add(altarOffsetPos);
TileEntity tile = world.getTileEntity(altarPos);
AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE);
if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof TileAltar)) {
for (BlockPos newPos : altarRange.getContainedPositions(pos)) {
TileEntity nextTile = world.getTileEntity(newPos);
if (nextTile instanceof TileAltar) {
tile = nextTile;
altarOffsetPos = newPos.subtract(pos);
altarRange.resetCache();
break;
}
}
}
if (tile instanceof TileAltar) {
TileAltar tileAltar = (TileAltar) tile;
AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE);
AxisAlignedBB range = damageRange.getAABB(pos);
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range);
for (EntityLivingBase entity : entities) {
EntityEntry entityEntry = EntityRegistry.getEntry(entity.getClass());
if (entityEntry == null || BloodMagicAPI.INSTANCE.getBlacklist().getSacrifice().contains(entityEntry.getRegistryName()))
continue;
int lifeEssenceRatio = BloodMagicAPI.INSTANCE.getValueManager().getSacrificial().getOrDefault(entityEntry.getRegistryName(), SACRIFICE_AMOUNT);
if (lifeEssenceRatio <= 0)
continue;
if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) {
if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) {
if (entity.isChild())
lifeEssenceRatio *= 0.5F;
tileAltar.sacrificialDaggerCall(lifeEssenceRatio, true);
totalEffects++;
if (totalEffects >= maxEffects) {
break;
}
}
}
}
}
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
}
Aggregations