use of WayofTime.alchemicalWizardry.api.event.RitualActivatedEvent in project BloodMagic by WayofTime.
the class TEMasterStone method activateRitual.
public void activateRitual(World world, int crystalLevel, ItemStack activationCrystal, EntityPlayer player, String crystalOwner) {
if (world.isRemote) {
return;
}
String testRitual = Rituals.checkValidRitual(world, xCoord, yCoord, zCoord);
if (testRitual.equals("")) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.nothinghappened"));
return;
}
// TODO
RitualActivatedEvent event = new RitualActivatedEvent(this, crystalOwner, testRitual, player, activationCrystal, crystalLevel);
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.somethingstoppedyou"));
return;
}
int eventCrystalTier = event.crystalTier;
String eventRitualKey = event.ritualKey;
String eventOwnerKey = event.ownerKey;
boolean testLevel = Rituals.canCrystalActivate(eventRitualKey, eventCrystalTier);
if (!testLevel) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.crystalvibrates"));
return;
}
int currentEssence = SoulNetworkHandler.getCurrentEssence(eventOwnerKey);
if (currentEssence < Rituals.getCostForActivation(testRitual)) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.youfeelapull"));
return;
}
if (!world.isRemote) {
if (!Rituals.startRitual(this, testRitual, player)) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.ritualresistyou"));
return;
} else {
int drain = SoulNetworkHandler.syphonFromNetwork(eventOwnerKey, Rituals.getCostForActivation(testRitual));
if (drain > 0) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.energyflows"));
for (int i = 0; i < 12; i++) {
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
} else {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.somethingstoppedyou"));
return;
}
}
}
if (!this.currentRitualString.equals("")) {
Rituals.onRitualBroken(this, this.currentRitualString, RitualBreakMethod.ACTIVATE);
}
this.setOwner(eventOwnerKey);
cooldown = Rituals.getInitialCooldown(testRitual);
var1 = 0;
currentRitualString = testRitual;
storage = Rituals.getLocalStorage(currentRitualString);
storage.setLocation(new Int3(xCoord, yCoord, zCoord));
isActive = true;
isRunning = true;
direction = Rituals.getDirectionOfRitual(world, xCoord, yCoord, zCoord, testRitual);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Aggregations