mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 13:53:07 +00:00
Merge branch 'dev' into syntax-highlighter-unified
This commit is contained in:
commit
aa53d0588c
157 files changed
+3922
-1792
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.AbilityScriptPacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
|
||||
/**
|
||||
* Script handler for ability scripts.
|
||||
* Manages a single script container for ability hooks (abilityStart, abilityTick, abilityComplete, etc.).
|
||||
*/
|
||||
public class AbilityScript extends SingleScriptHandler implements IScriptHandlerPacket {
|
||||
|
||||
/**
|
||||
* The ability ID (UUID) for packet communication. Empty if not bound.
|
||||
*/
|
||||
private String abilityId = "";
|
||||
|
||||
/**
|
||||
* Create an unbound AbilityScript (for server-side use).
|
||||
*/
|
||||
public AbilityScript() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AbilityScript bound to a specific ability (for GUI use).
|
||||
*
|
||||
* @param abilityId The UUID of the ability
|
||||
*/
|
||||
public AbilityScript(String abilityId) {
|
||||
this.abilityId = abilityId != null ? abilityId : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptContext getContext() {
|
||||
return ScriptContext.ABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String noticeString() {
|
||||
return !abilityId.isEmpty() ? "Ability[" + abilityId + "]" : "Ability";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestData() {
|
||||
if (!abilityId.isEmpty())
|
||||
AbilityScriptPacket.Get(abilityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
|
||||
if (!abilityId.isEmpty())
|
||||
AbilityScriptPacket.Save(abilityId, index, totalCount, nbt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.ChainedAbilityScriptPacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
|
||||
/**
|
||||
* Script handler for chained ability scripts.
|
||||
* Manages a single script container for chained ability hooks.
|
||||
*/
|
||||
public class ChainedAbilityScript extends SingleScriptHandler implements IScriptHandlerPacket {
|
||||
|
||||
/**
|
||||
* The chained ability ID (UUID) for packet communication. Empty if not bound.
|
||||
*/
|
||||
private String chainId = "";
|
||||
|
||||
/**
|
||||
* Create an unbound ChainedAbilityScript (for server-side use).
|
||||
*/
|
||||
public ChainedAbilityScript() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ChainedAbilityScript bound to a specific chained ability (for GUI use).
|
||||
*
|
||||
* @param chainId The UUID of the chained ability
|
||||
*/
|
||||
public ChainedAbilityScript(String chainId) {
|
||||
this.chainId = chainId != null ? chainId : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptContext getContext() {
|
||||
return ScriptContext.CHAINED_ABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String noticeString() {
|
||||
return !chainId.isEmpty() ? "ChainedAbility[" + chainId + "]" : "ChainedAbility";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestData() {
|
||||
if (!chainId.isEmpty())
|
||||
ChainedAbilityScriptPacket.Get(chainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
|
||||
if (!chainId.isEmpty())
|
||||
ChainedAbilityScriptPacket.Save(chainId, index, totalCount, nbt);
|
||||
}
|
||||
}
|
||||
@@ -26,15 +26,14 @@ public class CustomEffect implements ICustomEffect {
|
||||
public String icon = "";
|
||||
public int iconX = 0, iconY = 0;
|
||||
|
||||
/**
|
||||
* Experimental script stuff.
|
||||
*/
|
||||
public Consumer<PlayerEvent.EffectEvent.Added> onAddedConsumer;
|
||||
public Consumer<PlayerEvent.EffectEvent.Ticked> onTickConsumer;
|
||||
public Consumer<PlayerEvent.EffectEvent.Removed> onRemovedConsumer;
|
||||
public String menuName = "§aNEW EFFECT";
|
||||
public int width = 16, height = 16;
|
||||
|
||||
// Animation
|
||||
public boolean animated = false;
|
||||
public int frameCount = 1;
|
||||
public int frametime = 2;
|
||||
|
||||
public int index = 0;
|
||||
|
||||
public CustomEffect() {
|
||||
@@ -143,6 +142,36 @@ public class CustomEffect implements ICustomEffect {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnimated() {
|
||||
return animated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimated(boolean animated) {
|
||||
this.animated = animated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFrameCount() {
|
||||
return frameCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrameCount(int frameCount) {
|
||||
this.frameCount = Math.max(1, frameCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFrameTime() {
|
||||
return frametime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrameTime(int frametime) {
|
||||
this.frametime = Math.max(1, frametime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLossOnDeath() {
|
||||
return lossOnDeath;
|
||||
@@ -169,26 +198,10 @@ public class CustomEffect implements ICustomEffect {
|
||||
}
|
||||
|
||||
|
||||
public void onAdded(Consumer<PlayerEvent.EffectEvent.Added> function) {
|
||||
onAddedConsumer = function;
|
||||
}
|
||||
|
||||
public void onTick(Consumer<PlayerEvent.EffectEvent.Ticked> function) {
|
||||
onTickConsumer = function;
|
||||
}
|
||||
|
||||
public void onRemoved(Consumer<PlayerEvent.EffectEvent.Removed> function) {
|
||||
onRemovedConsumer = function;
|
||||
}
|
||||
|
||||
public void onAdded(EntityPlayer player, PlayerEffect playerEffect) {
|
||||
IPlayer iPlayer = NoppesUtilServer.getIPlayer(player);
|
||||
if (playerEffect.index == 0) {
|
||||
PlayerEvent.EffectEvent.Added event = new PlayerEvent.EffectEvent.Added(iPlayer, playerEffect);
|
||||
|
||||
if (onAddedConsumer != null)
|
||||
onAddedConsumer.accept(event);
|
||||
|
||||
EffectScript script = getScriptHandler();
|
||||
if (script == null) {
|
||||
return;
|
||||
@@ -204,11 +217,6 @@ public class CustomEffect implements ICustomEffect {
|
||||
IPlayer iPlayer = NoppesUtilServer.getIPlayer(player);
|
||||
if (playerEffect.index == 0) {
|
||||
PlayerEvent.EffectEvent.Ticked event = new PlayerEvent.EffectEvent.Ticked(iPlayer, playerEffect);
|
||||
|
||||
if (onTickConsumer != null) {
|
||||
onTickConsumer.accept(event);
|
||||
}
|
||||
|
||||
EffectScript script = getScriptHandler();
|
||||
if (script == null) {
|
||||
return;
|
||||
@@ -225,11 +233,6 @@ public class CustomEffect implements ICustomEffect {
|
||||
|
||||
if (playerEffect.index == 0) {
|
||||
PlayerEvent.EffectEvent.Removed event = new PlayerEvent.EffectEvent.Removed(iPlayer, playerEffect, type);
|
||||
|
||||
if (onRemovedConsumer != null) {
|
||||
onRemovedConsumer.accept(event);
|
||||
}
|
||||
|
||||
EffectScript script = getScriptHandler();
|
||||
if (script == null) {
|
||||
return;
|
||||
@@ -254,6 +257,9 @@ public class CustomEffect implements ICustomEffect {
|
||||
compound.setInteger("iconHeight", height);
|
||||
compound.setString("icon", icon);
|
||||
compound.setBoolean("lossOnDeath", lossOnDeath);
|
||||
compound.setBoolean("iconAnimated", animated);
|
||||
compound.setInteger("iconFrameCount", frameCount);
|
||||
compound.setInteger("iconFrameTime", frametime);
|
||||
|
||||
if (saveScripts) {
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
@@ -296,6 +302,13 @@ public class CustomEffect implements ICustomEffect {
|
||||
icon = compound.getString("icon");
|
||||
lossOnDeath = compound.getBoolean("lossOnDeath");
|
||||
|
||||
if (compound.hasKey("iconAnimated"))
|
||||
animated = compound.getBoolean("iconAnimated");
|
||||
if (compound.hasKey("iconFrameCount"))
|
||||
frameCount = Math.max(1, compound.getInteger("iconFrameCount"));
|
||||
if (compound.hasKey("iconFrameTime"))
|
||||
frametime = Math.max(1, compound.getInteger("iconFrameTime"));
|
||||
|
||||
if (compound.hasKey("ScriptData", Constants.NBT.TAG_COMPOUND)) {
|
||||
EffectScript handler = new EffectScript();
|
||||
handler.readFromNBT(compound.getCompoundTag("ScriptData"));
|
||||
|
||||
@@ -12,6 +12,11 @@ public class ItemDisplayData {
|
||||
public Boolean durabilityShow = false;
|
||||
public Integer durabilityColor = -1;
|
||||
|
||||
// Animation
|
||||
public Boolean animated = false;
|
||||
public Integer frameCount = 1;
|
||||
public Integer frametime = 2;
|
||||
|
||||
public NBTTagCompound writeToNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
this.writeToNBT(compound);
|
||||
@@ -42,6 +47,10 @@ public class ItemDisplayData {
|
||||
this.setFloat(compound, "TranslateY", this.translateY);
|
||||
this.setFloat(compound, "TranslateZ", this.translateZ);
|
||||
|
||||
this.setBoolean(compound, "Animated", this.animated);
|
||||
this.setInteger(compound, "FrameCount", this.frameCount);
|
||||
this.setInteger(compound, "FrameTime", this.frametime);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -97,6 +106,16 @@ public class ItemDisplayData {
|
||||
if (compound.hasKey("TranslateZ")) {
|
||||
this.translateZ = compound.getFloat("TranslateZ");
|
||||
}
|
||||
|
||||
if (compound.hasKey("Animated")) {
|
||||
this.animated = compound.getBoolean("Animated");
|
||||
}
|
||||
if (compound.hasKey("FrameCount")) {
|
||||
this.frameCount = Math.max(1, compound.getInteger("FrameCount"));
|
||||
}
|
||||
if (compound.hasKey("FrameTime")) {
|
||||
this.frametime = Math.max(1, compound.getInteger("FrameTime"));
|
||||
}
|
||||
}
|
||||
|
||||
private void setBoolean(NBTTagCompound compound, String key, Boolean value) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.controllers.data.ability.enums.AbilityPhase;
|
||||
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
|
||||
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
|
||||
import kamkeel.npcs.controllers.data.ability.data.entry.AbilityToggleEntry;
|
||||
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.network.packets.data.ability.AbilityCooldownSyncPacket;
|
||||
import kamkeel.npcs.network.packets.data.ability.PlayerAbilityStatePacket;
|
||||
@@ -25,10 +24,6 @@ import noppes.npcs.AbstractDataAbilities;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.api.ability.IPlayerAbilityData;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.player.PlayerAbilityEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -129,53 +124,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
return player != null ? player.worldObj.getTotalWorldTime() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireTickEvent(Ability ability, EntityLivingBase target) {
|
||||
EntityPlayer player = playerData.player;
|
||||
if (ScriptController.Instance == null || player == null) return;
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
|
||||
if (handler == null) return;
|
||||
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
PlayerAbilityEvent.TickEvent event = new PlayerAbilityEvent.TickEvent(
|
||||
iPlayer, ability, target, ability.getPhase().ordinal(), ability.getCurrentTick());
|
||||
EventHooks.onPlayerAbilityTick(handler, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean fireExecuteEvent(Ability ability, EntityLivingBase target) {
|
||||
EntityPlayer player = playerData.player;
|
||||
if (ScriptController.Instance == null || player == null) return false;
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
|
||||
if (handler == null) return false;
|
||||
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
PlayerAbilityEvent.ExecuteEvent event = new PlayerAbilityEvent.ExecuteEvent(iPlayer, ability, target);
|
||||
return EventHooks.onPlayerAbilityExecute(handler, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireCompleteEvent(Ability ability, EntityLivingBase target) {
|
||||
EntityPlayer player = playerData.player;
|
||||
if (ScriptController.Instance == null || player == null) return;
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
|
||||
if (handler == null) return;
|
||||
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
PlayerAbilityEvent.CompleteEvent event = new PlayerAbilityEvent.CompleteEvent(iPlayer, ability, target);
|
||||
EventHooks.onPlayerAbilityComplete(handler, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireInterruptEvent(Ability ability, EntityLivingBase target,
|
||||
DamageSource source, float damage) {
|
||||
EntityPlayer player = playerData.player;
|
||||
if (ScriptController.Instance == null || player == null) return;
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
|
||||
if (handler == null) return;
|
||||
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
PlayerAbilityEvent.InterruptEvent event = new PlayerAbilityEvent.InterruptEvent(
|
||||
iPlayer, ability, target, source, damage);
|
||||
EventHooks.onPlayerAbilityInterrupt(handler, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnTelegraph(Ability ability, EntityLivingBase target) {
|
||||
EntityPlayer player = playerData.player;
|
||||
@@ -423,7 +371,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
}
|
||||
|
||||
// Fire start event (cancelable)
|
||||
if (firePlayerStartEvent(player, ability)) {
|
||||
if (EventHooks.onAbilityStart(ability, player, null)) {
|
||||
return false; // Cancelled
|
||||
}
|
||||
|
||||
@@ -491,29 +439,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
protected void onToggleStateChanged(String key, boolean active, int state) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean fireToggleEvent(Ability ability, int oldState, int newState) {
|
||||
EntityPlayer player = playerData.player;
|
||||
if (ScriptController.Instance == null || player == null) return false;
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
|
||||
if (handler == null) return false;
|
||||
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
PlayerAbilityEvent.ToggleEvent event = new PlayerAbilityEvent.ToggleEvent(iPlayer, ability, oldState, newState);
|
||||
return EventHooks.onPlayerAbilityToggle(handler, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean fireToggleUpdateEvent(Ability ability, int tick, int state) {
|
||||
EntityPlayer player = playerData.player;
|
||||
if (ScriptController.Instance == null || player == null) return true;
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
|
||||
if (handler == null) return true;
|
||||
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
PlayerAbilityEvent.ToggleUpdateEvent event = new PlayerAbilityEvent.ToggleUpdateEvent(iPlayer, ability, tick, state);
|
||||
EventHooks.onPlayerAbilityToggleUpdate(handler, event);
|
||||
return event.isEnabled();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// SELECTION
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -861,32 +786,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
return 0;
|
||||
}
|
||||
|
||||
net.minecraft.entity.Entity sourceEntity = source.getEntity();
|
||||
EntityLivingBase attacker = sourceEntity instanceof EntityLivingBase ? (EntityLivingBase) sourceEntity : null;
|
||||
|
||||
// Track counter state before calling onDamageTaken
|
||||
boolean wasCounterTriggered = false;
|
||||
if (currentAbility instanceof AbilityGuard) {
|
||||
wasCounterTriggered = ((AbilityGuard) currentAbility).isCounterTriggered();
|
||||
}
|
||||
|
||||
currentAbility.onDamageTaken(playerData.player, attacker, source, amount);
|
||||
|
||||
// Guard: handle damage reduction and counter absorption
|
||||
if (currentAbility instanceof AbilityGuard) {
|
||||
AbilityGuard guard = (AbilityGuard) currentAbility;
|
||||
if (guard.isGuarding()) {
|
||||
// Counter just triggered — absorb full damage
|
||||
if (!wasCounterTriggered && guard.isCounterTriggered()) {
|
||||
return 0;
|
||||
}
|
||||
// Normal guard — apply flat damage reduction
|
||||
float reduction = guard.getDamageReductionFactor();
|
||||
return Math.max(0, amount - reduction);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for ability interruption
|
||||
if (currentAbility != null && currentAbility.canInterrupt(source)) {
|
||||
interruptCurrentAbility(source, amount);
|
||||
}
|
||||
@@ -1035,22 +934,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
}
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// SCRIPT EVENTS (Player-specific: start event only, others via abstract)
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Fire the ability start event. Returns true if cancelled.
|
||||
*/
|
||||
private boolean firePlayerStartEvent(EntityPlayer player, Ability ability) {
|
||||
if (ScriptController.Instance == null) return false;
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
|
||||
if (handler == null) return false;
|
||||
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
PlayerAbilityEvent.StartEvent event = new PlayerAbilityEvent.StartEvent(iPlayer, ability, null);
|
||||
return EventHooks.onPlayerAbilityStart(handler, event);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// NBT SERIALIZATION
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -1096,7 +979,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
}
|
||||
playingAbilityAnimation = compound.getBoolean("AbilityAnimating");
|
||||
|
||||
// Active toggles - restore state directly (no onToggleOn callback during load)
|
||||
// Active toggles - restore state directly (no onToggle callback during load)
|
||||
activeToggles.clear();
|
||||
if (compound.hasKey("ActiveToggles")) {
|
||||
NBTTagList toggleNbt = compound.getTagList("ActiveToggles", 10); // 10 = TAG_COMPOUND
|
||||
@@ -1117,9 +1000,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
*/
|
||||
private void validateUnlockedAbilities() {
|
||||
if (AbilityController.Instance == null) return;
|
||||
// Only validate on the server - the client trusts server-sent data.
|
||||
// Custom ability definitions may not have been synced to the client yet,
|
||||
// which would cause valid abilities to be incorrectly pruned.
|
||||
if (playerData == null || !(playerData.player instanceof EntityPlayerMP)) return;
|
||||
|
||||
Iterator<String> it = unlockedAbilities.iterator();
|
||||
|
||||
@@ -178,19 +178,50 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
public long getTimeUntilRepeat(EntityPlayer player) {
|
||||
if (ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared) {
|
||||
Profile profile = ProfileController.Instance.getProfile(player);
|
||||
IPlayer iPlayer = NoppesUtilServer.getIPlayer(player);
|
||||
long timeRemaining = 0L;
|
||||
for (ISlot slot : profile.getSlots().values()) {
|
||||
IPlayerData playerData = ProfileController.Instance.getSlotPlayerData(iPlayer, slot.getId());
|
||||
IPlayerQuestData iPlayerQuestData = playerData.getQuestData();
|
||||
timeRemaining = Math.max(timeRemaining, getTimeUntilRepeatQuestData(player, iPlayerQuestData));
|
||||
if (profile != null) {
|
||||
Long questTime = profile.sharedQuestTimestamps.get(this.id);
|
||||
if (questTime == null) return 0L;
|
||||
return calculateRemainingCooldown(player, questTime);
|
||||
}
|
||||
return timeRemaining;
|
||||
}
|
||||
IPlayerQuestData questData = PlayerData.get(player).getQuestData();
|
||||
return getTimeUntilRepeatQuestData(player, questData);
|
||||
}
|
||||
|
||||
public long calculateRemainingCooldown(EntityPlayer player, long questTime) {
|
||||
switch (repeat) {
|
||||
case MCDAILY: {
|
||||
long now = player.worldObj.getTotalWorldTime();
|
||||
long remainingTicks = questTime + 24000 - now;
|
||||
return Math.max(0, remainingTicks * 50);
|
||||
}
|
||||
case MCWEEKLY: {
|
||||
long now = player.worldObj.getTotalWorldTime();
|
||||
long remainingTicks = questTime + 168000 - now;
|
||||
return Math.max(0, remainingTicks * 50);
|
||||
}
|
||||
case MCCUSTOM: {
|
||||
long now = player.worldObj.getTotalWorldTime();
|
||||
long remainingTicks = questTime + this.customCooldown - now;
|
||||
return Math.max(0, remainingTicks * 50);
|
||||
}
|
||||
case RLDAILY: {
|
||||
long remainingMillis = questTime + 86400000 - System.currentTimeMillis();
|
||||
return Math.max(0, remainingMillis);
|
||||
}
|
||||
case RLWEEKLY: {
|
||||
long remainingMillis = questTime + 604800000 - System.currentTimeMillis();
|
||||
return Math.max(0, remainingMillis);
|
||||
}
|
||||
case RLCUSTOM: {
|
||||
long remainingMillis = questTime + this.customCooldown - System.currentTimeMillis();
|
||||
return Math.max(0, remainingMillis);
|
||||
}
|
||||
default:
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public long getTimeUntilRepeatQuestData(EntityPlayer player, IPlayerQuestData questData) {
|
||||
long questTime = questData.getLastCompletedTime(this.id);
|
||||
|
||||
|
||||
Reference in new issue
Block a user