]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Remove "Conflicts", prevent creative mode battles
authorStephen Seo <seo.disparate@gmail.com>
Thu, 13 Sep 2018 06:50:34 +0000 (15:50 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Thu, 13 Sep 2018 06:50:34 +0000 (15:50 +0900)
src/main/java/com/seodisparate/TurnBasedMinecraft/common/BattleManager.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/Config.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/EntityInfo.java
src/main/resources/assets/TurnBasedMinecraft/TBM_Config.xml

index d0a902a86bf61e0686222d11aac8b727fdc9434f..5679e78befb66eac3927f2c29d83c7885ef7cfe2 100644 (file)
@@ -36,9 +36,9 @@ public class BattleManager
      */
     public boolean checkAttack(final LivingAttackEvent event)
     {
-        // verify that both entities are EntityPlayer or has a corresponding EntityInfo
-        if(!(event.getEntity() instanceof EntityPlayer || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getEntity().getClass().getName()) != null)
-            || !(event.getSource().getTrueSource() instanceof EntityPlayer || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null))
+        // verify that both entities are EntityPlayer and not in creative or has a corresponding EntityInfo
+        if(!((event.getEntity() instanceof EntityPlayer && !((EntityPlayer)event.getEntity()).isCreative()) || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getEntity().getClass().getName()) != null)
+            || !((event.getSource().getTrueSource() instanceof EntityPlayer && !((EntityPlayer)event.getSource().getTrueSource()).isCreative()) || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null))
         {
             return false;
         }
index 00961c7394b180718cf3eaadfd34e528e7af4089..a3d146f88245f8f5c927c4c3b676f7cd5d7d8c56 100644 (file)
@@ -281,24 +281,6 @@ public class Config
                                     {
                                         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"))
                                     {
                                         if(xmlReader.getElementText().toLowerCase().equals("true"))
@@ -412,13 +394,6 @@ public class Config
         EntityInfo matching = entityInfoMap.get(entity.getClass().getName());
         if(matching != null && matching.classType.isInstance(entity))
         {
-            for(Class c : matching.conflictingTypes)
-            {
-                if(c.isInstance(entity))
-                {
-                    return entityInfoMap.get(c.getName());
-                }
-            }
             return matching;
         }
         return null;
index 11240683219d7ff54a47566519990b15478036a1..62d9086eadc5b85fbbccaaa4c46f47adb7f7604b 100644 (file)
@@ -10,7 +10,6 @@ import net.minecraft.potion.PotionEffect;
 public class EntityInfo
 {
     public Class classType;
-    public List<Class> conflictingTypes;
     public boolean ignoreBattle;
     public int attackPower;
     public int attackProbability;
@@ -310,7 +309,6 @@ public class EntityInfo
     public EntityInfo()
     {
         classType = null;
-        conflictingTypes = new ArrayList<Class>();
         ignoreBattle = false;
         attackPower = 0;
         attackProbability = 70;
@@ -331,11 +329,6 @@ public class EntityInfo
     {
         EntityInfo newEntityInfo = new EntityInfo();
         newEntityInfo.classType = classType;
-        newEntityInfo.conflictingTypes = new ArrayList<Class>();
-        for(Class c : conflictingTypes)
-        {
-            newEntityInfo.conflictingTypes.add(c);
-        }
         newEntityInfo.ignoreBattle = ignoreBattle;
         newEntityInfo.attackPower = attackPower;
         newEntityInfo.attackProbability = attackProbability;
index b5f3db3523aeeeb7a78344876d4bc355b9feb9ea..519449365997dba82c1cd0bee3dad6dfaf25a1d9 100644 (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). -->
                <!-- 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. -->
-               <!-- 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 -->
                <net.minecraft.entity.monster.EntityBlaze>
                        <AttackPower Probability="50">5</AttackPower>
                <net.minecraft.entity.monster.EntitySpider>
                        <AttackPower Probability="70">2</AttackPower>
                        <Evasion>25</Evasion>
-                       <Conflicts>
-                               <net.minecraft.entity.monster.EntityCaveSpider></net.minecraft.entity.monster.EntityCaveSpider>
-                       </Conflicts>
                        <Category>monster</Category>
                        <Speed>70</Speed>
                        <Decision>
                </net.minecraft.entity.monster.EntityWitherSkeleton>
                <net.minecraft.entity.monster.EntityZombie>
                        <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>
                        <Category>monster</Category>
                        <Speed>25</Speed>
                <net.minecraft.entity.passive.EntityCow>
                        <AttackPower Probability="50">0</AttackPower>
                        <Evasion>1</Evasion>
-                       <Conflicts>
-                               <net.minecraft.entity.passive.EntityMooshroom></net.minecraft.entity.passive.EntityMooshroom>
-                       </Conflicts>
                        <Category>passive</Category>
                        <Speed>20</Speed>
                        <Decision>