Move Collisions to Stats

This commit is contained in:
Kam committed 2024-04-09 20:35:29 -04:00
1 parent 169e8784f1
commit 48baa6de5f
7 files changed
+41 -43

No files matched your search

@@ -58,9 +58,6 @@ public class DataDisplay {
public ArrayList<UUID> invisibleToList = new ArrayList<>();
// 0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
public int collidesWith = 1;
public DataDisplay(EntityNPCInterface npc){
this.npc = npc;
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
@@ -109,8 +106,6 @@ public class DataDisplay {
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
nbttagcompound.setByte("BossBar", showBossBar);
nbttagcompound.setInteger("CollidesWith",collidesWith);
NBTTagList list = new NBTTagList();
for(UUID uuid : invisibleToList){
list.appendTag(new NBTTagString(uuid.toString()));
@@ -195,11 +190,6 @@ public class DataDisplay {
invisibleToList = new ArrayList<>();
}
if(nbttagcompound.hasKey("CollidesWith"))
collidesWith = nbttagcompound.getInteger("CollidesWith");
else
collidesWith = 1;
if(prevSkinType != skinType || !texture.equals(prevTexture)|| !url.equals(prevUrl))
npc.textureLocation = null;
npc.updateHitbox();
+22 -13
View File
@@ -9,12 +9,12 @@ import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.ValueUtil;
public class DataStats {
private float attackStrength = 5;
public int attackSpeed = 20, swingWarmUp = 0, attackRange = 2, knockback = 0;
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
public int aggroRange = 16;
public EnumPotionType potionType = EnumPotionType.None;
public int potionDuration = 5; //20 = 1 second
public int potionAmp = 0;
@@ -25,7 +25,7 @@ public class DataStats {
public boolean hideKilledBody = false;
public boolean canDespawn = false;
public boolean playerSetCanDespawn = false;
public Resistances resistances = new Resistances();
public boolean ignoreCobweb = false;
@@ -47,17 +47,20 @@ public class DataStats {
public String fireSound = "random.bow";
public boolean aimWhileShooting = false;
public boolean projectilesKeepTerrain = false;
public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED;
private EntityNPCInterface npc;
public boolean attackInvisible = false;
// 0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
public int collidesWith = 1;
public DataStats(EntityNPCInterface npc){
this.npc = npc;
}
public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
{
compound.setTag("Resistances", resistances.writeToNBT());
compound.setDouble("MaxHealth", maxHealth);
compound.setInteger("AggroRange", aggroRange);
@@ -68,7 +71,7 @@ public class DataStats {
compound.setBoolean("IgnoreCobweb", ignoreCobweb);
compound.setFloat("HealthRegen", healthRegen);
compound.setFloat("CombatRegen", combatRegen);
compound.setFloat("AttackStrenght", attackStrength);
compound.setInteger("AttackRange", attackRange);
compound.setInteger("AttackSpeed", attackSpeed);
@@ -77,7 +80,7 @@ public class DataStats {
compound.setInteger("PotionEffect", potionType.ordinal());
compound.setInteger("PotionDuration", potionDuration);
compound.setInteger("PotionAmp", potionAmp);
compound.setInteger("MaxFiringRange", rangedRange);
compound.setInteger("FireRate", fireRate);
compound.setInteger("minDelay", minDelay);
@@ -85,7 +88,7 @@ public class DataStats {
compound.setInteger("BurstCount", burstCount);
compound.setInteger("ShotCount", shotCount);
compound.setInteger("Accuracy", accuracy);
compound.setFloat("pDamage", pDamage);
compound.setInteger("pImpact", pImpact);
compound.setInteger("pSize", pSize);
@@ -114,7 +117,8 @@ public class DataStats {
compound.setBoolean("AttackInvisible", attackInvisible);
compound.setBoolean("CanDespawn", canDespawn);
compound.setBoolean("PlayerSetCanDespawn", playerSetCanDespawn);
compound.setInteger("CollidesWith",collidesWith);
return compound;
}
@@ -176,8 +180,13 @@ public class DataStats {
attackInvisible = compound.getBoolean("AttackInvisible");
canDespawn = compound.getBoolean("CanDespawn");
playerSetCanDespawn = compound.getBoolean("PlayerSetCanDespawn");
npc.setImmuneToFire(immuneToFire);
if(compound.hasKey("CollidesWith"))
collidesWith = compound.getInteger("CollidesWith");
else
collidesWith = 1;
}
public float getAttackStrength(){
@@ -187,7 +196,7 @@ public class DataStats {
attackStrength = (float)(Math.floor(strength));
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
}
public void setMaxHealth(double maxHealth) {
this.maxHealth = Math.floor(maxHealth);
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
@@ -79,15 +79,12 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
y+=23;
addLabel(new GuiNpcLabel(5,"display.livingAnimation", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no"}, display.disableLivingAnimation?1:0));
addLabel(new GuiNpcLabel(6,"display.collides", guiLeft + 185, y + 5));
this.addButton(new GuiNpcButton(6, guiLeft + 300, y, 100, 20, new String[]{"gui.yes","gui.no","Only CNPCs","Only Players","CNPCs & Players"}, display.collidesWith));
this.addButton(new GuiNpcButton(13, guiLeft + 185, y , 100, 20, "display.tintsettings"));
this.addButton(new GuiNpcButton(12,guiLeft + 300, y, 100, 20, "display.hitboxsettings"));
y+=23;
addLabel(new GuiNpcLabel(7,"display.visible", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no","gui.partly"}, display.visible));
this.addButton(new GuiNpcButton(13, guiLeft + 185, y , 100, 20, "display.tintsettings"));
this.addButton(new GuiNpcButton(12,guiLeft + 300, y, 100, 20, "display.hitboxsettings"));
y+=23;
addLabel(new GuiNpcLabel(10,"display.bossbar", guiLeft + 5, y + 5));
@@ -130,7 +127,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
boolean isGlow = true;
if(npc.display.skinOverlayData.has(0))
isGlow = npc.display.skinOverlayData.overlayList.get(0).getGlow();
SkinOverlay skinOverlay = new SkinOverlay(textfield.getText());
skinOverlay.setGlow(isGlow);
skinOverlay.setBlend(isGlow);
@@ -166,9 +163,6 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
else if(button.id == 5){
display.disableLivingAnimation = button.getValue() == 1;
}
else if(button.id == 6){
display.collidesWith = button.getValue();
}
else if(button.id == 7){
display.visible = button.getValue();
}
@@ -58,8 +58,10 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
addLabel(new GuiNpcLabel(10,"stats.fireimmune", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(5,guiLeft + 217, y, 56, 20, new String[]{"stats.never","stats.inWater","stats.inAir"} , stats.drowningType));
addLabel(new GuiNpcLabel(11,"stats.candrown", guiLeft + 140, y + 5));
addButton(new GuiNpcButton(23, guiLeft + 358, y, 56, 20, new String[]{"display.all","gui.none","NPCs","Players","Both"}, stats.collidesWith));
addLabel(new GuiNpcLabel(23,"stats.collides", guiLeft + 275, y + 5));
addButton(new GuiNpcButton(6,guiLeft + 82, y+=22, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0));
addButton(new GuiNpcButton(6,guiLeft + 82, y+=22, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0));
addLabel(new GuiNpcLabel(12,"stats.burninsun", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(7,guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.noFallDamage? 1:0));
addLabel(new GuiNpcLabel(13,"stats.nofalldamage", guiLeft + 140, y + 5));
@@ -138,6 +140,9 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
else if (button.id == 22) {
stats.ignoreCobweb = (button.getValue() == 0);
}
else if(button.id == 23){
stats.collidesWith = button.getValue();
}
// Button 300
if(guibutton instanceof GuiNpcButton)
@@ -249,7 +249,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
boolean didAttack = false;
if(DBCAddon.instance.canDBCAttack(this, f, receiver)){
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), 1.0f);
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), 0.001f);
if(didAttack)
DBCAddon.instance.doDBCDamage(this, f, receiver);
}
@@ -1773,13 +1773,13 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
@Override
public boolean canBePushed() {
return this.display.collidesWith == 0;
return this.stats.collidesWith == 0;
}
// checks for any entity within a certain boundingbox, eg minecarts
@Override
protected void collideWithNearbyEntities() {
if(this.display.collidesWith != 1) {
if(this.stats.collidesWith != 1) {
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
if (list != null && !list.isEmpty()) {
@@ -1787,8 +1787,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
Entity entity = (Entity) list.get(i);
if (this.canBePushed() ||
(entity instanceof EntityNPCInterface && (this.display.collidesWith == 2 || this.display.collidesWith == 4)) ||
(entity instanceof EntityPlayerMP && (this.display.collidesWith == 3 || this.display.collidesWith == 4))
(entity instanceof EntityNPCInterface && (this.stats.collidesWith == 2 || this.stats.collidesWith == 4)) ||
(entity instanceof EntityPlayerMP && (this.stats.collidesWith == 3 || this.stats.collidesWith == 4))
) {
super.collideWithEntity(entity);
}
@@ -1824,8 +1824,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
d0 *= (double)(1.0F - this.entityCollisionReduction);
d1 *= (double)(1.0F - this.entityCollisionReduction);
if (this.canBePushed() ||
(entity instanceof EntityNPCInterface && (this.display.collidesWith == 2 || this.display.collidesWith == 4)) ||
(entity instanceof EntityPlayerMP && (this.display.collidesWith == 3 || this.display.collidesWith == 4))
(entity instanceof EntityNPCInterface && (this.stats.collidesWith == 2 || this.stats.collidesWith == 4)) ||
(entity instanceof EntityPlayerMP && (this.stats.collidesWith == 3 || this.stats.collidesWith == 4))
)
this.addVelocity(-d0, 0.0D, -d1);
entity.addVelocity(d0, 0.0D, d1);
@@ -1363,10 +1363,10 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
}
public void setCollisionType(int type){
npc.display.collidesWith = type;
npc.stats.collidesWith = type;
}
public int getCollisionType(){
return npc.display.collidesWith;
return npc.stats.collidesWith;
}
public void updateClient() { this.npc.updateClient(); }