initial commit

This commit is contained in:
Sen 2025-03-11 00:23:54 +01:00 committed by Sen
parent 3c9ee26b06
commit 22186c33b9
1458 changed files with 282792 additions and 0 deletions

View file

@ -0,0 +1,96 @@
package game.entity.effect;
import java.util.List;
import game.entity.Entity;
import game.entity.types.EntityLiving;
import game.entity.types.EntityWeatherEffect;
import game.init.Blocks;
import game.init.Config;
import game.init.SoundEvent;
import game.material.Material;
import game.world.BlockPos;
import game.world.BoundingBox;
import game.world.World;
import game.world.WorldClient;
public class EntityLightning extends EntityWeatherEffect
{
public final int color;
public final int damage;
public final boolean fire;
public final EntityLiving summoner;
private int lightningState;
public long boltVertex;
private int boltLivingTime;
public EntityLightning(World worldIn, double posX, double posY, double posZ, int color, int damage, boolean fire, EntityLiving summoner)
{
super(worldIn);
this.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
this.lightningState = 2;
this.color = color;
this.fire = fire;
this.damage = damage;
this.summoner = summoner;
this.boltVertex = this.rand.longv();
this.boltLivingTime = this.rand.roll(3);
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (this.lightningState == 2)
{
this.worldObj.playSound(SoundEvent.THUNDER, this.posX, this.posY, this.posZ, 10000.0F, 0.8F + this.rand.floatv() * 0.2F);
this.worldObj.playSound(SoundEvent.EXPLODE, this.posX, this.posY, this.posZ, 2.0F, 0.5F + this.rand.floatv() * 0.2F);
}
--this.lightningState;
if (this.lightningState < 0)
{
if (this.boltLivingTime == 0)
{
this.setDead();
}
else if (this.lightningState < -this.rand.zrange(10))
{
--this.boltLivingTime;
this.lightningState = 1;
this.boltVertex = this.rand.longv();
BlockPos blockpos = new BlockPos(this);
if (!this.worldObj.client && this.fire && Config.fire && this.worldObj.isAreaLoaded(blockpos, 10) && this.worldObj.getState(blockpos).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(this.worldObj, blockpos))
{
this.worldObj.setState(blockpos, Blocks.fire.getState());
}
}
}
if (this.lightningState >= 0)
{
if (this.worldObj.client)
{
((WorldClient)this.worldObj).setLastLightning(2, this.color);
}
else // if(this.damage > 0)
{
double d0 = 3.0D;
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, new BoundingBox(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0));
for (int i = 0; i < list.size(); ++i)
{
Entity entity = (Entity)list.get(i);
if(entity != this.summoner)
entity.onStruckByLightning(this);
}
}
}
}
}