clean up particles
This commit is contained in:
parent
874e118d9d
commit
baa3f501b6
22 changed files with 75 additions and 154 deletions
|
@ -1526,7 +1526,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
|
|
||||||
if (entity instanceof EntityLiving living)
|
if (entity instanceof EntityLiving living)
|
||||||
{
|
{
|
||||||
PotionEffect potioneffect = new PotionEffect(packetIn.getEffectId(), packetIn.getDuration(), packetIn.getAmplifier(), false, packetIn.hasParticles())
|
PotionEffect potioneffect = new PotionEffect(packetIn.getEffectId(), packetIn.getDuration(), packetIn.getAmplifier())
|
||||||
.setRemaining(packetIn.getRemaining());
|
.setRemaining(packetIn.getRemaining());
|
||||||
living.addEffect(potioneffect);
|
living.addEffect(potioneffect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,7 @@ public class EffectRenderer
|
||||||
private void registerVanillaParticles()
|
private void registerVanillaParticles()
|
||||||
{
|
{
|
||||||
this.register(ParticleType.EXPLOSION_NORMAL, new EntityExplodeFX.Factory());
|
this.register(ParticleType.EXPLOSION_NORMAL, new EntityExplodeFX.Factory());
|
||||||
this.register(ParticleType.WATER_BUBBLE, new EntityBubbleFX.Factory());
|
this.register(ParticleType.SPLASH, new EntitySplashFX.Factory());
|
||||||
this.register(ParticleType.WATER_SPLASH, new EntitySplashFX.Factory());
|
|
||||||
this.register(ParticleType.WATER_DROP, new EntityDownfallFX.RainFactory());
|
this.register(ParticleType.WATER_DROP, new EntityDownfallFX.RainFactory());
|
||||||
this.register(ParticleType.DEPTH, new EntityAuraFX.SuspendFactory());
|
this.register(ParticleType.DEPTH, new EntityAuraFX.SuspendFactory());
|
||||||
this.register(ParticleType.CRIT, new EntityCritFX.Factory());
|
this.register(ParticleType.CRIT, new EntityCritFX.Factory());
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
package client.renderer.particle;
|
|
||||||
|
|
||||||
import common.block.Material;
|
|
||||||
import common.util.BlockPos;
|
|
||||||
import common.world.World;
|
|
||||||
|
|
||||||
public class EntityBubbleFX extends EntityFX
|
|
||||||
{
|
|
||||||
protected EntityBubbleFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn)
|
|
||||||
{
|
|
||||||
super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
|
|
||||||
this.particleRed = 1.0F;
|
|
||||||
this.particleGreen = 1.0F;
|
|
||||||
this.particleBlue = 1.0F;
|
|
||||||
this.setParticleTextureIndex(32);
|
|
||||||
this.setSize(0.02F, 0.02F);
|
|
||||||
this.particleScale *= this.rand.floatv() * 0.6F + 0.2F;
|
|
||||||
this.motionX = xSpeedIn * 0.20000000298023224D + (Math.random() * 2.0D - 1.0D) * 0.019999999552965164D;
|
|
||||||
this.motionY = ySpeedIn * 0.20000000298023224D + (Math.random() * 2.0D - 1.0D) * 0.019999999552965164D;
|
|
||||||
this.motionZ = zSpeedIn * 0.20000000298023224D + (Math.random() * 2.0D - 1.0D) * 0.019999999552965164D;
|
|
||||||
this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to update the entity's position/logic.
|
|
||||||
*/
|
|
||||||
public void onUpdate()
|
|
||||||
{
|
|
||||||
this.prevX = this.posX;
|
|
||||||
this.prevY = this.posY;
|
|
||||||
this.prevZ = this.posZ;
|
|
||||||
this.motionY += 0.002D;
|
|
||||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
|
||||||
this.motionX *= 0.8500000238418579D;
|
|
||||||
this.motionY *= 0.8500000238418579D;
|
|
||||||
this.motionZ *= 0.8500000238418579D;
|
|
||||||
|
|
||||||
if (this.worldObj.getState(new BlockPos(this)).getBlock().getMaterial() != Material.WATER)
|
|
||||||
{
|
|
||||||
this.setDead();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.particleMaxAge-- <= 0)
|
|
||||||
{
|
|
||||||
this.setDead();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Factory implements IParticleFactory
|
|
||||||
{
|
|
||||||
public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data)
|
|
||||||
{
|
|
||||||
return new EntityBubbleFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -648,7 +648,7 @@ public class WorldClient extends AWorldClient
|
||||||
this.spawnEntityFX(ParticleType.ITEM_CRACK, ParticleType.ITEM_CRACK.isUnlimited(), d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, ItemRegistry.getId(Items.potion));
|
this.spawnEntityFX(ParticleType.ITEM_CRACK, ParticleType.ITEM_CRACK.isUnlimited(), d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, ItemRegistry.getId(Items.potion));
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleType enumparticletypes = ParticleType.WATER_SPLASH;
|
ParticleType enumparticletypes = ParticleType.SPLASH;
|
||||||
float f = 1.0F;
|
float f = 1.0F;
|
||||||
float f1 = 1.0F;
|
float f1 = 1.0F;
|
||||||
float f2 = 1.0F;
|
float f2 = 1.0F;
|
||||||
|
@ -672,7 +672,7 @@ public class WorldClient extends AWorldClient
|
||||||
|
|
||||||
if (entityfx != null)
|
if (entityfx != null)
|
||||||
{
|
{
|
||||||
if(enumparticletypes != ParticleType.WATER_SPLASH) {
|
if(enumparticletypes != ParticleType.SPLASH) {
|
||||||
float f3 = 0.75F + this.rand.floatv() * 0.25F;
|
float f3 = 0.75F + this.rand.floatv() * 0.25F;
|
||||||
entityfx.setRBGColorF(f * f3, f1 * f3, f2 * f3);
|
entityfx.setRBGColorF(f * f3, f1 * f3, f2 * f3);
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 17 KiB |
|
@ -1006,7 +1006,7 @@ public abstract class Entity
|
||||||
{
|
{
|
||||||
float f2 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
float f2 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
||||||
float f3 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
float f3 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_BUBBLE, this.posX + (double)f2, (double)(f1 + 1.0F), this.posZ + (double)f3, this.motionX, this.motionY - (double)(this.rand.floatv() * 0.2F), this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, this.posX + (double)f2, (double)(f1 + 1.0F), this.posZ + (double)f3, this.motionX, this.motionY - (double)(this.rand.floatv() * 0.2F), this.motionZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.worldObj.getState(new BlockPos(this.posX, this.posY, this.posZ)).getBlock().getMaterial() == Material.WATER) {
|
if(this.worldObj.getState(new BlockPos(this.posX, this.posY, this.posZ)).getBlock().getMaterial() == Material.WATER) {
|
||||||
|
@ -1014,7 +1014,7 @@ public abstract class Entity
|
||||||
{
|
{
|
||||||
float f4 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
float f4 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
||||||
float f5 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
float f5 = (this.rand.floatv() * 2.0F - 1.0F) * this.width;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_SPLASH, this.posX + (double)f4, (double)(f1 + 1.0F), this.posZ + (double)f5, this.motionX, this.motionY, this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, this.posX + (double)f4, (double)(f1 + 1.0F), this.posZ + (double)f5, this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class EntityWolf extends EntityTameable
|
||||||
{
|
{
|
||||||
float f1 = (this.rand.floatv() * 2.0F - 1.0F) * this.width * 0.5F;
|
float f1 = (this.rand.floatv() * 2.0F - 1.0F) * this.width * 0.5F;
|
||||||
float f2 = (this.rand.floatv() * 2.0F - 1.0F) * this.width * 0.5F;
|
float f2 = (this.rand.floatv() * 2.0F - 1.0F) * this.width * 0.5F;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_SPLASH, this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,13 +279,13 @@ public class EntityBoat extends Entity
|
||||||
{
|
{
|
||||||
double d7 = this.posX - d2 * d5 * 0.8D + d4 * d6;
|
double d7 = this.posX - d2 * d5 * 0.8D + d4 * d6;
|
||||||
double d8 = this.posZ - d4 * d5 * 0.8D - d2 * d6;
|
double d8 = this.posZ - d4 * d5 * 0.8D - d2 * d6;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_SPLASH, d7, this.posY - 0.125D, d8, this.motionX, this.motionY, this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, d7, this.posY - 0.125D, d8, this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double d24 = this.posX + d2 + d4 * d5 * 0.7D;
|
double d24 = this.posX + d2 + d4 * d5 * 0.7D;
|
||||||
double d25 = this.posZ + d4 - d2 * d5 * 0.7D;
|
double d25 = this.posZ + d4 - d2 * d5 * 0.7D;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_SPLASH, d24, this.posY - 0.125D, d25, this.motionX, this.motionY, this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, d24, this.posY - 0.125D, d25, this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4596,11 +4596,11 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
this.setHealth(this.getMaxHealth());
|
this.setHealth(this.getMaxHealth());
|
||||||
this.setManaPoints(this.getMaxMana());
|
this.setManaPoints(this.getMaxMana());
|
||||||
this.clearEffects(false);
|
this.clearEffects(false);
|
||||||
this.addEffect(new PotionEffect(Potion.HASTE, Integer.MAX_VALUE, 255, false, false));
|
this.addEffect(new PotionEffect(Potion.HASTE, Integer.MAX_VALUE, 255));
|
||||||
this.addEffect(new PotionEffect(Potion.RESISTANCE, Integer.MAX_VALUE, 255, false, false));
|
this.addEffect(new PotionEffect(Potion.RESISTANCE, Integer.MAX_VALUE, 255));
|
||||||
this.addEffect(new PotionEffect(Potion.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, false, false));
|
this.addEffect(new PotionEffect(Potion.FIRE_RESISTANCE, Integer.MAX_VALUE, 0));
|
||||||
this.addEffect(new PotionEffect(Potion.FLYING, Integer.MAX_VALUE, 1, false, false));
|
this.addEffect(new PotionEffect(Potion.FLYING, Integer.MAX_VALUE, 1));
|
||||||
this.addEffect(new PotionEffect(Potion.MANA_GENERATION, Integer.MAX_VALUE, 255, false, false));
|
this.addEffect(new PotionEffect(Potion.MANA_GENERATION, Integer.MAX_VALUE, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,7 +444,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
|
||||||
for (int i1 = 0; i1 < 4; ++i1)
|
for (int i1 = 0; i1 < 4; ++i1)
|
||||||
{
|
{
|
||||||
float f8 = 0.25F;
|
float f8 = 0.25F;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_BUBBLE, this.posX - this.motionX * (double)f8, this.posY - this.motionY * (double)f8, this.posZ - this.motionZ * (double)f8, this.motionX, this.motionY, this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, this.posX - this.motionX * (double)f8, this.posY - this.motionY * (double)f8, this.posZ - this.motionZ * (double)f8, this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
f4 = 0.6F;
|
f4 = 0.6F;
|
||||||
|
|
|
@ -417,7 +417,7 @@ public class EntityHook extends Entity implements IObjectData
|
||||||
this.motionY -= 0.20000000298023224D;
|
this.motionY -= 0.20000000298023224D;
|
||||||
this.playSound(SoundEvent.SPLASH, 0.25F);
|
this.playSound(SoundEvent.SPLASH, 0.25F);
|
||||||
float f8 = (float)ExtMath.floord(this.getEntityBoundingBox().minY);
|
float f8 = (float)ExtMath.floord(this.getEntityBoundingBox().minY);
|
||||||
worldserver.spawnParticle(ParticleType.WATER_BUBBLE, this.posX, (double)(f8 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D, 0);
|
worldserver.spawnParticle(ParticleType.SPLASH, this.posX, (double)(f8 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D, 0);
|
||||||
worldserver.spawnParticle(ParticleType.WATER_DROP, this.posX, (double)(f8 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D, 0);
|
worldserver.spawnParticle(ParticleType.WATER_DROP, this.posX, (double)(f8 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D, 0);
|
||||||
this.ticksCatchable = this.rand.range(10, 30);
|
this.ticksCatchable = this.rand.range(10, 30);
|
||||||
}
|
}
|
||||||
|
@ -436,7 +436,7 @@ public class EntityHook extends Entity implements IObjectData
|
||||||
{
|
{
|
||||||
if (this.rand.floatv() < 0.15F)
|
if (this.rand.floatv() < 0.15F)
|
||||||
{
|
{
|
||||||
worldserver.spawnParticle(ParticleType.WATER_BUBBLE, d13, d15 - 0.10000000149011612D, d16, 1, (double)f10, 0.1D, (double)f11, 0.0D, 0);
|
worldserver.spawnParticle(ParticleType.SPLASH, d13, d15 - 0.10000000149011612D, d16, 1, (double)f10, 0.1D, (double)f11, 0.0D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float f3 = f10 * 0.04F;
|
float f3 = f10 * 0.04F;
|
||||||
|
@ -475,7 +475,7 @@ public class EntityHook extends Entity implements IObjectData
|
||||||
|
|
||||||
if (block == Blocks.water || block == Blocks.flowing_water)
|
if (block == Blocks.water || block == Blocks.flowing_water)
|
||||||
{
|
{
|
||||||
worldserver.spawnParticle(ParticleType.WATER_SPLASH, d12, d14, d6, this.rand.range(2, 3), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, 0);
|
worldserver.spawnParticle(ParticleType.SPLASH, d12, d14, d6, this.rand.range(2, 3), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ public abstract class EntityProjectile extends Entity
|
||||||
for (int j = 0; j < 4; ++j)
|
for (int j = 0; j < 4; ++j)
|
||||||
{
|
{
|
||||||
float f3 = 0.25F;
|
float f3 = 0.25F;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_BUBBLE, this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
f2 = 0.8F;
|
f2 = 0.8F;
|
||||||
|
|
|
@ -274,7 +274,7 @@ public abstract class EntityThrowable extends Entity implements IProjectile
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
float f4 = 0.25F;
|
float f4 = 0.25F;
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
|
this.worldObj.spawnParticle(ParticleType.SPLASH, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
f2 = 0.8F;
|
f2 = 0.8F;
|
||||||
|
|
|
@ -6,8 +6,7 @@ public enum ParticleType implements Identifyable {
|
||||||
EXPLOSION_NORMAL("explode", true),
|
EXPLOSION_NORMAL("explode", true),
|
||||||
EXPLOSION_LARGE("explode_large", true),
|
EXPLOSION_LARGE("explode_large", true),
|
||||||
EXPLOSION_HUGE("explode_huge", true),
|
EXPLOSION_HUGE("explode_huge", true),
|
||||||
WATER_BUBBLE("bubble"),
|
SPLASH("splash"),
|
||||||
WATER_SPLASH("splash"),
|
|
||||||
DEPTH("depth"),
|
DEPTH("depth"),
|
||||||
CRIT("crit"),
|
CRIT("crit"),
|
||||||
SMOKE("smoke"),
|
SMOKE("smoke"),
|
||||||
|
@ -21,7 +20,7 @@ public enum ParticleType implements Identifyable {
|
||||||
HEART("heart"),
|
HEART("heart"),
|
||||||
ITEM_CRACK("item_crack"),
|
ITEM_CRACK("item_crack"),
|
||||||
BLOCK_CRACK("block_crack"),
|
BLOCK_CRACK("block_crack"),
|
||||||
WATER_DROP("droplet"),
|
WATER_DROP("rain"),
|
||||||
HAIL_CORN("hail");
|
HAIL_CORN("hail");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
@ -15,7 +15,6 @@ public class SPacketEntityEffect implements Packet<IClientPlayer>
|
||||||
private int amplifier;
|
private int amplifier;
|
||||||
private int duration;
|
private int duration;
|
||||||
private int remaining;
|
private int remaining;
|
||||||
private boolean particles;
|
|
||||||
|
|
||||||
public SPacketEntityEffect()
|
public SPacketEntityEffect()
|
||||||
{
|
{
|
||||||
|
@ -36,8 +35,6 @@ public class SPacketEntityEffect implements Packet<IClientPlayer>
|
||||||
this.duration = effect.getDuration();
|
this.duration = effect.getDuration();
|
||||||
this.remaining = effect.getRemaining();
|
this.remaining = effect.getRemaining();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
this.particles = effect.getIsShowParticles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +47,6 @@ public class SPacketEntityEffect implements Packet<IClientPlayer>
|
||||||
this.amplifier = buf.readVarInt();
|
this.amplifier = buf.readVarInt();
|
||||||
this.duration = buf.readVarInt();
|
this.duration = buf.readVarInt();
|
||||||
this.remaining = buf.readVarInt();
|
this.remaining = buf.readVarInt();
|
||||||
this.particles = buf.readBoolean();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +59,6 @@ public class SPacketEntityEffect implements Packet<IClientPlayer>
|
||||||
buf.writeVarInt(this.amplifier);
|
buf.writeVarInt(this.amplifier);
|
||||||
buf.writeVarInt(this.duration);
|
buf.writeVarInt(this.duration);
|
||||||
buf.writeVarInt(this.remaining);
|
buf.writeVarInt(this.remaining);
|
||||||
buf.writeBoolean(this.particles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,9 +93,4 @@ public class SPacketEntityEffect implements Packet<IClientPlayer>
|
||||||
{
|
{
|
||||||
return this.remaining;
|
return this.remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasParticles()
|
|
||||||
{
|
|
||||||
return this.particles;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,30 +8,20 @@ public class PotionEffect {
|
||||||
private final Potion potion;
|
private final Potion potion;
|
||||||
private final int duration;
|
private final int duration;
|
||||||
private final int amplifier;
|
private final int amplifier;
|
||||||
private final boolean ambient;
|
|
||||||
private final boolean particles;
|
|
||||||
|
|
||||||
private int remaining;
|
private int remaining;
|
||||||
private boolean thrown;
|
private boolean thrown;
|
||||||
|
|
||||||
public PotionEffect(Potion id, int duration, int amplifier) {
|
|
||||||
this(id, duration, amplifier, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PotionEffect(Potion id, int duration, int amplifier, boolean ambient, boolean showParticles) {
|
public PotionEffect(Potion id, int duration, int amplifier) {
|
||||||
this.potion = id;
|
this.potion = id;
|
||||||
this.duration = this.remaining = duration;
|
this.duration = this.remaining = duration;
|
||||||
this.amplifier = amplifier;
|
this.amplifier = amplifier;
|
||||||
this.ambient = ambient;
|
|
||||||
this.particles = showParticles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PotionEffect(PotionEffect other) {
|
public PotionEffect(PotionEffect other) {
|
||||||
this.potion = other.potion;
|
this.potion = other.potion;
|
||||||
this.duration = this.remaining = other.duration;
|
this.duration = this.remaining = other.duration;
|
||||||
this.amplifier = other.amplifier;
|
this.amplifier = other.amplifier;
|
||||||
this.ambient = other.ambient;
|
|
||||||
this.particles = other.particles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PotionEffect combine(PotionEffect other) {
|
public PotionEffect combine(PotionEffect other) {
|
||||||
|
@ -40,7 +30,6 @@ public class PotionEffect {
|
||||||
int duration = this.duration;
|
int duration = this.duration;
|
||||||
int amplifier = this.amplifier;
|
int amplifier = this.amplifier;
|
||||||
int remaining = this.remaining;
|
int remaining = this.remaining;
|
||||||
boolean ambient = this.ambient;
|
|
||||||
if(other.amplifier > this.amplifier) {
|
if(other.amplifier > this.amplifier) {
|
||||||
amplifier = other.amplifier;
|
amplifier = other.amplifier;
|
||||||
duration = other.duration;
|
duration = other.duration;
|
||||||
|
@ -50,10 +39,7 @@ public class PotionEffect {
|
||||||
duration = other.duration;
|
duration = other.duration;
|
||||||
remaining = other.remaining;
|
remaining = other.remaining;
|
||||||
}
|
}
|
||||||
else if(!other.ambient && this.ambient) {
|
return new PotionEffect(this.potion, duration, amplifier).setRemaining(remaining);
|
||||||
ambient = other.ambient;
|
|
||||||
}
|
|
||||||
return new PotionEffect(this.potion, duration, amplifier, ambient, other.particles).setRemaining(remaining);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Potion getPotion() {
|
public Potion getPotion() {
|
||||||
|
@ -86,14 +72,6 @@ public class PotionEffect {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAmbient() {
|
|
||||||
return this.ambient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getIsShowParticles() {
|
|
||||||
return this.particles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onUpdate(EntityLiving entityIn) {
|
public boolean onUpdate(EntityLiving entityIn) {
|
||||||
if(this.isInfinite() && this.remaining < 20 * 60)
|
if(this.isInfinite() && this.remaining < 20 * 60)
|
||||||
this.remaining = Integer.MAX_VALUE;
|
this.remaining = Integer.MAX_VALUE;
|
||||||
|
@ -132,7 +110,7 @@ public class PotionEffect {
|
||||||
return false;
|
return false;
|
||||||
PotionEffect other = (PotionEffect)obj;
|
PotionEffect other = (PotionEffect)obj;
|
||||||
return this.potion == other.potion && this.amplifier == other.amplifier && this.duration == other.duration
|
return this.potion == other.potion && this.amplifier == other.amplifier && this.duration == other.duration
|
||||||
&& this.thrown == other.thrown && this.remaining == other.remaining && this.ambient == other.ambient;
|
&& this.thrown == other.thrown && this.remaining == other.remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TagObject toTags() {
|
public TagObject toTags() {
|
||||||
|
@ -141,14 +119,12 @@ public class PotionEffect {
|
||||||
tag.setByte("Amplifier", (byte)this.amplifier);
|
tag.setByte("Amplifier", (byte)this.amplifier);
|
||||||
tag.setInt("Duration", this.duration);
|
tag.setInt("Duration", this.duration);
|
||||||
tag.setInt("Remaining", this.remaining);
|
tag.setInt("Remaining", this.remaining);
|
||||||
tag.setBool("Ambient", this.ambient);
|
|
||||||
tag.setBool("Particles", this.particles);
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PotionEffect fromTags(TagObject tag) {
|
public static PotionEffect fromTags(TagObject tag) {
|
||||||
Potion potion = Potion.getByName(tag.getString("Type"));
|
Potion potion = Potion.getByName(tag.getString("Type"));
|
||||||
return potion == null ? null : new PotionEffect(potion, tag.getInt("Duration"), (int)(tag.getByte("Amplifier") & 255), tag.getBool("Ambient"), tag.getBool("Particles"))
|
return potion == null ? null : new PotionEffect(potion, tag.getInt("Duration"), (int)(tag.getByte("Amplifier") & 255))
|
||||||
.setRemaining(tag.getInt("Remaining"));
|
.setRemaining(tag.getInt("Remaining"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,30 +81,27 @@ public class PotionHelper
|
||||||
/**
|
/**
|
||||||
* Given a {@link Collection}<{@link PotionEffect}> will return an Integer color.
|
* Given a {@link Collection}<{@link PotionEffect}> will return an Integer color.
|
||||||
*/
|
*/
|
||||||
public static int calcPotionLiquidColor(Collection<PotionEffect> p_77911_0_)
|
public static int calcPotionLiquidColor(Collection<PotionEffect> effects)
|
||||||
{
|
{
|
||||||
int i = 3694022;
|
int i = 3694022;
|
||||||
|
|
||||||
if (p_77911_0_ != null && !p_77911_0_.isEmpty())
|
if (effects != null && !effects.isEmpty())
|
||||||
{
|
{
|
||||||
float f = 0.0F;
|
float f = 0.0F;
|
||||||
float f1 = 0.0F;
|
float f1 = 0.0F;
|
||||||
float f2 = 0.0F;
|
float f2 = 0.0F;
|
||||||
float f3 = 0.0F;
|
float f3 = 0.0F;
|
||||||
|
|
||||||
for (PotionEffect potioneffect : p_77911_0_)
|
for (PotionEffect potioneffect : effects)
|
||||||
{
|
{
|
||||||
if (potioneffect.getIsShowParticles())
|
int j = potioneffect.getPotion().getColor();
|
||||||
{
|
|
||||||
int j = potioneffect.getPotion().getColor();
|
|
||||||
|
|
||||||
for (int k = 0; k <= potioneffect.getAmplifier(); ++k)
|
for (int k = 0; k <= potioneffect.getAmplifier(); ++k)
|
||||||
{
|
{
|
||||||
f += (float)(j >> 16 & 255) / 255.0F;
|
f += (float)(j >> 16 & 255) / 255.0F;
|
||||||
f1 += (float)(j >> 8 & 255) / 255.0F;
|
f1 += (float)(j >> 8 & 255) / 255.0F;
|
||||||
f2 += (float)(j >> 0 & 255) / 255.0F;
|
f2 += (float)(j >> 0 & 255) / 255.0F;
|
||||||
++f3;
|
++f3;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,22 +122,6 @@ public class PotionHelper
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether a {@link Collection}<{@link PotionEffect}> are all ambient.
|
|
||||||
*/
|
|
||||||
public static boolean getAreAmbient(Collection<PotionEffect> potionEffects)
|
|
||||||
{
|
|
||||||
for (PotionEffect potioneffect : potionEffects)
|
|
||||||
{
|
|
||||||
if (!potioneffect.isAmbient())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getLiquidColor(int meta)
|
public static int getLiquidColor(int meta)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,14 +68,14 @@ public class TileEntityBeacon extends TileEntity implements ITickable
|
||||||
|
|
||||||
for (EntityLiving entityplayer : list)
|
for (EntityLiving entityplayer : list)
|
||||||
{
|
{
|
||||||
entityplayer.addEffect(new PotionEffect(this.primaryEffect, 180, i, true, true));
|
entityplayer.addEffect(new PotionEffect(this.primaryEffect, 180, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null)
|
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null)
|
||||||
{
|
{
|
||||||
for (EntityLiving entityplayer1 : list)
|
for (EntityLiving entityplayer1 : list)
|
||||||
{
|
{
|
||||||
entityplayer1.addEffect(new PotionEffect(this.secondaryEffect, 180, 0, true, true));
|
entityplayer1.addEffect(new PotionEffect(this.secondaryEffect, 180, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,5 +276,6 @@ public class CommandEnvironment {
|
||||||
this.registerExecutable(new CommandDelwarp());
|
this.registerExecutable(new CommandDelwarp());
|
||||||
this.registerExecutable(new CommandShowwarp());
|
this.registerExecutable(new CommandShowwarp());
|
||||||
this.registerExecutable(new CommandTphere());
|
this.registerExecutable(new CommandTphere());
|
||||||
|
this.registerExecutable(new CommandEffect());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package server.command.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import common.model.ParticleType;
|
||||||
|
import common.packet.SPacketParticles;
|
||||||
|
import common.util.Vec3;
|
||||||
|
import server.command.Command;
|
||||||
|
import server.command.CommandEnvironment;
|
||||||
|
import server.command.Executor;
|
||||||
|
import server.command.UserPolicy;
|
||||||
|
import server.network.Player;
|
||||||
|
|
||||||
|
public class CommandEffect extends Command {
|
||||||
|
public CommandEffect() {
|
||||||
|
super("effect");
|
||||||
|
|
||||||
|
this.addPlayerList("player", false, UserPolicy.NON_ADMINS_OR_SELF);
|
||||||
|
this.addEnum("particle", ParticleType.class, ParticleType.values());
|
||||||
|
this.addVector("position", true, false);
|
||||||
|
this.setParamsOptional();
|
||||||
|
this.addVector("offset", false, false);
|
||||||
|
this.addDouble("speed", 0.0f, 100.0f, 0.0f);
|
||||||
|
this.addInt("count", 0, 1000, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exec(CommandEnvironment env, Executor exec, List<Player> players, ParticleType type, Vec3 pos, Vec3 offset, double speed, int count) {
|
||||||
|
offset = offset == null ? new Vec3(0.0, 0.0, 0.0) : offset;
|
||||||
|
for(Player player : players) {
|
||||||
|
player.sendPacket(new SPacketParticles(type, true, (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, (float)offset.xCoord, (float)offset.yCoord, (float)offset.zCoord, (float)speed, count, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,12 +20,10 @@ public class CommandPotion extends Command {
|
||||||
this.addInt("duration", 0, 1000000, 1000000);
|
this.addInt("duration", 0, 1000000, 1000000);
|
||||||
this.addInt("strength", 1, 256, 1);
|
this.addInt("strength", 1, 256, 1);
|
||||||
|
|
||||||
this.addFlag("particles", 'p');
|
|
||||||
this.addFlag("ambient", 'a');
|
|
||||||
this.addFlag("keep", 'k');
|
this.addFlag("keep", 'k');
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object exec(CommandEnvironment env, Executor exec, List<EntityLiving> entities, Potion type, int duration, int strength, boolean particles, boolean ambient, boolean keep) {
|
public Object exec(CommandEnvironment env, Executor exec, List<EntityLiving> entities, Potion type, int duration, int strength, boolean keep) {
|
||||||
int done = 0;
|
int done = 0;
|
||||||
for(EntityLiving entity : entities) {
|
for(EntityLiving entity : entities) {
|
||||||
if(entity.isPotionApplicable(type, strength - 1)) {
|
if(entity.isPotionApplicable(type, strength - 1)) {
|
||||||
|
@ -33,7 +31,7 @@ public class CommandPotion extends Command {
|
||||||
type.onImpact(null, null, entity, strength - 1, 1.0);
|
type.onImpact(null, null, entity, strength - 1, 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PotionEffect effect = new PotionEffect(type, duration == 0 ? Integer.MAX_VALUE : (duration * 20), strength - 1, ambient, particles);
|
PotionEffect effect = new PotionEffect(type, duration == 0 ? Integer.MAX_VALUE : (duration * 20), strength - 1);
|
||||||
if(!keep && entity.hasEffect(type))
|
if(!keep && entity.hasEffect(type))
|
||||||
entity.removeEffect(type);
|
entity.removeEffect(type);
|
||||||
entity.addEffect(effect);
|
entity.addEffect(effect);
|
||||||
|
|
|
@ -2687,7 +2687,7 @@ public class Player extends User implements Executor, IPlayer
|
||||||
if(this.entity.hasEffect(Potion.SPEED))
|
if(this.entity.hasEffect(Potion.SPEED))
|
||||||
this.entity.removeEffect(Potion.SPEED);
|
this.entity.removeEffect(Potion.SPEED);
|
||||||
else
|
else
|
||||||
this.entity.addEffect(new PotionEffect(Potion.SPEED, Integer.MAX_VALUE, 19, false, false));
|
this.entity.addEffect(new PotionEffect(Potion.SPEED, Integer.MAX_VALUE, 19));
|
||||||
this.addFeed(TextColor.GREEN + "Deine Geschwindigkeit wurde auf %dx geändert", (int)(this.entity.getAIMoveSpeed() * 10.0f));
|
this.addFeed(TextColor.GREEN + "Deine Geschwindigkeit wurde auf %dx geändert", (int)(this.entity.getAIMoveSpeed() * 10.0f));
|
||||||
// int speed = this.playerEntity.speed != 1.0f ? 1 : 5;
|
// int speed = this.playerEntity.speed != 1.0f ? 1 : 5;
|
||||||
// this.playerEntity.speed = (float)speed;
|
// this.playerEntity.speed = (float)speed;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue