-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec65fa5
commit 413ee7c
Showing
65 changed files
with
1,476 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/net/dakotapride/hibernalherbs/effect/InstabilityStatusEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package net.dakotapride.hibernalherbs.effect; | ||
|
||
import net.dakotapride.hibernalherbs.init.ParticleTypeInit; | ||
import net.minecraft.core.particles.ParticleOptions; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.animal.Fox; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.gameevent.GameEvent; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class InstabilityStatusEffect extends BasicStatusEffect { | ||
public InstabilityStatusEffect(MobEffectCategory category, int colour) { | ||
super(category, colour); | ||
} | ||
|
||
@Override | ||
public @NotNull ParticleOptions createParticleOptions(@NotNull MobEffectInstance effect) { | ||
return ParticleTypeInit.INSTABILITY.get(); | ||
} | ||
|
||
@Override | ||
public boolean applyEffectTick(LivingEntity livingEntity, int j) { | ||
Level level = livingEntity.level(); | ||
|
||
if (!level.isClientSide) { | ||
for (int i = 0; i < 16; i++) { | ||
double d = livingEntity.getX() + (livingEntity.getRandom().nextDouble() - 0.5) * 16.0; | ||
double e = Mth.clamp( | ||
livingEntity.getY() + (double)(livingEntity.getRandom().nextInt(16) - 8), | ||
level.getMinBuildHeight(), | ||
(level.getMinBuildHeight() + ((ServerLevel)level).getLogicalHeight() - 1) | ||
); | ||
double f = livingEntity.getZ() + (livingEntity.getRandom().nextDouble() - 0.5) * 16.0; | ||
if (livingEntity.isPassenger()) { | ||
livingEntity.stopRiding(); | ||
} | ||
|
||
Vec3 vec3 = livingEntity.position(); | ||
if (livingEntity.randomTeleport(d, e, f, true)) { | ||
level.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(livingEntity)); | ||
SoundSource soundSource; | ||
SoundEvent soundEvent; | ||
if (livingEntity instanceof Fox) { | ||
soundEvent = SoundEvents.FOX_TELEPORT; | ||
soundSource = SoundSource.NEUTRAL; | ||
} else { | ||
soundEvent = SoundEvents.CHORUS_FRUIT_TELEPORT; | ||
soundSource = SoundSource.PLAYERS; | ||
} | ||
|
||
level.playSound(null, livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), soundEvent, soundSource); | ||
livingEntity.resetFallDistance(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyEffectTickThisTick(int i, int j) { | ||
int k = 50 >> j; | ||
return k > 0 ? i % k == 0 : true; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/net/dakotapride/hibernalherbs/effect/ShriekingStatusEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package net.dakotapride.hibernalherbs.effect; | ||
|
||
import net.dakotapride.hibernalherbs.init.ParticleTypeInit; | ||
import net.minecraft.core.particles.ParticleOptions; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.util.SpawnUtil; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.MobSpawnType; | ||
import net.minecraft.world.entity.monster.warden.Warden; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.joml.Vector3f; | ||
|
||
public class ShriekingStatusEffect extends BasicStatusEffect { | ||
private final float chanceToSpawn; | ||
|
||
public ShriekingStatusEffect(MobEffectCategory mobEffectCategory, int i, float f) { | ||
super(mobEffectCategory, i); | ||
this.chanceToSpawn = f; | ||
} | ||
|
||
@Override | ||
public @NotNull ParticleOptions createParticleOptions(@NotNull MobEffectInstance effect) { | ||
return ParticleTypeInit.SHRIEKING.get(); | ||
} | ||
|
||
@Override | ||
public void onMobHurt(LivingEntity livingEntity, int i, DamageSource damageSource, float f) { | ||
if (livingEntity.getRandom().nextFloat() <= this.chanceToSpawn) { | ||
this.spawnWarden( | ||
livingEntity.level(), livingEntity, livingEntity.getX(), livingEntity.getY() + (double)livingEntity.getBbHeight() / 2.0, livingEntity.getZ() | ||
); | ||
} | ||
} | ||
|
||
private void spawnWarden(Level level, LivingEntity livingEntity, double d, double e, double f) { | ||
Warden warden = EntityType.WARDEN.create(level); | ||
if (warden != null) { | ||
//warden.setAggressive(true); | ||
//warden.setTarget(livingEntity); | ||
//SpawnUtil.trySpawnMob(EntityType.WARDEN, MobSpawnType.TRIGGERED, serverLevel, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER) | ||
RandomSource randomSource = livingEntity.getRandom(); | ||
float g = (float) (Math.PI / 2); | ||
float h = Mth.randomBetween(randomSource, (float) (-Math.PI / 2), (float) (Math.PI / 2)); | ||
Vector3f vector3f = livingEntity.getLookAngle().toVector3f().mul(0.3F).mul(1.0F, 1.5F, 1.0F).rotateY(h); | ||
warden.moveTo(d, e, f, level.getRandom().nextFloat() * 360.0F, 0.0F); | ||
warden.setDeltaMovement(new Vec3(vector3f)); | ||
//level.addFreshEntity(warden); | ||
if (level instanceof ServerLevel serverLevel) | ||
SpawnUtil.trySpawnMob(EntityType.WARDEN, MobSpawnType.TRIGGERED, serverLevel, livingEntity.blockPosition(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER); | ||
warden.playSound(SoundEvents.WARDEN_HURT); | ||
} | ||
} | ||
} |
Oops, something went wrong.