use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.
the class BloodAltar method updateAltar.
private void updateAltar() {
if (!isActive) {
if (cooldownAfterCrafting > 0)
cooldownAfterCrafting--;
return;
}
ItemStack input = tileAltar.getStackInSlot(0);
if (input.isEmpty())
return;
World world = tileAltar.getWorld();
BlockPos pos = tileAltar.getPos();
if (world.isRemote)
return;
if (!canBeFilled) {
boolean hasOperated = false;
int stackSize = input.getCount();
if (totalCharge > 0) {
int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge);
totalCharge -= chargeDrained;
progress += chargeDrained;
hasOperated = true;
}
if (fluid != null && fluid.amount >= 1) {
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
if (liquidDrained > (liquidRequired * stackSize - progress))
liquidDrained = liquidRequired * stackSize - progress;
fluid.amount = fluid.amount - liquidDrained;
progress += liquidDrained;
hasOperated = true;
if (internalCounter % 4 == 0 && world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
}
} else if (!hasOperated && progress > 0) {
progress -= (int) (efficiencyMultiplier * drainRate);
if (internalCounter % 2 == 0 && world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0, 0.1, 0);
}
}
if (hasOperated) {
if (progress >= liquidRequired * stackSize) {
ItemStack result = ItemHandlerHelper.copyStackWithSize(recipe.getOutput(), stackSize);
BloodMagicCraftedEvent.Altar event = new BloodMagicCraftedEvent.Altar(recipe.getInput(), result);
MinecraftForge.EVENT_BUS.post(event);
tileAltar.setInventorySlotContents(0, event.getOutput());
progress = 0;
if (world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0);
}
this.cooldownAfterCrafting = 30;
this.isActive = false;
}
}
} else {
ItemStack contained = tileAltar.getStackInSlot(0);
if (contained.isEmpty() || !(contained.getItem() instanceof IBloodOrb) || !(contained.getItem() instanceof IBindable))
return;
BloodOrb orb = ((IBloodOrb) contained.getItem()).getOrb(contained);
Binding binding = ((IBindable) contained.getItem()).getBinding(contained);
if (binding == null || orb == null)
return;
if (fluid != null && fluid.amount >= 1) {
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? orb.getFillRate() * (1 + consumptionMultiplier) : orb.getFillRate()), fluid.amount);
int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier));
fluid.amount = fluid.amount - drain;
if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.001);
}
}
}
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
}
use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.
the class ItemSigilBase method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
if (TextHelper.canTranslate(tooltipBase + "desc"))
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc"))));
if (!stack.hasTagCompound())
return;
Binding binding = getBinding(stack);
if (binding != null)
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
super.addInformation(stack, world, tooltip, flag);
}
use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.
the class ItemTelepositionFocus method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localize("tooltip.bloodmagic.telepositionFocus." + getItemType(stack).getInternalName()))));
super.addInformation(stack, world, tooltip, flag);
Binding binding = getBinding(stack);
if (binding != null)
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
if (!stack.hasTagCompound())
return;
NBTTagCompound tag = stack.getTagCompound();
BlockPos coords = getBlockPos(stack);
if (coords != null && tag != null) {
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", coords.getX(), coords.getY(), coords.getZ()));
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", tag.getInteger(Constants.NBT.DIMENSION_ID)));
}
}
use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.
the class TileMasterRitualStone method activateRitual.
@Override
public boolean activateRitual(ItemStack activationCrystal, @Nullable EntityPlayer activator, Ritual ritual) {
if (PlayerHelper.isFakePlayer(activator))
return false;
Binding binding = ((IBindable) activationCrystal.getItem()).getBinding(activationCrystal);
if (binding != null && ritual != null) {
if (activationCrystal.getItem() instanceof ItemActivationCrystal) {
int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) {
if (!getWorld().isRemote) {
SoulNetwork network = NetworkHelper.getSoulNetwork(binding);
if (!isRedstoned() && network.getCurrentEssence() < ritual.getActivationCost() && (activator != null && !activator.capabilities.isCreativeMode)) {
activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.weak"), true);
return false;
}
if (currentRitual != null)
currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, binding.getOwnerId(), ritual, activator, activationCrystal, crystalLevel);
if (MinecraftForge.EVENT_BUS.post(event)) {
if (activator != null)
activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.prevent"), true);
return false;
}
if (ritual.activateRitual(this, activator, binding.getOwnerId())) {
if (!isRedstoned() && (activator != null && !activator.capabilities.isCreativeMode))
network.syphon(ritual.getActivationCost());
if (activator != null)
activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.activate"), true);
this.active = true;
this.owner = binding.getOwnerId();
this.cachedNetwork = network;
this.currentRitual = ritual;
notifyUpdate();
return true;
}
}
notifyUpdate();
return true;
}
}
} else {
if (activator != null)
activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.notValid"), true);
}
return false;
}
use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.
the class TileMasterRitualStone method onUpdate.
@Override
public void onUpdate() {
if (getWorld().isRemote)
return;
if (isPowered() && isActive()) {
active = false;
redstoned = true;
stopRitual(Ritual.BreakType.REDSTONE);
return;
}
if (!isActive() && !isPowered() && isRedstoned() && getCurrentRitual() != null) {
active = true;
ItemStack crystalStack = NBTHelper.checkNBT(new ItemStack(RegistrarBloodMagicItems.ACTIVATION_CRYSTAL, 1, getCurrentRitual().getCrystalLevel()));
BindableHelper.applyBinding(crystalStack, new Binding(owner, PlayerHelper.getUsernameFromUUID(owner)));
activateRitual(crystalStack, null, getCurrentRitual());
redstoned = false;
}
if (getCurrentRitual() != null && isActive()) {
if (activeTime % getCurrentRitual().getRefreshTime() == 0)
performRitual(getWorld(), getPos());
activeTime++;
}
}
Aggregations