mirror of
https://github.com/TotalFreedomMC/TF-Marriage.git
synced 2024-05-29 16:11:24 +00:00
Fixed entity error :)
This commit is contained in:
parent
b757663d5c
commit
23d87962f1
|
@ -1,5 +1,6 @@
|
|||
package me.lenis0012.mr.children;
|
||||
|
||||
import me.lenis0012.mr.children.thinking.Brain;
|
||||
import net.minecraft.server.v1_4_R1.EntityLiving;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.lenis0012.mr.children;
|
||||
|
||||
import me.lenis0012.mr.children.thinking.FollowCell;
|
||||
import me.lenis0012.mr.children.thinking.LookAtClosestCell;
|
||||
import net.minecraft.server.v1_4_R1.EntityPlayer;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.lenis0012.mr.children;
|
||||
|
||||
import me.lenis0012.mr.children.thinking.Brain;
|
||||
import net.minecraft.server.v1_4_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_4_R1.World;
|
||||
import net.minecraft.server.v1_4_R1.WorldServer;
|
||||
|
@ -17,7 +18,7 @@ public class ChildControler implements Child {
|
|||
private Player owner;
|
||||
private ChildManager manager;
|
||||
private boolean spawned = false, staying = false, baby = true;
|
||||
protected Location loc;
|
||||
public Location loc;
|
||||
|
||||
public ChildControler(int id, Player owner) {
|
||||
this.brain = new Brain(this);
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package me.lenis0012.mr.children;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -11,6 +13,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.bergerkiller.bukkit.common.reflection.classes.EntityTypesRef;
|
||||
|
@ -41,6 +44,7 @@ public class ChildManager {
|
|||
return instance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void registerChildren() {
|
||||
if(!added) {
|
||||
try {
|
||||
|
@ -48,21 +52,24 @@ public class ChildManager {
|
|||
String cbType = "Villager";
|
||||
int cbID = EntityType.VILLAGER.getTypeId();
|
||||
|
||||
//Old reflection system
|
||||
/*//data format start
|
||||
Class[] tmp = new Class[3];
|
||||
tmp[0] = Class.class;
|
||||
tmp[1] = String.class;
|
||||
tmp[2] = int.class;
|
||||
//data format end
|
||||
Plugin bkc = Bukkit.getServer().getPluginManager().getPlugin("BKCommonLib");
|
||||
if(bkc != null)
|
||||
EntityTypesRef.register(cbClass, cbType, cbID);
|
||||
else {
|
||||
//data format start
|
||||
Class[] tmp = new Class[3];
|
||||
tmp[0] = Class.class;
|
||||
tmp[1] = String.class;
|
||||
tmp[2] = int.class;
|
||||
//data format end
|
||||
|
||||
Method entities = net.minecraft.server.v1_4_R1.EntityTypes.class.getDeclaredMethod("a", tmp);
|
||||
entities.setAccessible(true);
|
||||
|
||||
//write custom data to the entity list
|
||||
entities.invoke(entities, cbClass, cbType, cbID);
|
||||
}
|
||||
|
||||
Method entities = net.minecraft.server.v1_4_R1.EntityTypes.class.getDeclaredMethod("a", tmp);
|
||||
|
||||
//write custom data to the entity list
|
||||
entities.invoke(entities, cbClass, cbType, cbID);*/
|
||||
|
||||
//new reflection system, from BKCommonLib
|
||||
EntityTypesRef.register(cbClass, cbType, cbID);
|
||||
this.added = true;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package me.lenis0012.mr.children;
|
||||
package me.lenis0012.mr.children.thinking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import me.lenis0012.mr.children.ChildControler;
|
||||
|
||||
import org.bukkit.entity.Villager;
|
||||
|
||||
public class Brain {
|
|
@ -1,4 +1,4 @@
|
|||
package me.lenis0012.mr.children;
|
||||
package me.lenis0012.mr.children.thinking;
|
||||
|
||||
public interface BrainCell {
|
||||
public void onUpdate();
|
20
src/me/lenis0012/mr/children/thinking/CustomPath.java
Normal file
20
src/me/lenis0012/mr/children/thinking/CustomPath.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package me.lenis0012.mr.children.thinking;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_4_R1.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import net.minecraft.server.v1_4_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_4_R1.PathEntity;
|
||||
|
||||
public class CustomPath {
|
||||
|
||||
public static PathEntity createPath(EntityLiving entity, EntityLiving target) {
|
||||
return entity.world.findPath(entity, target, 20, true, false, false, true);
|
||||
}
|
||||
|
||||
public static PathEntity createPath(LivingEntity entity, LivingEntity target) {
|
||||
EntityLiving e1 = ((CraftLivingEntity)entity).getHandle();
|
||||
EntityLiving e2 = ((CraftLivingEntity)target).getHandle();
|
||||
return createPath(e1, e2);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package me.lenis0012.mr.children;
|
||||
package me.lenis0012.mr.children.thinking;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_4_R1.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import me.lenis0012.mr.children.Child;
|
||||
import net.minecraft.server.v1_4_R1.EntityCreature;
|
||||
import net.minecraft.server.v1_4_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_4_R1.PathEntity;
|
||||
|
@ -49,7 +50,7 @@ public class FollowCell implements BrainCell {
|
|||
}
|
||||
|
||||
private void follow() {
|
||||
PathEntity path = entity.world.findPath(entity, target, 20, true, false, false, true);
|
||||
PathEntity path = CustomPath.createPath(entity, target);
|
||||
((EntityCreature)entity).setPathEntity(path);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package me.lenis0012.mr.children;
|
||||
package me.lenis0012.mr.children.thinking;
|
||||
|
||||
import me.lenis0012.mr.children.Child;
|
||||
import net.minecraft.server.v1_4_R1.Entity;
|
||||
import net.minecraft.server.v1_4_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_4_R1.EntityLiving;
|
Loading…
Reference in a new issue