Fixed Pixies interacting with pressure plates (Closes #1217) and Pixie trail particles.
This commit is contained in:
parent
d5ceebedab
commit
198d9da3d0
6 changed files with 132 additions and 30 deletions
|
@ -19,6 +19,7 @@ import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
|
|
||||||
public class EntityPixieTrailFX extends Particle
|
public class EntityPixieTrailFX extends Particle
|
||||||
{
|
{
|
||||||
|
private float defaultParticleScale;
|
||||||
|
|
||||||
public EntityPixieTrailFX(World world, double xCoordIn, double yCoordIn, double zCoordIn, double motionXIn, double motionYIn, double motionZIn)
|
public EntityPixieTrailFX(World world, double xCoordIn, double yCoordIn, double zCoordIn, double motionXIn, double motionYIn, double motionZIn)
|
||||||
{
|
{
|
||||||
|
@ -41,13 +42,13 @@ public class EntityPixieTrailFX extends Particle
|
||||||
this.motionZ += motionZIn;
|
this.motionZ += motionZIn;
|
||||||
this.particleScale *= 0.75F;
|
this.particleScale *= 0.75F;
|
||||||
this.particleScale *= par14;
|
this.particleScale *= par14;
|
||||||
|
this.defaultParticleScale = this.particleScale;
|
||||||
this.particleMaxAge = (int)((8.0D / (Math.random() * 0.8D + 0.2D)) * 8);
|
this.particleMaxAge = (int)((8.0D / (Math.random() * 0.8D + 0.2D)) * 8);
|
||||||
this.particleMaxAge = (int)((float)this.particleMaxAge * par14);
|
this.particleMaxAge = (int)((float)this.particleMaxAge * par14);
|
||||||
this.particleAge = (particleMaxAge / 2) + (particleMaxAge / 2) * world.rand.nextInt(7);
|
this.particleAge = world.rand.nextInt(3);
|
||||||
this.particleAlpha = 1.0F;
|
this.particleAlpha = 1.0F;
|
||||||
this.particleRed = 1.0F;
|
this.particleGravity = 0.02F;
|
||||||
this.particleGreen = 1.0F;
|
this.canCollide = false;
|
||||||
this.particleBlue = 1.0F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,7 +65,7 @@ public class EntityPixieTrailFX extends Particle
|
||||||
|
|
||||||
float scaleMultiplier = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
|
float scaleMultiplier = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
|
||||||
scaleMultiplier = MathHelper.clamp(scaleMultiplier, 0.0F, 1.0F);
|
scaleMultiplier = MathHelper.clamp(scaleMultiplier, 0.0F, 1.0F);
|
||||||
this.particleScale = this.particleScale * scaleMultiplier;
|
this.particleScale = this.defaultParticleScale * scaleMultiplier;
|
||||||
|
|
||||||
GlStateManager.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
|
@ -74,13 +75,12 @@ public class EntityPixieTrailFX extends Particle
|
||||||
|
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBrightnessForRender(float p_189214_1_)
|
public int getBrightnessForRender(float p_189214_1_)
|
||||||
{
|
{
|
||||||
float f = ((float)this.particleAge + p_189214_1_) / (float)this.particleMaxAge;
|
float f = (float)this.particleMaxAge - (((float)this.particleAge + p_189214_1_) / (float)this.particleMaxAge);
|
||||||
f = MathHelper.clamp(f, 0.0F, 1.0F);
|
f = MathHelper.clamp(f, 0.0F, 1.0F);
|
||||||
int i = super.getBrightnessForRender(p_189214_1_);
|
int i = super.getBrightnessForRender(p_189214_1_);
|
||||||
int j = i & 255;
|
int j = i & 255;
|
||||||
|
@ -107,7 +107,7 @@ public class EntityPixieTrailFX extends Particle
|
||||||
this.setExpired();
|
this.setExpired();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.particleTextureIndexX = 7 - particleAge * 8 / particleMaxAge;
|
this.particleTextureIndexX = 7 - this.particleAge * 8 / this.particleMaxAge;
|
||||||
this.move(motionX, motionY, motionZ);
|
this.move(motionX, motionY, motionZ);
|
||||||
|
|
||||||
if (posY == prevPosY)
|
if (posY == prevPosY)
|
||||||
|
@ -120,12 +120,11 @@ public class EntityPixieTrailFX extends Particle
|
||||||
motionY *= 0.9599999785423279D;
|
motionY *= 0.9599999785423279D;
|
||||||
motionZ *= 0.9599999785423279D;
|
motionZ *= 0.9599999785423279D;
|
||||||
|
|
||||||
if (this.onGround)
|
if (onGround)
|
||||||
{
|
{
|
||||||
motionX *= 0.699999988079071D;
|
motionX *= 0.699999988079071D;
|
||||||
motionZ *= 0.699999988079071D;
|
motionZ *= 0.699999988079071D;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,10 +17,14 @@ import biomesoplenty.api.item.BOPItems;
|
||||||
import biomesoplenty.api.particle.BOPParticleTypes;
|
import biomesoplenty.api.particle.BOPParticleTypes;
|
||||||
import biomesoplenty.api.sound.BOPSounds;
|
import biomesoplenty.api.sound.BOPSounds;
|
||||||
import biomesoplenty.core.BiomesOPlenty;
|
import biomesoplenty.core.BiomesOPlenty;
|
||||||
import net.minecraft.entity.EntityFlying;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.MoverType;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.EntityAIBase;
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
import net.minecraft.entity.ai.EntityMoveHelper;
|
import net.minecraft.entity.ai.EntityMoveHelper;
|
||||||
import net.minecraft.entity.monster.IMob;
|
import net.minecraft.entity.monster.IMob;
|
||||||
|
import net.minecraft.entity.passive.EntityAmbientCreature;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
@ -28,10 +32,9 @@ import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.EnumSkyBlock;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class EntityPixie extends EntityFlying implements IMob {
|
public class EntityPixie extends EntityAmbientCreature implements IMob {
|
||||||
|
|
||||||
public EntityPixie(World worldIn) {
|
public EntityPixie(World worldIn) {
|
||||||
super(worldIn);
|
super(worldIn);
|
||||||
|
@ -45,7 +48,7 @@ public class EntityPixie extends EntityFlying implements IMob {
|
||||||
protected void applyEntityAttributes()
|
protected void applyEntityAttributes()
|
||||||
{
|
{
|
||||||
super.applyEntityAttributes();
|
super.applyEntityAttributes();
|
||||||
// TODO: get right value here this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
|
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(0.5D);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,14 +73,12 @@ public class EntityPixie extends EntityFlying implements IMob {
|
||||||
public void onLivingUpdate()
|
public void onLivingUpdate()
|
||||||
{
|
{
|
||||||
super.onLivingUpdate();
|
super.onLivingUpdate();
|
||||||
|
|
||||||
if (this.world.isRemote)
|
if (this.world.isRemote)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 7; i++)
|
if (world.rand.nextInt(2) == 0)
|
||||||
{
|
{
|
||||||
if (this.rand.nextInt(2)==0)
|
BiomesOPlenty.proxy.spawnParticle(BOPParticleTypes.PIXIETRAIL, this.world, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
{
|
|
||||||
BiomesOPlenty.proxy.spawnParticle(BOPParticleTypes.PIXIETRAIL, this.posX + (this.rand.nextDouble()) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - 0.25D, this.posZ + (this.rand.nextDouble()) * (double)this.width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,10 +107,110 @@ public class EntityPixie extends EntityFlying implements IMob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBePushed()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO - move PixieMoveTargetPos and AIPixieRandomFly outside and implement in a more generic way, to be reused for pixie and wasp
|
@Override
|
||||||
|
protected void collideWithEntity(Entity entityIn)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void collideWithNearbyEntities()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canTriggerWalking()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fall(float distance, float damageMultiplier)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesEntityNotTriggerPressurePlate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnLadder()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void travel(float strafe, float vertical, float forward)
|
||||||
|
{
|
||||||
|
if (this.isInWater())
|
||||||
|
{
|
||||||
|
this.moveRelative(strafe, vertical, forward, 0.02F);
|
||||||
|
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
|
||||||
|
this.motionX *= 0.800000011920929D;
|
||||||
|
this.motionY *= 0.800000011920929D;
|
||||||
|
this.motionZ *= 0.800000011920929D;
|
||||||
|
}
|
||||||
|
else if (this.isInLava())
|
||||||
|
{
|
||||||
|
this.moveRelative(strafe, vertical, forward, 0.02F);
|
||||||
|
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
|
||||||
|
this.motionX *= 0.5D;
|
||||||
|
this.motionY *= 0.5D;
|
||||||
|
this.motionZ *= 0.5D;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float f = 0.91F;
|
||||||
|
|
||||||
|
if (this.onGround)
|
||||||
|
{
|
||||||
|
BlockPos underPos = new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(this.getEntityBoundingBox().minY) - 1, MathHelper.floor(this.posZ));
|
||||||
|
IBlockState underState = this.world.getBlockState(underPos);
|
||||||
|
f = underState.getBlock().getSlipperiness(underState, this.world, underPos, this) * 0.91F;
|
||||||
|
}
|
||||||
|
|
||||||
|
float f1 = 0.16277136F / (f * f * f);
|
||||||
|
this.moveRelative(strafe, vertical, forward, this.onGround ? 0.1F * f1 : 0.02F);
|
||||||
|
f = 0.91F;
|
||||||
|
|
||||||
|
if (this.onGround)
|
||||||
|
{
|
||||||
|
BlockPos underPos = new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(this.getEntityBoundingBox().minY) - 1, MathHelper.floor(this.posZ));
|
||||||
|
IBlockState underState = this.world.getBlockState(underPos);
|
||||||
|
f = underState.getBlock().getSlipperiness(underState, this.world, underPos, this) * 0.91F;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
|
||||||
|
this.motionX *= (double)f;
|
||||||
|
this.motionY *= (double)f;
|
||||||
|
this.motionZ *= (double)f;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.prevLimbSwingAmount = this.limbSwingAmount;
|
||||||
|
double d1 = this.posX - this.prevPosX;
|
||||||
|
double d0 = this.posZ - this.prevPosZ;
|
||||||
|
float f2 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F;
|
||||||
|
|
||||||
|
if (f2 > 1.0F)
|
||||||
|
{
|
||||||
|
f2 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.limbSwingAmount += (f2 - this.limbSwingAmount) * 0.4F;
|
||||||
|
this.limbSwing += this.limbSwingAmount;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper class representing a point in space that the pixie is targeting for some reason
|
// Helper class representing a point in space that the pixie is targeting for some reason
|
||||||
class PixieMoveTargetPos
|
class PixieMoveTargetPos
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class EntityMudball extends EntityThrowable
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
BiomesOPlenty.proxy.spawnParticle(BOPParticleTypes.MUD, this.posX, this.posY, this.posZ);
|
BiomesOPlenty.proxy.spawnParticle(BOPParticleTypes.MUD, this.world, this.posX, this.posY, this.posZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class TrailsEventHandler
|
||||||
if (player.posX != player.prevPosX || player.posZ != player.prevPosZ) //Particles should only spawn if the player is moving
|
if (player.posX != player.prevPosX || player.posZ != player.prevPosZ) //Particles should only spawn if the player is moving
|
||||||
{
|
{
|
||||||
//Move the particle up by 0.01 on spawn to prevent z-fighting (the trail particles move down with time)
|
//Move the particle up by 0.01 on spawn to prevent z-fighting (the trail particles move down with time)
|
||||||
BiomesOPlenty.proxy.spawnParticle(BOPParticleTypes.PLAYER_TRAIL, player.posX + offsetX, ((int)player.posY) + groundYOffset + 0.01, player.posZ + offsetZ, trailName);
|
BiomesOPlenty.proxy.spawnParticle(BOPParticleTypes.PLAYER_TRAIL, world, player.posX + offsetX, ((int)player.posY) + groundYOffset + 0.01, player.posZ + offsetZ, trailName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.model.ModelDynBucket;
|
import net.minecraftforge.client.model.ModelDynBucket;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
import net.minecraftforge.common.ForgeModContainer;
|
import net.minecraftforge.common.ForgeModContainer;
|
||||||
|
@ -196,24 +197,24 @@ public class ClientProxy extends CommonProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnParticle(BOPParticleTypes type, double x, double y, double z, Object... info)
|
public void spawnParticle(BOPParticleTypes type, World parWorld, double x, double y, double z, Object... info)
|
||||||
{
|
{
|
||||||
Minecraft minecraft = Minecraft.getMinecraft();
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
Particle entityFx = null;
|
Particle entityFx = null;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case PIXIETRAIL:
|
case PIXIETRAIL:
|
||||||
entityFx = new EntityPixieTrailFX(minecraft.world, x, y, z, MathHelper.nextDouble(minecraft.world.rand, -0.03, 0.03), -0.02D, MathHelper.nextDouble(minecraft.world.rand, -0.03, 0.03));
|
entityFx = new EntityPixieTrailFX(parWorld, x, y, z, MathHelper.nextDouble(parWorld.rand, -0.03, 0.03), -0.02D, MathHelper.nextDouble(parWorld.rand, -0.03, 0.03));
|
||||||
break;
|
break;
|
||||||
case MUD:
|
case MUD:
|
||||||
int itemId = Item.getIdFromItem(BOPItems.mudball);
|
int itemId = Item.getIdFromItem(BOPItems.mudball);
|
||||||
minecraft.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, x, y, z, MathHelper.nextDouble(minecraft.world.rand, -0.08D, 0.08D), MathHelper.nextDouble(minecraft.world.rand, -0.08D, 0.08D), MathHelper.nextDouble(minecraft.world.rand, -0.08D, 0.08D), itemId);
|
minecraft.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, x, y, z, MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), itemId);
|
||||||
return;
|
return;
|
||||||
case PLAYER_TRAIL:
|
case PLAYER_TRAIL:
|
||||||
if (info.length < 1)
|
if (info.length < 1)
|
||||||
throw new RuntimeException("Missing argument for trail name!");
|
throw new RuntimeException("Missing argument for trail name!");
|
||||||
|
|
||||||
entityFx = new EntityTrailFX(minecraft.world, x, y, z, (String)info[0]);
|
entityFx = new EntityTrailFX(parWorld, x, y, z, (String)info[0]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -11,6 +11,7 @@ package biomesoplenty.core;
|
||||||
import biomesoplenty.api.particle.BOPParticleTypes;
|
import biomesoplenty.api.particle.BOPParticleTypes;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class CommonProxy
|
public class CommonProxy
|
||||||
{
|
{
|
||||||
|
@ -20,6 +21,6 @@ public class CommonProxy
|
||||||
public void registerBlockSided(Block block) {}
|
public void registerBlockSided(Block block) {}
|
||||||
public void registerItemSided(Item item) {}
|
public void registerItemSided(Item item) {}
|
||||||
public void registerFluidBlockRendering(Block block, String name) {}
|
public void registerFluidBlockRendering(Block block, String name) {}
|
||||||
public void spawnParticle(BOPParticleTypes type, double x, double y, double z, Object... info) {}
|
public void spawnParticle(BOPParticleTypes type, World parWorld, double x, double y, double z, Object... info) {}
|
||||||
public void replaceBOPBucketTexture() {}
|
public void replaceBOPBucketTexture() {}
|
||||||
}
|
}
|
Loading…
Reference in a new issue