More cleanup, more naming changes

This commit is contained in:
Sollace 2020-04-15 18:12:00 +02:00
parent db5f0a5544
commit 00972d4b91
143 changed files with 850 additions and 885 deletions

View file

@ -21,11 +21,11 @@ public class Config {
.setPrettyPrinting()
.create();
public static Config instance() {
public static Config getInstance() {
return instance;
}
public static void init(Path directory) {
static void init(Path directory) {
Path file = directory.resolve("unicopia.json");
try {

View file

@ -1,6 +1,8 @@
package com.minelittlepony.unicopia;
import com.google.common.base.Predicate;
import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
@ -8,11 +10,11 @@ import net.minecraft.entity.player.PlayerEntity;
public interface EquinePredicates {
Predicate<PlayerEntity> INTERACT_WITH_CLOUDS = player -> {
return player != null && SpeciesList.instance().getPlayer(player).getSpecies().canInteractWithClouds();
return player != null && Pony.of(player).getSpecies().canInteractWithClouds();
};
Predicate<Entity> MAGI = entity -> {
return entity instanceof PlayerEntity && SpeciesList.instance().getPlayer((PlayerEntity)entity).getSpecies().canCast();
return entity instanceof PlayerEntity && Pony.of((PlayerEntity)entity).getSpecies().canCast();
};
Predicate<Entity> ITEMS = entity -> {
@ -20,7 +22,7 @@ public interface EquinePredicates {
};
Predicate<ItemEntity> ITEM_INTERACT_WITH_CLOUDS = item -> {
return ITEMS.test(item) && SpeciesList.instance().getEntity(item).getSpecies().canInteractWithClouds();
return ITEMS.test(item) && Ponylike.of(item).getSpecies().canInteractWithClouds();
};
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = entity -> {
@ -32,7 +34,7 @@ public interface EquinePredicates {
Predicate<Entity> BUGGY = entity -> {
return entity instanceof PlayerEntity
&& SpeciesList.instance().getPlayer((PlayerEntity)entity).getSpecies() == Race.CHANGELING;
&& Pony.of((PlayerEntity)entity).getSpecies() == Race.CHANGELING;
};
static PlayerEntity getPlayerFromEntity(Entity entity) {

View file

@ -5,6 +5,8 @@ import java.util.Map;
import com.google.common.base.Strings;
import net.minecraft.entity.player.PlayerEntity;
public enum Race {
/**
* The default, unset race.
@ -66,6 +68,28 @@ public enum Race {
return String.format("unicopia.race.%s", name().toLowerCase());
}
public boolean isPermitted(PlayerEntity sender) {
if (isOp() && (sender == null || !sender.abilities.creativeMode)) {
return false;
}
return isDefault() || Config.getInstance().getSpeciesWhiteList().isEmpty() || Config.getInstance().getSpeciesWhiteList().contains(this);
}
public Race validate(PlayerEntity sender) {
if (!isPermitted(sender)) {
if (this == EARTH) {
return HUMAN;
}
return EARTH.validate(sender);
}
return this;
}
public boolean equals(String s) {
return name().equalsIgnoreCase(s)
|| getTranslationKey().equalsIgnoreCase(s);

View file

@ -1,77 +0,0 @@
package com.minelittlepony.unicopia;
import java.util.Optional;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Config;
import com.minelittlepony.unicopia.ducks.RaceContainerHolder;
import com.minelittlepony.unicopia.entity.IEntity;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
public class SpeciesList {
private static final SpeciesList instance = new SpeciesList();
public static SpeciesList instance() {
return instance;
}
public boolean whiteListRace(Race race) {
boolean result = Config.instance().getSpeciesWhiteList().add(race);
Config.instance().save();
return result;
}
public boolean unwhiteListRace(Race race) {
boolean result = Config.instance().getSpeciesWhiteList().remove(race);
Config.instance().save();
return result;
}
public boolean speciesPermitted(Race race, PlayerEntity sender) {
if (race.isOp() && (sender == null || !sender.abilities.creativeMode)) {
return false;
}
return race.isDefault() || Config.instance().getSpeciesWhiteList().isEmpty() || Config.instance().getSpeciesWhiteList().contains(race);
}
public Race validate(Race race, PlayerEntity sender) {
if (!speciesPermitted(race, sender)) {
race = Race.EARTH;
if (!speciesPermitted(race, sender)) {
race = Race.HUMAN;
}
}
return race;
}
@Nullable
public IPlayer getPlayer(@Nullable PlayerEntity player) {
return this.<IPlayer>getEntity(player);
}
@Nullable
public <T extends IEntity> T getEntity(Entity entity) {
return this.<Entity, T>getForEntity(entity)
.map(RaceContainerHolder::getRaceContainer)
.orElse(null);
}
@SuppressWarnings("unchecked")
public <E extends Entity, T extends IEntity> Optional<RaceContainerHolder<T>> getForEntity(Entity entity) {
if (entity instanceof RaceContainerHolder) {
return Optional.of(((RaceContainerHolder<T>)entity));
}
return Optional.empty();
}
}

View file

@ -5,7 +5,7 @@ import javax.annotation.Nullable;
import com.google.gson.annotations.Expose;
import com.minelittlepony.unicopia.IKeyBinding;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -20,12 +20,12 @@ public interface Ability<T extends Ability.IData> extends IKeyBinding {
/**
* Returns the number of ticks the player must hold the ability key to trigger this ability.
*/
int getWarmupTime(IPlayer player);
int getWarmupTime(Pony player);
/**
* Returns the number of ticks allowed for cooldown
*/
int getCooldownTime(IPlayer player);
int getCooldownTime(Pony player);
/**
* Called to check preconditions for activating the ability.
@ -34,7 +34,7 @@ public interface Ability<T extends Ability.IData> extends IKeyBinding {
* @param player The player
* @return True to allow activation
*/
default boolean canActivate(World w, IPlayer player) {
default boolean canActivate(World w, Pony player) {
return true;
}
@ -51,7 +51,7 @@ public interface Ability<T extends Ability.IData> extends IKeyBinding {
* @return Data to be sent, or null if activation failed
*/
@Nullable
T tryActivate(IPlayer player);
T tryActivate(Pony player);
Class<T> getPackageType();
@ -62,19 +62,19 @@ public interface Ability<T extends Ability.IData> extends IKeyBinding {
* @param player The player that triggered the ability
* @param data Data previously sent from the client
*/
void apply(IPlayer player, T data);
void apply(Pony player, T data);
/**
* Called every tick until the warmup timer runs out.
* @param player The current player
*/
void preApply(IPlayer player);
void preApply(Pony player);
/**
* Called every tick until the cooldown timer runs out.
* @param player The current player
*/
void postApply(IPlayer player);
void postApply(Pony player);
public interface IData {

View file

@ -6,10 +6,9 @@ import javax.annotation.Nullable;
import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.entity.InAnimate;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.util.VecHelper;
@ -42,12 +41,12 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
@Nullable
@Override
public Hit tryActivate(IPlayer player) {
public Hit tryActivate(Pony player) {
return new Hit();
}
@Override
public void apply(IPlayer iplayer, Hit data) {
public void apply(Pony iplayer, Hit data) {
PlayerEntity player = iplayer.getOwner();
HitResult trace = VecHelper.getObjectMouseOver(player, 10, 1);
@ -65,7 +64,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
looked = ((EntityHitResult)trace).getEntity();
if (looked instanceof PlayerEntity) {
looked = SpeciesList.instance().getPlayer((PlayerEntity)looked)
looked = Pony.of((PlayerEntity)looked)
.getEffect(DisguiseSpell.class)
.map(DisguiseSpell::getDisguise)
.orElse(looked);
@ -90,13 +89,13 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
player.addEnergy(2);
player.spawnParticles(UParticles.CHANGELING_MAGIC, 5);
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
player.setEnergy(0);
player.spawnParticles(UParticles.CHANGELING_MAGIC, 5);
}

View file

@ -8,7 +8,7 @@ import javax.annotation.Nullable;
import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.VecHelper;
@ -41,12 +41,12 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 5;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return canFeed(player) ? 15 : 80;
}
@ -57,7 +57,7 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
@Nullable
@Override
public Hit tryActivate(IPlayer player) {
public Hit tryActivate(Pony player) {
if (canFeed(player)) {
if (!getTargets(player).isEmpty()) {
return new Hit();
@ -67,7 +67,7 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
return null;
}
private boolean canFeed(IPlayer player) {
private boolean canFeed(Pony player) {
return player.getOwner().getHealth() < player.getOwner().getHealthMaximum() || player.getOwner().canConsume(false);
}
@ -86,7 +86,7 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
return Hit.class;
}
protected List<LivingEntity> getTargets(IPlayer player) {
protected List<LivingEntity> getTargets(Pony player) {
List<Entity> list = VecHelper.getWithinRange(player.getOwner(), 3, this::canDrain);
Entity looked = VecHelper.getLookedAtEntity(player.getOwner(), 17);
@ -98,7 +98,7 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
}
@Override
public void apply(IPlayer iplayer, Hit data) {
public void apply(Pony iplayer, Hit data) {
PlayerEntity player = iplayer.getOwner();
float maximumHealthGain = player.getHealthMaximum() - player.getHealth();
@ -156,12 +156,12 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
player.addExertion(6);
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
player.spawnParticles(ParticleTypes.HEART, 1);
}
}

View file

@ -5,7 +5,7 @@ import javax.annotation.Nullable;
import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.ChangelingTrapSpell;
public class ChangelingTrapAbility implements Ability<Ability.Hit> {
@ -21,12 +21,12 @@ public class ChangelingTrapAbility implements Ability<Ability.Hit> {
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 0;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return 30;
}
@ -37,7 +37,7 @@ public class ChangelingTrapAbility implements Ability<Ability.Hit> {
@Nullable
@Override
public Hit tryActivate(IPlayer player) {
public Hit tryActivate(Pony player) {
return new Hit();
}
@ -47,17 +47,17 @@ public class ChangelingTrapAbility implements Ability<Ability.Hit> {
}
@Override
public void apply(IPlayer player, Hit data) {
public void apply(Pony player, Hit data) {
new ChangelingTrapSpell().toss(player);
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
}
}

View file

@ -4,7 +4,7 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.BlockState;
@ -33,12 +33,12 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 10;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return 50;
}
@ -48,7 +48,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
}
@Override
public Pos tryActivate(IPlayer player) {
public Pos tryActivate(Pony player) {
HitResult ray = VecHelper.getObjectMouseOver(player.getOwner(), 3, 1);
if (ray instanceof BlockHitResult && ray.getType() == HitResult.Type.BLOCK) {
@ -64,7 +64,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
}
@Override
public void apply(IPlayer player, Pos data) {
public void apply(Pony player, Pos data) {
int count = 0;
for (BlockPos pos : BlockPos.iterate(
@ -91,7 +91,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
player.addExertion(3);
if (player.getWorld().isClient()) {
@ -100,7 +100,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
}
}

View file

@ -7,15 +7,14 @@ import org.lwjgl.glfw.GLFW;
import com.google.common.collect.Lists;
import com.google.gson.annotations.Expose;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.AppleItem;
import com.minelittlepony.unicopia.util.AwaitTickQueue;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.WorldEvent;
import com.minelittlepony.unicopia.util.shape.IShape;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.block.Block;
@ -63,12 +62,12 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 3;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return 50;
}
@ -78,7 +77,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
}
@Override
public EarthPonyStompAbility.Data tryActivate(IPlayer player) {
public EarthPonyStompAbility.Data tryActivate(Pony player) {
HitResult mop = VecHelper.getObjectMouseOver(player.getOwner(), 6, 1);
if (mop instanceof BlockHitResult && mop.getType() == HitResult.Type.BLOCK) {
@ -118,7 +117,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
}
@Override
public void apply(IPlayer iplayer, Data data) {
public void apply(Pony iplayer, Data data) {
PlayerEntity player = iplayer.getOwner();
@ -143,7 +142,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
double amount = (4 * player.getAttributeInstance(EntityAttributes.ATTACK_DAMAGE).getValue()) / (float)dist;
if (i instanceof PlayerEntity) {
Race race = SpeciesList.instance().getPlayer((PlayerEntity)i).getSpecies();
Race race = Pony.of((PlayerEntity)i).getSpecies();
if (race.canUseEarth()) {
amount /= 3;
}
@ -203,13 +202,13 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
player.addExertion(40);
player.getOwner().attemptSprintingParticles();
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
int timeDiff = getCooldownTime(player) - player.getAbilities().getRemainingCooldown();
if (player.getOwner().getEntityWorld().getTime() % 1 == 0 || timeDiff == 0) {
@ -224,7 +223,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
private void spawnParticleRing(PlayerEntity player, int timeDiff, double yVel) {
int animationTicks = timeDiff / 10;
if (animationTicks < 6) {
IShape shape = new Sphere(true, animationTicks, 1, 0, 1);
Shape shape = new Sphere(true, animationTicks, 1, 0, 1);
double y = 0.5 + (Math.sin(animationTicks) * 1.5);

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
/**
* Predicate for abilities to control whether a player can fly.
@ -8,5 +8,5 @@ import com.minelittlepony.unicopia.entity.player.IPlayer;
* This overrides what the race specifies.
*/
public interface FlightPredicate {
boolean checkCanFly(IPlayer player);
boolean checkCanFly(Pony player);
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
/**
* Predicate for abilities to control what the player's physical height is.
@ -8,7 +8,7 @@ import com.minelittlepony.unicopia.entity.player.IPlayer;
* This overrides the default.
*/
public interface HeightPredicate {
float getTargetEyeHeight(IPlayer player);
float getTargetEyeHeight(Pony player);
float getTargetBodyHeight(IPlayer player);
float getTargetBodyHeight(Pony player);
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
@ -29,12 +29,12 @@ public class PegasusCarryAbility implements Ability<Ability.Hit> {
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 0;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return 10;
}
@ -44,7 +44,7 @@ public class PegasusCarryAbility implements Ability<Ability.Hit> {
}
@Override
public Hit tryActivate(IPlayer player) {
public Hit tryActivate(Pony player) {
return new Hit();
}
@ -66,7 +66,7 @@ public class PegasusCarryAbility implements Ability<Ability.Hit> {
}
@Override
public void apply(IPlayer iplayer, Hit data) {
public void apply(Pony iplayer, Hit data) {
PlayerEntity player = iplayer.getOwner();
LivingEntity rider = findRider(player, iplayer.getWorld());
@ -82,11 +82,11 @@ public class PegasusCarryAbility implements Ability<Ability.Hit> {
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
}
public interface IPickupImmuned {

View file

@ -6,7 +6,7 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.entity.Entity;
@ -24,12 +24,12 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 10;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return 5;
}
@ -39,7 +39,7 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
}
@Override
public Numeric tryActivate(IPlayer player) {
public Numeric tryActivate(Pony player) {
return findTarget(player).map(cloud -> {
Numeric data = new Numeric(player.getOwner().inventory.selectedSlot + 1);
cloud.handlePegasusInteration(data.type);
@ -54,13 +54,13 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
}
@Override
public void apply(IPlayer player, Numeric data) {
public void apply(Pony player, Numeric data) {
findTarget(player).ifPresent(cloud -> {
cloud.handlePegasusInteration(data.type);
});
}
protected Optional<ICloudEntity> findTarget(IPlayer player) {
protected Optional<ICloudEntity> findTarget(Pony player) {
if (player.getOwner().hasVehicle() && player.getOwner().getVehicle() instanceof ICloudEntity) {
return Optional.ofNullable((ICloudEntity)player.getOwner().getVehicle());
}
@ -75,12 +75,12 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 10);
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
player.spawnParticles(UParticles.RAIN_DROPS, 5);
}

View file

@ -4,7 +4,7 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.ShieldSpell;
/**
@ -24,12 +24,12 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 20;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return 0;
}
@ -39,7 +39,7 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
}
@Override
public Hit tryActivate(IPlayer player) {
public Hit tryActivate(Pony player) {
return new Hit();
}
@ -49,7 +49,7 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
}
@Override
public void apply(IPlayer player, Hit data) {
public void apply(Pony player, Hit data) {
// TODO: A way to pick the active effect
if (player.getEffect() instanceof ShieldSpell) {
player.setEffect(null);
@ -59,12 +59,12 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5);
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5);
}
}

View file

@ -4,7 +4,7 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.Block;
@ -40,12 +40,12 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
}
@Override
public int getWarmupTime(IPlayer player) {
public int getWarmupTime(Pony player) {
return 20;
}
@Override
public int getCooldownTime(IPlayer player) {
public int getCooldownTime(Pony player) {
return 50;
}
@ -55,7 +55,7 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
}
@Override
public Pos tryActivate(IPlayer player) {
public Pos tryActivate(Pony player) {
HitResult ray = VecHelper.getObjectMouseOver(player.getOwner(), 100, 1);
World w = player.getWorld();
@ -115,7 +115,7 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
}
@Override
public void apply(IPlayer iplayer, Pos data) {
public void apply(Pony iplayer, Pos data) {
iplayer.getWorld().playSound(null, iplayer.getOrigin(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 1, 1);
PlayerEntity player = iplayer.getOwner();
@ -164,13 +164,13 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
}
@Override
public void preApply(IPlayer player) {
public void preApply(Pony player) {
player.addExertion(3);
player.spawnParticles(UParticles.UNICORN_MAGIC, 5);
}
@Override
public void postApply(IPlayer player) {
public void postApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5);
}
}

View file

@ -3,9 +3,8 @@ package com.minelittlepony.unicopia.block;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UMaterials;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;
@ -60,7 +59,7 @@ public class ChiselledChitinBlock extends Block {
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView worldIn, BlockPos pos) {
float hardness = super.calcBlockBreakingDelta(state, player, worldIn, pos);
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
Race race = iplayer.getSpecies();
if (race == Race.CHANGELING) {

View file

@ -1,9 +1,8 @@
package com.minelittlepony.unicopia.block;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UMaterials;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;
@ -43,7 +42,7 @@ public class ChitinBlock extends Block {
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
float hardness = super.calcBlockBreakingDelta(state, player, world, pos);
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
Race race = iplayer.getSpecies();
if (race == Race.CHANGELING) {

View file

@ -5,8 +5,8 @@ import java.util.function.Function;
import javax.annotation.Nonnull;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.ducks.Colourful;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;
@ -84,7 +84,7 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful {
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack stack = player.getStackInHand(hand);
if (SpeciesList.instance().getPlayer(player).getSpecies().canUseEarth()) {
if (Pony.of(player).getSpecies().canUseEarth()) {
if (stack.isEmpty()) {
if (state.get(HEAVY)) {

View file

@ -5,13 +5,12 @@ import java.util.Random;
import com.google.common.collect.Maps;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.UMaterials;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.shape.IShape;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
@ -43,7 +42,7 @@ public class HiveWallBlock extends FallingBlock {
public static final EnumProperty<State> STATE = EnumProperty.of("state", State.class);
public static final EnumProperty<Axis> AXIS = EnumProperty.of("axis", Axis.class);
private static final IShape shape = new Sphere(false, 1.5);
private static final Shape shape = new Sphere(false, 1.5);
@SuppressWarnings("deprecation")
public HiveWallBlock() {
@ -185,7 +184,7 @@ public class HiveWallBlock extends FallingBlock {
@Override
public void onSteppedOn(World world, BlockPos pos, Entity entity) {
if (entity instanceof PlayerEntity) {
IPlayer player = SpeciesList.instance().getPlayer((PlayerEntity)entity);
Pony player = Pony.of((PlayerEntity)entity);
if (player.getSpecies() != Race.CHANGELING && !world.isClient) {
if (((isEmptySpace(world, pos.down()) || canFallThrough(world.getBlockState(pos.down()))) && pos.getY() >= 0)) {
@ -206,7 +205,7 @@ public class HiveWallBlock extends FallingBlock {
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (hand == Hand.MAIN_HAND && player.getStackInHand(hand).isEmpty()) {
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
if (iplayer.getSpecies() == Race.CHANGELING) {
retreat(world, pos);

View file

@ -4,10 +4,9 @@ import java.util.HashSet;
import java.util.Set;
import com.minelittlepony.unicopia.IKeyBinding;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UnicopiaCore;
import com.minelittlepony.unicopia.ability.Abilities;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
@ -39,7 +38,7 @@ class KeyBindingsHandler {
|| client.player == null) {
return;
}
IPlayer iplayer = SpeciesList.instance().getPlayer(client.player);
Pony iplayer = Pony.of(client.player);
for (KeyBinding i : bindings) {
if (i.isPressed()) {

View file

@ -10,13 +10,12 @@ import com.minelittlepony.jumpingcastle.api.Target;
import com.minelittlepony.unicopia.Config;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.UnicopiaCore;
import com.minelittlepony.unicopia.ability.Abilities;
import com.minelittlepony.unicopia.client.render.DisguiseRenderer;
import com.minelittlepony.unicopia.ducks.Colourful;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
@ -55,7 +54,7 @@ public class UnicopiaCoreClient extends InteractionManager implements ClientModI
private static Race clientPlayerRace = getclientPlayerRace();
private static Race getclientPlayerRace() {
if (!Config.instance().ignoresMineLittlePony()
if (!Config.getInstance().ignoresMineLittlePony()
&& MinecraftClient.getInstance().player != null) {
Race race = MineLPConnector.getPlayerPonyRace();
@ -65,7 +64,7 @@ public class UnicopiaCoreClient extends InteractionManager implements ClientModI
}
return Config.instance().getPrefferedRace();
return Config.getInstance().getPrefferedRace();
}
@Override
@ -87,7 +86,7 @@ public class UnicopiaCoreClient extends InteractionManager implements ClientModI
return false;
}
return IPlayer.equal(MinecraftClient.getInstance().player, player);
return Pony.equal(MinecraftClient.getInstance().player, player);
}
@Override
@ -97,7 +96,7 @@ public class UnicopiaCoreClient extends InteractionManager implements ClientModI
public void postRenderEntity(Entity entity) {
if (entity instanceof PlayerEntity) {
IPlayer iplayer = SpeciesList.instance().getPlayer((PlayerEntity)entity);
Pony iplayer = Pony.of((PlayerEntity)entity);
if (iplayer.getGravity().getGravitationConstant() < 0) {
GlStateManager.translated(0, entity.getDimensions(entity.getPose()).height, 0);
@ -115,7 +114,7 @@ public class UnicopiaCoreClient extends InteractionManager implements ClientModI
}
if (entity instanceof PlayerEntity) {
IPlayer iplayer = SpeciesList.instance().getPlayer((PlayerEntity)entity);
Pony iplayer = Pony.of((PlayerEntity)entity);
if (iplayer.getGravity().getGravitationConstant() < 0) {
GlStateManager.scalef(1, -1, 1);

View file

@ -1,11 +1,12 @@
package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.client.gui.UHud;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.MinecraftClient;
// TODO: forge events
class ClientHooks {
public static void beforePreRenderHud() {
GlStateManager.pushMatrix();
@ -13,7 +14,7 @@ class ClientHooks {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null && client.world != null) {
UHud.instance.repositionElements(SpeciesList.instance().getPlayer(client.player), client.window, true);
UHud.instance.repositionElements(Pony.of(client.player), client.window, true);
}
}
@ -22,7 +23,7 @@ class ClientHooks {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null && client.world != null) {
UHud.instance.renderHud(SpeciesList.instance().getPlayer(client.player), client.window);
UHud.instance.renderHud(Pony.of(client.player), client.window);
}
GlStateManager.popMatrix();

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.DrawableHelper;
@ -11,7 +11,7 @@ class FlightExperienceBar extends DrawableHelper implements IHudElement {
static final Identifier TEXTURE = new Identifier("textures/gui/bars.png");
@Override
public boolean shouldRender(IPlayer player) {
public boolean shouldRender(Pony player) {
return player.getSpecies().canFly()
&& !player.getOwner().abilities.creativeMode;
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
public interface IHudElement {
@ -8,5 +8,5 @@ public interface IHudElement {
void renderHud(UHud context);
boolean shouldRender(IPlayer player);
boolean shouldRender(Pony player);
}

View file

@ -1,16 +1,16 @@
package com.minelittlepony.unicopia.container;
package com.minelittlepony.unicopia.client.gui;
import org.lwjgl.opengl.GL11;
import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UnicopiaCore;
import com.minelittlepony.unicopia.container.SpellBookContainer;
import com.minelittlepony.unicopia.container.SpellBookContainer.SpellbookSlot;
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
import com.minelittlepony.unicopia.enchanting.Page;
import com.minelittlepony.unicopia.enchanting.PageState;
import com.minelittlepony.unicopia.enchanting.Pages;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen;
@ -26,7 +26,7 @@ public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer>
public static final Identifier spellBookGuiTextures = new Identifier("unicopia", "textures/gui/container/book.png");
private IPlayer playerExtension;
private Pony player;
private PageButton nextPage;
private PageButton prevPage;
@ -41,7 +41,7 @@ public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer>
containerWidth = 405;
containerHeight = 219;
playerExtension = SpeciesList.instance().getPlayer(player);
this.player = Pony.of(player);
}
@Override
@ -63,11 +63,11 @@ public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer>
onPageChange();
if (playerExtension.hasPageStateRelative(currentPage, PageState.UNREAD, Page::next)) {
if (player.getPages().hasPageStateRelative(currentPage, PageState.UNREAD, Page::next)) {
nextPage.triggerShake();
}
if (playerExtension.hasPageStateRelative(currentPage, PageState.UNREAD, Page::prev)) {
if (player.getPages().hasPageStateRelative(currentPage, PageState.UNREAD, Page::prev)) {
prevPage.triggerShake();
}
}
@ -76,8 +76,8 @@ public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer>
prevPage.setEnabled(currentPage.getIndex() > 0);
nextPage.setEnabled(currentPage.getIndex() < Pages.instance().getTotalPages() - 1);
if (playerExtension.getPageState(currentPage) == PageState.UNREAD) {
playerExtension.setPageState(currentPage, PageState.READ);
if (player.getPages().getPageState(currentPage) == PageState.UNREAD) {
player.getPages().setPageState(currentPage, PageState.READ);
}
}
@ -152,7 +152,7 @@ public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer>
minecraft.getTextureManager().bindTexture(spellBookGuiTextures);
blit(left + 147, top + 49, 407, 2, 100, 101, 512, 256);
if (playerExtension.getPageState(currentPage) != PageState.LOCKED) {
if (player.getPages().getPageState(currentPage) != PageState.LOCKED) {
Identifier texture = currentPage.getTexture();
if (minecraft.getTextureManager().getTexture(texture) != MissingSprite.getMissingSpriteTexture()) {
@ -161,7 +161,7 @@ public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer>
minecraft.getTextureManager().bindTexture(texture);
blit(left, top, 0, 0, containerWidth, containerHeight, 512, 256);
} else {
if (playerExtension.getWorld().random.nextInt(100) == 0) {
if (player.getWorld().random.nextInt(100) == 0) {
UnicopiaCore.LOGGER.fatal("Missing texture " + texture);
}
}

View file

@ -5,7 +5,7 @@ import java.util.List;
import org.lwjgl.opengl.GL11;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.MinecraftClient;
@ -22,7 +22,7 @@ public class UHud {
TextRenderer fonts = mc.textRenderer;
IPlayer player;
Pony player;
int width;
@ -34,7 +34,7 @@ public class UHud {
elements.add(new FlightExperienceBar());
}
public void renderHud(IPlayer player, Window resolution) {
public void renderHud(Pony player, Window resolution) {
this.width = resolution.getScaledWidth();
this.height = resolution.getScaledHeight();
this.player = player;
@ -43,7 +43,7 @@ public class UHud {
elements.forEach(this::renderElement);
}
public void repositionElements(IPlayer player, Window window, boolean begin) {
public void repositionElements(Pony player, Window window, boolean begin) {
this.width = window.getScaledWidth();
this.height = window.getScaledHeight();
this.player = player;

View file

@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.entity.player.PlayerCamera;
import net.minecraft.client.MinecraftClient;
@ -24,7 +24,7 @@ abstract class MixinCamera {
PlayerEntity player = MinecraftClient.getInstance().player;
if (player != null) {
PlayerCamera view = SpeciesList.instance().getPlayer(player).getCamera();
PlayerCamera view = Pony.of(player).getCamera();
//event.setRoll(view.calculateRoll());
pitch = view.calculatePitch(pitch);

View file

@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
@ -18,7 +18,7 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
at = @At("RETURN"),
cancellable = true)
private void onGetFov(Camera camera, float f, boolean z, CallbackInfoReturnable<Double> info) {
info.setReturnValue(SpeciesList.instance().getPlayer(MinecraftClient.getInstance().player)
info.setReturnValue(Pony.of(MinecraftClient.getInstance().player)
.getCamera()
.calculateFieldOfView(info.getReturnValue()));
}

View file

@ -5,8 +5,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input;
@ -16,7 +15,7 @@ import net.minecraft.client.input.KeyboardInput;
abstract class MixinKeyboardInput extends Input {
@Inject(method = "tick(ZZ)V", at = @At("RETURN"))
private void onTick(boolean one, boolean two, CallbackInfo info) {
IPlayer player = SpeciesList.instance().getPlayer(MinecraftClient.getInstance().player);
Pony player = Pony.of(MinecraftClient.getInstance().player);
if (player.getGravity().getGravitationConstant() < 0) {
boolean tmp = pressingLeft;

View file

@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Mouse;
@ -23,7 +23,7 @@ abstract class MixinMouse {
@Inject(method = "updateMouse()V", at = @At("HEAD"))
private void onUpdateMouse(CallbackInfo info) {
if (SpeciesList.instance().getPlayer(client.player).getGravity().getGravitationConstant() < 0) {
if (Pony.of(client.player).getGravity().getGravitationConstant() < 0) {
cursorDeltaX = -cursorDeltaX;
cursorDeltaY = -cursorDeltaY;
}

View file

@ -16,11 +16,11 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import com.minelittlepony.unicopia.client.render.SphereModel;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.util.particles.ParticleConnection.IAttachableParticle;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.particles.ParticleConnection.AttachableParticle;
import com.mojang.blaze3d.platform.GlStateManager;
public class SphereParticle extends Particle implements IAttachableParticle {
public class SphereParticle extends Particle implements AttachableParticle {
protected float red;
protected float green;
@ -29,7 +29,7 @@ public class SphereParticle extends Particle implements IAttachableParticle {
protected float radius;
private ICaster<?> caster;
private Caster<?> caster;
private static final SphereModel model = new SphereModel();
@ -63,7 +63,7 @@ public class SphereParticle extends Particle implements IAttachableParticle {
}
@Override
public void attachTo(ICaster<?> caster) {
public void attachTo(Caster<?> caster) {
setMaxAge(50000);
this.caster = caster;
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import net.minecraft.client.MinecraftClient;
@ -46,7 +46,7 @@ public class DisguiseRenderer {
renderDisguise(renderMan, entity, x, y, z);
}
public boolean renderDisguiseToGui(IPlayer player) {
public boolean renderDisguiseToGui(Pony player) {
DisguiseSpell effect = player.getEffect(DisguiseSpell.class, false);
if (effect == null || effect.isDead()) {

View file

@ -2,8 +2,7 @@ package com.minelittlepony.unicopia.command;
import java.util.function.Function;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -53,7 +52,7 @@ public class DisguiseCommand {
nbt = nbt.method_10553();
nbt.putString("id", id.toString());
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
Entity entity = EntityType.loadEntityWithPassengers(nbt, source.getWorld(), Function.identity());
@ -82,7 +81,7 @@ public class DisguiseCommand {
}
static int reveal(ServerCommandSource source, PlayerEntity player) {
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
iplayer.getEffect(DisguiseSpell.class).ifPresent(disguise -> {
disguise.setDead();
});

View file

@ -1,7 +1,6 @@
package com.minelittlepony.unicopia.command;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -37,7 +36,7 @@ class GravityCommand {
static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) {
String translationKey = "commands.gravity.get";
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
float gravity = iplayer.getGravity().getGravitationConstant();
@ -53,7 +52,7 @@ class GravityCommand {
static int set(ServerCommandSource source, PlayerEntity player, float gravity, boolean isSelf) {
String translationKey = "commands.gravity.set";
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
iplayer.getGravity().setGraviationConstant(gravity);
iplayer.sendCapabilities(true);

View file

@ -1,9 +1,9 @@
package com.minelittlepony.unicopia.command;
import java.util.function.BiFunction;
import java.util.function.Function;
import com.minelittlepony.unicopia.Config;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -21,20 +21,32 @@ class RacelistCommand {
builder.then(CommandManager.literal("allow")
.then(CommandManager.argument("race", new RaceArgument())
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "allowed", SpeciesList::unwhiteListRace))
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "allowed", race -> {
boolean result = Config.getInstance().getSpeciesWhiteList().remove(race);
Config.getInstance().save();
return result;
}))
));
builder.then(CommandManager.literal("disallow")
.then(CommandManager.argument("race", new RaceArgument())
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "disallowed", SpeciesList::whiteListRace))
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "disallowed", race -> {
boolean result = Config.getInstance().getSpeciesWhiteList().add(race);
Config.getInstance().save();
return result;
}))
));
dispatcher.register(builder);
}
static int toggle(ServerCommandSource source, ServerPlayerEntity player, Race race, String action, BiFunction<SpeciesList, Race, Boolean> func) {
static int toggle(ServerCommandSource source, ServerPlayerEntity player, Race race, String action, Function<Race, Boolean> func) {
String translationKey = "commands.racelist." + action;
if (!func.apply(SpeciesList.instance(), race)) {
if (!func.apply(race)) {
translationKey += ".failed";
}

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.command;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -46,8 +46,8 @@ class SpeciesCommand {
static int set(ServerCommandSource source, PlayerEntity player, Race race, boolean isSelf) {
if (SpeciesList.instance().speciesPermitted(race, player)) {
SpeciesList.instance().getPlayer(player).setSpecies(race);
if (race.isPermitted(player)) {
Pony.of(player).setSpecies(race);
Text formattedName = new TranslatableText(race.name().toLowerCase());
@ -67,7 +67,7 @@ class SpeciesCommand {
}
static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) {
Race spec = SpeciesList.instance().getPlayer(player).getSpecies();
Race spec = Pony.of(player).getSpecies();
String name = "commands.race.tell.";
name += isSelf ? "self" : "other";
@ -91,7 +91,7 @@ class SpeciesCommand {
boolean first = true;
for (Race i : Race.values()) {
if (!i.isDefault() && SpeciesList.instance().speciesPermitted(i, player)) {
if (!i.isDefault() && i.isPermitted(player)) {
message.append(new TranslatableText((!first ? "\n" : "") + " - " + i.name().toLowerCase()));
first = false;
}

View file

@ -6,9 +6,9 @@ import java.util.Optional;
import java.util.function.BiFunction;
import com.minelittlepony.unicopia.advancement.BOHDeathCriterion;
import com.minelittlepony.unicopia.magic.IMagicalItem;
import com.minelittlepony.unicopia.magic.MagicalItem;
import com.minelittlepony.unicopia.util.HeavyInventoryUtils;
import com.minelittlepony.unicopia.util.InbtSerialisable;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.block.Block;
@ -36,7 +36,7 @@ import net.minecraft.world.explosion.Explosion.DestructionType;
import net.minecraft.world.loot.context.LootContext;
import net.minecraft.world.loot.context.LootContextParameters;
public class BagOfHoldingInventory extends BasicInventory implements InbtSerialisable {
public class BagOfHoldingInventory extends BasicInventory implements NbtSerialisable {
public static final int NBT_COMPOUND = 10;
public static final int MIN_SIZE = 18;
@ -159,7 +159,7 @@ public class BagOfHoldingInventory extends BasicInventory implements InbtSeriali
// TODO: tag for items that are invalid for the inventory of holding
|| stack.getItem() instanceof BlockItem && (((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|| (compound != null && compound.containsKey("invalid"))
|| (stack.getItem() instanceof IMagicalItem && ((IMagicalItem) stack.getItem()).hasInnerSpace());
|| (stack.getItem() instanceof MagicalItem && ((MagicalItem) stack.getItem()).hasInnerSpace());
}
protected boolean isIllegalBlock(Block block) {

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.container;
import javax.annotation.Nonnull;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.AwaitTickQueue;
@ -65,7 +65,7 @@ public class SpellBookContainer extends Container {
addSlot(new SpellbookSlot(craftMatrix, 2, 175, 134));
addSlot(new SpellbookSlot(craftMatrix, 3, 226, 120));
addSlot(new SpellbookSlot(craftMatrix, 4, 227, 65));
addSlot(resultSlot = new SpellbookResultSlot(listener, SpeciesList.instance().getPlayer(player), craftMatrix, craftResult, 0, 191, 92));
addSlot(resultSlot = new SpellbookResultSlot(listener, Pony.of(player), craftMatrix, craftResult, 0, 191, 92));
}
@Override
@ -161,7 +161,7 @@ public class SpellBookContainer extends Container {
return EquinePredicates.MAGI.test(player);
}
static class SpellbookSlot extends Slot {
public static class SpellbookSlot extends Slot {
public SpellbookSlot(Inventory inventoryIn, int index, int xPosition, int yPosition) {
super(inventoryIn, index, xPosition, yPosition);

View file

@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.container;
import com.minelittlepony.unicopia.enchanting.IPageOwner;
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
import com.minelittlepony.unicopia.enchanting.SpellCraftingEvent;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.MagicGemItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
@ -15,16 +15,16 @@ import net.minecraft.util.DefaultedList;
public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot {
private final IPageOwner owner;
private final Pony player;
private final SpellBookInventory craftMatrix;
private IPageUnlockListener listener;
private boolean crafted;
public SpellbookResultSlot(IPageUnlockListener listener, IPageOwner owner, SpellBookInventory craftMatric, Inventory inventory, int index, int xPosition, int yPosition) {
public SpellbookResultSlot(IPageUnlockListener listener, Pony player, SpellBookInventory craftMatric, Inventory inventory, int index, int xPosition, int yPosition) {
super(inventory, index, xPosition, yPosition);
this.owner = owner;
this.player = player;
this.listener = listener;
craftMatrix = craftMatric;
}
@ -85,7 +85,7 @@ public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot {
@Override
protected void onCrafted(ItemStack stack) {
SpellCraftingEvent.trigger(owner, stack, listener);
SpellCraftingEvent.trigger(player.getPages(), stack, listener);
}
@Override

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ducks;
import com.minelittlepony.unicopia.entity.ItemEntityCapabilities;
public interface IItemEntity extends RaceContainerHolder<ItemEntityCapabilities> {
public interface IItemEntity extends PonyContainer<ItemEntityCapabilities> {
int getAge();

View file

@ -0,0 +1,37 @@
package com.minelittlepony.unicopia.ducks;
import java.util.Optional;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.magic.Caster;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
public interface PonyContainer<T extends Ponylike> {
Ponylike create();
T get();
@SuppressWarnings("unchecked")
@Nullable
default <E extends LivingEntity> Caster<E> getCaster() {
T ientity = get();
if (ientity instanceof Caster) {
return (Caster<E>)ientity;
}
return null;
}
@SuppressWarnings("unchecked")
static <E extends Entity, T extends Ponylike> Optional<PonyContainer<T>> of(Entity entity) {
if (entity instanceof PonyContainer) {
return Optional.of(((PonyContainer<T>)entity));
}
return Optional.empty();
}
}

View file

@ -1,25 +0,0 @@
package com.minelittlepony.unicopia.ducks;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.IEntity;
import com.minelittlepony.unicopia.magic.ICaster;
import net.minecraft.entity.LivingEntity;
public interface RaceContainerHolder<T extends IEntity> {
T getRaceContainer();
@SuppressWarnings("unchecked")
@Nullable
default <E extends LivingEntity> ICaster<E> getCaster() {
T ientity = getRaceContainer();
if (ientity instanceof ICaster) {
return (ICaster<E>)ientity;
}
return null;
}
IEntity createRaceContainer();
}

View file

@ -35,7 +35,7 @@ public class CompoundCondition implements IUnlockCondition<IUnlockEvent> {
}
@Override
public boolean matches(IPageOwner owner, IUnlockEvent event) {
public boolean matches(PageOwner owner, IUnlockEvent event) {
return operation.test.apply(conditions.stream(), condition -> condition.accepts(event) && condition.matches(owner, event));
}

View file

@ -20,7 +20,7 @@ public interface IUnlockCondition<T extends IUnlockEvent> {
* @param prop PlayerExtension for the player doing the crafting
* @param stack ItemStack crafted
*/
boolean matches(IPageOwner owner, T event);
boolean matches(PageOwner owner, T event);
default void require(JsonObject json, String memberName) {
if (!json.has(memberName)) {

View file

@ -21,7 +21,7 @@ public interface Page extends Comparable<Page> {
* Tests unlock conditions for this page.
* Returns true if the owner is permitted to read this page.
*/
boolean canUnlock(IPageOwner owner, IUnlockEvent event);
boolean canUnlock(PageOwner owner, IUnlockEvent event);
/**
* Gets the texture.

View file

@ -76,7 +76,7 @@ class PageInstance implements Page {
}
@Override
public boolean canUnlock(IPageOwner owner, IUnlockEvent event) {
public boolean canUnlock(PageOwner owner, IUnlockEvent event) {
return condition == null || condition.accepts(event) && condition.matches(owner, event);
}

View file

@ -13,7 +13,7 @@ import net.minecraft.util.Identifier;
* Interface for things that own and can unlock pages.
*
*/
public interface IPageOwner extends Transmittable {
public interface PageOwner extends Transmittable {
@Nonnull
Map<Identifier, PageState> getPageStates();

View file

@ -19,7 +19,7 @@ public class PageStateCondition implements IUnlockCondition<IUnlockEvent> {
}
@Override
public boolean matches(IPageOwner owner, IUnlockEvent event) {
public boolean matches(PageOwner owner, IUnlockEvent event) {
Page ipage = Pages.instance().getByName(page);
if (ipage != null) {

View file

@ -118,13 +118,13 @@ public class Pages extends JsonDataLoader implements IdentifiableResourceReloadL
return pages.values().stream().map(Page.class::cast).filter(predicate);
}
public void triggerUnlockEvent(IPageOwner owner, IUnlockEvent event, @Nullable IPageUnlockListener unlockListener) {
public void triggerUnlockEvent(PageOwner owner, IUnlockEvent event, @Nullable IPageUnlockListener unlockListener) {
pages.values().stream()
.filter(page -> page.canUnlock(owner, event))
.forEach(page -> unlockPage(owner, page, unlockListener));
}
public void unlockPage(IPageOwner owner, Page page, @Nullable IPageUnlockListener unlockListener) {
public void unlockPage(PageOwner owner, Page page, @Nullable IPageUnlockListener unlockListener) {
if (owner.getPageState(page).isLocked()) {
if (unlockListener == null || unlockListener.onPageUnlocked(page)) {
owner.setPageState(page, PageState.UNREAD);

View file

@ -16,7 +16,7 @@ import net.minecraft.item.ItemStack;
*/
public class SpellCraftingEvent {
public static void trigger(IPageOwner owner, ItemStack stack, @Nullable IPageUnlockListener unlockListener) {
public static void trigger(PageOwner owner, ItemStack stack, @Nullable IPageUnlockListener unlockListener) {
Pages.instance().triggerUnlockEvent(owner, new Event(stack), unlockListener);
}
@ -49,7 +49,7 @@ public class SpellCraftingEvent {
}
@Override
public boolean matches(IPageOwner prop, Event event) {
public boolean matches(PageOwner prop, Event event) {
if (!event.stack.isEmpty() && event.stack.getItem() instanceof MagicGemItem) {
return ((MagicGemItem)event.stack.getItem()).getAffinity() == affinity
&& SpellRegistry.getKeyFromStack(event.stack).equals(spell);

View file

@ -6,10 +6,10 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloudEntity;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.util.particles.ParticleEmitter;
@ -329,7 +329,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
player.horizontalSpeed = (float)(player.horizontalSpeed + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
player.distanceWalked = (float)(player.distanceWalked + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
if (SpeciesList.instance().getPlayer(player).stepOnCloud()) {
if (Pony.of(player).stepOnCloud()) {
BlockSoundGroup soundtype = BlockSoundGroup.WOOL;
player.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
@ -506,7 +506,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
public ItemEntity dropItem(ItemConvertible stack, int amount) {
ItemEntity item = super.dropItem(stack, amount);
SpeciesList.instance().getEntity(item).setSpecies(Race.PEGASUS);
Ponylike.of(item).setSpecies(Race.PEGASUS);
item.setNoGravity(true);
item.setVelocity(0, 0, 0);

View file

@ -7,9 +7,9 @@ import javax.annotation.Nullable;
import com.google.common.collect.Lists;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.block.Blocks;
@ -156,7 +156,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
if (player.canConsume(false) || player.getHealth() < player.getHealthMaximum()) {
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player);
SpeciesList.instance().getPlayer(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7);
Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7);
if (passenger instanceof LivingEntity) {
if (player.hasStatusEffect(StatusEffects.NAUSEA)) {

View file

@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.entity.ai;
package com.minelittlepony.unicopia.entity;
import java.util.EnumSet;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.Caster;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
@ -19,7 +19,7 @@ import net.minecraft.world.ViewableWorld;
public class FollowCasterGoal<T extends MobEntity> extends Goal {
protected final ICaster<?> caster;
protected final Caster<?> caster;
protected final MobEntity entity;
@ -38,7 +38,7 @@ public class FollowCasterGoal<T extends MobEntity> extends Goal {
private float oldWaterCost;
public FollowCasterGoal(ICaster<T> caster, double followSpeed, float minDist, float maxDist) {
public FollowCasterGoal(Caster<T> caster, double followSpeed, float minDist, float maxDist) {
this.caster = caster;
this.entity = (MobEntity)caster.getEntity();

View file

@ -2,10 +2,10 @@ package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.IAffine;
import com.minelittlepony.unicopia.magic.IAttachedEffect;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync;
@ -15,7 +15,7 @@ import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.nbt.CompoundTag;
public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, ICaster<LivingEntity> {
public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, Caster<LivingEntity> {
private static final TrackedData<CompoundTag> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
@ -41,12 +41,12 @@ public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, IC
}
@Override
public void setEffect(IMagicEffect effect) {
public void setEffect(MagicEffect effect) {
effectDelegate.set(effect);
}
@Override
public <T extends IMagicEffect> T getEffect(Class<T> type, boolean update) {
public <T extends MagicEffect> T getEffect(Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@ -58,7 +58,7 @@ public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, IC
@Override
public void onUpdate() {
if (hasEffect()) {
IAttachedEffect effect = getEffect(IAttachedEffect.class, true);
AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true);
if (effect != null) {
if (entity.getEntityWorld().isClient()) {
@ -98,15 +98,15 @@ public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, IC
@Override
public Affinity getAffinity() {
if (getOwner() instanceof IAffine) {
return ((IAffine)getOwner()).getAffinity();
if (getOwner() instanceof Affine) {
return ((Affine)getOwner()).getAffinity();
}
return Affinity.NEUTRAL;
}
@Override
public void toNBT(CompoundTag compound) {
IMagicEffect effect = getEffect();
MagicEffect effect = getEffect();
if (effect != null) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));

View file

@ -1,12 +1,16 @@
package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.util.InbtSerialisable;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ducks.PonyContainer;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemStack;
public interface IEntity extends InbtSerialisable, Updatable {
public interface Ponylike extends NbtSerialisable, Updatable {
Race getSpecies();
void setSpecies(Race race);
@ -56,4 +60,11 @@ public interface IEntity extends InbtSerialisable, Updatable {
default void onJump() {
}
@Nullable
static <T extends Ponylike> T of(Entity entity) {
return PonyContainer.<Entity, T>of(entity)
.map(PonyContainer::get)
.orElse(null);
}
}

View file

@ -3,14 +3,14 @@ package com.minelittlepony.unicopia.entity;
import java.util.UUID;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.ITossedEffect;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.TossedMagicEffect;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.util.projectile.IAdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.ITossable;
import com.minelittlepony.unicopia.util.projectile.ITossableItem;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.Tossable;
import com.minelittlepony.unicopia.util.projectile.TossableItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
@ -39,7 +39,7 @@ import net.minecraft.world.World;
*
* Can also carry a spell if needed.
*/
public class ProjectileEntity extends ThrownItemEntity implements IMagicals, IAdvancedProjectile, ICaster<LivingEntity> {
public class ProjectileEntity extends ThrownItemEntity implements IMagicals, AdvancedProjectile, Caster<LivingEntity> {
private static final TrackedData<Float> DAMAGE = DataTracker.registerData(ProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<Boolean> HYDROPHOBIC = DataTracker.registerData(ProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
@ -116,12 +116,12 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, IAd
}
@Override
public void setEffect(ITossedEffect effect) {
setEffect((IMagicEffect)effect);
public void setEffect(TossedMagicEffect effect) {
setEffect((MagicEffect)effect);
}
@Override
public void setEffect(IMagicEffect effect) {
public void setEffect(MagicEffect effect) {
effectDelegate.set(effect);
if (effect != null) {
@ -130,7 +130,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, IAd
}
@Override
public <T extends IMagicEffect> T getEffect(Class<T> type, boolean update) {
public <T extends MagicEffect> T getEffect(Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@ -260,15 +260,15 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, IAd
protected void onHitBlock(BlockHitResult hit) {
Item item = getItem().getItem();
if (item instanceof ITossableItem) {
((ITossableItem)item).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));
if (item instanceof TossableItem) {
((TossableItem)item).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));
}
if (hasEffect()) {
IMagicEffect effect = getEffect();
MagicEffect effect = getEffect();
if (effect instanceof ITossable) {
((ITossable<?>)effect).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));
if (effect instanceof Tossable) {
((Tossable<?>)effect).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));
}
}
}
@ -276,7 +276,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, IAd
protected void onHitEntity(EntityHitResult hit) {
Entity entity = hit.getEntity();
if (entity instanceof IAdvancedProjectile) {
if (entity instanceof AdvancedProjectile) {
return;
}

View file

@ -7,6 +7,6 @@ import net.minecraft.entity.Entity;
*
* @param <T> The type of owner
*/
public interface RaceContainer<T extends Entity> extends IEntity {
public interface RaceContainer<T extends Entity> extends Ponylike {
}

View file

@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.magic.ITossedEffect;
import com.minelittlepony.unicopia.magic.TossedMagicEffect;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.projectile.IAdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import net.minecraft.client.network.packet.GameStateChangeS2CPacket;
import net.minecraft.enchantment.EnchantmentHelper;
@ -25,7 +25,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class SpearEntity extends ArrowEntity implements IAdvancedProjectile {
public class SpearEntity extends ArrowEntity implements AdvancedProjectile {
private static final TrackedData<ItemStack> ITEM = DataTracker.registerData(SpearEntity.class, TrackedDataHandlerRegistry.ITEM_STACK);
@ -184,6 +184,6 @@ public class SpearEntity extends ArrowEntity implements IAdvancedProjectile {
}
@Override
public void setEffect(ITossedEffect effect) {
public void setEffect(TossedMagicEffect effect) {
}
}

View file

@ -9,9 +9,9 @@ import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.ICastable;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.Castable;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync;
@ -43,7 +43,7 @@ import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion.DestructionType;
public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICaster<LivingEntity>, InAnimate {
public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caster<LivingEntity>, InAnimate {
private LivingEntity owner = null;
@ -99,7 +99,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
}
@Override
public void setEffect(@Nullable IMagicEffect effect) {
public void setEffect(@Nullable MagicEffect effect) {
effectDelegate.set(effect);
if (effect != null) {
@ -114,7 +114,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
@Nullable
@Override
public <T extends IMagicEffect> T getEffect(@Nullable Class<T> type, boolean update) {
public <T extends MagicEffect> T getEffect(@Nullable Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@ -294,8 +294,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND);
if (currentItem != null
&& currentItem.getItem() instanceof ICastable
&& ((ICastable)currentItem.getItem()).canFeed(this, currentItem)
&& currentItem.getItem() instanceof Castable
&& ((Castable)currentItem.getItem()).canFeed(this, currentItem)
&& tryLevelUp(currentItem)) {
if (!player.abilities.creativeMode) {

View file

@ -10,13 +10,13 @@ import com.minelittlepony.unicopia.ability.Ability;
import com.minelittlepony.unicopia.ability.Abilities;
import com.minelittlepony.unicopia.entity.Updatable;
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
import com.minelittlepony.unicopia.util.InbtSerialisable;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.nbt.CompoundTag;
class AbilityDelegate implements AbilityReceiver, Updatable, InbtSerialisable {
class AbilityDelegate implements AbilityReceiver, Updatable, NbtSerialisable {
private final IPlayer player;
private final Pony player;
/**
* Ticks of warmup before an ability is triggered.
@ -36,7 +36,7 @@ class AbilityDelegate implements AbilityReceiver, Updatable, InbtSerialisable {
@Nullable
private Ability<?> activeAbility = null;
public AbilityDelegate(IPlayer player) {
public AbilityDelegate(Pony player) {
this.player = player;
}

View file

@ -9,9 +9,9 @@ import com.minelittlepony.unicopia.ability.FlightPredicate;
import com.minelittlepony.unicopia.ability.HeightPredicate;
import com.minelittlepony.unicopia.entity.FlightControl;
import com.minelittlepony.unicopia.entity.Updatable;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.mixin.MixinEntity;
import com.minelittlepony.unicopia.util.InbtSerialisable;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.MutableVector;
import net.minecraft.entity.Entity;
@ -24,9 +24,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class GravityDelegate implements Updatable, FlightControl, InbtSerialisable, FlightPredicate, HeightPredicate {
public class GravityDelegate implements Updatable, FlightControl, NbtSerialisable, FlightPredicate, HeightPredicate {
private final IPlayer player;
private final Pony player;
private static final float MAXIMUM_FLIGHT_EXPERIENCE = 1500;
@ -41,18 +41,18 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
private float gravity = 0;
public GravityDelegate(IPlayer player) {
public GravityDelegate(Pony player) {
this.player = player;
}
@Override
public boolean checkCanFly(IPlayer player) {
public boolean checkCanFly(Pony player) {
if (player.getOwner().abilities.creativeMode) {
return true;
}
if (player.hasEffect()) {
IMagicEffect effect = player.getEffect();
MagicEffect effect = player.getEffect();
if (!effect.isDead() && effect instanceof FlightPredicate) {
return ((FlightPredicate)effect).checkCanFly(player);
}
@ -61,14 +61,14 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
return player.getSpecies().canFly();
}
protected boolean isRainboom(IPlayer player) {
protected boolean isRainboom(Pony player) {
return Math.sqrt(getHorizontalMotion(player.getOwner())) > 0.4F;
}
@Override
public float getTargetEyeHeight(IPlayer player) {
public float getTargetEyeHeight(Pony player) {
if (player.hasEffect()) {
IMagicEffect effect = player.getEffect();
MagicEffect effect = player.getEffect();
if (!effect.isDead() && effect instanceof HeightPredicate) {
float val = ((HeightPredicate)effect).getTargetEyeHeight(player);
if (val > 0) {
@ -85,9 +85,9 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
}
@Override
public float getTargetBodyHeight(IPlayer player) {
public float getTargetBodyHeight(Pony player) {
if (player.hasEffect()) {
IMagicEffect effect = player.getEffect();
MagicEffect effect = player.getEffect();
if (!effect.isDead() && effect instanceof HeightPredicate) {
float val = ((HeightPredicate)effect).getTargetBodyHeight(player);
if (val > 0) {

View file

@ -6,11 +6,11 @@ import net.minecraft.util.math.Vec3d;
public class PlayerCamera extends MotionCompositor {
private final IPlayer player;
private final Pony player;
private double baseRoll = 0;
public PlayerCamera(IPlayer player) {
public PlayerCamera(Pony player) {
this.player = player;
}

View file

@ -1,23 +1,20 @@
package com.minelittlepony.unicopia.entity.player;
import java.util.Map;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UEffects;
import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.UnicopiaCore;
import com.minelittlepony.unicopia.ability.AbilityReceiver;
import com.minelittlepony.unicopia.enchanting.PageState;
import com.minelittlepony.unicopia.enchanting.PageOwner;
import com.minelittlepony.unicopia.entity.FlightControl;
import com.minelittlepony.unicopia.entity.Trap;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.IAttachedEffect;
import com.minelittlepony.unicopia.magic.IHeldEffect;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.IMagicalItem;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
import com.minelittlepony.unicopia.magic.HeldMagicEffect;
import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.MagicalItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
@ -42,13 +39,12 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Difficulty;
public class PlayerCapabilities implements IPlayer {
public class PlayerImpl implements Pony {
private static final TrackedData<Integer> PLAYER_RACE = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
private static final TrackedData<Float> ENERGY = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
@ -81,7 +77,7 @@ public class PlayerCapabilities implements IPlayer {
private boolean invisible = false;
public PlayerCapabilities(PlayerEntity player) {
public PlayerImpl(PlayerEntity player) {
this.entity = player;
player.getDataTracker().startTracking(PLAYER_RACE, Race.EARTH.ordinal());
@ -102,7 +98,7 @@ public class PlayerCapabilities implements IPlayer {
@Override
public void setSpecies(Race race) {
race = SpeciesList.instance().validate(race, entity);
race = race.validate(entity);
entity.getDataTracker().set(PLAYER_RACE, race.ordinal());
@ -145,7 +141,7 @@ public class PlayerCapabilities implements IPlayer {
@Nullable
@Override
public IHeldEffect getHeldEffect(ItemStack stack) {
public HeldMagicEffect getHeldEffect(ItemStack stack) {
if (!getSpecies().canCast()) {
heldEffectDelegate.set(null);
@ -153,7 +149,7 @@ public class PlayerCapabilities implements IPlayer {
return null;
}
IHeldEffect heldEffect = heldEffectDelegate.get(IHeldEffect.class, true);
HeldMagicEffect heldEffect = heldEffectDelegate.get(HeldMagicEffect.class, true);
if (heldEffect == null || !heldEffect.getName().equals(SpellRegistry.getKeyFromStack(stack))) {
heldEffect = SpellRegistry.instance().getHeldFrom(stack);
@ -193,6 +189,11 @@ public class PlayerCapabilities implements IPlayer {
return powers;
}
@Override
public PageOwner getPages() {
return pageStates;
}
@Override
public GravityDelegate getGravity() {
return gravity;
@ -247,7 +248,7 @@ public class PlayerCapabilities implements IPlayer {
gravity.onUpdate();
if (hasEffect()) {
IAttachedEffect effect = getEffect(IAttachedEffect.class, true);
AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true);
if (effect != null) {
if (entity.getEntityWorld().isClient()) {
@ -262,10 +263,10 @@ public class PlayerCapabilities implements IPlayer {
ItemStack stack = entity.getStackInHand(Hand.MAIN_HAND);
IHeldEffect effect = getHeldEffect(stack);
HeldMagicEffect effect = getHeldEffect(stack);
if (effect != null) {
Affinity affinity = stack.getItem() instanceof IMagicalItem ? ((IMagicalItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
Affinity affinity = stack.getItem() instanceof MagicalItem ? ((MagicalItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
effect.updateInHand(this, affinity);
}
@ -299,7 +300,7 @@ public class PlayerCapabilities implements IPlayer {
@Override
public boolean onProjectileImpact(ProjectileEntity projectile) {
if (hasEffect()) {
IMagicEffect effect = getEffect();
MagicEffect effect = getEffect();
if (!effect.isDead() && effect.handleProjectileImpact(projectile)) {
return true;
}
@ -346,7 +347,7 @@ public class PlayerCapabilities implements IPlayer {
return Either.left(SleepFailureReason.OTHER_PROBLEM);
}
if (findAllSpellsInRange(10).anyMatch(c -> c instanceof IPlayer && ((IPlayer)c).getInventory().matches(UTags.CURSED_ARTEFACTS))) {
if (findAllSpellsInRange(10).anyMatch(c -> c instanceof Pony && ((Pony)c).getInventory().matches(UTags.CURSED_ARTEFACTS))) {
return Either.left(SleepFailureReason.NOT_SAFE);
}
@ -391,7 +392,7 @@ public class PlayerCapabilities implements IPlayer {
compound.put("powers", powers.toNBT());
compound.put("gravity", gravity.toNBT());
IMagicEffect effect = getEffect();
MagicEffect effect = getEffect();
if (effect != null) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));
@ -415,13 +416,13 @@ public class PlayerCapabilities implements IPlayer {
}
@Override
public void copyFrom(IPlayer oldPlayer) {
public void copyFrom(Pony oldPlayer) {
setEffect(oldPlayer.getEffect());
setSpecies(oldPlayer.getSpecies());
}
@Override
public void setEffect(@Nullable IMagicEffect effect) {
public void setEffect(@Nullable MagicEffect effect) {
effectDelegate.set(effect);
sendCapabilities(true);
@ -434,7 +435,7 @@ public class PlayerCapabilities implements IPlayer {
@Nullable
@Override
public <T extends IMagicEffect> T getEffect(@Nullable Class<T> type, boolean update) {
public <T extends MagicEffect> T getEffect(@Nullable Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@ -456,9 +457,4 @@ public class PlayerCapabilities implements IPlayer {
public void setCurrentLevel(int level) {
}
@Override
public Map<Identifier, PageState> getPageStates() {
return pageStates.getPageStates();
}
}

View file

@ -5,9 +5,9 @@ import java.util.Map;
import com.google.common.collect.Maps;
import com.minelittlepony.unicopia.entity.Updatable;
import com.minelittlepony.unicopia.magic.IDependable;
import com.minelittlepony.unicopia.magic.IMagicalItem;
import com.minelittlepony.unicopia.util.InbtSerialisable;
import com.minelittlepony.unicopia.magic.AddictiveMagicalItem;
import com.minelittlepony.unicopia.magic.MagicalItem;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -17,12 +17,12 @@ import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class PlayerInventory implements Updatable, InbtSerialisable {
private final Map<IDependable, Entry> dependencies = Maps.newHashMap();
public class PlayerInventory implements Updatable, NbtSerialisable {
private final Map<AddictiveMagicalItem, Entry> dependencies = Maps.newHashMap();
private final IPlayer player;
private final Pony player;
PlayerInventory(IPlayer player) {
PlayerInventory(Pony player) {
this.player = player;
}
@ -32,7 +32,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
*
* Bad things might happen when it's removed.
*/
public synchronized void enforceDependency(IDependable item) {
public synchronized void enforceDependency(AddictiveMagicalItem item) {
if (dependencies.containsKey(item)) {
dependencies.get(item).reinforce();
} else {
@ -43,7 +43,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
/**
* Returns how long the player has been wearing the given item.
*/
public synchronized int getTicksAttached(IDependable item) {
public synchronized int getTicksAttached(AddictiveMagicalItem item) {
if (dependencies.containsKey(item)) {
return dependencies.get(item).ticksAttached;
}
@ -56,7 +56,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
*
* Zero means not dependent at all / not wearing.
*/
public synchronized float getNeedfulness(IDependable item) {
public synchronized float getNeedfulness(AddictiveMagicalItem item) {
if (dependencies.containsKey(item)) {
return dependencies.get(item).needfulness;
}
@ -67,10 +67,10 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
@Override
public synchronized void onUpdate() {
Iterator<Map.Entry<IDependable, Entry>> iterator = dependencies.entrySet().iterator();
Iterator<Map.Entry<AddictiveMagicalItem, Entry>> iterator = dependencies.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<IDependable, Entry> entry = iterator.next();
Map.Entry<AddictiveMagicalItem, Entry> entry = iterator.next();
Entry item = entry.getValue();
@ -85,7 +85,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
/**
* Checks if the player is wearing the specified magical artifact.
*/
public boolean isWearing(IMagicalItem item) {
public boolean isWearing(MagicalItem item) {
for (ItemStack i : player.getOwner().getArmorItems()) {
if (!i.isEmpty() && i.getItem() == item) {
return true;
@ -131,18 +131,18 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
});
}
class Entry implements Updatable, InbtSerialisable {
class Entry implements Updatable, NbtSerialisable {
int ticksAttached = 0;
float needfulness = 1;
IDependable item;
AddictiveMagicalItem item;
Entry() {
}
Entry(IDependable key) {
Entry(AddictiveMagicalItem key) {
this.item = key;
}
@ -175,7 +175,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
Item item = Registry.ITEM.get(new Identifier(compound.getString("item")));
this.item = item instanceof IDependable ? (IDependable)item : null;
this.item = item instanceof AddictiveMagicalItem ? (AddictiveMagicalItem)item : null;
}
}
}

View file

@ -3,14 +3,14 @@ package com.minelittlepony.unicopia.entity.player;
import java.util.HashMap;
import java.util.Map;
import com.minelittlepony.unicopia.enchanting.IPageOwner;
import com.minelittlepony.unicopia.enchanting.PageOwner;
import com.minelittlepony.unicopia.enchanting.PageState;
import com.minelittlepony.unicopia.util.InbtSerialisable;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Identifier;
public class PlayerPageStats implements InbtSerialisable, IPageOwner {
public class PlayerPageStats implements NbtSerialisable, PageOwner {
private final Map<Identifier, PageState> pageStates = new HashMap<>();
@Override
@ -23,7 +23,6 @@ public class PlayerPageStats implements InbtSerialisable, IPageOwner {
}
@Override
public void toNBT(CompoundTag compound) {
if (!pageStates.isEmpty()) {

View file

@ -4,11 +4,12 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.ability.AbilityReceiver;
import com.minelittlepony.unicopia.enchanting.IPageOwner;
import com.minelittlepony.unicopia.enchanting.PageOwner;
import com.minelittlepony.unicopia.entity.FlightControl;
import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.entity.RaceContainer;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.IHeldEffect;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.HeldMagicEffect;
import com.minelittlepony.unicopia.network.Transmittable;
import com.minelittlepony.util.IInterpolator;
import com.mojang.authlib.GameProfile;
@ -24,7 +25,7 @@ import net.minecraft.util.math.BlockPos;
*
* This is the core of unicopia.
*/
public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEntity>, Transmittable, IPageOwner {
public interface Pony extends Caster<PlayerEntity>, RaceContainer<PlayerEntity>, Transmittable {
/**
* Gets the player's magical abilities delegate responsible for all spell casting and persisting/updating.
@ -56,6 +57,8 @@ public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEnti
*/
IInterpolator getInterpolator();
PageOwner getPages();
/**
* Gets the amount of exertion this player has put toward any given activity.
* This is simillar to tiredness.
@ -92,7 +95,7 @@ public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEnti
setEnergy(getEnergy() + energy / 100F);
}
void copyFrom(IPlayer oldPlayer);
void copyFrom(Pony oldPlayer);
/**
* Called when the player steps on clouds.
@ -106,7 +109,7 @@ public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEnti
* Returns null if the passed item has no held effect.
*/
@Nullable
IHeldEffect getHeldEffect(ItemStack stack);
HeldMagicEffect getHeldEffect(ItemStack stack);
/**
* Called when this player falls.
@ -129,6 +132,11 @@ public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEnti
return InteractionManager.instance().isClientPlayer(getOwner());
}
@Nullable
static Pony of(@Nullable PlayerEntity player) {
return Ponylike.<Pony>of(player);
}
static boolean equal(GameProfile one, GameProfile two) {
return one == two || (one != null && two != null && one.getId().equals(two.getId()));
}

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.gas;
import java.util.Random;
import com.minelittlepony.unicopia.CloudType;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.MossItem;
import com.minelittlepony.unicopia.util.HoeUtil;
@ -116,6 +116,6 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
@Override
public boolean canTill(ItemUsageContext context) {
return context.getPlayer() == null || SpeciesList.instance().getPlayer(context.getPlayer()).getSpecies().canInteractWithClouds();
return context.getPlayer() == null || Pony.of(context.getPlayer()).getSpecies().canInteractWithClouds();
}
}

View file

@ -6,12 +6,11 @@ import java.util.UUID;
import javax.annotation.Nullable;
import com.google.common.collect.Multimap;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.ducks.IItemEntity;
import com.minelittlepony.unicopia.entity.ItemEntityCapabilities;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.IDependable;
import com.minelittlepony.unicopia.magic.AddictiveMagicalItem;
import com.minelittlepony.unicopia.util.AwaitTickQueue;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.VecHelper;
@ -48,7 +47,7 @@ import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion.DestructionType;
public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEntityCapabilities.TickableItem {
public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem, ItemEntityCapabilities.TickableItem {
private static final UUID[] MODIFIERS = new UUID[] {
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
@ -70,7 +69,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
@Override
public ActionResult onGroundTick(IItemEntity item) {
ItemEntity entity = item.getRaceContainer().getOwner();
ItemEntity entity = item.get().getOwner();
World world = entity.world;
@ -119,7 +118,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
IPlayer iplayer = SpeciesList.instance().getPlayer(MinecraftClient.getInstance().player);
Pony iplayer = Pony.of(MinecraftClient.getInstance().player);
if (iplayer != null) {
int attachedTime = iplayer.getInventory().getTicksAttached(this);
@ -160,7 +159,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
player.getHungerManager().add(1, 0);
}
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
float attachedTime = iplayer.getInventory().getTicksAttached(this);
@ -227,7 +226,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
}
@Override
public void onRemoved(IPlayer player, float needfulness) {
public void onRemoved(Pony player, float needfulness) {
float attachedTime = player.getInventory().getTicksAttached(this) / 100F;

View file

@ -69,7 +69,7 @@ public class AppleItem extends Item implements Toxic, ItemEntityCapabilities.Tic
@Override
public ActionResult onGroundTick(IItemEntity item) {
ItemEntity entity = item.getRaceContainer().getOwner();
ItemEntity entity = item.get().getOwner();
if (!entity.removed && item.getAge() > item.getPickupDelay()) {

View file

@ -10,7 +10,7 @@ import com.minelittlepony.unicopia.UContainers;
import com.minelittlepony.unicopia.container.BagOfHoldingContainer;
import com.minelittlepony.unicopia.container.BagOfHoldingInventory;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.IMagicalItem;
import com.minelittlepony.unicopia.magic.MagicalItem;
import com.minelittlepony.unicopia.util.VecHelper;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
@ -37,7 +37,7 @@ import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BagOfHoldingItem extends Item implements IMagicalItem {
public class BagOfHoldingItem extends Item implements MagicalItem {
public BagOfHoldingItem() {
super(new Settings().maxCount(1).group(ItemGroup.TRANSPORTATION));

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.entity.CloudEntity;
import com.minelittlepony.unicopia.magic.IDispensable;
import com.minelittlepony.unicopia.magic.Dispensable;
import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.EntityType;
@ -20,7 +20,7 @@ import net.minecraft.util.math.Position;
import net.minecraft.world.RayTraceContext;
import net.minecraft.world.World;
public class CloudPlacerItem extends Item implements IDispensable {
public class CloudPlacerItem extends Item implements Dispensable {
private final EntityType<? extends CloudEntity> cloudSupplier;

View file

@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.IDispenceable;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.item.ItemStack;
@ -16,7 +16,7 @@ import net.minecraft.world.explosion.Explosion.DestructionType;
public class CursedMagicGemItem extends MagicGemItem {
@Override
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, IDispenceable effect) {
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect) {
BlockPos pos = source.getBlockPos();
World world = source.getWorld();
@ -37,7 +37,7 @@ public class CursedMagicGemItem extends MagicGemItem {
}
@Override
public CastResult onCastSpell(ItemUsageContext context, IMagicEffect effect) {
public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) {
CastResult result = super.onCastSpell(context, effect);
if (result != CastResult.NONE) {

View file

@ -6,14 +6,13 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.IAffine;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.ITossedEffect;
import com.minelittlepony.unicopia.util.projectile.ITossableItem;
import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.TossedMagicEffect;
import com.minelittlepony.unicopia.util.projectile.TossableItem;
import net.minecraft.block.BlockState;
import net.minecraft.client.item.TooltipContext;
@ -34,12 +33,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class EnchantedStaffItem extends StaffItem implements IAffine, ITossableItem {
public class EnchantedStaffItem extends StaffItem implements Affine, TossableItem {
@Nonnull
private final ITossedEffect effect;
private final TossedMagicEffect effect;
public EnchantedStaffItem(Settings settings, @Nonnull ITossedEffect effect) {
public EnchantedStaffItem(Settings settings, @Nonnull TossedMagicEffect effect) {
super(settings.maxDamage(500));
this.effect = effect;
@ -131,7 +130,7 @@ public class EnchantedStaffItem extends StaffItem implements IAffine, ITossableI
@Override
public void toss(World world, ItemStack stack, PlayerEntity player) {
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
Pony iplayer = Pony.of(player);
iplayer.subtractEnergyCost(4);
effect.toss(iplayer);
@ -140,7 +139,7 @@ public class EnchantedStaffItem extends StaffItem implements IAffine, ITossableI
}
@Override
public void onImpact(ICaster<?> caster, BlockPos pos, BlockState state) {
public void onImpact(Caster<?> caster, BlockPos pos, BlockState state) {
effect.onImpact(caster, pos, state);
}

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.magic.IDispensable;
import com.minelittlepony.unicopia.magic.Dispensable;
import net.minecraft.block.BlockState;
import net.minecraft.block.DispenserBlock;
@ -50,7 +50,7 @@ public class ExtendedShearsItem extends ShearsItem {
public ExtendedShearsItem() {
super(new Item.Settings().maxDamage(238).group(ItemGroup.TOOLS));
vanillaDispenserBehaviour = IDispensable.getBehaviorForItem(new ItemStack(Items.SHEARS));
vanillaDispenserBehaviour = Dispensable.getBehaviorForItem(new ItemStack(Items.SHEARS));
DispenserBlock.registerBehavior(Items.SHEARS, dispenserBehavior);
DispenserBlock.registerBehavior(this, dispenserBehavior);
}

View file

@ -8,10 +8,10 @@ import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.ICastable;
import com.minelittlepony.unicopia.magic.IDispenceable;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.IUseable;
import com.minelittlepony.unicopia.magic.Castable;
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.VecHelper;
@ -34,7 +34,7 @@ import net.minecraft.util.Rarity;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public class MagicGemItem extends Item implements ICastable {
public class MagicGemItem extends Item implements Castable {
public MagicGemItem() {
super(new Settings()
@ -50,7 +50,7 @@ public class MagicGemItem extends Item implements ICastable {
}
@Override
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, IDispenceable effect) {
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect) {
Direction facing = source.getBlockState().get(DispenserBlock.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
@ -58,9 +58,9 @@ public class MagicGemItem extends Item implements ICastable {
}
@Override
public CastResult onCastSpell(ItemUsageContext context, IMagicEffect effect) {
if (effect instanceof IUseable) {
return ((IUseable)effect).onUse(context, getAffinity(context.getStack()));
public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) {
if (effect instanceof Useable) {
return ((Useable)effect).onUse(context, getAffinity(context.getStack()));
}
return CastResult.PLACE;
@ -83,7 +83,7 @@ public class MagicGemItem extends Item implements ICastable {
return ActionResult.FAIL;
}
IMagicEffect effect = SpellRegistry.instance().getSpellFrom(stack);
MagicEffect effect = SpellRegistry.instance().getSpellFrom(stack);
if (effect == null) {
return ActionResult.FAIL;
@ -123,7 +123,7 @@ public class MagicGemItem extends Item implements ICastable {
return new TypedActionResult<>(ActionResult.FAIL, stack);
}
IUseable effect = SpellRegistry.instance().getUseActionFrom(stack);
Useable effect = SpellRegistry.instance().getUseActionFrom(stack);
if (effect != null) {
CastResult result = effect.onUse(stack, getAffinity(stack), player, world, VecHelper.getLookedAtEntity(player, 5));
@ -188,7 +188,7 @@ public class MagicGemItem extends Item implements ICastable {
@Override
public boolean canFeed(SpellcastEntity entity, ItemStack stack) {
IMagicEffect effect = entity.getEffect();
MagicEffect effect = entity.getEffect();
return effect != null
&& entity.getAffinity() == getAffinity()

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.toxin.ToxicItem;
import com.minelittlepony.unicopia.toxin.Toxicity;
import com.minelittlepony.unicopia.util.collection.ReversableStateMapList;
@ -50,7 +50,7 @@ public class MossItem extends ToxicItem {
int amount = 1;
if (player != null && SpeciesList.instance().getPlayer(player).getSpecies().canUseEarth()) {
if (player != null && Pony.of(player).getSpecies().canUseEarth()) {
amount = world.random.nextInt(4);
}

View file

@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.util.projectile.ITossableItem;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.projectile.TossableItem;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
@ -17,7 +17,7 @@ import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class RottenTomatoItem extends TomatoItem implements ITossableItem {
public class RottenTomatoItem extends TomatoItem implements TossableItem {
public RottenTomatoItem(int hunger, float saturation) {
super(hunger, saturation);
@ -40,7 +40,7 @@ public class RottenTomatoItem extends TomatoItem implements ITossableItem {
protected boolean isSickening(ItemStack stack, PlayerEntity player) {
return canBeThrown(stack)
&& !SpeciesList.instance().getPlayer(player).getSpecies().canUseEarth();
&& !Pony.of(player).getSpecies().canUseEarth();
}
@Override
@ -61,7 +61,7 @@ public class RottenTomatoItem extends TomatoItem implements ITossableItem {
}
@Override
public void onImpact(ICaster<?> caster, BlockPos pos, BlockState state) {
public void onImpact(Caster<?> caster, BlockPos pos, BlockState state) {
if (caster.isLocal() && state.getMaterial() == Material.GLASS) {
caster.getWorld().breakBlock(pos, true);
}

View file

@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.SpearEntity;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.util.projectile.IAdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.ITossableItem;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.TossableItem;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EquipmentSlot;
@ -21,7 +21,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Position;
import net.minecraft.world.World;
public class SpearItem extends Item implements ITossableItem {
public class SpearItem extends Item implements TossableItem {
public SpearItem(Settings settings) {
super(settings);
@ -84,18 +84,18 @@ public class SpearItem extends Item implements ITossableItem {
@Nullable
@Override
public IAdvancedProjectile createProjectile(World world, PlayerEntity player) {
public AdvancedProjectile createProjectile(World world, PlayerEntity player) {
return new SpearEntity(world, player);
}
@Nullable
@Override
public IAdvancedProjectile createProjectile(World world, Position pos) {
public AdvancedProjectile createProjectile(World world, Position pos) {
return null;
}
@Override
public void onImpact(ICaster<?> caster, BlockPos pos, BlockState state) {
public void onImpact(Caster<?> caster, BlockPos pos, BlockState state) {
}
}

View file

@ -5,7 +5,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.UEntities;
import com.minelittlepony.unicopia.entity.SpellbookEntity;
import com.minelittlepony.unicopia.magic.IDispensable;
import com.minelittlepony.unicopia.magic.Dispensable;
import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.player.PlayerEntity;
@ -21,7 +21,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public class SpellbookItem extends BookItem implements IDispensable {
public class SpellbookItem extends BookItem implements Dispensable {
public SpellbookItem() {
super(new Item.Settings()

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -20,7 +20,7 @@ public class SugaryItem extends Item {
@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) {
if (sugarAmount != 0 && entity instanceof PlayerEntity) {
SpeciesList.instance().getPlayer((PlayerEntity)entity).addEnergy(sugarAmount);
Pony.of((PlayerEntity)entity).addEnergy(sugarAmount);
}
return super.finishUsing(stack, world, entity);

View file

@ -0,0 +1,7 @@
package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.entity.player.Pony;
public interface AddictiveMagicalItem extends MagicalItem {
void onRemoved(Pony player, float needfulness);
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic;
/**
* Interface for things that have an affine alignment.
*/
public interface IAffine {
public interface Affine {
/**
* Gets the current alignment.
* Good/Bad/Neutral

View file

@ -1,13 +1,13 @@
package com.minelittlepony.unicopia.magic;
public interface IAttachedEffect extends IMagicEffect {
public interface AttachedMagicEffect extends MagicEffect {
/**
* Called every tick when attached to a player.
*
* @param source The entity we are currently attached to.
* @return true to keep alive
*/
boolean updateOnPerson(ICaster<?> caster);
boolean updateOnPerson(Caster<?> caster);
/**
* Called every tick when attached to a player. Used to apply particle effects.
@ -15,5 +15,5 @@ public interface IAttachedEffect extends IMagicEffect {
*
* @param source The entity we are currently attached to.
*/
default void renderOnPerson(ICaster<?> source) {}
default void renderOnPerson(Caster<?> source) {}
}

View file

@ -11,11 +11,11 @@ import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface ICastable extends IMagicalItem, IDispensable {
public interface Castable extends MagicalItem, Dispensable {
@Override
default TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) {
IDispenceable effect = SpellRegistry.instance().getDispenseActionFrom(stack);
DispenceableMagicEffect effect = SpellRegistry.instance().getDispenseActionFrom(stack);
if (effect == null) {
return new TypedActionResult<>(ActionResult.FAIL, stack);
@ -36,16 +36,16 @@ public interface ICastable extends IMagicalItem, IDispensable {
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
CastResult onDispenseSpell(BlockPointer source, ItemStack stack, IDispenceable effect);
CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect);
CastResult onCastSpell(ItemUsageContext context, IMagicEffect effect);
CastResult onCastSpell(ItemUsageContext context, MagicEffect effect);
boolean canFeed(SpellcastEntity spell, ItemStack stack);
/**
* Called to cast a spell. The result is an entity spawned with the spell attached.
*/
default SpellcastEntity castContainedSpell(World world, BlockPos pos, ItemStack stack, IMagicEffect effect) {
default SpellcastEntity castContainedSpell(World world, BlockPos pos, ItemStack stack, MagicEffect effect) {
SpellcastEntity spell = new SpellcastEntity(null, world);
spell.setAffinity(getAffinity(stack));

View file

@ -21,15 +21,15 @@ import net.minecraft.world.World;
/**
* Interface for any magically capable entities that can cast and persist spells.
*/
public interface ICaster<E extends LivingEntity> extends Owned<E>, ILevelled, IAffine, IMagicals, ParticleSource {
public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affine, IMagicals, ParticleSource {
void setEffect(@Nullable IMagicEffect effect);
void setEffect(@Nullable MagicEffect effect);
/**
* Gets the active effect for this caster.
*/
@Nullable
default IMagicEffect getEffect(boolean update) {
default MagicEffect getEffect(boolean update) {
return getEffect(null, update);
}
@ -38,19 +38,19 @@ public interface ICaster<E extends LivingEntity> extends Owned<E>, ILevelled, IA
* Returns null if no such effect exists for this caster.
*/
@Nullable
<T extends IMagicEffect> T getEffect(@Nullable Class<T> type, boolean update);
<T extends MagicEffect> T getEffect(@Nullable Class<T> type, boolean update);
/**
* Gets the active effect for this caster updating it if needed.
*/
@Nullable
default IMagicEffect getEffect() {
default MagicEffect getEffect() {
return getEffect(true);
}
@SuppressWarnings("unchecked")
default <T extends IMagicEffect> Optional<T> getEffect(Class<T> type) {
IMagicEffect effect = getEffect();
default <T extends MagicEffect> Optional<T> getEffect(Class<T> type) {
MagicEffect effect = getEffect();
if (effect == null || effect.isDead() || !type.isAssignableFrom(effect.getClass())) {
return Optional.empty();
@ -122,11 +122,11 @@ public interface ICaster<E extends LivingEntity> extends Owned<E>, ILevelled, IA
return getOwner().getHealth() > 0;
}
default Stream<ICaster<?>> findAllSpellsInRange(double radius) {
default Stream<Caster<?>> findAllSpellsInRange(double radius) {
return CasterUtils.findAllSpellsInRange(this, radius);
}
default Stream<ICaster<?>> findAllSpellsInRange(Box bb) {
default Stream<Caster<?>> findAllSpellsInRange(Box bb) {
return CasterUtils.findAllSpellsInRange(this, bb);
}

View file

@ -7,8 +7,7 @@ import javax.annotation.Nullable;
import com.google.common.collect.Streams;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.ducks.RaceContainerHolder;
import com.minelittlepony.unicopia.ducks.PonyContainer;
import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
@ -22,7 +21,7 @@ public class CasterUtils {
/**
* Finds all surrounding spells withing range from the given caster.
*/
public static Stream<ICaster<?>> findAllSpellsInRange(ICaster<?> source, double radius) {
public static Stream<Caster<?>> findAllSpellsInRange(Caster<?> source, double radius) {
BlockPos origin = source.getOrigin();
@ -32,7 +31,7 @@ public class CasterUtils {
Box bb = new Box(begin, end);
return source.getWorld().getEntities(source.getEntity(), bb, e ->
!e.removed && (e instanceof ICaster || e instanceof PlayerEntity)
!e.removed && (e instanceof Caster || e instanceof PlayerEntity)
).stream().filter(e -> {
double dist = e.squaredDistanceTo(origin.getX(), origin.getY(), origin.getZ());
double dist2 = e.squaredDistanceTo(origin.getX(), origin.getY() - e.getStandingEyeHeight(), origin.getZ());
@ -44,16 +43,16 @@ public class CasterUtils {
.map(Optional::get);
}
static Stream<ICaster<?>> findAllSpellsInRange(ICaster<?> source, Box bb) {
return source.getWorld().getEntities(source.getEntity(), bb, e -> !e.removed && (e instanceof ICaster || EquinePredicates.MAGI.test(e))).stream()
static Stream<Caster<?>> findAllSpellsInRange(Caster<?> source, Box bb) {
return source.getWorld().getEntities(source.getEntity(), bb, e -> !e.removed && (e instanceof Caster || EquinePredicates.MAGI.test(e))).stream()
.map(CasterUtils::toCaster)
.filter(o -> o.isPresent() && o.get() != source)
.map(Optional::get);
}
static <T extends IMagicEffect> Optional<T> toMagicEffect(Class<T> type, @Nullable Entity entity) {
static <T extends MagicEffect> Optional<T> toMagicEffect(Class<T> type, @Nullable Entity entity) {
return toCaster(entity)
.filter(ICaster::hasEffect)
.filter(Caster::hasEffect)
.map(caster -> caster.getEffect(type, false))
.filter(e -> !e.isDead());
}
@ -71,14 +70,13 @@ public class CasterUtils {
/**
* Attempts to convert the passed entity into a caster using all the known methods.
*/
public static Optional<ICaster<?>> toCaster(@Nullable Entity entity) {
if (entity instanceof ICaster<?>) {
return Optional.of((ICaster<?>)entity);
public static Optional<Caster<?>> toCaster(@Nullable Entity entity) {
if (entity instanceof Caster<?>) {
return Optional.of((Caster<?>)entity);
}
if (entity instanceof LivingEntity && !(entity instanceof IMagicals)) {
return SpeciesList.instance().getForEntity(entity)
.map(RaceContainerHolder::getCaster);
return PonyContainer.of(entity).map(PonyContainer::getCaster);
}
return Optional.empty();

View file

@ -7,7 +7,7 @@ import net.minecraft.util.math.Direction;
/**
* Represents an object with an action to perform when dispensed from a dispenser.
*/
public interface IDispenceable extends IMagicEffect {
public interface DispenceableMagicEffect extends MagicEffect {
/**
* Called when dispensed.

View file

@ -11,7 +11,7 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPointer;
public interface IDispensable {
public interface Dispensable {
/**
* Enables dispensing behaviours for this item.
*/

View file

@ -1,15 +1,15 @@
package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.entity.player.Pony;
/**
* Represents a passive spell that does something when held in the player's hand.
*/
public interface IHeldEffect extends IMagicEffect {
public interface HeldMagicEffect extends MagicEffect {
/**
* Called every tick when held in a player's inventory.
*
* @param source The entity we are currently attached to.
*/
void updateInHand(IPlayer caster, Affinity affinity);
void updateInHand(Pony caster, Affinity affinity);
}

View file

@ -1,7 +0,0 @@
package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.entity.player.IPlayer;
public interface IDependable extends IMagicalItem {
void onRemoved(IPlayer player, float needfulness);
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic;
/**
* Object with levelling capabilities.
*/
public interface ILevelled {
public interface Levelled {
/**
* Maximum level this spell can reach or -1 for unlimited.

View file

@ -1,14 +1,14 @@
package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.InbtSerialisable;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.entity.projectile.ProjectileEntity;
/**
* Interface for a magic spells
*/
public interface IMagicEffect extends InbtSerialisable, IAffine {
public interface MagicEffect extends NbtSerialisable, Affine {
/**
* Gets the name used to identify this effect.
@ -49,19 +49,19 @@ public interface IMagicEffect extends InbtSerialisable, IAffine {
* Gets the highest level this spell can be safely operated at.
* Gems may go higher, however chance of explosion/exhaustion increases with every level.
*/
int getMaxLevelCutOff(ICaster<?> caster);
int getMaxLevelCutOff(Caster<?> caster);
float getMaxExhaustion(ICaster<?> caster);
float getMaxExhaustion(Caster<?> caster);
/**
* Gets the chances of this effect turning into an innert gem or exploding.
*/
float getExhaustion(ICaster<?> caster);
float getExhaustion(Caster<?> caster);
/**
* Called when first attached to a gem.
*/
default void onPlaced(ICaster<?> caster) {
default void onPlaced(Caster<?> caster) {
}
@ -75,7 +75,7 @@ public interface IMagicEffect extends InbtSerialisable, IAffine {
*
* @param source The entity we are currently attached to.
*/
boolean update(ICaster<?> source);
boolean update(Caster<?> source);
/**
* Called every tick when attached to an entity to produce particle effects.
@ -83,7 +83,7 @@ public interface IMagicEffect extends InbtSerialisable, IAffine {
*
* @param source The entity we are attached to.
*/
void render(ICaster<?> source);
void render(Caster<?> source);
/**
* Return true to allow the gem update and move.
@ -95,7 +95,7 @@ public interface IMagicEffect extends InbtSerialisable, IAffine {
/**
* Returns a new, deep-copied instance of this spell.
*/
default IMagicEffect copy() {
default MagicEffect copy() {
return SpellRegistry.instance().copyInstance(this);
}
}

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.magic;
import net.minecraft.item.ItemStack;
public interface IMagicalItem extends IAffine {
public interface MagicalItem extends Affine {
/**
* If true this item serves as host to its own inner dimensional space.
* Bag of Holding will explode if you try to store items of this kind inside of it.

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic;
/**
* Magic effects that can be suppressed by other nearby effects.
*/
public interface ISuppressable extends IMagicEffect {
public interface SuppressableEffect extends MagicEffect {
/**
* Returns true if this spell is currently still suppressed.
@ -13,10 +13,10 @@ public interface ISuppressable extends IMagicEffect {
/**
* Returns true if this spell can be suppressed by the given other spell and caster.
*/
boolean isVulnerable(ICaster<?> otherSource, IMagicEffect other);
boolean isVulnerable(Caster<?> otherSource, MagicEffect other);
/**
* Event triggered when this effect is suppressed.
*/
void onSuppressed(ICaster<?> otherSource);
void onSuppressed(Caster<?> otherSource);
}

View file

@ -5,8 +5,8 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.ProjectileEntity;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.projectile.IAdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.ITossable;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.Tossable;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
@ -19,17 +19,17 @@ import net.minecraft.world.World;
/**
* Magic effects that can be thrown.
*/
public interface ITossedEffect extends IMagicEffect, ITossable<ICaster<?>> {
public interface TossedMagicEffect extends MagicEffect, Tossable<Caster<?>> {
@Override
default SoundEvent getThrowSound(ICaster<?> caster) {
default SoundEvent getThrowSound(Caster<?> caster) {
return SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
}
/**
* Gets the appearance to be used when projecting this spell.
*/
default ItemStack getCastAppearance(ICaster<?> caster) {
default ItemStack getCastAppearance(Caster<?> caster) {
Item item = getAffinity() == Affinity.BAD ? UItems.curse : UItems.spell;
return SpellRegistry.instance().enchantStack(new ItemStack(item), getName());
@ -41,7 +41,7 @@ public interface ITossedEffect extends IMagicEffect, ITossable<ICaster<?>> {
* Returns the resulting projectile entity for customization (or null if on the client).
*/
@Nullable
default IAdvancedProjectile toss(ICaster<?> caster) {
default AdvancedProjectile toss(Caster<?> caster) {
World world = caster.getWorld();
Entity entity = caster.getOwner();
@ -49,7 +49,7 @@ public interface ITossedEffect extends IMagicEffect, ITossable<ICaster<?>> {
world.playSound(null, entity.x, entity.y, entity.z, getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
if (caster.isLocal()) {
IAdvancedProjectile projectile = new ProjectileEntity(null, world, caster.getOwner());
AdvancedProjectile projectile = new ProjectileEntity(null, world, caster.getOwner());
projectile.setItem(getCastAppearance(caster));
projectile.setThrowDamage(getThrowDamage(caster));

View file

@ -12,7 +12,7 @@ import net.minecraft.world.World;
* Interface for right-click actions.
*
*/
public interface IUseable {
public interface Useable {
/**
* Triggered when the player right clicks a block

View file

@ -6,7 +6,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.Caster;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
@ -43,7 +43,7 @@ public abstract class AbstractAttachableSpell extends AbstractSpell {
}
@Nullable
protected SpellcastEntity getTarget(ICaster<?> source) {
protected SpellcastEntity getTarget(Caster<?> source) {
if (targettedEntity == null && targettedEntityId != null) {
Entity e = ((ServerWorld)source.getWorld()).getEntity(targettedEntityId);
@ -63,7 +63,7 @@ public abstract class AbstractAttachableSpell extends AbstractSpell {
}
@Override
public boolean update(ICaster<?> source) {
public boolean update(Caster<?> source) {
if (source.getWorld() instanceof ServerWorld) {
if (searching) {
@ -76,7 +76,7 @@ public abstract class AbstractAttachableSpell extends AbstractSpell {
return !isDead();
}
protected void searchForTarget(ICaster<?> source) {
protected void searchForTarget(Caster<?> source) {
BlockPos origin = source.getOrigin();
source.getWorld().getEntities(source.getEntity(), getSearchArea(source), e -> {
@ -88,7 +88,7 @@ public abstract class AbstractAttachableSpell extends AbstractSpell {
.ifPresent(this::setTarget);
}
protected abstract Box getSearchArea(ICaster<?> source);
protected abstract Box getSearchArea(Caster<?> source);
protected abstract boolean canTargetEntity(SpellcastEntity e);

View file

@ -1,11 +1,11 @@
package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.IMagicEffect;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect;
import net.minecraft.nbt.CompoundTag;
public abstract class AbstractSpell implements IMagicEffect {
public abstract class AbstractSpell implements MagicEffect {
protected boolean isDead;
protected boolean isDirty;
@ -36,17 +36,17 @@ public abstract class AbstractSpell implements IMagicEffect {
}
@Override
public int getMaxLevelCutOff(ICaster<?> source) {
public int getMaxLevelCutOff(Caster<?> source) {
return 1;
}
@Override
public float getMaxExhaustion(ICaster<?> caster) {
public float getMaxExhaustion(Caster<?> caster) {
return 1;
}
@Override
public float getExhaustion(ICaster<?> caster) {
public float getExhaustion(Caster<?> caster) {
return 0;
}
@ -64,17 +64,17 @@ public abstract class AbstractSpell implements IMagicEffect {
public static abstract class RangedAreaSpell extends AbstractSpell {
@Override
public int getMaxLevelCutOff(ICaster<?> source) {
public int getMaxLevelCutOff(Caster<?> source) {
return 17;
}
@Override
public float getMaxExhaustion(ICaster<?> caster) {
public float getMaxExhaustion(Caster<?> caster) {
return 1000;
}
@Override
public float getExhaustion(ICaster<?> caster) {
public float getExhaustion(Caster<?> caster) {
float max = getMaxLevelCutOff(caster);
float current = caster.getCurrentLevel();

View file

@ -1,9 +1,9 @@
package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.shape.Sphere;
@ -30,7 +30,7 @@ public class AttractiveSpell extends ShieldSpell {
}
@Override
public void render(ICaster<?> source) {
public void render(Caster<?> source) {
int range = 4 + (source.getCurrentLevel() * 2);
Vec3d pos = source.getOriginVector();
@ -40,18 +40,18 @@ public class AttractiveSpell extends ShieldSpell {
}
@Override
public double getDrawDropOffRange(ICaster<?> caster) {
public double getDrawDropOffRange(Caster<?> caster) {
return 10 + (caster.getCurrentLevel() * 2);
}
@Override
protected void applyRadialEffect(ICaster<?> source, Entity target, double distance, double radius) {
protected void applyRadialEffect(Caster<?> source, Entity target, double distance, double radius) {
Vec3d pos = source.getOriginVector();
double force = 2.5F / distance;
if (source.getAffinity() != Affinity.BAD && target instanceof PlayerEntity) {
force *= calculateAdjustedForce(SpeciesList.instance().getPlayer((PlayerEntity)target));
force *= calculateAdjustedForce(Pony.of((PlayerEntity)target));
}
if (source.getAffinity() == Affinity.BAD && source.getWorld().random.nextInt(4500) == 0) {

Some files were not shown because too many files have changed in this diff Show more