mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +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()) {
|
if (!recurseMinion && pony instanceof Creature creature && creature.isMinion()) {
|
||||||
recurseMinion = true;
|
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);
|
return PassThroughVertexConsumer.of(vertices.getBuffer(layer), MINION_OVERLAY);
|
||||||
}, light);
|
}, light);
|
||||||
recurseMinion = false;
|
recurseMinion = false;
|
||||||
|
@ -106,7 +106,7 @@ public class WorldRenderDelegate {
|
||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
Entity owner = pony.getEntity();
|
Entity owner = pony.asEntity();
|
||||||
|
|
||||||
boolean negative = pony.getPhysics().isGravityNegative();
|
boolean negative = pony.getPhysics().isGravityNegative();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class MagicAuraSoundInstance extends FadeOutSoundInstance {
|
||||||
y = pos.y;
|
y = pos.y;
|
||||||
z = pos.z;
|
z = pos.z;
|
||||||
|
|
||||||
if (!living.getEntity().isRemoved() && data.isPresent()) {
|
if (!living.asEntity().isRemoved() && data.isPresent()) {
|
||||||
float level = data.get().level;
|
float level = data.get().level;
|
||||||
if (level != targetVolume) {
|
if (level != targetVolume) {
|
||||||
setTargetVolume(level);
|
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.EatMuffinGoal;
|
||||||
import com.minelittlepony.unicopia.entity.ai.WantItTakeItGoal;
|
import com.minelittlepony.unicopia.entity.ai.WantItTakeItGoal;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.SpawnGroup;
|
import net.minecraft.entity.SpawnGroup;
|
||||||
import net.minecraft.entity.ai.goal.*;
|
import net.minecraft.entity.ai.goal.*;
|
||||||
|
@ -94,11 +93,6 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
|
||||||
return master;
|
return master;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Entity getEntity() {
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<GoalSelector> getTargets() {
|
public Optional<GoalSelector> getTargets() {
|
||||||
return Optional.ofNullable(targets);
|
return Optional.ofNullable(targets);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ import java.util.*;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.util.Copyable;
|
import com.minelittlepony.unicopia.util.Copyable;
|
||||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemConvertible;
|
import net.minecraft.item.ItemConvertible;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
@ -72,10 +72,10 @@ public class ItemTracker implements NbtSerialisable, Copyable<ItemTracker> {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!(living.getEntity() instanceof PlayerEntity)) {
|
if (!(living instanceof Pony)) {
|
||||||
foundStacks.forEach(stack -> {
|
foundStacks.forEach(stack -> {
|
||||||
if (getTicks((Trackable)stack.getItem()) == 1) {
|
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();
|
return asEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use asEntity()
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
|
@Override
|
||||||
|
public final Entity getEntity() {
|
||||||
|
return asEntity();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final T asEntity() {
|
public final T asEntity() {
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -121,7 +130,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
try {
|
try {
|
||||||
getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.world.isClient);
|
getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.world.isClient);
|
||||||
} catch (Exception e) {
|
} 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) {
|
if (invinsibilityTicks > 0) {
|
||||||
|
|
|
@ -288,15 +288,6 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
return interpolator;
|
return interpolator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use asEntity()
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Override
|
|
||||||
public final Entity getEntity() {
|
|
||||||
return asEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use asEntity()
|
* @deprecated use asEntity()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEquipped(Living<?> wearer) {
|
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
|
@Override
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class GemFindingEnchantment extends SimpleEnchantment {
|
||||||
@Override
|
@Override
|
||||||
public void onEquipped(Living<?> user) {
|
public void onEquipped(Living<?> user) {
|
||||||
if (user.isClient()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int light = user.getReferenceWorld().getLightLevel(user.getEntity().getRootVehicle().getBlockPos());
|
int light = user.getReferenceWorld().getLightLevel(user.asEntity().getRootVehicle().getBlockPos());
|
||||||
Random rng = user.getReferenceWorld().random;
|
Random rng = user.getReferenceWorld().random;
|
||||||
Data data = user.getEnchants().computeIfAbsent(this, Data::new);
|
Data data = user.getEnchants().computeIfAbsent(this, Data::new);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi
|
||||||
|
|
||||||
user.getReferenceWorld().playSoundFromEntity(
|
user.getReferenceWorld().playSoundFromEntity(
|
||||||
null,
|
null,
|
||||||
user.getEntity(),
|
user.asEntity(),
|
||||||
sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE,
|
sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE,
|
||||||
0.5F + rng.nextFloat() * 0.5F,
|
0.5F + rng.nextFloat() * 0.5F,
|
||||||
0.5F + rng.nextFloat() * 0.5F
|
0.5F + rng.nextFloat() * 0.5F
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class WantItNeedItEnchantment extends SimpleEnchantment {
|
||||||
@Override
|
@Override
|
||||||
public void onUserTick(Living<?> user, int level) {
|
public void onUserTick(Living<?> user, int level) {
|
||||||
if (user instanceof Creature && user.getReferenceWorld().random.nextInt(10) == 0) {
|
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