]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Minor fixes 1.7
authorStephen Seo <seo.disparate@gmail.com>
Fri, 26 Oct 2018 05:18:48 +0000 (14:18 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 26 Oct 2018 05:18:48 +0000 (14:18 +0900)
src/main/java/com/seodisparate/TurnBasedMinecraft/common/AttackEventHandler.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/BattleManager.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/EntityInfo.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketEditingMessage.java

index ae02a2711d5fe5a4807c672253f69122af3a359c..1c83f31321f3ae8bf4df9a124ebb10da3798aefb 100644 (file)
@@ -95,12 +95,16 @@ public class AttackEventHandler
                     }
                     else
                     {
-                        editingInfo.entityInfo = config.getMatchingEntityInfo(event.getEntity()).clone();
+                        editingInfo.entityInfo = config.getMatchingEntityInfo(event.getEntity());
                         if(editingInfo.entityInfo == null)
                         {
                             editingInfo.entityInfo = new EntityInfo();
                             editingInfo.entityInfo.classType = event.getEntity().getClass();
                         }
+                        else
+                        {
+                            editingInfo.entityInfo = editingInfo.entityInfo.clone();
+                        }
                         TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""), (EntityPlayerMP) editingInfo.editor);
                         TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
                         TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP) editingInfo.editor);
index 9f1f5af2335e7087dcd247434859765680fa9f50..7b552df5a3f9644ebfa9ad98db9b2eed013b9dd6 100644 (file)
@@ -45,21 +45,22 @@ public class BattleManager
      */
     public boolean checkAttack(final LivingAttackEvent event)
     {
+        Config config = TurnBasedMinecraftMod.proxy.getConfig();
         // 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.proxy.getConfig().getEntityInfoReference(event.getEntity().getClass().getName()) != null)
-            || !((event.getSource().getTrueSource() instanceof EntityPlayer && !((EntityPlayer)event.getSource().getTrueSource()).isCreative()) || TurnBasedMinecraftMod.proxy.getConfig().getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null))
+        if(!((event.getEntity() instanceof EntityPlayer && !((EntityPlayer)event.getEntity()).isCreative()) || (config.getEntityInfoReference(event.getEntity().getClass().getName()) != null || config.getCustomEntityInfoReference(event.getEntity().getCustomNameTag()) != null))
+            || !((event.getSource().getTrueSource() instanceof EntityPlayer && !((EntityPlayer)event.getSource().getTrueSource()).isCreative()) || (config.getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null || config.getCustomEntityInfoReference(event.getSource().getTrueSource().getCustomNameTag()) != null)))
         {
             return false;
         }
         
         // check if ignore battle in config
-        EntityInfo entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(event.getEntity().getCustomNameTag());
+        EntityInfo entityInfo = config.getCustomEntityInfoReference(event.getEntity().getCustomNameTag());
         if(entityInfo == null)
         {
-            entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getEntity());
+            entityInfo = config.getMatchingEntityInfo(event.getEntity());
         }
 
-        if(entityInfo != null && (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
+        if(entityInfo != null && (config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
         {
             // attacked entity ignores battle
             synchronized(battleMap)
@@ -68,16 +69,22 @@ public class BattleManager
                 {
                     if(b.hasCombatant(event.getSource().getTrueSource().getEntityId()))
                     {
-    //                    logger.debug("Attack Canceled: attacked ignores battle but attacker in battle");
+                        logger.debug("Attack Canceled: attacked ignores battle but attacker in battle");
                         return true;
                     }
                 }
             }
-//            logger.debug("Attack Not Canceled: attacked ignores battle");
+            logger.debug("Attack Not Canceled: attacked ignores battle");
             return false;
         }
-        entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getSource().getTrueSource());
-        if(entityInfo != null && (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
+
+        entityInfo = config.getCustomEntityInfoReference(event.getSource().getTrueSource().getCustomNameTag());
+        if(entityInfo == null)
+        {
+            entityInfo = config.getMatchingEntityInfo(event.getSource().getTrueSource());
+        }
+
+        if(entityInfo != null && (config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
         {
             // attacker entity ignores battle
             synchronized(battleMap)
@@ -86,12 +93,12 @@ public class BattleManager
                 {
                     if(b.hasCombatant(event.getEntity().getEntityId()))
                     {
-    //                    logger.debug("Attack Canceled: attacker ignores battle but attacked in battle");
+                        logger.debug("Attack Canceled: attacker ignores battle but attacked in battle");
                         return true;
                     }
                 }
             }
-//            logger.debug("Attack Not Canceled: attacker ignores battle");
+            logger.debug("Attack Not Canceled: attacker ignores battle");
             return false;
         }
         
@@ -109,7 +116,7 @@ public class BattleManager
                     if(inBattle != null)
                     {
                         // both combatants are in battle
-    //                    logger.debug("Attack Canceled: both are in battle");
+                        logger.debug("Attack Canceled: both are in battle");
                         return true;
                     }
                     else
@@ -124,7 +131,7 @@ public class BattleManager
                     if(inBattle != null)
                     {
                         // both combatants are in battle
-    //                    logger.debug("Attack Canceled: both are in battle");
+                        logger.debug("Attack Canceled: both are in battle");
                         return true;
                     }
                     else
@@ -148,17 +155,17 @@ public class BattleManager
                 sideA.add(event.getEntity());
                 sideB.add(event.getSource().getTrueSource());
                 createBattle(sideA, sideB);
-//                logger.debug("Attack Not Canceled: new battle created");
+                logger.debug("Attack Not Canceled: new battle created");
             }
             else
             {
-//                logger.debug("Attack Not Canceled: neither are in battle or players");
+                logger.debug("Attack Not Canceled: neither are in battle or players");
             }
             return false;
         }
 
         // at this point only one entity is in battle, so add entity to other side
-        if(battle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle())
+        if(battle.getSize() >= config.getMaxInBattle())
         {
             // battle limit reached, cannot add to battle
             return true;
@@ -172,14 +179,31 @@ public class BattleManager
             battle.addCombatantToSideA(notInBattle);
         }
 
-//        logger.debug("Attack Canceled: one is in battle");
+        logger.debug("Attack Canceled: one is in battle");
         return true;
     }
     
     public void checkTargeted(LivingSetAttackTargetEvent event)
     {
-        EntityInfo attackerInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getEntity());
-        EntityInfo targetedInfo = event.getTarget() instanceof EntityPlayer ? null : TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getTarget());
+        EntityInfo attackerInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(event.getEntity().getCustomNameTag());
+        if(attackerInfo == null)
+        {
+            attackerInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getEntity());
+        }
+
+        EntityInfo targetedInfo;
+        if(event.getTarget() instanceof EntityPlayer)
+        {
+            targetedInfo = null;
+        }
+        else
+        {
+            targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(event.getTarget().getCustomNameTag());
+            if(targetedInfo == null)
+            {
+                targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getTarget());
+            }
+        }
         if((event.getTarget() instanceof EntityPlayer && ((EntityPlayer)event.getTarget()).isCreative())
                 || attackerInfo == null
                 || attackerInfo.ignoreBattle
index 6b86eae6d6a7674485bce548d8eebca4b7cec675..5fc994a55e150741f934c7fc57b0e719dfd3e8e8 100644 (file)
@@ -287,7 +287,7 @@ public class EntityInfo
         
         public void applyEffectToEntity(EntityLivingBase entity)
         {
-            applyEffectToEntity(entity, 20 * 7, 0);
+            applyEffectToEntity(entity, 20 * 12, 0);
         }
         
         public void applyEffectToEntity(EntityLivingBase entity, int duration, int amplifier)
index a402b6b80d0ffbe85f498e79d82e695845fc93b1..621455d788aa7c3dbe7301a0b79ea227d96d24f5 100644 (file)
@@ -78,7 +78,10 @@ public class PacketEditingMessage implements IMessage
     public PacketEditingMessage(Type type, EntityInfo entityInfo)
     {
         this.type = type;
-        this.entityInfo = entityInfo;
+        if(entityInfo != null)
+        {
+            this.entityInfo = entityInfo;
+        }
     }
 
     @Override