mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17: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 net.minecraft.entity.mob.CreeperEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class CreeperBehaviour extends EntityBehaviour<CreeperEntity> {
|
||||
@Override
|
||||
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);
|
||||
} else {
|
||||
entity.setFuseSpeed(-1);
|
||||
entity.setTarget(null);
|
||||
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.prevHorizontalSpeed = from.prevHorizontalSpeed;
|
||||
to.setOnGround(from.isOnGround());
|
||||
to.setInvulnerable(from.isInvulnerable() || (from instanceof PlayerEntity && ((PlayerEntity)from).getAbilities().creativeMode));
|
||||
|
||||
to.distanceTraveled = from.distanceTraveled;
|
||||
|
||||
|
@ -248,7 +249,7 @@ public class EntityBehaviour<T extends Entity> {
|
|||
|
||||
protected boolean isSneakingOnGround(Caster<?> source) {
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue