Remove "Conflicts", prevent creative mode battles

This commit is contained in:
Stephen Seo 2018-09-13 15:50:34 +09:00
parent d316261b76
commit 6a97a90d68
4 changed files with 3 additions and 46 deletions

View file

@ -36,9 +36,9 @@ public class BattleManager
*/ */
public boolean checkAttack(final LivingAttackEvent event) public boolean checkAttack(final LivingAttackEvent event)
{ {
// verify that both entities are EntityPlayer or has a corresponding EntityInfo // verify that both entities are EntityPlayer and not in creative or has a corresponding EntityInfo
if(!(event.getEntity() instanceof EntityPlayer || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getEntity().getClass().getName()) != null) if(!((event.getEntity() instanceof EntityPlayer && !((EntityPlayer)event.getEntity()).isCreative()) || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getEntity().getClass().getName()) != null)
|| !(event.getSource().getTrueSource() instanceof EntityPlayer || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null)) || !((event.getSource().getTrueSource() instanceof EntityPlayer && !((EntityPlayer)event.getSource().getTrueSource()).isCreative()) || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null))
{ {
return false; return false;
} }

View file

@ -281,24 +281,6 @@ public class Config
{ {
eInfo.category = xmlReader.getElementText().toLowerCase(); eInfo.category = xmlReader.getElementText().toLowerCase();
} }
else if(xmlReader.getLocalName().equals("Conflicts"))
{
do
{
xmlReader.next();
if(xmlReader.isStartElement())
{
try
{
Class conflictingType = Class.forName(xmlReader.getLocalName());
eInfo.conflictingTypes.add(conflictingType);
} catch(ClassNotFoundException e)
{
logger.warn("Invalid conflicting type for entity " + eInfo.classType.getName());
}
}
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("Conflicts")));
}
else if(xmlReader.getLocalName().equals("IgnoreBattle")) else if(xmlReader.getLocalName().equals("IgnoreBattle"))
{ {
if(xmlReader.getElementText().toLowerCase().equals("true")) if(xmlReader.getElementText().toLowerCase().equals("true"))
@ -412,13 +394,6 @@ public class Config
EntityInfo matching = entityInfoMap.get(entity.getClass().getName()); EntityInfo matching = entityInfoMap.get(entity.getClass().getName());
if(matching != null && matching.classType.isInstance(entity)) if(matching != null && matching.classType.isInstance(entity))
{ {
for(Class c : matching.conflictingTypes)
{
if(c.isInstance(entity))
{
return entityInfoMap.get(c.getName());
}
}
return matching; return matching;
} }
return null; return null;

View file

@ -10,7 +10,6 @@ import net.minecraft.potion.PotionEffect;
public class EntityInfo public class EntityInfo
{ {
public Class classType; public Class classType;
public List<Class> conflictingTypes;
public boolean ignoreBattle; public boolean ignoreBattle;
public int attackPower; public int attackPower;
public int attackProbability; public int attackProbability;
@ -310,7 +309,6 @@ public class EntityInfo
public EntityInfo() public EntityInfo()
{ {
classType = null; classType = null;
conflictingTypes = new ArrayList<Class>();
ignoreBattle = false; ignoreBattle = false;
attackPower = 0; attackPower = 0;
attackProbability = 70; attackProbability = 70;
@ -331,11 +329,6 @@ public class EntityInfo
{ {
EntityInfo newEntityInfo = new EntityInfo(); EntityInfo newEntityInfo = new EntityInfo();
newEntityInfo.classType = classType; newEntityInfo.classType = classType;
newEntityInfo.conflictingTypes = new ArrayList<Class>();
for(Class c : conflictingTypes)
{
newEntityInfo.conflictingTypes.add(c);
}
newEntityInfo.ignoreBattle = ignoreBattle; newEntityInfo.ignoreBattle = ignoreBattle;
newEntityInfo.attackPower = attackPower; newEntityInfo.attackPower = attackPower;
newEntityInfo.attackProbability = attackProbability; newEntityInfo.attackProbability = attackProbability;

View file

@ -31,7 +31,6 @@
<!-- Speed: Value in range of 0 to 100 that determines the order entities act in battle. Higher is sooner. Entities with same speed will take their turn as a group in random order (not at the same time). --> <!-- Speed: Value in range of 0 to 100 that determines the order entities act in battle. Higher is sooner. Entities with same speed will take their turn as a group in random order (not at the same time). -->
<!-- IgnoreBattle: (Optional) Per entity setting to not enter turn-based-battle if value is "true". If "true" these stats will not apply to the entity as they are only used in turn-based-battle. --> <!-- IgnoreBattle: (Optional) Per entity setting to not enter turn-based-battle if value is "true". If "true" these stats will not apply to the entity as they are only used in turn-based-battle. -->
<!-- Category: Sets the type of the entity, used by "IgnoreBattleTypes" to determine what types ignore battle. --> <!-- Category: Sets the type of the entity, used by "IgnoreBattleTypes" to determine what types ignore battle. -->
<!-- Conflicts: (Optional) Tells the mod that this entity should not be mistaken for the listed entities (possible because some entities derive from others; CaveSpiders are also Spiders). -->
<!-- Decision: Lists percentages of what action taken by the entity, one of Attack, Defend, or Flee. If the sum is less than 100, the mob has a chance to do nothing with the remaining percentage --> <!-- Decision: Lists percentages of what action taken by the entity, one of Attack, Defend, or Flee. If the sum is less than 100, the mob has a chance to do nothing with the remaining percentage -->
<net.minecraft.entity.monster.EntityBlaze> <net.minecraft.entity.monster.EntityBlaze>
<AttackPower Probability="50">5</AttackPower> <AttackPower Probability="50">5</AttackPower>
@ -263,9 +262,6 @@
<net.minecraft.entity.monster.EntitySpider> <net.minecraft.entity.monster.EntitySpider>
<AttackPower Probability="70">2</AttackPower> <AttackPower Probability="70">2</AttackPower>
<Evasion>25</Evasion> <Evasion>25</Evasion>
<Conflicts>
<net.minecraft.entity.monster.EntityCaveSpider></net.minecraft.entity.monster.EntityCaveSpider>
</Conflicts>
<Category>monster</Category> <Category>monster</Category>
<Speed>70</Speed> <Speed>70</Speed>
<Decision> <Decision>
@ -333,10 +329,6 @@
</net.minecraft.entity.monster.EntityWitherSkeleton> </net.minecraft.entity.monster.EntityWitherSkeleton>
<net.minecraft.entity.monster.EntityZombie> <net.minecraft.entity.monster.EntityZombie>
<AttackPower Probability="70">3</AttackPower> <AttackPower Probability="70">3</AttackPower>
<Conflicts>
<net.minecraft.entity.monster.EntityHusk></net.minecraft.entity.monster.EntityHusk>
<net.minecraft.entity.monster.EntityZombieVillager></net.minecraft.entity.monster.EntityZombieVillager>
</Conflicts>
<Evasion>5</Evasion> <Evasion>5</Evasion>
<Category>monster</Category> <Category>monster</Category>
<Speed>25</Speed> <Speed>25</Speed>
@ -382,9 +374,6 @@
<net.minecraft.entity.passive.EntityCow> <net.minecraft.entity.passive.EntityCow>
<AttackPower Probability="50">0</AttackPower> <AttackPower Probability="50">0</AttackPower>
<Evasion>1</Evasion> <Evasion>1</Evasion>
<Conflicts>
<net.minecraft.entity.passive.EntityMooshroom></net.minecraft.entity.passive.EntityMooshroom>
</Conflicts>
<Category>passive</Category> <Category>passive</Category>
<Speed>20</Speed> <Speed>20</Speed>
<Decision> <Decision>