2020-07-22 06:23:34 +01:00
|
|
|
package net.minecraft.world.entity.animal;
|
|
|
|
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
|
|
import net.minecraft.world.level.Level;
|
|
|
|
import net.minecraft.world.entity.EntityType;
|
|
|
|
import net.minecraft.world.entity.TamableAnimal;
|
|
|
|
|
|
|
|
public abstract class ShoulderRidingEntity extends TamableAnimal {
|
|
|
|
private int rideCooldownCounter;
|
|
|
|
|
2020-07-22 06:25:47 +01:00
|
|
|
protected ShoulderRidingEntity(final EntityType<? extends ShoulderRidingEntity> akr, final Level bjt) {
|
|
|
|
super(akr, bjt);
|
2020-07-22 06:23:34 +01:00
|
|
|
}
|
|
|
|
|
2020-07-22 06:25:47 +01:00
|
|
|
public boolean setEntityOnShoulder(final ServerPlayer xe) {
|
|
|
|
final CompoundTag jt3 = new CompoundTag();
|
|
|
|
jt3.putString("id", this.getEncodeId());
|
|
|
|
this.saveWithoutId(jt3);
|
|
|
|
if (xe.setEntityOnShoulder(jt3)) {
|
2020-07-22 06:23:34 +01:00
|
|
|
this.remove();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void tick() {
|
|
|
|
++this.rideCooldownCounter;
|
|
|
|
super.tick();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canSitOnShoulder() {
|
|
|
|
return this.rideCooldownCounter > 100;
|
|
|
|
}
|
|
|
|
}
|