siege dropship functionality, particle effects

This commit is contained in:
Bob 2022-01-20 22:50:33 +01:00
parent dbef397738
commit b3bf7f0f50
7 changed files with 121 additions and 46 deletions

View File

@ -19,7 +19,7 @@ public class SiegeShield extends SiegeBase {
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if(SiegeOrchestrator.siegeMobCount > SiegeOrchestrator.getExpansionThreshold(world))
if(SiegeOrchestrator.siegeMobCount > SiegeOrchestrator.getExpansionThreshold(world) || !SiegeOrchestrator.enableBaseSpawning(world))
return;
int succ = 0;

View File

@ -1,12 +1,15 @@
package com.hbm.entity.missile;
import com.hbm.blocks.ModBlocks;
import com.hbm.entity.mob.siege.SiegeTier;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.handler.SiegeOrchestrator;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
@ -15,15 +18,18 @@ import net.minecraft.world.World;
public class EntitySiegeDropship extends EntityThrowable {
public int health = 10;
public int health = 20;
public EntitySiegeDropship(World world) {
super(world);
this.health *= Math.pow((SiegeOrchestrator.level + 1), 2);
this.setSize(0.5F, 1F);
}
public EntitySiegeDropship(World world, double x, double y, double z) {
super(world, x, y, z);
this.health *= (SiegeOrchestrator.level + 1);
this.health *= Math.pow((SiegeOrchestrator.level + 1), 2);
this.setSize(0.5F, 1F);
}
@Override
@ -45,6 +51,25 @@ public class EntitySiegeDropship extends EntityThrowable {
if(this.health <= 0) {
this.setDead();
SiegeOrchestrator.levelCounter += SiegeOrchestrator.getTierAddDrop(worldObj);
SiegeTier tier = SiegeTier.tiers[SiegeOrchestrator.level];
if(tier == null)
tier = SiegeTier.DNT;
for(ItemStack drop : tier.dropItem) {
this.entityDropItem(drop.copy(), 0F);
}
ExplosionLarge.spawnParticles(worldObj, posX, posY + 1, posZ, 10);
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "plasmablast");
data.setFloat("r", 1F);
data.setFloat("g", 0F);
data.setFloat("b", 0F);
data.setFloat("scale", 20F);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ),
new TargetPoint(worldObj.provider.dimensionId, posX, posY, posZ, 100));
}
}
@ -58,6 +83,17 @@ public class EntitySiegeDropship extends EntityThrowable {
this.motionX = 0;
this.motionY = -0.5;
this.motionZ = 0;
if(!worldObj.isRemote && this.ticksExisted % 2 == 0) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "plasmablast");
data.setFloat("r", 0.1F);
data.setFloat("g", 0.75F);
data.setFloat("b", 1.0F);
data.setFloat("scale", 3F);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ),
new TargetPoint(worldObj.provider.dimensionId, posX, posY, posZ, 100));
}
super.onUpdate();
}
@ -71,10 +107,10 @@ public class EntitySiegeDropship extends EntityThrowable {
if(SiegeOrchestrator.enableBaseSpawning(worldObj)) {
worldObj.setBlock(mop.blockX, mop.blockY, mop.blockZ, ModBlocks.siege_shield);
} else if(SiegeOrchestrator.enableMobSpawning(worldObj)) {
SiegeOrchestrator.spawnRandomMob(worldObj, mop.blockX + 0.5, mop.blockY + 1, mop.blockZ + 0.5);
SiegeOrchestrator.spawnRandomMob(worldObj, mop.blockX + 0.5, mop.blockY + 1, mop.blockZ + 0.5, null);
}
ExplosionLarge.spawnParticles(worldObj, posX, posY + 1, posZ, 15);
ExplosionLarge.spawnParticles(worldObj, posX, posY + 1, posZ, 10);
}
}

View File

@ -10,9 +10,9 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.util.AxisAlignedBB;
@ -99,6 +99,10 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
return;
}
}
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
if(this.courseChangeCooldown > 0) {
this.courseChangeCooldown--;
@ -124,11 +128,16 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
double z = posZ;
Vec3 vec = Vec3.createVectorHelper(target.posX - x, target.posY + target.height * 0.5 - y, target.posZ - z).normalize();
SiegeTier tier = this.getTier();
EntitySiegeLaser laser = new EntitySiegeLaser(worldObj, this);
laser.setPosition(x, y, z);
laser.setThrowableHeading(vec.xCoord, vec.yCoord, vec.zCoord, 1F, 0.15F);
laser.setColor(0x802000);
laser.setDamage(tier.damageMod);
laser.setExplosive(tier.laserExplosive);
laser.setBreakChance(tier.laserBreak);
if(tier.laserIncendiary) laser.setIncendiary();
worldObj.spawnEntityInWorld(laser);
this.playSound("hbm:weapon.ballsLaser", 2.0F, 1.0F);
}
@ -146,7 +155,7 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
if(entity instanceof EntityPlayer) {
if(((EntityPlayer)entity).capabilities.isCreativeMode)
continue;
// continue;
if(((EntityPlayer)entity).isPotionActive(Potion.invisibility.id))
continue;
@ -181,17 +190,13 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
this.courseChangeCooldown = 20 + rand.nextInt(20);
} else {
int x = (int) Math.floor(posX + rand.nextGaussian() * 2);
int z = (int) Math.floor(posZ + rand.nextGaussian() * 2);
int x = (int) Math.floor(posX + rand.nextGaussian() * 5);
int z = (int) Math.floor(posZ + rand.nextGaussian() * 5);
this.setWaypoint(x, this.worldObj.getHeightValue(x, z) + 2 + rand.nextInt(3), z);
this.courseChangeCooldown = 60 + rand.nextInt(20);
}
}
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
if(this.courseChangeCooldown > 0) {
double deltaX = this.getX() - this.posX;
@ -266,4 +271,14 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
this.setTier(SiegeTier.tiers[rand.nextInt(SiegeTier.getLength())]);
return super.onSpawnWithEgg(data);
}
@Override
protected void dropFewItems(boolean byPlayer, int fortune) {
if(byPlayer) {
for(ItemStack drop : this.getTier().dropItem) {
this.entityDropItem(drop.copy(), 0F);
}
}
}
}

View File

@ -70,7 +70,7 @@ public class EntitySiegeLaser extends EntityThrowable {
public void onUpdate() {
super.onUpdate();
if(this.ticksExisted > 100)
if(this.ticksExisted > 60)
this.setDead();
}
@ -85,18 +85,21 @@ public class EntitySiegeLaser extends EntityThrowable {
else
dmg = new DamageSource(ModDamageSource.s_laser);
mop.entityHit.attackEntityFrom(dmg, this.damage);
if(mop.entityHit.attackEntityFrom(dmg, this.damage)) {
this.setDead();
if(this.incendiary)
mop.entityHit.setFire(3);
if(this.explosive > 0)
this.worldObj.newExplosion(this, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, this.explosive, this.incendiary, false);
}
if(this.incendiary)
mop.entityHit.setFire(3);
if(this.explosive > 0)
this.worldObj.newExplosion(this, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, this.explosive, false, this.incendiary);
} else if(mop.typeOfHit == MovingObjectType.BLOCK) {
if(this.explosive > 0) {
this.worldObj.newExplosion(this, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, this.explosive, false, this.incendiary);
this.worldObj.newExplosion(this, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, this.explosive, this.incendiary, false);
} else if(this.incendiary) {
ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit);
@ -112,6 +115,8 @@ public class EntitySiegeLaser extends EntityThrowable {
if(this.rand.nextFloat() < this.breakChance) {
this.worldObj.func_147480_a(mop.blockX, mop.blockY, mop.blockZ, false);
}
this.setDead();
}
}

View File

@ -1,8 +1,10 @@
package com.hbm.handler;
import com.hbm.entity.missile.EntitySiegeDropship;
import com.hbm.entity.mob.siege.EntitySiegeSkeleton;
import com.hbm.entity.mob.siege.EntitySiegeUFO;
import com.hbm.entity.mob.siege.EntitySiegeZombie;
import com.hbm.entity.mob.siege.SiegeTier;
import com.hbm.util.ChatBuilder;
import com.hbm.util.GameRuleHelper;
@ -11,9 +13,9 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Vec3;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
@ -29,7 +31,7 @@ public class SiegeOrchestrator {
public static void update(World world) {
//abort loop if sieges are disabled
if(!siegeEnabled(world))
if(world.isRemote || !siegeEnabled(world))
return;
int waveTime = getWaveDuration(world);
@ -45,6 +47,8 @@ public class SiegeOrchestrator {
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatBuilder.start("[SIEGE MODE] The wave has ended!").color(EnumChatFormatting.RED).flush());
}
lastWave = wave;
//if we're on pause, do nothing
if(!wave)
return;
@ -82,7 +86,7 @@ public class SiegeOrchestrator {
//if the tier has changed, send a broadcast
if(prevLevel != level) {
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatBuilder.start("[SIEGE MODE] The siege tier is now " + level + "!").color(EnumChatFormatting.RED).flush());
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatBuilder.start("[SIEGE MODE] The siege tier is now " + (level + 1) + "!").color(EnumChatFormatting.RED).flush());
}
//every 10s we recount the loaded siege mobs
@ -92,7 +96,17 @@ public class SiegeOrchestrator {
}
public static void perPlayerSpawn(EntityPlayer player) {
//TODO: either spawn siege mobs outright or dropships, depending on whether dropships are enabled
Vec3 vec = Vec3.createVectorHelper(getSpawnDist(player.worldObj), 0, 0);
vec.rotateAroundY((float)(player.getRNG().nextFloat() * Math.PI));
double x = player.posX + vec.xCoord;
double z = player.posZ + vec.zCoord;
if(enableMissileSpawn(player.worldObj)) {
EntitySiegeDropship ship = new EntitySiegeDropship(player.worldObj, x, 300, z);
player.worldObj.spawnEntityInWorld(ship);
}
}
public static void playerDeathHook(EntityPlayer player, DamageSource source) {
@ -118,16 +132,23 @@ public class SiegeOrchestrator {
if(world.isRemote)
return;
SiegeTier tier = SiegeTier.tiers[level];
if(tier == null)
tier = SiegeTier.DNT;
EntityLiving entity;
float f = world.rand.nextFloat();
if(f < 0.1F) {
entity = new EntitySiegeUFO(world);
((EntitySiegeUFO)entity).setTier(tier);
} else if(f < 0.4F) {
entity = new EntitySiegeSkeleton(world);
entity = new EntitySiegeUFO(world);
((EntitySiegeUFO)entity).setTier(tier);
} else {
entity = new EntitySiegeZombie(world);
((EntitySiegeZombie)entity).setTier(tier);
}
entity.setPositionAndRotation(x, y, z, (float)Math.PI * 2F, 0F);
@ -258,4 +279,8 @@ public class SiegeOrchestrator {
public static boolean enableMobSpawning(World world) {
return world.getGameRules().getGameRuleBooleanValue(KEY_ENABLE_SPAWNS);
}
public static boolean enableMissileSpawn(World world) {
return world.getGameRules().getGameRuleBooleanValue(KEY_ENABLE_MISSILES);
}
}

View File

@ -873,6 +873,7 @@ public class ModEventHandler {
if(event.phase == Phase.START) {
BossSpawnHandler.rollTheDice(event.world);
TimedGenerator.automaton(event.world, 100);
SiegeOrchestrator.update(event.world);
}
}

View File

@ -8,6 +8,7 @@ import com.hbm.blocks.BlockDummyable;
import com.hbm.entity.logic.EntityBomber;
import com.hbm.entity.missile.EntityMissileBaseAdvanced;
import com.hbm.entity.missile.EntityMissileCustom;
import com.hbm.entity.missile.EntitySiegeDropship;
import com.hbm.entity.projectile.EntityBulletBase;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
@ -551,33 +552,25 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
if(targetAnimals) {
if(e instanceof IAnimals)
return true;
if(e instanceof INpc)
return true;
if(e instanceof IAnimals) return true;
if(e instanceof INpc) return true;
}
if(targetMobs) {
//never target the ender dragon directly
if(e instanceof EntityDragon)
return false;
if(e instanceof EntityDragonPart)
return true;
if(e instanceof IMob)
return true;
if(e instanceof EntityDragon) return false;
if(e instanceof EntityDragonPart) return true;
if(e instanceof IMob) return true;
}
if(targetMachines) {
if(e instanceof EntityMissileBaseAdvanced)
return true;
if(e instanceof EntityMissileCustom)
return true;
if(e instanceof EntityMinecart)
return true;
if(e instanceof EntityBomber)
return true;
if(e instanceof EntityMissileBaseAdvanced) return true;
if(e instanceof EntityMissileCustom) return true;
if(e instanceof EntityMinecart) return true;
if(e instanceof EntityBomber) return true;
if(e instanceof EntitySiegeDropship) return true;
}
if(targetPlayers && e instanceof EntityPlayer) {