use of net.minecraft.entity.mob.PhantomEntity in project MCDoom by AzureDoom.
the class BFGEntity method doDamage.
public void doDamage() {
float q = 24.0F;
int k = MathHelper.floor(this.getX() - (double) q - 1.0D);
int l = MathHelper.floor(this.getX() + (double) q + 1.0D);
int t = MathHelper.floor(this.getY() - (double) q - 1.0D);
int u = MathHelper.floor(this.getY() + (double) q + 1.0D);
int v = MathHelper.floor(this.getZ() - (double) q - 1.0D);
int w = MathHelper.floor(this.getZ() + (double) q + 1.0D);
List<Entity> list = this.world.getOtherEntities(this, new Box((double) k, (double) t, (double) v, (double) l, (double) u, (double) w));
Vec3d vec3d = new Vec3d(this.getX(), this.getY(), this.getZ());
for (int x = 0; x < list.size(); ++x) {
Entity entity = (Entity) list.get(x);
double y = (double) (MathHelper.sqrt((float) entity.squaredDistanceTo(vec3d)) / q);
if (!(entity instanceof PlayerEntity || entity instanceof EnderDragonEntity || entity instanceof GoreNestEntity || entity instanceof IconofsinEntity) && (entity instanceof HostileEntity || entity instanceof SlimeEntity || entity instanceof PhantomEntity || entity instanceof ShulkerEntity || entity instanceof HoglinEntity)) {
if (y <= 1.0D) {
entity.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage);
if (!this.world.isClient) {
List<LivingEntity> list1 = this.world.getNonSpectatingEntities(LivingEntity.class, this.getBoundingBox().expand(4.0D, 2.0D, 4.0D));
AreaEffectCloudEntity areaeffectcloudentity = new AreaEffectCloudEntity(entity.world, entity.getX(), entity.getY(), entity.getZ());
areaeffectcloudentity.setParticleType(ParticleTypes.TOTEM_OF_UNDYING);
areaeffectcloudentity.setRadius(3.0F);
areaeffectcloudentity.setDuration(10);
if (!list1.isEmpty()) {
for (LivingEntity livingentity : list1) {
double d0 = this.squaredDistanceTo(livingentity);
if (d0 < 16.0D) {
areaeffectcloudentity.updatePosition(entity.getX(), entity.getEyeY(), entity.getZ());
break;
}
}
}
this.world.spawnEntity(areaeffectcloudentity);
}
}
}
if (entity instanceof EnderDragonEntity) {
if (entity.isAlive()) {
((EnderDragonEntity) entity).head.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage_dragon);
}
}
if (entity instanceof IconofsinEntity) {
if (entity.isAlive()) {
entity.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage * 0.1F);
}
}
}
}
use of net.minecraft.entity.mob.PhantomEntity in project MCDoom by AzureDoom.
the class BFGEntity method tick.
@Override
public void tick() {
int idleOpt = 100;
if (getVelocity().lengthSquared() < 0.01)
idleTicks++;
else
idleTicks = 0;
if (idleOpt <= 0 || idleTicks < idleOpt)
super.tick();
boolean isInsideWaterBlock = world.isWater(getBlockPos());
spawnLightSource(isInsideWaterBlock);
if (this.age >= 100) {
this.remove(Entity.RemovalReason.DISCARDED);
}
float q = 24.0F;
int k = MathHelper.floor(this.getX() - (double) q - 1.0D);
int l = MathHelper.floor(this.getX() + (double) q + 1.0D);
int t = MathHelper.floor(this.getY() - (double) q - 1.0D);
int u = MathHelper.floor(this.getY() + (double) q + 1.0D);
int v = MathHelper.floor(this.getZ() - (double) q - 1.0D);
int w = MathHelper.floor(this.getZ() + (double) q + 1.0D);
List<Entity> list = this.world.getOtherEntities(this, new Box((double) k, (double) t, (double) v, (double) l, (double) u, (double) w));
Vec3d vec3d1 = new Vec3d(this.getX(), this.getY(), this.getZ());
for (int x = 0; x < list.size(); ++x) {
Entity entity = (Entity) list.get(x);
double y = (double) (MathHelper.sqrt((float) entity.squaredDistanceTo(vec3d1)) / q);
if (!(entity instanceof PlayerEntity || entity instanceof EnderDragonEntity || entity instanceof GoreNestEntity || entity instanceof IconofsinEntity) && (entity instanceof HostileEntity || entity instanceof SlimeEntity || entity instanceof PhantomEntity || entity instanceof ShulkerEntity || entity instanceof HoglinEntity)) {
if (y <= 1.0D) {
if (entity.isAlive()) {
entity.damage(DamageSource.explosion(this.shooter), DoomMod.config.weapons.bfgball_damage_aoe);
setBeamTarget(entity.getId());
}
}
}
if (entity instanceof IconofsinEntity) {
if (entity.isAlive()) {
entity.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage_aoe * 0.1F);
}
}
if (!(entity instanceof PlayerEntity) && entity instanceof EnderDragonEntity) {
if (entity.isAlive()) {
((EnderDragonEntity) entity).head.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage_aoe);
setBeamTarget(entity.getId());
}
}
}
}
use of net.minecraft.entity.mob.PhantomEntity in project Entity_Texture_Features by Traben-0.
the class MIX_EyesFeatureRenderer method getAlteredEyesTexture.
private Identifier getAlteredEyesTexture(LivingEntity entity) {
String path = "";
if (entity instanceof EndermanEntity) {
path = "textures/entity/enderman/enderman_eyes.png";
} else if (entity instanceof SpiderEntity) {
path = "textures/entity/spider_eyes.png";
} else if (entity instanceof PhantomEntity) {
path = "textures/entity/phantom_eyes.png";
}
Identifier vanilla = new Identifier(path);
UUID id = entity.getUuid();
try {
if (!Texture_OptifineOrTrueRandom.containsKey(path)) {
ETF_processNewRandomTextureCandidate(path);
}
if (Texture_OptifineOrTrueRandom.containsKey(path)) {
// if needs to check if change required
if (UUID_entityAwaitingDataClearing2.containsKey(id)) {
if (UUID_randomTextureSuffix2.containsKey(id)) {
if (!hasUpdatableRandomCases2.containsKey(id)) {
hasUpdatableRandomCases2.put(id, true);
}
if (hasUpdatableRandomCases2.get(id)) {
// UUID_entityAwaitingDataClearing.put(id, UUID_entityAwaitingDataClearing.get(id)+1);
if (UUID_entityAwaitingDataClearing2.get(id) + 100 < System.currentTimeMillis()) {
if (Texture_OptifineOrTrueRandom.get(path)) {
// if (UUID_randomTextureSuffix.containsKey(id)) {
int hold = UUID_randomTextureSuffix2.get(id);
ETF_resetSingleData(id);
ETF_testCases(path, id, entity, true, UUID_randomTextureSuffix2, hasUpdatableRandomCases2);
// if didnt change keep the same
if (!UUID_randomTextureSuffix2.containsKey(id)) {
UUID_randomTextureSuffix2.put(id, hold);
}
// }
}
// else here would do something for true random but no need really - may optimise this
UUID_entityAwaitingDataClearing2.remove(id);
}
} else {
UUID_entityAwaitingDataClearing2.remove(id);
}
}
}
if (Texture_OptifineOrTrueRandom.get(path)) {
// if it doesn't have a random already assign one
if (!UUID_randomTextureSuffix2.containsKey(id)) {
ETF_testCases(path, id, entity, false, UUID_randomTextureSuffix2, hasUpdatableRandomCases2);
// if all failed set to vanilla
if (!UUID_randomTextureSuffix2.containsKey(id)) {
UUID_randomTextureSuffix2.put(id, 0);
}
UUID_entityAlreadyCalculated.add(id);
}
// System.out.println("suffix was ="+UUID_randomTextureSuffix.get(id));
if (UUID_randomTextureSuffix2.get(id) == 0) {
if (!TEXTURE_HasOptifineDefaultReplacement.containsKey(vanilla.toString())) {
TEXTURE_HasOptifineDefaultReplacement.put(vanilla.toString(), ETF_isExistingFile(ETF_returnOptifineOrVanillaIdentifier(path)));
}
if (TEXTURE_HasOptifineDefaultReplacement.get(vanilla.toString())) {
return ETF_returnBlinkIdOrGiven(entity, ETF_returnOptifineOrVanillaIdentifier(path).toString(), id);
} else {
return ETF_returnBlinkIdOrGiven(entity, vanilla.toString(), id);
}
} else {
return ETF_returnBlinkIdOrGiven(entity, ETF_returnOptifineOrVanillaIdentifier(path, UUID_randomTextureSuffix2.get(id)).toString(), id);
}
} else {
// true random assign
hasUpdatableRandomCases2.put(id, false);
if (Texture_TotalTrueRandom.get(path) > 0) {
if (!UUID_randomTextureSuffix2.containsKey(id)) {
int randomReliable = Math.abs(id.hashCode());
randomReliable %= Texture_TotalTrueRandom.get(path);
randomReliable++;
if (randomReliable == 1 && ignoreOnePNG.get(path)) {
randomReliable = 0;
}
UUID_randomTextureSuffix2.put(id, randomReliable);
UUID_entityAlreadyCalculated.add(id);
}
if (UUID_randomTextureSuffix2.get(id) == 0) {
return ETF_returnBlinkIdOrGiven(entity, vanilla.toString(), id);
} else {
return ETF_returnBlinkIdOrGiven(entity, ETF_returnOptifineOrVanillaPath(path, UUID_randomTextureSuffix2.get(id), ""), id);
}
} else {
return ETF_returnBlinkIdOrGiven(entity, vanilla.toString(), id);
}
}
} else {
ETF_modMessage("not random", false);
return ETF_returnBlinkIdOrGiven(entity, vanilla.toString(), id);
}
} catch (Exception e) {
ETF_modMessage(e.toString(), false);
return ETF_returnBlinkIdOrGiven(entity, vanilla.toString(), id);
}
}
Aggregations