mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 02:42:18 +00:00
Merge branch 'dev' into janino-scripts
This commit is contained in:
commit
fb0332e5cf
53 files changed
+3017
-376
No files matched your search
@@ -136,10 +136,14 @@ public class PlayerQuestController {
|
||||
return player.worldObj.getTotalWorldTime() - questTime >= 24000;
|
||||
} else if (quest.repeat == EnumQuestRepeat.MCWEEKLY) {
|
||||
return player.worldObj.getTotalWorldTime() - questTime >= 168000;
|
||||
} else if (quest.repeat == EnumQuestRepeat.MCCUSTOM) {
|
||||
return player.worldObj.getTotalWorldTime() - questTime >= quest.customCooldown;
|
||||
} else if (quest.repeat == EnumQuestRepeat.RLDAILY) {
|
||||
return System.currentTimeMillis() - questTime >= 86400000;
|
||||
} else if (quest.repeat == EnumQuestRepeat.RLWEEKLY) {
|
||||
return System.currentTimeMillis() - questTime >= 604800000;
|
||||
} else if (quest.repeat == EnumQuestRepeat.RLCUSTOM) {
|
||||
return System.currentTimeMillis() - questTime >= quest.customCooldown;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,10 @@ import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Animation implements IAnimation {
|
||||
public AnimationData parent; //Client-sided only
|
||||
@@ -34,6 +37,12 @@ public class Animation implements IAnimation {
|
||||
//Client-sided
|
||||
public boolean paused;
|
||||
|
||||
protected final Map<String, Object> dataStore = new HashMap<>();
|
||||
|
||||
public Consumer<IAnimation> onAnimationStart;
|
||||
public BiConsumer<Integer, IAnimation> onAnimationFrame;
|
||||
public Consumer<IAnimation> onAnimationEnd;
|
||||
|
||||
public Animation() {
|
||||
}
|
||||
|
||||
@@ -175,6 +184,18 @@ public class Animation implements IAnimation {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasData(String key) {return dataStore.containsKey(key);}
|
||||
|
||||
@Override
|
||||
public Object getData(String key) {return dataStore.get(key);}
|
||||
|
||||
@Override
|
||||
public IAnimation setData(String key, Object v) {dataStore.put(key, v);return this;}
|
||||
|
||||
@Override
|
||||
public IAnimation removeData(String key) {dataStore.remove(key);return this;}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
if (compound.hasKey("ID")) {
|
||||
id = compound.getInteger("ID");
|
||||
@@ -254,8 +275,10 @@ public class Animation implements IAnimation {
|
||||
|
||||
if (this.currentFrame() != null) {
|
||||
EventHooks.onAnimationFrameEntered(this, this.currentFrame());
|
||||
fireFrameTask(this.currentFrame);
|
||||
} else {
|
||||
EventHooks.onAnimationEnded(this);
|
||||
fireEndTask();
|
||||
}
|
||||
|
||||
if (nextFrame != null) {
|
||||
@@ -294,4 +317,61 @@ public class Animation implements IAnimation {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnimation onStart(Consumer<IAnimation> task) {
|
||||
this.onAnimationStart = task;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnimation onFrame(BiConsumer<Integer, IAnimation> task) {
|
||||
this.onAnimationFrame = task;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnimation onEnd(Consumer<IAnimation> task) {
|
||||
this.onAnimationEnd = task;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void fireStartTask() {
|
||||
if (this.onAnimationStart != null) {
|
||||
this.onAnimationStart.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fireFrameTask(int frame) {
|
||||
if (this.onAnimationFrame != null) {
|
||||
this.onAnimationFrame.accept(frame, this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fireEndTask() {
|
||||
if (this.onAnimationEnd != null) {
|
||||
this.onAnimationEnd.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only called on setAnimation, to transfer tasks from
|
||||
* this global instance stored in AnimationController
|
||||
* to the new local instance on entity's AnimationData,
|
||||
* and clear them from the global instance.
|
||||
*/
|
||||
public void moveFromGlobalToLocal(Animation animation) {
|
||||
this.onAnimationStart = animation.onAnimationStart;
|
||||
this.onAnimationFrame = animation.onAnimationFrame;
|
||||
this.onAnimationEnd = animation.onAnimationEnd;
|
||||
|
||||
animation.onAnimationEnd = null;
|
||||
animation.onAnimationFrame = null;
|
||||
animation.onAnimationStart = null;
|
||||
|
||||
this.dataStore.putAll(animation.dataStore);
|
||||
animation.dataStore.clear();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -98,15 +98,18 @@ public class AnimationData implements IAnimationData {
|
||||
this.isClientAnimating = this.allowAnimation && this.animation != null;
|
||||
if (prevIsClientAnimating && (!this.isClientAnimating || this.animation != this.currentClientAnimation)) {
|
||||
EventHooks.onAnimationEnded(this.currentClientAnimation);
|
||||
this.currentClientAnimation.fireEndTask();
|
||||
}
|
||||
if (this.isClientAnimating) {
|
||||
this.currentClientAnimation = this.animation;
|
||||
}
|
||||
|
||||
if (this.animation != null && this.allowAnimation) {
|
||||
this.animation.fireStartTask();
|
||||
if (EventHooks.onAnimationStarted(this.animation))
|
||||
return;
|
||||
EventHooks.onAnimationFrameEntered(this.animation, this.animation.currentFrame());
|
||||
this.animation.fireFrameTask(this.animation.currentFrame);
|
||||
}
|
||||
|
||||
List<EntityPlayer> entities = sendingEntity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(
|
||||
@@ -269,6 +272,7 @@ public class AnimationData implements IAnimationData {
|
||||
newAnim.currentFrame = 0;
|
||||
newAnim.currentFrameTime = 0;
|
||||
newAnim.parent = this;
|
||||
newAnim.moveFromGlobalToLocal((Animation) animation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class LinkedItem implements ILinkedItem {
|
||||
public boolean isNormalItem = false;
|
||||
public boolean isTool = false;
|
||||
public int digSpeed = 1;
|
||||
public int attackSpeed = 20;
|
||||
public int attackSpeed = 10;
|
||||
public int armorType = -2; //-2: Fits in no armor slot, -1: Fits in all slots, 0 - 3: Fits in Head -> Boots slot respectively
|
||||
public int enchantability;
|
||||
|
||||
@@ -59,7 +59,8 @@ public class LinkedItem implements ILinkedItem {
|
||||
compound.setBoolean("IsTool", this.isTool);
|
||||
compound.setBoolean("IsNormalItem", this.isNormalItem);
|
||||
compound.setInteger("DigSpeed", this.digSpeed);
|
||||
compound.setInteger("AttackSpeed",this.attackSpeed);
|
||||
compound.setInteger("AttackSpeed", this.attackSpeed);
|
||||
|
||||
compound.setInteger("ArmorType", this.armorType);
|
||||
compound.setInteger("Enchantability", this.enchantability);
|
||||
|
||||
@@ -89,7 +90,7 @@ public class LinkedItem implements ILinkedItem {
|
||||
this.isTool = compound.getBoolean("IsTool");
|
||||
this.isNormalItem = compound.getBoolean("IsNormalItem");
|
||||
this.digSpeed = compound.getInteger("DigSpeed");
|
||||
this.attackSpeed = compound.getInteger("AttackSpeed");
|
||||
this.setAttackSpeed(compound.getInteger("AttackSpeed"));
|
||||
this.armorType = compound.getInteger("ArmorType");
|
||||
this.enchantability = compound.getInteger("Enchantability");
|
||||
|
||||
@@ -241,6 +242,19 @@ public class LinkedItem implements ILinkedItem {
|
||||
this.enchantability = enchantability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAttackSpeed() {
|
||||
return attackSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttackSpeed(int time) {
|
||||
if(time <= 0) {
|
||||
time = 10;
|
||||
}
|
||||
this.attackSpeed = time;
|
||||
}
|
||||
|
||||
public LinkedItem clone() {
|
||||
NBTTagCompound nbt = this.writeToNBT(true);
|
||||
LinkedItem clone = new LinkedItem(this.name);
|
||||
@@ -254,10 +268,4 @@ public class LinkedItem implements ILinkedItem {
|
||||
setScriptHandler(data = new LinkedItemScript());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAttackSpeed() {return attackSpeed;}
|
||||
|
||||
@Override
|
||||
public void setAttackSpeed(int time) {this.attackSpeed = time;}
|
||||
}
|
||||
@@ -84,6 +84,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
public ScreenSize screenSize = new ScreenSize(-1, -1);
|
||||
|
||||
public int profileSlot = 0;
|
||||
private boolean specialKeyDown = false;
|
||||
|
||||
public void onLogin() {
|
||||
// Continue playing animation for self when re-logging
|
||||
@@ -267,6 +268,14 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
return this.isGUIOpen;
|
||||
}
|
||||
|
||||
public boolean isSpecialKeyDown() {
|
||||
return specialKeyDown;
|
||||
}
|
||||
|
||||
public void setSpecialKeyDown(boolean specialKeyDown) {
|
||||
this.specialKeyDown = specialKeyDown;
|
||||
}
|
||||
|
||||
public ScreenSize getScreenSize() {
|
||||
return screenSize;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user