mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
his name is jim, and he likes throwing rocks at people
This commit is contained in:
parent
9a955245cb
commit
27d613e1c2
@ -176,8 +176,7 @@ public class EntityGlyphid extends EntityMob {
|
||||
protected Entity findPlayerToAttack() {
|
||||
if(this.isPotionActive(Potion.blindness)) return null;
|
||||
|
||||
EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, useExtendedTargeting() ? 128D : 16D);
|
||||
return entityplayer;
|
||||
return this.worldObj.getClosestVulnerablePlayerToEntity(this, useExtendedTargeting() ? 128D : 16D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,12 +1,26 @@
|
||||
package com.hbm.entity.mob;
|
||||
|
||||
import com.hbm.entity.projectile.EntityRubble;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.ResourceManager;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityGlyphidDigger extends EntityGlyphid {
|
||||
protected Entity lastTarget;
|
||||
protected double lastX;
|
||||
protected double lastY;
|
||||
protected double lastZ;
|
||||
|
||||
public EntityGlyphidDigger(World world) {
|
||||
super(world);
|
||||
@ -18,17 +32,119 @@ public class EntityGlyphidDigger extends EntityGlyphid {
|
||||
|
||||
@Override
|
||||
public double getScale() {
|
||||
return 1.25D;
|
||||
return 1.3D;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyEntityAttributes() {
|
||||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(35D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5D);
|
||||
}
|
||||
|
||||
public int timer = 0;
|
||||
@Override
|
||||
public void onUpdate(){
|
||||
super.onUpdate();
|
||||
Entity e = this.getEntityToAttack();
|
||||
if (e != null) {
|
||||
|
||||
this.lastX = e.posX;
|
||||
this.lastY = e.posY;
|
||||
this.lastZ = e.posZ;
|
||||
|
||||
if (--timer <= 0) {
|
||||
groundSlam();
|
||||
timer = 120;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Mainly composed of crusty old power fist code, with some touch ups
|
||||
**/
|
||||
public void groundSlam(){
|
||||
if (!worldObj.isRemote && entityToAttack instanceof EntityLivingBase && this.getDistanceToEntity(entityToAttack) < (useExtendedTargeting() ? 128D : 16D)) {
|
||||
Entity e = this.getEntityToAttack();
|
||||
|
||||
boolean topAttack = false;
|
||||
|
||||
int l = 6;
|
||||
float part = -1F / 16F;
|
||||
|
||||
int bugX = (int) posX;
|
||||
int bugY = (int) posY;
|
||||
int bugZ = (int) posZ;
|
||||
|
||||
Vec3 vec0 = getLookVec();
|
||||
|
||||
List<int[]> list = Library.getBlockPosInPath(bugX, bugY, bugZ, l, vec0);
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
vec0.rotateAroundY(part);
|
||||
list.addAll(Library.getBlockPosInPath(bugX, bugY - 1, bugZ, l, vec0));
|
||||
}
|
||||
|
||||
double velX = e.posX - lastX;
|
||||
double velY = e.posY - lastY;
|
||||
double velZ = e.posZ - lastZ;
|
||||
|
||||
if(this.lastTarget != e) {
|
||||
velX = velY = velZ = 0;
|
||||
} else if (this.getDistanceToEntity(e) < 11) {
|
||||
topAttack = true;
|
||||
}
|
||||
|
||||
int prediction = 60;
|
||||
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 = 1.2;
|
||||
double v02 = v0 * v0;
|
||||
double g = 0.07D;
|
||||
double upperLower = topAttack ? 1 : -1;
|
||||
double targetPitch = Math.atan((v02 + Math.sqrt(v02*v02 - g*(g*x*x + 2*y*v02)) * upperLower) / (g*x));
|
||||
Vec3 fireVec = null;
|
||||
if(!Double.isNaN(targetPitch)) {
|
||||
|
||||
fireVec = Vec3.createVectorHelper(v0, 0, 0);
|
||||
fireVec.rotateAroundZ((float) -targetPitch);
|
||||
fireVec.rotateAroundY((float) -(targetYaw + Math.PI * 0.5));
|
||||
}
|
||||
|
||||
for (int[] ints : list) {
|
||||
|
||||
int x1 = ints[0];
|
||||
int y1 = ints[1];
|
||||
int z1 = ints[2];
|
||||
|
||||
|
||||
Block b = worldObj.getBlock(x1, y1, z1);
|
||||
float k = b.getExplosionResistance(null);
|
||||
|
||||
if (k < 6000 && b.isNormalCube()) {
|
||||
|
||||
EntityRubble rubble = new EntityRubble(worldObj);
|
||||
rubble.posX = x1 + 0.5F;
|
||||
rubble.posY = y1 + 2;
|
||||
rubble.posZ = z1 + 0.5F;
|
||||
|
||||
rubble.setMetaBasedOnBlock(b, worldObj.getBlockMetadata(x1, y1, z1));
|
||||
|
||||
if(fireVec != null)
|
||||
rubble.setThrowableHeading(fireVec.xCoord, fireVec.yCoord, fireVec.zCoord, (float) v0, rand.nextFloat());
|
||||
|
||||
worldObj.spawnEntityInWorld(rubble);
|
||||
|
||||
worldObj.setBlock(x1, y1, z1, Blocks.air);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isArmorBroken(float amount) {
|
||||
return this.rand.nextInt(100) <= Math.min(Math.pow(amount * 0.25, 2), 100);
|
||||
|
||||
@ -12,16 +12,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityRubble extends EntityThrowable {
|
||||
public class EntityRubble extends EntityThrowableInterp {
|
||||
|
||||
public EntityRubble(World p_i1773_1_)
|
||||
public EntityRubble(World world)
|
||||
{
|
||||
super(p_i1773_1_);
|
||||
}
|
||||
|
||||
public EntityRubble(World p_i1774_1_, EntityLivingBase p_i1774_2_)
|
||||
{
|
||||
super(p_i1774_1_, p_i1774_2_);
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,19 +25,18 @@ public class EntityRubble extends EntityThrowable {
|
||||
this.dataWatcher.addObject(17, (int)Integer.valueOf(0));
|
||||
}
|
||||
|
||||
public EntityRubble(World p_i1775_1_, double p_i1775_2_, double p_i1775_4_, double p_i1775_6_)
|
||||
{
|
||||
super(p_i1775_1_, p_i1775_2_, p_i1775_4_, p_i1775_6_);
|
||||
public EntityRubble(World world, double x, double y, double z) {
|
||||
super(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition p_70184_1_)
|
||||
protected void onImpact(MovingObjectPosition mop)
|
||||
{
|
||||
if (p_70184_1_.entityHit != null)
|
||||
if (mop.entityHit != null)
|
||||
{
|
||||
byte b0 = 15;
|
||||
|
||||
p_70184_1_.entityHit.attackEntityFrom(ModDamageSource.rubble, b0);
|
||||
mop.entityHit.attackEntityFrom(ModDamageSource.rubble, b0);
|
||||
}
|
||||
|
||||
if(this.ticksExisted > 2) {
|
||||
@ -55,7 +49,17 @@ public class EntityRubble extends EntityThrowable {
|
||||
PacketDispatcher.wrapper.sendToAllAround(new ParticleBurstPacket((int)Math.floor(posX), (int)posY, (int)Math.floor(posZ), this.dataWatcher.getWatchableObjectInt(16), this.dataWatcher.getWatchableObjectInt(17)), new TargetPoint(worldObj.provider.dimensionId, posX, posY, posZ, 50));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getGravityVelocity() {
|
||||
return 0.07D;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getAirDrag() {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
public void setMetaBasedOnBlock(Block b, int i) {
|
||||
|
||||
this.dataWatcher.updateObject(16, Block.getIdFromBlock(b));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user