mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Apply the same to Living<T>
This commit is contained in:
parent
34b9a54487
commit
bf5649a966
10 changed files with 21 additions and 27 deletions
|
@ -75,7 +75,7 @@ public class WorldRenderDelegate {
|
|||
|
||||
if (!recurseMinion && pony instanceof Creature creature && creature.isMinion()) {
|
||||
recurseMinion = true;
|
||||
dispatcher.render(creature.getEntity(), x, y, z, yaw, tickDelta, matrices, layer -> {
|
||||
dispatcher.render(creature.asEntity(), x, y, z, yaw, tickDelta, matrices, layer -> {
|
||||
return PassThroughVertexConsumer.of(vertices.getBuffer(layer), MINION_OVERLAY);
|
||||
}, light);
|
||||
recurseMinion = false;
|
||||
|
@ -106,7 +106,7 @@ public class WorldRenderDelegate {
|
|||
|
||||
matrices.push();
|
||||
|
||||
Entity owner = pony.getEntity();
|
||||
Entity owner = pony.asEntity();
|
||||
|
||||
boolean negative = pony.getPhysics().isGravityNegative();
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class MagicAuraSoundInstance extends FadeOutSoundInstance {
|
|||
y = pos.y;
|
||||
z = pos.z;
|
||||
|
||||
if (!living.getEntity().isRemoved() && data.isPresent()) {
|
||||
if (!living.asEntity().isRemoved() && data.isPresent()) {
|
||||
float level = data.get().level;
|
||||
if (level != targetVolume) {
|
||||
setTargetVolume(level);
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.minelittlepony.unicopia.entity.ai.DynamicTargetGoal;
|
|||
import com.minelittlepony.unicopia.entity.ai.EatMuffinGoal;
|
||||
import com.minelittlepony.unicopia.entity.ai.WantItTakeItGoal;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.entity.ai.goal.*;
|
||||
|
@ -94,11 +93,6 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
|
|||
return master;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Optional<GoalSelector> getTargets() {
|
||||
return Optional.ofNullable(targets);
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ import java.util.*;
|
|||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.Copyable;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
@ -72,10 +72,10 @@ public class ItemTracker implements NbtSerialisable, Copyable<ItemTracker> {
|
|||
return false;
|
||||
});
|
||||
|
||||
if (!(living.getEntity() instanceof PlayerEntity)) {
|
||||
if (!(living instanceof Pony)) {
|
||||
foundStacks.forEach(stack -> {
|
||||
if (getTicks((Trackable)stack.getItem()) == 1) {
|
||||
stack.inventoryTick(living.getReferenceWorld(), living.getEntity(), 0, false);
|
||||
stack.inventoryTick(living.getReferenceWorld(), living.asEntity(), 0, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -109,6 +109,15 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
return asEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use asEntity()
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Override
|
||||
public final Entity getEntity() {
|
||||
return asEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T asEntity() {
|
||||
return entity;
|
||||
|
@ -121,7 +130,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
try {
|
||||
getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.world.isClient);
|
||||
} catch (Exception e) {
|
||||
Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", getEntity(), e);
|
||||
Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", entity, e);
|
||||
}
|
||||
|
||||
if (invinsibilityTicks > 0) {
|
||||
|
|
|
@ -288,15 +288,6 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
return interpolator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use asEntity()
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Override
|
||||
public final Entity getEntity() {
|
||||
return asEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use asEntity()
|
||||
*/
|
||||
|
|
|
@ -110,7 +110,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
|||
|
||||
@Override
|
||||
public void onEquipped(Living<?> wearer) {
|
||||
wearer.getReferenceWorld().playSound(null, wearer.getOrigin(), USounds.ITEM_ALICORN_AMULET_CURSE, wearer.getEntity().getSoundCategory(), 3, 1);
|
||||
wearer.playSound(USounds.ITEM_ALICORN_AMULET_CURSE, 3, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,7 @@ public class GemFindingEnchantment extends SimpleEnchantment {
|
|||
@Override
|
||||
public void onEquipped(Living<?> user) {
|
||||
if (user.isClient()) {
|
||||
MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.getEntity().getSoundCategory(), user, user.getReferenceWorld().getRandom()));
|
||||
MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.asEntity().getSoundCategory(), user, user.getReferenceWorld().getRandom()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi
|
|||
return;
|
||||
}
|
||||
|
||||
int light = user.getReferenceWorld().getLightLevel(user.getEntity().getRootVehicle().getBlockPos());
|
||||
int light = user.getReferenceWorld().getLightLevel(user.asEntity().getRootVehicle().getBlockPos());
|
||||
Random rng = user.getReferenceWorld().random;
|
||||
Data data = user.getEnchants().computeIfAbsent(this, Data::new);
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi
|
|||
|
||||
user.getReferenceWorld().playSoundFromEntity(
|
||||
null,
|
||||
user.getEntity(),
|
||||
user.asEntity(),
|
||||
sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE,
|
||||
0.5F + rng.nextFloat() * 0.5F,
|
||||
0.5F + rng.nextFloat() * 0.5F
|
||||
|
|
|
@ -17,7 +17,7 @@ public class WantItNeedItEnchantment extends SimpleEnchantment {
|
|||
@Override
|
||||
public void onUserTick(Living<?> user, int level) {
|
||||
if (user instanceof Creature && user.getReferenceWorld().random.nextInt(10) == 0) {
|
||||
ParticleUtils.spawnParticles(new FollowingParticleEffect(UParticles.HEALTH_DRAIN, user.getEntity(), 0.2F), user.getEntity(), 1);
|
||||
ParticleUtils.spawnParticles(new FollowingParticleEffect(UParticles.HEALTH_DRAIN, user.asEntity(), 0.2F), user.asEntity(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue