Changed entity search method for custom particles to solely use entity IDs instead of entities near the closest player.

This commit is contained in:
luisc committed 2021-09-06 12:28:14 -05:00
1 parent fbc22fdef2
commit 6e9c693d49
3 files changed
+17 -42

No files matched your search

@@ -296,27 +296,15 @@ public class NoppesUtilServer {
double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
String playerName, EntityPlayer playerObj
int entityID
){
List<Entity> playerEntities = playerObj.worldObj.getEntitiesWithinAABB(Entity.class, playerObj.boundingBox.expand(300, 300, 300));
String UUID = "";
int entityID = -1;
for(Entity e : playerEntities){
if(e.equals(entity)){
UUID = e.getUniqueID().toString();
entityID = e.getEntityId();
break;
}
}
Server.sendAssociatedData(entity, EnumPacketClient.SCRIPTED_PARTICLE,
directory, HEXcolor, amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
playerName, UUID, entityID
entityID
);
}
@@ -99,9 +99,6 @@ public class NoppesUtil {
float alphaRate = buffer.readFloat();
int alphaRateStart = buffer.readInt();
String playerName = Server.readString(buffer);
String UUID = Server.readString(buffer);
int entityID = buffer.readInt();
ModelPartData particle = new ModelPartData();
@@ -114,25 +111,20 @@ public class NoppesUtil {
);
World worldObj = Minecraft.getMinecraft().theWorld;
EntityPlayer player = worldObj.getPlayerEntityByName(playerName);
List<Entity> entities = player.worldObj.getEntitiesWithinAABB(Entity.class, player.boundingBox.expand(300, 300, 300));
for(Entity entity : entities){
if(UUID.equals(entity.getPersistentID().toString()) || (entity.getEntityId() == entityID)){
EntityCustomFX fx = new EntityCustomFX(
entity,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
particle.getMaxAge(),
particle
);
Entity entity = worldObj.getEntityByID(entityID);
for(int i = 0; i < particle.getAmount(); i++){
minecraft.effectRenderer.addEffect(fx);
}
break;
}
EntityCustomFX fx = new EntityCustomFX(
entity,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
particle.getMaxAge(),
particle
);
for(int i = 0; i < particle.getAmount(); i++){
minecraft.effectRenderer.addEffect(fx);
}
}
@@ -61,18 +61,13 @@ public class ScriptEntity {
float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart
) {
List<EntityPlayer> entities = entity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, entity.boundingBox.expand(300, 300, 300));
if(entities.size() < 1)
return;
EntityPlayer playerObj = entities.get(0);
String playerName = playerObj.getDisplayName();
int entityID = entity.getEntityId();
NoppesUtilServer.spawnScriptedParticle(entity, directory, HEXcolor, amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
playerName, playerObj
entityID
);
}