mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Fixed the shotgun creeper bug
This commit is contained in:
parent
82a315510e
commit
bf84d19722
2 changed files with 21 additions and 2 deletions
|
@ -4,16 +4,34 @@ import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
||||||
|
|
||||||
import net.minecraft.entity.mob.CreeperEntity;
|
import net.minecraft.entity.mob.CreeperEntity;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class CreeperBehaviour extends EntityBehaviour<CreeperEntity> {
|
public class CreeperBehaviour extends EntityBehaviour<CreeperEntity> {
|
||||||
@Override
|
@Override
|
||||||
public void update(Caster<?> source, CreeperEntity entity, DisguiseSpell spell) {
|
public void update(Caster<?> source, CreeperEntity entity, DisguiseSpell spell) {
|
||||||
if (isSneakingOnGround(source)) {
|
int fuseCountDown = spell.getDisguise().getOrCreateTag().getInt("fuseCountdown");
|
||||||
|
|
||||||
|
boolean trigger = isSneakingOnGround(source);
|
||||||
|
|
||||||
|
if (trigger) {
|
||||||
|
fuseCountDown++;
|
||||||
|
} else if (fuseCountDown > 0) {
|
||||||
|
fuseCountDown--;
|
||||||
|
}
|
||||||
|
|
||||||
|
int max = source.isClient() ? 90 : 30;
|
||||||
|
|
||||||
|
fuseCountDown = MathHelper.clamp(fuseCountDown, 0, max + 1);
|
||||||
|
|
||||||
|
if (fuseCountDown <= max && trigger) {
|
||||||
entity.setFuseSpeed(1);
|
entity.setFuseSpeed(1);
|
||||||
} else {
|
} else {
|
||||||
entity.setFuseSpeed(-1);
|
entity.setFuseSpeed(-1);
|
||||||
entity.setTarget(null);
|
entity.setTarget(null);
|
||||||
entity.getVisibilityCache().clear();
|
entity.getVisibilityCache().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println(fuseCountDown);
|
||||||
|
spell.getDisguise().getOrCreateTag().putInt("fuseCountdown", fuseCountDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,7 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
to.horizontalSpeed = from.horizontalSpeed;
|
to.horizontalSpeed = from.horizontalSpeed;
|
||||||
to.prevHorizontalSpeed = from.prevHorizontalSpeed;
|
to.prevHorizontalSpeed = from.prevHorizontalSpeed;
|
||||||
to.setOnGround(from.isOnGround());
|
to.setOnGround(from.isOnGround());
|
||||||
|
to.setInvulnerable(from.isInvulnerable() || (from instanceof PlayerEntity && ((PlayerEntity)from).getAbilities().creativeMode));
|
||||||
|
|
||||||
to.distanceTraveled = from.distanceTraveled;
|
to.distanceTraveled = from.distanceTraveled;
|
||||||
|
|
||||||
|
@ -248,7 +249,7 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
|
|
||||||
protected boolean isSneakingOnGround(Caster<?> source) {
|
protected boolean isSneakingOnGround(Caster<?> source) {
|
||||||
Entity e = source.getEntity();
|
Entity e = source.getEntity();
|
||||||
return e.isSneaking() && (e.isOnGround() || !(e instanceof PlayerEntity && ((PlayerEntity)e).getAbilities().flying));
|
return e.isSneaking() && (e.isOnGround() && !(e instanceof PlayerEntity && ((PlayerEntity)e).getAbilities().flying));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Entity> void register(Supplier<EntityBehaviour<T>> behaviour, EntityType<?>... types) {
|
public static <T extends Entity> void register(Supplier<EntityBehaviour<T>> behaviour, EntityType<?>... types) {
|
||||||
|
|
Loading…
Reference in a new issue