glyphid bombardier, train collisions

This commit is contained in:
Bob 2023-06-17 18:29:57 +02:00
parent 9b2826465c
commit 5411e3fa3f
15 changed files with 346 additions and 11 deletions

View File

@ -211,6 +211,7 @@ public class EntityMappings {
addEntity(EntitySawblade.class, "entity_stray_saw", 1000);
addEntity(EntityChemical.class, "entity_chemthrower_splash", 1000);
addEntity(EntityMist.class, "entity_mist", 250, false);
addEntity(EntityAcidBomb.class, "entity_acid_bomb", 1000);
addEntity(EntityItemWaste.class, "entity_item_waste", 100);
addEntity(EntityItemBuoyant.class, "entity_item_buoyant", 100);
@ -242,6 +243,8 @@ public class EntityMappings {
addMob(EntityGlyphidBrawler.class, "entity_glyphid_brawler", 0x273038, 0xD2BB72);
addMob(EntityGlyphidBehemoth.class, "entity_glyphid_behemoth", 0x267F00, 0xD2BB72);
addMob(EntityGlyphidBrenda.class, "entity_glyphid_brenda", 0x4FC0C0, 0xA0A0A0);
addMob(EntityGlyphidBombardier.class, "entity_glyphid_bombardier", 0xDDD919, 0xDBB79D);
addMob(EntityGlyphidBlaster.class, "entity_glyphid_blaster", 0xD83737, 0xDBB79D);
addSpawn(EntityCreeperPhosgene.class, 5, 1, 1, EnumCreatureType.monster, BiomeGenBase.getBiomeGenArray());
addSpawn(EntityCreeperVolatile.class, 10, 1, 1, EnumCreatureType.monster, BiomeGenBase.getBiomeGenArray());

View File

@ -78,7 +78,7 @@ public class EntityGlyphid extends EntityMob {
}
amount -= getDamageThreshold();
if(amount < 0) return false;
if(amount < 0) return true;
}
amount = this.calculateDamage(amount);
@ -141,7 +141,7 @@ public class EntityGlyphid extends EntityMob {
if(!this.worldObj.isRemote) {
this.setBesideClimbableBlock(this.isCollidedHorizontally);
if(worldObj.getTotalWorldTime() % 100 == 0) {
if(worldObj.getTotalWorldTime() % 200 == 0) {
this.swingItem();
}
}

View File

@ -33,7 +33,7 @@ public class EntityGlyphidBehemoth extends EntityGlyphid {
@Override
public int getArmorBreakChance(float amount) {
return amount < 15 ? 10 : amount < 25 ? 5 : amount > 75 ? 1 : 3;
return amount < 20 ? 10 : amount < 100 ? 5 : amount > 200 ? 1 : 3;
}
@Override

View File

@ -0,0 +1,80 @@
package com.hbm.entity.mob;
import com.hbm.main.ResourceManager;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class EntityGlyphidBlaster extends EntityGlyphidBombardier {
public EntityGlyphidBlaster(World world) {
super(world);
this.setSize(2F, 1.125F);
}
@Override
public ResourceLocation getSkin() {
return ResourceManager.glyphid_blaster_tex;
}
@Override
public double getScale() {
return 1.25D;
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10D);
}
@Override
public int getArmorBreakChance(float amount) {
return amount < 10 ? 10 : amount < 25 ? 5 : amount > 100 ? 1 : 3;
}
@Override
public float calculateDamage(float amount) {
byte armor = this.dataWatcher.getWatchableObjectByte(17);
int divisor = 1;
for(int i = 0; i < 5; i++) {
if((armor & (1 << i)) > 0) {
divisor += 2;
}
}
amount /= divisor;
return amount;
}
@Override
public float getDamageThreshold() {
return 1.0F;
}
@Override
public float getBombDamage() {
return 10F;
}
@Override
public int getBombCount() {
return 20;
}
@Override
public float getSpreadMult() {
return 0.75F;
}
@Override
public double getV0() {
return 1.25D;
}
}

View File

@ -0,0 +1,101 @@
package com.hbm.entity.mob;
import com.hbm.entity.projectile.EntityAcidBomb;
import com.hbm.main.ResourceManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityGlyphidBombardier extends EntityGlyphid {
public EntityGlyphidBombardier(World world) {
super(world);
}
public ResourceLocation getSkin() {
return ResourceManager.glyphid_bombardier_tex;
}
protected Entity lastTarget;
protected double lastX;
protected double lastY;
protected double lastZ;
@Override
public void onUpdate() {
super.onUpdate();
if(!this.worldObj.isRemote) {
Entity e = this.getEntityToAttack();
if(this.ticksExisted % 20 == 0 && e != null) {
this.lastTarget = e;
this.lastX = e.posX;
this.lastY = e.posY;
this.lastZ = e.posZ;
}
if(this.ticksExisted % 20 == 1 && e != null) {
boolean topAttack = rand.nextBoolean();
double velX = e.posX - lastX;
double velY = e.posY - lastY;
double velZ = e.posZ - lastZ;
if(this.lastTarget != e || Vec3.createVectorHelper(velX, velY, velZ).lengthVector() > 30) {
velX = velY = velZ = 0;
}
int prediction = topAttack ? 60 : 20;
Vec3 delta = Vec3.createVectorHelper(e.posX - posX + velX * prediction, (e.posY + e.height / 2) - (posY + 1) + velY * prediction, e.posZ - posZ + velZ * prediction);
double len = delta.lengthVector();
if(len < 3) return;
double targetYaw = -Math.atan2(delta.xCoord, delta.zCoord);
double x = Math.sqrt(delta.xCoord * delta.xCoord + delta.zCoord * delta.zCoord);
double y = delta.yCoord;
double v0 = getV0();
double v02 = v0 * v0;
double g = 0.04D;
double upperLower = topAttack ? 1 : -1;
double targetPitch = Math.atan((v02 + Math.sqrt(v02*v02 - g*(g*x*x + 2*y*v02)) * upperLower) / (g*x));
if(!Double.isNaN(targetPitch)) {
Vec3 fireVec = Vec3.createVectorHelper(v0, 0, 0);
fireVec.rotateAroundZ((float) -targetPitch);
fireVec.rotateAroundY((float) -(targetYaw + Math.PI * 0.5));
for(int i = 0; i < getBombCount(); i++) {
EntityAcidBomb bomb = new EntityAcidBomb(worldObj, posX, posY + 1, posZ);
bomb.setThrowableHeading(fireVec.xCoord, fireVec.yCoord, fireVec.zCoord, (float) v0, i * getSpreadMult());
bomb.damage = getBombDamage();
worldObj.spawnEntityInWorld(bomb);
}
this.swingItem();
}
}
}
}
public float getBombDamage() {
return 1.5F;
}
public int getBombCount() {
return 10;
}
public float getSpreadMult() {
return 1F;
}
public double getV0() {
return 1D;
}
}

View File

@ -33,7 +33,7 @@ public class EntityGlyphidBrawler extends EntityGlyphid {
@Override
public int getArmorBreakChance(float amount) {
return amount < 10 ? 10 : amount < 20 ? 5 : amount > 50 ? 1 : 3;
return amount < 10 ? 10 : amount < 25 ? 5 : amount > 100 ? 1 : 3;
}
@Override

View File

@ -3,6 +3,8 @@ package com.hbm.entity.mob;
import com.hbm.main.ResourceManager;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@ -11,6 +13,7 @@ public class EntityGlyphidBrenda extends EntityGlyphid {
public EntityGlyphidBrenda(World world) {
super(world);
this.setSize(2.5F, 2F);
this.isImmuneToFire = true;
}
@Override
@ -33,7 +36,7 @@ public class EntityGlyphidBrenda extends EntityGlyphid {
@Override
public int getArmorBreakChance(float amount) {
return amount < 25 ? 100 : amount > 500 ? 1 : 10;
return amount < 25 ? 100 : amount > 1000 ? 1 : 10;
}
@Override
@ -57,4 +60,22 @@ public class EntityGlyphidBrenda extends EntityGlyphid {
public float getDamageThreshold() {
return 10F;
}
@Override
public void setDead() {
if(!this.worldObj.isRemote && this.getHealth() <= 0.0F) {
for(int i = 0; i < 12; ++i) {
EntityGlyphid glyphid = new EntityGlyphid(worldObj);
glyphid.setLocationAndAngles(this.posX, this.posY + 0.5D, this.posZ, rand.nextFloat() * 360.0F, 0.0F);
glyphid.addPotionEffect(new PotionEffect(Potion.resistance.id, 5 * 60 * 20, 2));
glyphid.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 5 * 60 * 20, 0));
glyphid.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 5 * 60 * 20, 4));
glyphid.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 5 * 60 * 20, 19));
this.worldObj.spawnEntityInWorld(glyphid);
glyphid.moveEntity(rand.nextGaussian(), 0, rand.nextGaussian());
}
}
super.setDead();
}
}

View File

@ -0,0 +1,60 @@
package com.hbm.entity.projectile;
import com.hbm.entity.mob.EntityGlyphid;
import com.hbm.lib.ModDamageSource;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityAcidBomb extends EntityThrowableInterp {
public float damage = 1.5F;
public EntityAcidBomb(World world) {
super(world);
}
public EntityAcidBomb(World world, double x, double y, double z) {
super(world, x, y, z);
}
@Override
protected void onImpact(MovingObjectPosition mop) {
if(worldObj.isRemote) return;
if(mop.typeOfHit == mop.typeOfHit.ENTITY) {
if(!(mop.entityHit instanceof EntityGlyphid)) {
mop.entityHit.attackEntityFrom(ModDamageSource.acid, damage);
this.setDead();
}
}
if(mop.typeOfHit == mop.typeOfHit.BLOCK)
this.setDead();
}
@Override
public double getGravityVelocity() {
return 0.04D;
}
@Override
protected float getAirDrag() {
return 1.0F;
}
@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
nbt.setFloat("damage", damage);
}
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
this.damage = nbt.getFloat("damage");
}
}

View File

@ -132,7 +132,7 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
data.setString("type", "debug");
data.setInteger("color", 0x0000ff);
data.setFloat("scale", 1.5F);
data.setString("text", id);
data.setString("text", id + " (#" + train.ltuIndex + ")");
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, train.posX, train.posY + 1, train.posZ), new TargetPoint(this.dimension, train.posX, train.posY + 1, train.posZ, 50));
}
}
@ -180,9 +180,6 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
}
} else {
PacketDispatcher.wrapper.sendToAllAround(new PlayerInformPacket(ChatBuilder.start("" + this.rotationPitch).color(EnumChatFormatting.RED).flush(), 1),
new TargetPoint(dimension, posX, posY + 1, posZ, 50));
if(this.coupledFront != null && this.coupledFront.isDead) {
this.coupledFront = null;
@ -319,7 +316,7 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
for(LogicalTrainUnit ltu : ltus) {
double speed = ltu.getTotalSpeed();
double speed = ltu.getTotalSpeed() + ltu.pushForce;
if(Math.abs(speed) < 0.001) speed = 0;
@ -346,6 +343,10 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
} else {
ltu.setRenderPos(train, frontPos, backPos);
}
//ltu.pushForce *= 0.95;
ltu.pushForce = 0;
ltu.collideTrain(speed);
continue;
}
@ -355,6 +356,12 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
} else {
ltu.moveTrainByApproach(speed);
}
if(ltu.trains.length != 1) {
//ltu.pushForce *= 0.95;
ltu.pushForce = 0;
ltu.collideTrain(speed);
}
}
}
@ -540,6 +547,7 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
public static class LogicalTrainUnit {
protected double pushForce;
protected EntityRailCarBase trains[];
/** Assumes that the train is an endpoint, i.e. that only one coupling is in use */
@ -742,7 +750,6 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
/** Determines the "front" wagon based on the movement and moves it, then moves all other wagons towards that */
public void moveTrainByApproach(double speed) {
boolean forward = speed < 0;
double origSpeed = speed;
speed = Math.abs(speed);
EntityRailCarBase previous = null;
@ -798,6 +805,55 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
current.motionY = current.rotationPitch / 360D;
current.velocityChanged = true;
}
public void collideTrain(double speed) {
EntityRailCarBase collidingTrain = speed > 0 ? trains[0] : trains[trains.length - 1];
List<EntityRailCarBase> intersect = collidingTrain.worldObj.getEntitiesWithinAABB(EntityRailCarBase.class, collidingTrain.boundingBox.expand(1, 1, 1));
EntityRailCarBase collidesWith = null;
for(EntityRailCarBase train : intersect) {
if(train.ltu != null && train.ltu != this) {
collidesWith = train;
break;
}
}
if(collidesWith == null) return;
Vec3 delta = Vec3.createVectorHelper(collidingTrain.posX - collidesWith.posX, 0, collidingTrain.posZ - collidesWith.posZ);
double totalSpan = collidingTrain.getCollisionSpan() + collidesWith.getCollisionSpan();
double diff = delta.lengthVector();
if(diff > totalSpan) return;
double push = (totalSpan - diff);
//PacketDispatcher.wrapper.sendToAllAround(new PlayerInformPacket(ChatBuilder.start("" + collidesWith.ltuIndex + " " + collidingTrain.ltuIndex).color(EnumChatFormatting.RED).flush(), 1),
// new TargetPoint(collidingTrain.dimension, collidingTrain.posX, collidingTrain.posY + 1, collidingTrain.posZ, 50));
EntityRailCarBase[][] whatever = new EntityRailCarBase[][] {{collidingTrain, collidesWith}, {collidesWith, collidingTrain}};
for(EntityRailCarBase[] array : whatever) {
LogicalTrainUnit ltu = array[0].ltu;
if(ltu.trains.length == 1) {
Vec3 rot = Vec3.createVectorHelper(0, 0, array[0].getCollisionSpan());
rot.rotateAroundX((float) (array[0].rotationPitch * Math.PI / 180D));
rot.rotateAroundY((float) (-array[0].rotationYaw * Math.PI / 180));
Vec3 forward = Vec3.createVectorHelper(array[1].posX - (array[0].posX + rot.xCoord), 0, array[1].posZ - (array[0].posZ + rot.zCoord));
Vec3 backward = Vec3.createVectorHelper(array[1].posX - (array[0].posX - rot.xCoord), 0, array[1].posZ - (array[0].posZ - rot.zCoord));
if(forward.lengthVector() > backward.lengthVector()) {
ltu.pushForce += push;
} else {
ltu.pushForce -= push;
}
} else {
if(array[0].ltuIndex < ltu.trains.length / 2) {
ltu.pushForce -= push;
} else {
ltu.pushForce += push;
}
}
}
}
}
@Override

View File

@ -19,6 +19,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -587,6 +588,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerEntityRenderingHandler(EntitySawblade.class, new RenderSawblade());
RenderingRegistry.registerEntityRenderingHandler(EntityChemical.class, new RenderChemical());
RenderingRegistry.registerEntityRenderingHandler(EntityMist.class, new RenderMist());
RenderingRegistry.registerEntityRenderingHandler(EntityAcidBomb.class, new RenderSnowball(Items.slime_ball));
//grenades
RenderingRegistry.registerEntityRenderingHandler(EntityGrenadeGeneric.class, new RenderSnowball(ModItems.grenade_generic));
RenderingRegistry.registerEntityRenderingHandler(EntityGrenadeStrong.class, new RenderSnowball(ModItems.grenade_strong));
@ -725,6 +727,8 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityGlyphidBrawler.class, new RenderGlyphid());
RenderingRegistry.registerEntityRenderingHandler(EntityGlyphidBehemoth.class, new RenderGlyphid());
RenderingRegistry.registerEntityRenderingHandler(EntityGlyphidBrenda.class, new RenderGlyphid());
RenderingRegistry.registerEntityRenderingHandler(EntityGlyphidBombardier.class, new RenderGlyphid());
RenderingRegistry.registerEntityRenderingHandler(EntityGlyphidBlaster.class, new RenderGlyphid());
//"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 }));
RenderingRegistry.registerEntityRenderingHandler(EntityBSmokeFX.class, new MultiCloudRenderer(new Item[] { ModItems.b_smoke1, ModItems.b_smoke2, ModItems.b_smoke3, ModItems.b_smoke4, ModItems.b_smoke5, ModItems.b_smoke6, ModItems.b_smoke7, ModItems.b_smoke8 }));

View File

@ -663,6 +663,8 @@ public class ResourceManager {
public static final ResourceLocation glyphid_brawler_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_brawler.png");
public static final ResourceLocation glyphid_behemoth_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_behemoth.png");
public static final ResourceLocation glyphid_brenda_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_brenda.png");
public static final ResourceLocation glyphid_bombardier_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_bombardier.png");
public static final ResourceLocation glyphid_blaster_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_blaster.png");
//ZIRNOX
public static final ResourceLocation zirnox_tex = new ResourceLocation(RefStrings.MODID, "textures/models/zirnox.png");

View File

@ -505,6 +505,10 @@ digamma.title=DIGAMMA-DIAGNOSEGERÄT
entity.entity_cyber_crab.name=Cyber-Krabbe
entity.entity_elder_one.name=Quackos der Älteste
entity.entity_fucc_a_ducc.name=Ente
entity.entity_glyphid.name=Glyphid
entity.entity_glyphid_behemoth.name=Glyphid-Behemoth
entity.entity_glyphid_brawler.name=Glyphid-Schläger
entity.entity_glyphid_brenda.name=Brenda
entity.entity_ntm_fbi.name=FBI Agent
entity.entity_ntm_radiation_blaze.name=Kernschmelze-Elementar
entity.hbm.entity_ntm_ufo.name=Marsianisches Invasionsschiff

View File

@ -951,6 +951,10 @@ digamma.title=DIGAMMA DIAGNOSTIC
entity.entity_cyber_crab.name=Cyber Crab
entity.entity_elder_one.name=Quackos The Elder One
entity.entity_fucc_a_ducc.name=Duck
entity.entity_glyphid.name=Glyphid
entity.entity_glyphid_behemoth.name=Glyphid Behemoth
entity.entity_glyphid_brawler.name=Glyphid Brawler
entity.entity_glyphid_brenda.name=Brenda
entity.entity_ntm_fbi.name=FBI Agent
entity.entity_ntm_radiation_blaze.name=Meltdown Elemental
entity.hbm.entity_ntm_ufo.name=Martian Invasion Ship

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB