siege UFO miniboss

This commit is contained in:
Bob 2022-01-22 22:05:18 +01:00
parent 458500f35e
commit 9294758fef
19 changed files with 5636 additions and 146 deletions

View File

@ -0,0 +1,196 @@
package com.hbm.entity.mob;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
public abstract class EntityUFOBase extends EntityFlying implements IMob {
protected int scanCooldown;
protected int courseChangeCooldown;
protected Entity target;
public EntityUFOBase(World p_i1587_1_) {
super(p_i1587_1_);
}
@Override
protected void entityInit() {
super.entityInit();
//XYZ
this.getDataWatcher().addObject(17, 0);
this.getDataWatcher().addObject(18, 0);
this.getDataWatcher().addObject(19, 0);
}
@Override
protected void updateEntityActionState() {
if(!this.worldObj.isRemote) {
if(this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) {
this.setDead();
return;
}
}
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
if(this.target != null && !this.target.isEntityAlive()) {
this.target = null;
}
scanForTarget();
if(this.courseChangeCooldown <= 0) {
this.setCourse();
}
/*
* Make sure to invoke super.updateEntityActionState(); in the beginning of the child's override
* Motion is set to 0 and the targeting should optimally be handled before anything else
*/
}
/**
* Standard implementation for choosing single player targets
* Keeps the check delay in mind and resets it too, simply call this every update
*/
protected void scanForTarget() {
int range = getScanRange();
if(this.scanCooldown <= 0) {
List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, this.boundingBox.expand(range, range / 2, range));
this.target = null;
for(Entity entity : entities) {
if(!entity.isEntityAlive() || !canAttackClass(entity.getClass()))
continue;
if(entity instanceof EntityPlayer) {
if(((EntityPlayer)entity).capabilities.isCreativeMode)
continue;
if(((EntityPlayer)entity).isPotionActive(Potion.invisibility.id))
continue;
if(this.target == null) {
this.target = entity;
} else {
if(this.getDistanceSqToEntity(entity) < this.getDistanceSqToEntity(this.target)) {
this.target = entity;
}
}
}
}
this.scanCooldown = getScanDelay();
}
}
protected int getScanRange() {
return 50;
}
protected int getScanDelay() {
return 100;
}
protected boolean isCourseTraversable(double p_70790_1_, double p_70790_3_, double p_70790_5_, double p_70790_7_) {
double d4 = (this.getX() - this.posX) / p_70790_7_;
double d5 = (this.getY() - this.posY) / p_70790_7_;
double d6 = (this.getZ() - this.posZ) / p_70790_7_;
AxisAlignedBB axisalignedbb = this.boundingBox.copy();
for(int i = 1; i < p_70790_7_; ++i) {
axisalignedbb.offset(d4, d5, d6);
if(!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) {
return false;
}
}
return true;
}
protected void approachPosition(double speed) {
double deltaX = this.getX() - this.posX;
double deltaY = this.getY() - this.posY;
double deltaZ = this.getZ() - this.posZ;
Vec3 delta = Vec3.createVectorHelper(deltaX, deltaY, deltaZ);
double len = delta.lengthVector();
if(len > 5) {
if(this.isCourseTraversable(this.getX(), this.getY(), this.getZ(), len)) {
this.motionX = delta.xCoord * speed / len;
this.motionY = delta.yCoord * speed / len;
this.motionZ = delta.zCoord * speed / len;
} else {
this.courseChangeCooldown = 0;
}
}
}
protected void setCourse() {
if(this.target != null) {
this.setCourseForTaget();
this.courseChangeCooldown = 20 + rand.nextInt(20);
} else {
this.setCourseWithoutTaget();
this.courseChangeCooldown = 60 + rand.nextInt(20);
}
}
protected void setCourseForTaget() {
Vec3 vec = Vec3.createVectorHelper(this.posX - this.target.posX, 0, this.posZ - this.target.posZ);
vec.rotateAroundY((float)Math.PI * 2 * rand.nextFloat());
double length = vec.lengthVector();
double overshoot = 10 + rand.nextDouble() * 10;
int wX = (int)Math.floor(this.target.posX - vec.xCoord / length * overshoot);
int wZ = (int)Math.floor(this.target.posZ - vec.zCoord / length * overshoot);
this.setWaypoint(wX, Math.max(this.worldObj.getHeightValue(wX, wZ) + 2 + rand.nextInt(2), (int) this.target.posY + rand.nextInt(3)), wZ);
}
protected void setCourseWithoutTaget() {
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);
}
public void setWaypoint(int x, int y, int z) {
this.dataWatcher.updateObject(17, x);
this.dataWatcher.updateObject(18, y);
this.dataWatcher.updateObject(19, z);
}
public int getX() {
return this.dataWatcher.getWatchableObjectInt(17);
}
public int getY() {
return this.dataWatcher.getWatchableObjectInt(18);
}
public int getZ() {
return this.dataWatcher.getWatchableObjectInt(19);
}
}

View File

@ -0,0 +1,120 @@
package com.hbm.entity.mob.siege;
import com.hbm.entity.mob.EntityUFOBase;
import com.hbm.entity.projectile.EntitySiegeLaser;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntitySiegeCraft extends EntityUFOBase implements IBossDisplayData {
private int attackCooldown;
public EntitySiegeCraft(World world) {
super(world);
this.setSize(7F, 1F);
}
@Override
protected void entityInit() {
super.entityInit();
this.getDataWatcher().addObject(12, (int) 0);
}
public void setTier(SiegeTier tier) {
this.getDataWatcher().updateObject(12, tier.id);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(tier.speedMod);
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(tier.health * 25);
this.setHealth(this.getMaxHealth());
}
public SiegeTier getTier() {
SiegeTier tier = SiegeTier.tiers[this.getDataWatcher().getWatchableObjectInt(12)];
return tier != null ? tier : SiegeTier.CLAY;
}
@Override
protected void updateEntityActionState() {
super.updateEntityActionState();
if(this.courseChangeCooldown > 0) {
this.courseChangeCooldown--;
}
if(this.scanCooldown > 0) {
this.scanCooldown--;
}
if(!worldObj.isRemote) {
if(this.attackCooldown > 0) {
this.attackCooldown--;
}
if(this.attackCooldown == 0 && this.target != null) {
this.attackCooldown = 20 + rand.nextInt(5);
double x = posX;
double y = posY;
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(0x808080);
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);
}
}
if(this.courseChangeCooldown > 0) {
approachPosition(this.target == null ? 0.25D : 0.5D + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * 1);
}
}
@Override
protected void setCourseWithoutTaget() {
int x = (int) Math.floor(posX + rand.nextGaussian() * 15);
int z = (int) Math.floor(posZ + rand.nextGaussian() * 15);
this.setWaypoint(x, this.worldObj.getHeightValue(x, z) + 5 + rand.nextInt(6), z);
}
@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
nbt.setInteger("siegeTier", this.getTier().id);
}
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
this.setTier(SiegeTier.tiers[nbt.getInteger("siegeTier")]);
}
@Override
public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
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

@ -1,36 +1,26 @@
package com.hbm.entity.mob.siege;
import java.util.List;
import com.hbm.entity.mob.EntityUFOBase;
import com.hbm.entity.projectile.EntitySiegeLaser;
import com.hbm.handler.SiegeOrchestrator;
import api.hbm.entity.IRadiationImmune;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
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;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmune {
public class EntitySiegeUFO extends EntityUFOBase implements IRadiationImmune {
public int courseChangeCooldown;
public int scanCooldown;
private int attackCooldown;
private Entity target;
public EntitySiegeUFO(World p_i1587_1_) {
super(p_i1587_1_);
public EntitySiegeUFO(World world) {
super(world);
this.setSize(1.5F, 1F);
}
@ -38,10 +28,6 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
protected void entityInit() {
super.entityInit();
this.getDataWatcher().addObject(12, (int) 0);
//XYZ
this.getDataWatcher().addObject(17, 0);
this.getDataWatcher().addObject(18, 0);
this.getDataWatcher().addObject(19, 0);
}
public void setTier(SiegeTier tier) {
@ -52,6 +38,11 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
this.setHealth(this.getMaxHealth());
}
public SiegeTier getTier() {
SiegeTier tier = SiegeTier.tiers[this.getDataWatcher().getWatchableObjectInt(12)];
return tier != null ? tier : SiegeTier.CLAY;
}
@Override
public boolean attackEntityFrom(DamageSource source, float damage) {
@ -83,26 +74,10 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
return super.attackEntityFrom(source, damage);
}
public SiegeTier getTier() {
SiegeTier tier = SiegeTier.tiers[this.getDataWatcher().getWatchableObjectInt(12)];
return tier != null ? tier : SiegeTier.CLAY;
}
@Override
protected void updateEntityActionState() {
if(!this.worldObj.isRemote) {
if(this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) {
this.setDead();
return;
}
}
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
super.updateEntityActionState();
if(this.courseChangeCooldown > 0) {
this.courseChangeCooldown--;
@ -111,10 +86,6 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
this.scanCooldown--;
}
if(this.target != null && !this.target.isEntityAlive()) {
this.target = null;
}
if(!worldObj.isRemote) {
if(this.attackCooldown > 0) {
this.attackCooldown--;
@ -143,116 +114,10 @@ public class EntitySiegeUFO extends EntityFlying implements IMob, IRadiationImmu
}
}
if(this.scanCooldown <= 0) {
List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, this.boundingBox.expand(50, 20, 50));
this.target = null;
for(Entity entity : entities) {
if(!entity.isEntityAlive() || !canAttackClass(entity.getClass()))
continue;
if(entity instanceof EntityPlayer) {
if(((EntityPlayer)entity).capabilities.isCreativeMode)
// continue;
if(((EntityPlayer)entity).isPotionActive(Potion.invisibility.id))
continue;
if(this.target == null) {
this.target = entity;
} else {
if(this.getDistanceSqToEntity(entity) < this.getDistanceSqToEntity(this.target)) {
this.target = entity;
}
}
}
}
this.scanCooldown = 100;
}
if(this.courseChangeCooldown <= 0) {
if(this.target != null) {
Vec3 vec = Vec3.createVectorHelper(this.posX - this.target.posX, 0, this.posZ - this.target.posZ);
vec.rotateAroundY((float)Math.PI * 2 * rand.nextFloat());
double length = vec.lengthVector();
double overshoot = 10 + rand.nextDouble() * 10;
int wX = (int)Math.floor(this.target.posX - vec.xCoord / length * overshoot);
int wZ = (int)Math.floor(this.target.posZ - vec.zCoord / length * overshoot);
this.setWaypoint(wX, Math.max(this.worldObj.getHeightValue(wX, wZ) + 2 + rand.nextInt(2), (int) this.target.posY + rand.nextInt(3)), wZ);
this.courseChangeCooldown = 20 + rand.nextInt(20);
} else {
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);
}
}
if(this.courseChangeCooldown > 0) {
double deltaX = this.getX() - this.posX;
double deltaY = this.getY() - this.posY;
double deltaZ = this.getZ() - this.posZ;
Vec3 delta = Vec3.createVectorHelper(deltaX, deltaY, deltaZ);
double len = delta.lengthVector();
double speed = this.target == null ? 0.25D : 0.5D + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * 1;
if(len > 5) {
if(isCourseTraversable(this.getX(), this.getY(), this.getZ(), len)) {
this.motionX = delta.xCoord * speed / len;
this.motionY = delta.yCoord * speed / len;
this.motionZ = delta.zCoord * speed / len;
} else {
this.courseChangeCooldown = 0;
}
}
approachPosition(this.target == null ? 0.25D : 0.5D + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * 1);
}
}
private boolean isCourseTraversable(double p_70790_1_, double p_70790_3_, double p_70790_5_, double p_70790_7_) {
double d4 = (this.getX() - this.posX) / p_70790_7_;
double d5 = (this.getY() - this.posY) / p_70790_7_;
double d6 = (this.getZ() - this.posZ) / p_70790_7_;
AxisAlignedBB axisalignedbb = this.boundingBox.copy();
for(int i = 1; i < p_70790_7_; ++i) {
axisalignedbb.offset(d4, d5, d6);
if(!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) {
return false;
}
}
return true;
}
public void setWaypoint(int x, int y, int z) {
this.dataWatcher.updateObject(17, x);
this.dataWatcher.updateObject(18, y);
this.dataWatcher.updateObject(19, z);
}
public int getX() {
return this.dataWatcher.getWatchableObjectInt(17);
}
public int getY() {
return this.dataWatcher.getWatchableObjectInt(18);
}
public int getZ() {
return this.dataWatcher.getWatchableObjectInt(19);
}
@Override
public void writeEntityToNBT(NBTTagCompound nbt) {

View File

@ -587,6 +587,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityUFO.class, new RenderUFO());
RenderingRegistry.registerEntityRenderingHandler(EntitySiegeZombie.class, new RenderSiegeZombie());
RenderingRegistry.registerEntityRenderingHandler(EntitySiegeUFO.class, new RenderSiegeUFO());
RenderingRegistry.registerEntityRenderingHandler(EntitySiegeCraft.class, new RenderSiegeCraft());
RenderingRegistry.registerEntityRenderingHandler(EntityGhost.class, new RenderGhost());
//"particles"
RenderingRegistry.registerEntityRenderingHandler(EntitySmokeFX.class, new MultiCloudRenderer(new Item[] { ModItems.smoke1, ModItems.smoke2, ModItems.smoke3, ModItems.smoke4, ModItems.smoke5, ModItems.smoke6, ModItems.smoke7, ModItems.smoke8 }));

View File

@ -495,6 +495,7 @@ public class MainRegistry {
EntityRegistry.registerGlobalEntityID(EntitySiegeZombie.class, "entity_meme_zombie", EntityRegistry.findGlobalUniqueEntityId(), 0x303030, 0x008000);
EntityRegistry.registerGlobalEntityID(EntitySiegeSkeleton.class, "entity_meme_skeleton", EntityRegistry.findGlobalUniqueEntityId(), 0x303030, 0x000080);
EntityRegistry.registerGlobalEntityID(EntitySiegeUFO.class, "entity_meme_ufo", EntityRegistry.findGlobalUniqueEntityId(), 0x303030, 0x800000);
EntityRegistry.registerGlobalEntityID(EntitySiegeCraft.class, "entity_meme_craft", EntityRegistry.findGlobalUniqueEntityId(), 0x303030, 0x808000);
EntityRegistry.registerModEntity(EntitySPV.class, "entity_self_propelled_vehicle_mark_1", 160, this, 1000, 1, true);

View File

@ -263,6 +263,7 @@ public class ResourceManager {
public static final IModelCustom spider = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/mobs/blockspider.obj"));
public static final IModelCustom ufo = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/mobs/ufo.obj"));
public static final IModelCustom mini_ufo = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/mobs/mini_ufo.obj"));
public static final IModelCustom siege_ufo = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/mobs/siege_ufo.obj"));
//ZIRNOX
public static final IModelCustom zirnox = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/zirnox.obj"));

View File

@ -0,0 +1,89 @@
package com.hbm.render.entity.mob;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import com.hbm.entity.mob.siege.EntitySiegeCraft;
import com.hbm.entity.mob.siege.SiegeTier;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager;
import com.hbm.render.util.BeamPronter;
import com.hbm.render.util.BeamPronter.EnumBeamType;
import com.hbm.render.util.BeamPronter.EnumWaveType;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
public class RenderSiegeCraft extends Render {
@Override
public void doRender(Entity entity, double x, double y, double z, float f0, float f1) {
GL11.glPushMatrix();
GL11.glTranslated(x, y + 0.5, z);
EntitySiegeCraft ufo = (EntitySiegeCraft) entity;
//BossStatus.setBossStatus(ufo, false);
this.bindTexture(getEntityTexture(entity));
double rot = (entity.ticksExisted + f1) * 5 % 360D;
GL11.glRotated(rot, 0, 1, 0);
if(!ufo.isEntityAlive()) {
float tilt = ufo.deathTime + f1;
GL11.glRotatef(tilt * 5, 1, 0, 1);
}
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glDisable(GL11.GL_CULL_FACE);
ResourceManager.siege_ufo.renderPart("UFO");
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
GL11.glDisable(GL11.GL_LIGHTING);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
float health = ufo.getHealth() / ufo.getMaxHealth();
GL11.glColor3f(1F - health, health, 0F);
ResourceManager.siege_ufo.renderPart("Coils");
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopAttrib();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(1F, 1F, 1F);
Random rand = new Random(entity.ticksExisted / 4);
GL11.glPushMatrix();
for(int i = 0; i < 8; i++) {
GL11.glRotated(45D, 0, 1, 0);
if(rand.nextInt(5) == 0) {
GL11.glPushMatrix();
GL11.glTranslated(4, 0, 0);
BeamPronter.prontBeam(Vec3.createVectorHelper(-1.125, 0, 2.875), EnumWaveType.RANDOM, EnumBeamType.LINE, 0x80d0ff, 0xffffff, (int)(System.currentTimeMillis() % 1000) / 50, 15, 0.125F, 1, 0);
GL11.glPopMatrix();
}
}
GL11.glPopMatrix();
GL11.glPopMatrix();
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((EntitySiegeCraft) entity);
}
protected ResourceLocation getEntityTexture(EntitySiegeCraft entity) {
SiegeTier tier = entity.getTier();
return new ResourceLocation(RefStrings.MODID + ":textures/entity/siege_craft_" + tier.name + ".png");
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B