use of net.minecraft.entity.mob.SlimeEntity 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.SlimeEntity 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.SlimeEntity in project wildmod by Osmiooo.
the class FrogGoal method tick.
public void tick() {
World world = this.mob.getEntityWorld();
Box box2 = new Box(this.mob.getBlockPos().add(-12, -4, -12), this.mob.getBlockPos().add(12, 6, 12));
if (this.mob.isSubmergedInWater() && this.mob.isTouchingWater()) {
if (world.getBlockState(this.mob.getBlockPos().up()) != Blocks.AIR.getDefaultState() && world.getBlockState(this.mob.getBlockPos().up()) != Blocks.WATER.getDefaultState()) {
double angle = Math.random() * 360;
double radius = Math.random() * 0.3;
this.mob.setYaw((float) angle);
this.mob.updateVelocity(2F, new Vec3d(-Math.sin(angle) * radius, 0, -Math.cos(angle) * radius));
this.mob.getLookControl().lookAt(new Vec3d(-Math.sin(angle) * radius, 0, -Math.cos(angle) * radius));
}
if (Math.random() < 0.5) {
double result;
int radius = 3;
BlockPos targetPos = null;
ArrayList<BlockPos> targetList = checkforSafePlaceToGo(world, this.mob.getBlockPos(), radius);
if (targetList.size() > 0) {
result = Math.round(Math.random() * (targetList.size() - 1));
targetPos = targetList.get((int) result);
}
if (!(targetPos == null)) {
double dx = targetPos.getX() - this.mob.getBlockPos().getX();
double dy = targetPos.getY() - this.mob.getBlockPos().getY();
double dz = targetPos.getZ() - this.mob.getBlockPos().getZ();
if (dy < 0) {
dy = 0;
}
if (Math.sqrt(dx * dx) > 0 || Math.sqrt(dz * dz) > 0) {
this.mob.updateVelocity(2F, new Vec3d(dx / 15, 0.1 + dy / 10, dz / 15));
this.mob.getLookControl().lookAt(new Vec3d(dx / 15, 0.1 + dy / 10, dz / 15));
}
}
}
}
if (this.mob.isSubmergedInWater()) {
if (Math.random() < 0.05) {
double jumpamount = Math.random() / 4;
double angle = Math.random() * 360;
double radius = Math.random() / 10;
this.mob.setYaw((float) angle);
this.mob.updateVelocity(2F, new Vec3d(-Math.sin(angle) * radius, jumpamount, -Math.cos(angle) * radius));
this.mob.getLookControl().lookAt(new Vec3d(-Math.sin(angle) * radius, jumpamount, -Math.cos(angle) * radius));
}
}
if (this.mob.isOnGround()) {
this.mob.setBodyYaw((float) Math.random());
if (this.mob.getTongue() < 1) {
double d = 3;
List<SlimeEntity> slimes = this.mob.getWorld().getNonSpectatingEntities(SlimeEntity.class, box2);
// List<FireflyEntity> fireflies = this.mob.getWorld().getNonSpectatingEntities(FireflyEntity.class, box2);
List<GoatEntity> goats = this.mob.getWorld().getNonSpectatingEntities(GoatEntity.class, box2);
ArrayList<LivingEntity> allEntities = new ArrayList<>();
if (slimes.size() > 0) {
for (SlimeEntity target : slimes) {
if (target.getSize() == 1) {
allEntities.add(target);
}
}
}
// allEntities.addAll(fireflies);
LivingEntity chosen = this.mob.getWorld().getClosestEntity(allEntities, TargetPredicate.DEFAULT, this.mob, this.mob.getX(), this.mob.getY(), this.mob.getZ());
if (chosen != null) {
this.mob.getNavigation().startMovingTo(chosen, 1.8);
}
}
}
if (Math.random() < 0.025) {
double jumpamount = Math.random() / 2;
if (jumpamount < 0.25) {
jumpamount = 0.25;
}
if (Math.random() < 0.25) {
// RANDOM JUMP
double angle = Math.random() * 360;
double radius = Math.random() * 0.3;
this.mob.updateVelocity(2F, new Vec3d(-Math.sin(angle) * radius, jumpamount, -Math.cos(angle) * radius));
this.mob.getLookControl().lookAt(new Vec3d(-Math.sin(angle) * radius, jumpamount, -Math.cos(angle) * radius));
this.mob.playSound(RegisterSounds.ENTITY_FROG_LONG_JUMP, 1.0f, 1.0f);
} else {
// LILYPAD/DRIPLEAF JUMP
double result;
int radius = 5;
BlockPos targetPos = null;
ArrayList<BlockPos> targetList = Sphere.checkSpherePos(Blocks.LILY_PAD.getDefaultState(), this.mob.getEntityWorld(), this.mob.getBlockPos(), radius, true);
ArrayList<BlockPos> northDripleafList = Sphere.checkSpherePos(Blocks.BIG_DRIPLEAF.getDefaultState().with(BigDripleafBlock.FACING, Direction.NORTH), this.mob.getEntityWorld(), this.mob.getBlockPos(), radius, true);
ArrayList<BlockPos> southDripleafList = Sphere.checkSpherePos(Blocks.BIG_DRIPLEAF.getDefaultState().with(BigDripleafBlock.FACING, Direction.SOUTH), this.mob.getEntityWorld(), this.mob.getBlockPos(), radius, true);
ArrayList<BlockPos> eastDripleafList = Sphere.checkSpherePos(Blocks.BIG_DRIPLEAF.getDefaultState().with(BigDripleafBlock.FACING, Direction.EAST), this.mob.getEntityWorld(), this.mob.getBlockPos(), radius, true);
ArrayList<BlockPos> westDripleafList = Sphere.checkSpherePos(Blocks.BIG_DRIPLEAF.getDefaultState().with(BigDripleafBlock.FACING, Direction.WEST), this.mob.getEntityWorld(), this.mob.getBlockPos(), radius, true);
targetList.addAll(northDripleafList);
targetList.addAll(southDripleafList);
targetList.addAll(eastDripleafList);
targetList.addAll(westDripleafList);
if (targetList.size() > 0) {
result = Math.round(Math.random() * (targetList.size() - 1));
targetPos = targetList.get((int) result);
}
if (!(targetPos == null)) {
double dx = targetPos.getX() - this.mob.getBlockPos().getX();
double dy = targetPos.getY() - this.mob.getBlockPos().getY();
double dz = targetPos.getZ() - this.mob.getBlockPos().getZ();
if (dy < 0) {
dy = 0;
}
if (Math.sqrt(dx * dx) > 0 || Math.sqrt(dz * dz) > 0) {
this.mob.updateVelocity(2F, new Vec3d(dx / 10, jumpamount + dy / 10, dz / 10));
this.mob.playSound(RegisterSounds.ENTITY_FROG_LONG_JUMP, 1.0f, 1.0f);
}
}
}
}
/*List<FireflyEntity> list = world.getNonSpectatingEntities(FireflyEntity.class, box2);
if (list.size() > 0) {
if (world.getTime()-this.mob.eatTimer>=50 && this.mob.getBlockPos().getSquaredDistance(list.get(0).getBlockPos())<=6) {
FireflyEntity target = list.get(0);
world.sendEntityStatus(this.mob, (byte) 4);
target.teleport(this.mob.getX(), this.mob.getY(), this.mob.getZ());
target.setInvulnerable(true);
this.mob.playSound(RegisterSounds.ENTITY_FROG_TONGUE, 1.0F, 1.0F);
this.mob.targetRemoveTimer=10;
this.mob.targetID=target.getId();
this.mob.eatTimer = world.getTime();
}
}*/
List<GoatEntity> goatlist = world.getNonSpectatingEntities(GoatEntity.class, box2);
String string = Formatting.strip(this.mob.getName().getString());
if ("Osmiooo".equals(string)) {
if (goatlist.size() > 0) {
for (GoatEntity target : goatlist) {
if (world.getTime() - this.mob.eatTimer >= 50 && this.mob.getBlockPos().getSquaredDistance(target.getBlockPos()) <= 6) {
world.sendEntityStatus(this.mob, (byte) 4);
target.teleport(this.mob.getX(), this.mob.getY(), this.mob.getZ());
target.setInvulnerable(true);
this.mob.playSound(RegisterSounds.ENTITY_FROG_TONGUE, 1.0F, 1.0F);
this.mob.targetRemoveTimer = 10;
this.mob.targetID = target.getId();
this.mob.eatTimer = world.getTime();
}
}
}
}
List<SlimeEntity> slimelist = world.getNonSpectatingEntities(SlimeEntity.class, box2);
if (slimelist.size() > 0) {
for (SlimeEntity target : slimelist) {
if (target.getSize() == 1 && target.getType() != EntityType.MAGMA_CUBE && target.isAlive()) {
if (world.getTime() - this.mob.eatTimer >= 50 && this.mob.getBlockPos().getSquaredDistance(target.getBlockPos()) <= 6) {
world.sendEntityStatus(this.mob, (byte) 4);
target.teleport(this.mob.getX(), this.mob.getY(), this.mob.getZ());
target.setInvulnerable(true);
this.mob.playSound(RegisterSounds.ENTITY_FROG_TONGUE, 1.0F, 1.0F);
this.mob.targetRemoveTimer = 10;
this.mob.targetID = target.getId();
this.mob.eatTimer = world.getTime();
}
}
}
}
List<MagmaCubeEntity> magmalist = world.getNonSpectatingEntities(MagmaCubeEntity.class, box2);
if (magmalist.size() > 0) {
for (MagmaCubeEntity target : magmalist) {
if (target.getSize() == 1 && target.isAlive()) {
if (world.getTime() - this.mob.eatTimer >= 50 && this.mob.getBlockPos().getSquaredDistance(target.getBlockPos()) <= 6) {
world.sendEntityStatus(this.mob, (byte) 4);
target.teleport(this.mob.getX(), this.mob.getY(), this.mob.getZ());
target.setInvulnerable(true);
this.mob.playSound(RegisterSounds.ENTITY_FROG_TONGUE, 1.0F, 1.0F);
this.mob.targetRemoveTimer = 10;
this.mob.targetID = target.getId();
this.mob.eatTimer = world.getTime();
}
}
}
}
}
use of net.minecraft.entity.mob.SlimeEntity in project Biome-Makeover by Lemonszz.
the class GiantSlimeEntity method remove.
public void remove() {
int size = this.getSize();
if (!this.world.isClient && size > 1 && this.isDead()) {
Text text = this.getCustomName();
boolean hasDisabledAI = this.isAiDisabled();
DecayedEntity decayed = BMEntities.DECAYED.create(this.world);
if (this.isPersistent()) {
decayed.setPersistent();
}
decayed.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.AIR));
decayed.equipStack(EquipmentSlot.OFFHAND, new ItemStack(Items.AIR));
decayed.setCustomName(text);
decayed.setAiDisabled(hasDisabledAI);
decayed.setInvulnerable(this.isInvulnerable());
decayed.refreshPositionAndAngles(this.getX(), this.getY() + 0.5D, this.getZ(), yaw, pitch);
this.world.spawnEntity(decayed);
}
if (!this.world.isClient && size > 1 && this.isDead()) {
Text text = this.getCustomName();
boolean bl = this.isAiDisabled();
float quarterSize = (float) size / 4.0F;
int halfSize = size / 2;
int count = 2 + this.random.nextInt(3);
for (int in = 0; in < count; ++in) {
float offsetX = ((float) (in % 2) - 0.5F) * quarterSize;
float offsetY = ((float) (in / 2) - 0.5F) * quarterSize;
SlimeEntity slimeEntity = EntityType.SLIME.create(this.world);
if (this.isPersistent()) {
slimeEntity.setPersistent();
}
slimeEntity.setCustomName(text);
slimeEntity.setAiDisabled(bl);
slimeEntity.setInvulnerable(this.isInvulnerable());
((SlimeEntityAccess) slimeEntity).bm_setSlimeSize(halfSize, true);
slimeEntity.refreshPositionAndAngles(this.getX() + (double) offsetX, this.getY() + 0.5D, this.getZ() + (double) offsetY, this.random.nextFloat() * 360.0F, 0.0F);
this.world.spawnEntity(slimeEntity);
}
}
this.removed = true;
}
Aggregations