Added new ScriptDBCPlayer class for manipulating Dragon Block C attributes.

Flying NPCs no longer chase you down if you're dead, or if they're dead.
This commit is contained in:
luisc committed 2021-12-05 15:04:03 -06:00
1 parent 3c1bc30e44
commit 3cd1410c19
3 files changed
+213 -29

No files matched your search

@@ -45,40 +45,36 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
this.motionY *= speed*speedMult;
Entity entity = this.getAttackTarget();
if (!this.worldObj.isRemote)
{
if (entity != null)
{
if (this.posY < entity.posY)
{
if (this.motionY < 0.0D)
{
this.motionY = 0.0D;
if(isEntityAlive()) {
if (!this.worldObj.isRemote) {
Entity entity = this.getAttackTarget();
if (entity != null && entity.isEntityAlive()) {
if (this.posY < entity.posY) {
if (this.motionY < 0.0D) {
this.motionY = 0.0D;
}
this.motionY += (speed - this.motionY) * speed * speedMult;
}
this.motionY += (speed - this.motionY) * speed*speedMult;
double d0 = entity.posX - this.posX;
double d1 = entity.posY - this.posY;
double d2 = entity.posZ - this.posZ;
double d3 = d0 * d0 + d2 * d2;
if (d3 > 9.0D) {
double d5 = (double) MathHelper.sqrt_double(d3);
this.motionX += (d0 / d5 * speed - this.motionX) * speed * speedMult;
this.motionZ += (d2 / d5 * speed - this.motionZ) * speed * speedMult;
}
this.rotationYaw = (float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI));
}
double d0 = entity.posX - this.posX;
double d1 = entity.posY - this.posY;
double d2 = entity.posZ - this.posZ;
double d3 = d0 * d0 + d2 * d2;
if (d3 > 9.0D)
{
double d5 = (double)MathHelper.sqrt_double(d3);
this.motionX += (d0 / d5 * speed - this.motionX) * speed*speedMult;
this.motionZ += (d2 / d5 * speed - this.motionZ) * speed*speedMult;
}
this.rotationYaw = (float)((Math.atan2(-d0,-d2)+Math.PI)*-(180F/Math.PI));
}
}
if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D && isEntityAlive())
{
this.rotationYaw = (float)Math.atan2(this.motionZ, this.motionX) * (180F / (float)Math.PI) - 90.0F;
if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D && isEntityAlive()) {
this.rotationYaw = (float) Math.atan2(this.motionZ, this.motionX) * (180F / (float) Math.PI) - 90.0F;
}
}
super.onLivingUpdate();
@@ -0,0 +1,169 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.scripted.CustomNPCsException;
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
public T player;
public ScriptDBCPlayer(T player){
super(player);
this.player = player;
}
public void setStat(String stat, int value) {
stat = stat.toLowerCase().trim();
switch (stat) {
case "str":
case "strength":
player.getEntityData().setInteger("jrmcStrI", value);
break;
case "dex":
case "dexterity":
player.getEntityData().setInteger("jrmcDexI", value);
break;
case "con":
case "constitution":
player.getEntityData().setInteger("jrmcCnsI", value);
break;
case "wil":
case "willpower":
player.getEntityData().setInteger("jrmcWilI", value);
break;
case "mnd":
case "mind":
player.getEntityData().setInteger("jrmcIntI", value);
break;
case "spi":
case "spirit":
player.getEntityData().setInteger("jrmcCncI", value);
break;
}
}
public int getStat(String stat) {
stat = stat.toLowerCase().trim();
switch (stat) {
case "str":
case "strength":
return player.getEntityData().getInteger("jrmcStrI");
case "dex":
case "dexterity":
return player.getEntityData().getInteger("jrmcDexI");
case "con":
case "constitution":
return player.getEntityData().getInteger("jrmcCnsI");
case "wil":
case "willpower":
return player.getEntityData().getInteger("jrmcWilI");
case "mnd":
case "mind":
return player.getEntityData().getInteger("jrmcIntI");
case "spi":
case "spirit":
return player.getEntityData().getInteger("jrmcCncI");
}
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
}
public void setRelease(byte release){
player.getEntityData().setByte("jrmcRelease",release);
}
public byte getRelease(){
return player.getEntityData().getByte("jrmcRelease");
}
public void setBody(int body){
player.getEntityData().setInteger("jrmcBdy",body);
}
public int getBody(){
return player.getEntityData().getInteger("jrmcBdy");
}
public void setStamina(int stamina){
player.getEntityData().setInteger("jrmcStamina",stamina);
}
public int getStamina(){
return player.getEntityData().getInteger("jrmcStamina");
}
public void setKi(int ki){
player.getEntityData().setInteger("jrmcEnrgy",ki);
}
public int getKi(){
return player.getEntityData().getInteger("jrmcEnrgy");
}
public void setTP(int tp){
player.getEntityData().setInteger("jrmcTpint",tp);
}
public int getTP(){
return player.getEntityData().getInteger("jrmcTpint");
}
public void setGravity(float gravity){
player.getEntityData().setFloat("jrmcGravForce",gravity);
}
public float getGravity(){
return player.getEntityData().getFloat("jrmcGravForce");
}
public void setForm(byte form){
player.getEntityData().setByte("jrmcState",form);
}
public byte getForm(){
return player.getEntityData().getByte("jrmcState");
}
public void setForm2(byte form2){
player.getEntityData().setByte("jrmcState2",form2);
}
public byte getForm2(){
return player.getEntityData().getByte("jrmcState2");
}
public void setPowerPoints(int points){
player.getEntityData().setInteger("jrmcArcRsrv",points);
}
public int getPowerPoints(){
return player.getEntityData().getInteger("jrmcArcRsrv");
}
public void setAuraColor(int color){
player.getEntityData().setInteger("jrmcAuraColor",color);
}
public int getAuraColor(){
return player.getEntityData().getInteger("jrmcAuraColor");
}
public byte getDBCClass(){
return player.getEntityData().getByte("jrmcClass");
}
public int getRace(){
return player.getEntityData().getByte("jrmcRace");
}
public int getPowerType(){
return player.getEntityData().getByte("jrmcPwrtyp");
}
public int getKillCount(String type){
type = type.toLowerCase().trim();
int evilKills = player.getEntityData().getInteger("jrmcKillCountEvil");
int goodKills = player.getEntityData().getInteger("jrmcKillCountGood");
int neutKills = player.getEntityData().getInteger("jrmcKillCountNeut");
switch (type) {
case "evil":
return evilKills;
case "good":
return goodKills;
case "neutral":
return neutKills;
case "all":
return evilKills + goodKills + neutKills;
}
throw new CustomNPCsException("Invalid kill type: " + type + "\nValid kill types are: evil, good, neutral, all", new Object[0]);
}
}
@@ -4,6 +4,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList;
@@ -24,6 +26,7 @@ import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptItemStack;
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
@@ -32,6 +35,9 @@ import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.util.ValueUtil;
import java.util.Iterator;
import java.util.Set;
public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T> implements IPlayer {
public T player;
public ScriptPlayer(T player){
@@ -383,4 +389,17 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
PlayerData data = PlayerDataController.instance.getPlayerData(player);
return data.getGUIOpen();
}
public ScriptDBCPlayer<T> getDBCPlayer() {
Set keySet = player.getEntityData().func_150296_c();
Iterator iterator = keySet.iterator();
while (iterator.hasNext())
{
String s = (String)iterator.next();
if(s.contains("jrmc"))
return new ScriptDBCPlayer<>(this.player);
}
return null;
}
}