Instead of having a internal entityId. Use mojang's entityid's but add one everytime you want it. Also allow fetching of the next entityid to be used
This commit is contained in:
parent
e654b23a50
commit
0813f0a914
@ -33,7 +33,6 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
|
||||
public class UtilEnt
|
||||
{
|
||||
private static int entityIdCount = 455000;
|
||||
|
||||
//Custom Entity Names
|
||||
private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>();
|
||||
@ -574,6 +573,30 @@ public class UtilEnt
|
||||
|
||||
public static int getNewEntityId()
|
||||
{
|
||||
return entityIdCount++;
|
||||
return getNewEntityId(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use false if you don't want to modify the next entityid to be used.
|
||||
*
|
||||
* Normally you want true if you want a unique entityid to use.
|
||||
**/
|
||||
public static int getNewEntityId(boolean modifynumber)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field field = net.minecraft.server.v1_7_R4.Entity.class.getDeclaredField("entityCount");
|
||||
field.setAccessible(true);
|
||||
int entityId = field.getInt(null);
|
||||
if (modifynumber) {
|
||||
field.set(null, entityId+1);
|
||||
}
|
||||
return entityId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user