Changing custom zombie from 1.5.2 to 1.6.2

Discussion in 'Plugin Development' started by mike0631, Jul 15, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    mike0631

    Hey,

    I have no idea what I have to change to do this.

    Code:java
    1. import java.lang.reflect.Field;
    2. import java.util.List;
    3.  
    4. import net.minecraft.server.v1_6_R2.EntityPlayer;
    5. import net.minecraft.server.v1_6_R2.EntityVillager;
    6. import net.minecraft.server.v1_6_R2.PathfinderGoalFleeSun;
    7. import net.minecraft.server.v1_6_R2.PathfinderGoalFloat;
    8. import net.minecraft.server.v1_6_R2.PathfinderGoalHurtByTarget;
    9. import net.minecraft.server.v1_6_R2.PathfinderGoalLookAtPlayer;
    10. import net.minecraft.server.v1_6_R2.PathfinderGoalMeleeAttack;
    11. import net.minecraft.server.v1_6_R2.PathfinderGoalMoveTowardsRestriction;
    12. import net.minecraft.server.v1_6_R2.PathfinderGoalNearestAttackableTarget;
    13. import net.minecraft.server.v1_6_R2.PathfinderGoalRandomLookaround;
    14. import net.minecraft.server.v1_6_R2.PathfinderGoalRandomStroll;
    15. import net.minecraft.server.v1_6_R2.World;
    16.  
    17. import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftItemStack;
    18. import org.bukkit.craftbukkit.v1_6_R2.util.UnsafeList;
    19. import org.bukkit.inventory.ItemStack;
    20.  
    21. public class CustomZombie extends net.minecraft.server.v1_6_R2.EntityZombie {
    22.  
    23. public int damage;
    24. public int xp;
    25. private ItemStack weapon;
    26.  
    27. public CustomZombie(World world) {
    28. super(world);
    29. this.bw = 2F; // 1.5.2 - SPEED
    30. this.maxHealth = 20; // 1.5.2 - MAX HEALTH
    31. this.health = 20; // 1.5.2 - CURRENT HEALTH
    32. this.damage = 6;
    33. this.xp = 10;
    34. setGoals();
    35. }
    36.  
    37. public void setExp(int xp){
    38. this.xp = xp;
    39. }
    40.  
    41. public int getExp() {
    42. return this.xp;
    43. }
    44.  
    45. public void setDamage(int damage){
    46. this.damage = damage;
    47. }
    48.  
    49. public int getDamage() {
    50. return this.damage;
    51. }
    52.  
    53. public void setGoals() {
    54. try {
    55. Field gsa = net.minecraft.server.v1_6_R2.PathfinderGoalSelector.class.getDeclaredField("a");
    56. gsa.setAccessible(true);
    57. gsa.set(this.goalSelector, new UnsafeList<Object>());
    58. gsa.set(this.targetSelector, new UnsafeList<Object>());
    59. } catch (SecurityException e) {
    60. e.printStackTrace();
    61. } catch (NoSuchFieldException e) {
    62. e.printStackTrace();
    63. e.printStackTrace();
    64. e.printStackTrace();
    65. }
    66.  
    67. clearGoals();
    68. this.goalSelector.a(0, new PathfinderGoalFloat(this));
    69. this.goalSelector.a(0, new PathfinderGoalFleeSun(this, (float) (this.bw + 0.05)));
    70. this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, EntityVillager.class, (float) (this.bw), true));
    71. this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityPlayer.class, (float) (this.bw), true));
    72. this.goalSelector.a(3, new PathfinderGoalMoveTowardsRestriction(this, (float) (this.bw)));
    73. this.goalSelector.a(4, new PathfinderGoalRandomStroll(this, (float) this.bw));
    74. this.goalSelector.a(5, new PathfinderGoalLookAtPlayer(this, EntityPlayer.class, 8.0F));
    75. this.goalSelector.a(5, new PathfinderGoalLookAtPlayer(this, EntityVillager.class, 16.0F));
    76. this.goalSelector.a(6, new PathfinderGoalRandomLookaround(this));
    77. this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true));
    78. this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityPlayer.class, 100.0F, 0, true));
    79. this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 100.0F, 0, true));
    80. }
    81.  
    82. public void clearGoals() {
    83. try {
    84. Field arrayListField = net.minecraft.server.v1_6_R2.PathfinderGoalSelector.class.getDeclaredField("a");
    85. arrayListField.setAccessible(true);
    86. ((List<?>) arrayListField.get(this.goalSelector)).clear();
    87. } catch (Exception e) {
    88. e.printStackTrace();
    89. }
    90. try {
    91. Field arrayListField = net.minecraft.server.v1_6_R2.PathfinderGoalSelector.class.getDeclaredField("b");
    92. arrayListField.setAccessible(true);
    93. ((List<?>) arrayListField.get(this.goalSelector)).clear();
    94. } catch (Exception e) {
    95. e.printStackTrace();
    96. }
    97. }
    98.  
    99. public void setHelmet(ItemStack i) {
    100. net.minecraft.server.v1_6_R2.ItemStack item = CraftItemStack.asNMSCopy(i);
    101. setEquipment(4, item);
    102. }
    103.  
    104. public void setWeapon(ItemStack i) {
    105. this.weapon = i;
    106. if (weapon == null)
    107. return;
    108.  
    109. net.minecraft.server.v1_6_R2.ItemStack item = CraftItemStack.asNMSCopy(weapon);
    110. setEquipment(0, item);
    111. }
    112.  
    113. public void setSpeed(Float speed){
    114. this.bw = speed;
    115. setGoals();
    116. }
    117.  
    118. }


    Code:
    The operator + is undefined for the argument type(s) Entity, double
    The field EntityInsentient.bw is not visible
    Cannot cast from Entity to float
    The field EntityInsentient.bw is not visible
    Cannot cast from Entity to float
    The field EntityInsentient.bw is not visible
    Cannot cast from Entity to float
    The field EntityInsentient.bw is not visible
    The field EntityInsentient.bw is not visible
    Type mismatch: cannot convert from float to Entity
    maxHealth cannot be resolved or is not a field
    health cannot be resolved or is not a field
    The constructor PathfinderGoalNearestAttackableTarget(CustomZombie, Class<EntityVillager>, float, int, boolean) is undefined
    The constructor PathfinderGoalNearestAttackableTarget(CustomZombie, Class<EntityPlayer>, float, int, boolean) is undefined
    The field EntityInsentient.bw is not visible
    Cannot cast from Entity to float
    Type mismatch: cannot convert from Float to Entity
    The field EntityInsentient.bw is not visible
    
    If someone could help me with this, I'll be very thankful.
     
  2. Offline

    Minecrell

  3. Offline

    etaxi341

    There are many .v1_5_R3 in this code. you need to replace them all with .v1_6_R2
     
  4. Offline

    mike0631

    Changed them, Still alot errors.
     
  5. Offline

    Minecrell

    The obfuscation might have changed.
     
  6. Offline

    mike0631

    Im very sure they did, but I dont know to what.
     
  7. Offline

    ZeusAllMighty11

    Check MCP mappings.
     
  8. Offline

    SgtPunishment

    Code:java
    1. import java.lang.reflect.Field;
    2. import java.util.List;
    3.  
    4. import net.minecraft.server.v1_6_R2.EntityPlayer;
    5. import net.minecraft.server.v1_6_R2.EntityVillager;
    6. import net.minecraft.server.v1_6_R2.EntityZombie;
    7. import net.minecraft.server.v1_6_R2.GenericAttributes;
    8. import net.minecraft.server.v1_6_R2.PathfinderGoalFleeSun;
    9. import net.minecraft.server.v1_6_R2.PathfinderGoalFloat;
    10. import net.minecraft.server.v1_6_R2.PathfinderGoalHurtByTarget;
    11. import net.minecraft.server.v1_6_R2.PathfinderGoalLookAtPlayer;
    12. import net.minecraft.server.v1_6_R2.PathfinderGoalMeleeAttack;
    13. import net.minecraft.server.v1_6_R2.PathfinderGoalMoveTowardsRestriction;
    14. import net.minecraft.server.v1_6_R2.PathfinderGoalNearestAttackableTarget;
    15. import net.minecraft.server.v1_6_R2.PathfinderGoalRandomLookaround;
    16. import net.minecraft.server.v1_6_R2.PathfinderGoalRandomStroll;
    17. import net.minecraft.server.v1_6_R2.PathfinderGoalSelector;
    18. import net.minecraft.server.v1_6_R2.World;
    19.  
    20. import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftItemStack;
    21. import org.bukkit.craftbukkit.v1_6_R2.util.UnsafeList;
    22. import org.bukkit.inventory.ItemStack;
    23.  
    24. public class CustomZombie extends EntityZombie {
    25.  
    26. public int damage;
    27. public int xp;
    28. private ItemStack weapon;
    29. private Float bw;
    30. private int maxHealth;
    31.  
    32. public CustomZombie(World world) {
    33. super(world);
    34. // movementSpeed
    35. this.bw = 2F;
    36. this.getAttributeInstance(GenericAttributes.d).setValue(this.bw); // 1.6.2
    37. // maxHealth
    38. this.maxHealth = 20; // 1.5.2 - MAX HEALTH
    39. this.getAttributeInstance(GenericAttributes.a).setValue(this.maxHealth); // 1.6.2
    40. this.damage = 6;
    41. this.xp = 10;
    42. setGoals();
    43. }
    44.  
    45. public void setExp(int xp) {
    46. this.xp = xp;
    47. }
    48.  
    49. public int getExp() {
    50. return this.xp;
    51. }
    52.  
    53. public void setDamage(int damage) {
    54. this.damage = damage;
    55. }
    56.  
    57. public int getDamage() {
    58. return this.damage;
    59. }
    60.  
    61. public void setGoals() {
    62. try {
    63. Field gsa = PathfinderGoalSelector.class.getDeclaredField("a");
    64. gsa.setAccessible(true);
    65. gsa.set(this.goalSelector, new UnsafeList<Object>());
    66. gsa.set(this.targetSelector, new UnsafeList<Object>());
    67. } catch (SecurityException e) {
    68. e.printStackTrace();
    69. } catch (NoSuchFieldException e) {
    70. e.printStackTrace();
    71. e.printStackTrace();
    72. } catch (IllegalAccessException e) {
    73. e.printStackTrace();
    74. }
    75.  
    76. clearGoals();
    77. this.goalSelector.a(0, new PathfinderGoalFloat(this));
    78. this.goalSelector.a(0, new PathfinderGoalFleeSun(this, (float) (this.bw + 0.05)));
    79. this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, EntityVillager.class, (float) (this.bw), true));
    80. this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityPlayer.class, (float) (this.bw), true));
    81. this.goalSelector.a(3, new PathfinderGoalMoveTowardsRestriction(this, (float) (this.bw)));
    82. this.goalSelector.a(4, new PathfinderGoalRandomStroll(this, (float) this.bw));
    83. this.goalSelector.a(5, new PathfinderGoalLookAtPlayer(this, EntityPlayer.class, 8.0F));
    84. this.goalSelector.a(5, new PathfinderGoalLookAtPlayer(this, EntityVillager.class, 16.0F));
    85. this.goalSelector.a(6, new PathfinderGoalRandomLookaround(this));
    86. this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true));
    87. this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityPlayer.class, 0, true));
    88. this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, true));
    89. }
    90.  
    91. public void clearGoals() {
    92. try {
    93. Field arrayListField = PathfinderGoalSelector.class.getDeclaredField("a");
    94. arrayListField.setAccessible(true);
    95. ((List<?>) arrayListField.get(this.goalSelector)).clear();
    96. } catch (Exception e) {
    97. e.printStackTrace();
    98. }
    99. try {
    100. Field arrayListField = PathfinderGoalSelector.class.getDeclaredField("b");
    101. arrayListField.setAccessible(true);
    102. ((List<?>) arrayListField.get(this.goalSelector)).clear();
    103. } catch (Exception e) {
    104. e.printStackTrace();
    105. }
    106. }
    107.  
    108. public void setHelmet(ItemStack i) {
    109. net.minecraft.server.v1_6_R2.ItemStack item = CraftItemStack
    110. .asNMSCopy(i);
    111. setEquipment(4, item);
    112. }
    113.  
    114. public void setWeapon(ItemStack i) {
    115. this.weapon = i;
    116. if (weapon == null)
    117. return;
    118.  
    119. net.minecraft.server.v1_6_R2.ItemStack item = CraftItemStack
    120. .asNMSCopy(weapon);
    121. setEquipment(0, item);
    122. }
    123.  
    124. public void setSpeed(Float speed) {
    125. this.bw = speed;
    126. setGoals();
    127. }
    128.  
    129. }


    No idea if this will actually work, but it doesn't have any errors for me.
     
  9. Offline

    xTrollxDudex

Thread Status:
Not open for further replies.

Share This Page