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() .setPrettyPrinting()
.create(); .create();
public static Config instance() { public static Config getInstance() {
return instance; return instance;
} }
public static void init(Path directory) { static void init(Path directory) {
Path file = directory.resolve("unicopia.json"); Path file = directory.resolve("unicopia.json");
try { try {

View file

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

View file

@ -5,6 +5,8 @@ import java.util.Map;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import net.minecraft.entity.player.PlayerEntity;
public enum Race { public enum Race {
/** /**
* The default, unset race. * The default, unset race.
@ -66,6 +68,28 @@ public enum Race {
return String.format("unicopia.race.%s", name().toLowerCase()); 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) { public boolean equals(String s) {
return name().equalsIgnoreCase(s) return name().equalsIgnoreCase(s)
|| getTranslationKey().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.google.gson.annotations.Expose;
import com.minelittlepony.unicopia.IKeyBinding; import com.minelittlepony.unicopia.IKeyBinding;
import com.minelittlepony.unicopia.Race; 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.util.math.BlockPos;
import net.minecraft.world.World; 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. * 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 * Returns the number of ticks allowed for cooldown
*/ */
int getCooldownTime(IPlayer player); int getCooldownTime(Pony player);
/** /**
* Called to check preconditions for activating the ability. * 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 * @param player The player
* @return True to allow activation * @return True to allow activation
*/ */
default boolean canActivate(World w, IPlayer player) { default boolean canActivate(World w, Pony player) {
return true; 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 * @return Data to be sent, or null if activation failed
*/ */
@Nullable @Nullable
T tryActivate(IPlayer player); T tryActivate(Pony player);
Class<T> getPackageType(); 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 player The player that triggered the ability
* @param data Data previously sent from the client * @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. * Called every tick until the warmup timer runs out.
* @param player The current player * @param player The current player
*/ */
void preApply(IPlayer player); void preApply(Pony player);
/** /**
* Called every tick until the cooldown timer runs out. * Called every tick until the cooldown timer runs out.
* @param player The current player * @param player The current player
*/ */
void postApply(IPlayer player); void postApply(Pony player);
public interface IData { public interface IData {

View file

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

View file

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

View file

@ -5,7 +5,7 @@ import javax.annotation.Nullable;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race; 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; import com.minelittlepony.unicopia.magic.spell.ChangelingTrapSpell;
public class ChangelingTrapAbility implements Ability<Ability.Hit> { public class ChangelingTrapAbility implements Ability<Ability.Hit> {
@ -21,12 +21,12 @@ public class ChangelingTrapAbility implements Ability<Ability.Hit> {
} }
@Override @Override
public int getWarmupTime(IPlayer player) { public int getWarmupTime(Pony player) {
return 0; return 0;
} }
@Override @Override
public int getCooldownTime(IPlayer player) { public int getCooldownTime(Pony player) {
return 30; return 30;
} }
@ -37,7 +37,7 @@ public class ChangelingTrapAbility implements Ability<Ability.Hit> {
@Nullable @Nullable
@Override @Override
public Hit tryActivate(IPlayer player) { public Hit tryActivate(Pony player) {
return new Hit(); return new Hit();
} }
@ -47,17 +47,17 @@ public class ChangelingTrapAbility implements Ability<Ability.Hit> {
} }
@Override @Override
public void apply(IPlayer player, Hit data) { public void apply(Pony player, Hit data) {
new ChangelingTrapSpell().toss(player); new ChangelingTrapSpell().toss(player);
} }
@Override @Override
public void preApply(IPlayer player) { public void preApply(Pony player) {
} }
@Override @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.Race;
import com.minelittlepony.unicopia.UParticles; 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 com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -33,12 +33,12 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
} }
@Override @Override
public int getWarmupTime(IPlayer player) { public int getWarmupTime(Pony player) {
return 10; return 10;
} }
@Override @Override
public int getCooldownTime(IPlayer player) { public int getCooldownTime(Pony player) {
return 50; return 50;
} }
@ -48,7 +48,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
} }
@Override @Override
public Pos tryActivate(IPlayer player) { public Pos tryActivate(Pony player) {
HitResult ray = VecHelper.getObjectMouseOver(player.getOwner(), 3, 1); HitResult ray = VecHelper.getObjectMouseOver(player.getOwner(), 3, 1);
if (ray instanceof BlockHitResult && ray.getType() == HitResult.Type.BLOCK) { if (ray instanceof BlockHitResult && ray.getType() == HitResult.Type.BLOCK) {
@ -64,7 +64,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
} }
@Override @Override
public void apply(IPlayer player, Pos data) { public void apply(Pony player, Pos data) {
int count = 0; int count = 0;
for (BlockPos pos : BlockPos.iterate( for (BlockPos pos : BlockPos.iterate(
@ -91,7 +91,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
} }
@Override @Override
public void preApply(IPlayer player) { public void preApply(Pony player) {
player.addExertion(3); player.addExertion(3);
if (player.getWorld().isClient()) { if (player.getWorld().isClient()) {
@ -100,7 +100,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
} }
@Override @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.common.collect.Lists;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.item.AppleItem; import com.minelittlepony.unicopia.item.AppleItem;
import com.minelittlepony.unicopia.util.AwaitTickQueue; import com.minelittlepony.unicopia.util.AwaitTickQueue;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.WorldEvent; 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 com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -63,12 +62,12 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
} }
@Override @Override
public int getWarmupTime(IPlayer player) { public int getWarmupTime(Pony player) {
return 3; return 3;
} }
@Override @Override
public int getCooldownTime(IPlayer player) { public int getCooldownTime(Pony player) {
return 50; return 50;
} }
@ -78,7 +77,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
} }
@Override @Override
public EarthPonyStompAbility.Data tryActivate(IPlayer player) { public EarthPonyStompAbility.Data tryActivate(Pony player) {
HitResult mop = VecHelper.getObjectMouseOver(player.getOwner(), 6, 1); HitResult mop = VecHelper.getObjectMouseOver(player.getOwner(), 6, 1);
if (mop instanceof BlockHitResult && mop.getType() == HitResult.Type.BLOCK) { if (mop instanceof BlockHitResult && mop.getType() == HitResult.Type.BLOCK) {
@ -118,7 +117,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
} }
@Override @Override
public void apply(IPlayer iplayer, Data data) { public void apply(Pony iplayer, Data data) {
PlayerEntity player = iplayer.getOwner(); 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; double amount = (4 * player.getAttributeInstance(EntityAttributes.ATTACK_DAMAGE).getValue()) / (float)dist;
if (i instanceof PlayerEntity) { if (i instanceof PlayerEntity) {
Race race = SpeciesList.instance().getPlayer((PlayerEntity)i).getSpecies(); Race race = Pony.of((PlayerEntity)i).getSpecies();
if (race.canUseEarth()) { if (race.canUseEarth()) {
amount /= 3; amount /= 3;
} }
@ -203,13 +202,13 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
} }
@Override @Override
public void preApply(IPlayer player) { public void preApply(Pony player) {
player.addExertion(40); player.addExertion(40);
player.getOwner().attemptSprintingParticles(); player.getOwner().attemptSprintingParticles();
} }
@Override @Override
public void postApply(IPlayer player) { public void postApply(Pony player) {
int timeDiff = getCooldownTime(player) - player.getAbilities().getRemainingCooldown(); int timeDiff = getCooldownTime(player) - player.getAbilities().getRemainingCooldown();
if (player.getOwner().getEntityWorld().getTime() % 1 == 0 || timeDiff == 0) { 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) { private void spawnParticleRing(PlayerEntity player, int timeDiff, double yVel) {
int animationTicks = timeDiff / 10; int animationTicks = timeDiff / 10;
if (animationTicks < 6) { 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); double y = 0.5 + (Math.sin(animationTicks) * 1.5);

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability; 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. * 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. * This overrides what the race specifies.
*/ */
public interface FlightPredicate { public interface FlightPredicate {
boolean checkCanFly(IPlayer player); boolean checkCanFly(Pony player);
} }

View file

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

View file

@ -6,7 +6,7 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UParticles; 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 com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -24,12 +24,12 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
} }
@Override @Override
public int getWarmupTime(IPlayer player) { public int getWarmupTime(Pony player) {
return 10; return 10;
} }
@Override @Override
public int getCooldownTime(IPlayer player) { public int getCooldownTime(Pony player) {
return 5; return 5;
} }
@ -39,7 +39,7 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
} }
@Override @Override
public Numeric tryActivate(IPlayer player) { public Numeric tryActivate(Pony player) {
return findTarget(player).map(cloud -> { return findTarget(player).map(cloud -> {
Numeric data = new Numeric(player.getOwner().inventory.selectedSlot + 1); Numeric data = new Numeric(player.getOwner().inventory.selectedSlot + 1);
cloud.handlePegasusInteration(data.type); cloud.handlePegasusInteration(data.type);
@ -54,13 +54,13 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
} }
@Override @Override
public void apply(IPlayer player, Numeric data) { public void apply(Pony player, Numeric data) {
findTarget(player).ifPresent(cloud -> { findTarget(player).ifPresent(cloud -> {
cloud.handlePegasusInteration(data.type); 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) { if (player.getOwner().hasVehicle() && player.getOwner().getVehicle() instanceof ICloudEntity) {
return Optional.ofNullable((ICloudEntity)player.getOwner().getVehicle()); return Optional.ofNullable((ICloudEntity)player.getOwner().getVehicle());
} }
@ -75,12 +75,12 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
} }
@Override @Override
public void preApply(IPlayer player) { public void preApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 10); player.spawnParticles(UParticles.UNICORN_MAGIC, 10);
} }
@Override @Override
public void postApply(IPlayer player) { public void postApply(Pony player) {
player.spawnParticles(UParticles.RAIN_DROPS, 5); 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.Race;
import com.minelittlepony.unicopia.UParticles; 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; import com.minelittlepony.unicopia.magic.spell.ShieldSpell;
/** /**
@ -24,12 +24,12 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
} }
@Override @Override
public int getWarmupTime(IPlayer player) { public int getWarmupTime(Pony player) {
return 20; return 20;
} }
@Override @Override
public int getCooldownTime(IPlayer player) { public int getCooldownTime(Pony player) {
return 0; return 0;
} }
@ -39,7 +39,7 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
} }
@Override @Override
public Hit tryActivate(IPlayer player) { public Hit tryActivate(Pony player) {
return new Hit(); return new Hit();
} }
@ -49,7 +49,7 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
} }
@Override @Override
public void apply(IPlayer player, Hit data) { public void apply(Pony player, Hit data) {
// TODO: A way to pick the active effect // TODO: A way to pick the active effect
if (player.getEffect() instanceof ShieldSpell) { if (player.getEffect() instanceof ShieldSpell) {
player.setEffect(null); player.setEffect(null);
@ -59,12 +59,12 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
} }
@Override @Override
public void preApply(IPlayer player) { public void preApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); player.spawnParticles(UParticles.UNICORN_MAGIC, 5);
} }
@Override @Override
public void postApply(IPlayer player) { public void postApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); 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.Race;
import com.minelittlepony.unicopia.UParticles; 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 com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -40,12 +40,12 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
} }
@Override @Override
public int getWarmupTime(IPlayer player) { public int getWarmupTime(Pony player) {
return 20; return 20;
} }
@Override @Override
public int getCooldownTime(IPlayer player) { public int getCooldownTime(Pony player) {
return 50; return 50;
} }
@ -55,7 +55,7 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
} }
@Override @Override
public Pos tryActivate(IPlayer player) { public Pos tryActivate(Pony player) {
HitResult ray = VecHelper.getObjectMouseOver(player.getOwner(), 100, 1); HitResult ray = VecHelper.getObjectMouseOver(player.getOwner(), 100, 1);
World w = player.getWorld(); World w = player.getWorld();
@ -115,7 +115,7 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
} }
@Override @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); iplayer.getWorld().playSound(null, iplayer.getOrigin(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 1, 1);
PlayerEntity player = iplayer.getOwner(); PlayerEntity player = iplayer.getOwner();
@ -164,13 +164,13 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
} }
@Override @Override
public void preApply(IPlayer player) { public void preApply(Pony player) {
player.addExertion(3); player.addExertion(3);
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); player.spawnParticles(UParticles.UNICORN_MAGIC, 5);
} }
@Override @Override
public void postApply(IPlayer player) { public void postApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); player.spawnParticles(UParticles.UNICORN_MAGIC, 5);
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,12 @@
package com.minelittlepony.unicopia.client.gui; package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.client.gui.UHud; import com.minelittlepony.unicopia.client.gui.UHud;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
// TODO: forge events
class ClientHooks { class ClientHooks {
public static void beforePreRenderHud() { public static void beforePreRenderHud() {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
@ -13,7 +14,7 @@ class ClientHooks {
MinecraftClient client = MinecraftClient.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null && client.world != null) { 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(); MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null && client.world != null) { 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(); GlStateManager.popMatrix();

View file

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

View file

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

View file

@ -5,7 +5,7 @@ import java.util.List;
import org.lwjgl.opengl.GL11; 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 com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@ -22,7 +22,7 @@ public class UHud {
TextRenderer fonts = mc.textRenderer; TextRenderer fonts = mc.textRenderer;
IPlayer player; Pony player;
int width; int width;
@ -34,7 +34,7 @@ public class UHud {
elements.add(new FlightExperienceBar()); elements.add(new FlightExperienceBar());
} }
public void renderHud(IPlayer player, Window resolution) { public void renderHud(Pony player, Window resolution) {
this.width = resolution.getScaledWidth(); this.width = resolution.getScaledWidth();
this.height = resolution.getScaledHeight(); this.height = resolution.getScaledHeight();
this.player = player; this.player = player;
@ -43,7 +43,7 @@ public class UHud {
elements.forEach(this::renderElement); 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.width = window.getScaledWidth();
this.height = window.getScaledHeight(); this.height = window.getScaledHeight();
this.player = player; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; 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 com.minelittlepony.unicopia.entity.player.PlayerCamera;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@ -24,7 +24,7 @@ abstract class MixinCamera {
PlayerEntity player = MinecraftClient.getInstance().player; PlayerEntity player = MinecraftClient.getInstance().player;
if (player != null) { if (player != null) {
PlayerCamera view = SpeciesList.instance().getPlayer(player).getCamera(); PlayerCamera view = Pony.of(player).getCamera();
//event.setRoll(view.calculateRoll()); //event.setRoll(view.calculateRoll());
pitch = view.calculatePitch(pitch); 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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 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.MinecraftClient;
import net.minecraft.client.render.Camera; import net.minecraft.client.render.Camera;
@ -18,7 +18,7 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
at = @At("RETURN"), at = @At("RETURN"),
cancellable = true) cancellable = true)
private void onGetFov(Camera camera, float f, boolean z, CallbackInfoReturnable<Double> info) { 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() .getCamera()
.calculateFieldOfView(info.getReturnValue())); .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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.SpeciesList; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input; import net.minecraft.client.input.Input;
@ -16,7 +15,7 @@ import net.minecraft.client.input.KeyboardInput;
abstract class MixinKeyboardInput extends Input { abstract class MixinKeyboardInput extends Input {
@Inject(method = "tick(ZZ)V", at = @At("RETURN")) @Inject(method = "tick(ZZ)V", at = @At("RETURN"))
private void onTick(boolean one, boolean two, CallbackInfo info) { 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) { if (player.getGravity().getGravitationConstant() < 0) {
boolean tmp = pressingLeft; 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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 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.MinecraftClient;
import net.minecraft.client.Mouse; import net.minecraft.client.Mouse;
@ -23,7 +23,7 @@ abstract class MixinMouse {
@Inject(method = "updateMouse()V", at = @At("HEAD")) @Inject(method = "updateMouse()V", at = @At("HEAD"))
private void onUpdateMouse(CallbackInfo info) { private void onUpdateMouse(CallbackInfo info) {
if (SpeciesList.instance().getPlayer(client.player).getGravity().getGravitationConstant() < 0) { if (Pony.of(client.player).getGravity().getGravitationConstant() < 0) {
cursorDeltaX = -cursorDeltaX; cursorDeltaX = -cursorDeltaX;
cursorDeltaY = -cursorDeltaY; cursorDeltaY = -cursorDeltaY;
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
package com.minelittlepony.unicopia.command; 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.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -21,20 +21,32 @@ class RacelistCommand {
builder.then(CommandManager.literal("allow") builder.then(CommandManager.literal("allow")
.then(CommandManager.argument("race", new RaceArgument()) .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") builder.then(CommandManager.literal("disallow")
.then(CommandManager.argument("race", new RaceArgument()) .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); 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; String translationKey = "commands.racelist." + action;
if (!func.apply(SpeciesList.instance(), race)) { if (!func.apply(race)) {
translationKey += ".failed"; translationKey += ".failed";
} }

View file

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

View file

@ -6,9 +6,9 @@ import java.util.Optional;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import com.minelittlepony.unicopia.advancement.BOHDeathCriterion; 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.HeavyInventoryUtils;
import com.minelittlepony.unicopia.util.InbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.block.Block; 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.LootContext;
import net.minecraft.world.loot.context.LootContextParameters; 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 NBT_COMPOUND = 10;
public static final int MIN_SIZE = 18; 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 // TODO: tag for items that are invalid for the inventory of holding
|| stack.getItem() instanceof BlockItem && (((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock) || stack.getItem() instanceof BlockItem && (((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|| (compound != null && compound.containsKey("invalid")) || (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) { protected boolean isIllegalBlock(Block block) {

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.container;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener; import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.AwaitTickQueue; 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, 2, 175, 134));
addSlot(new SpellbookSlot(craftMatrix, 3, 226, 120)); addSlot(new SpellbookSlot(craftMatrix, 3, 226, 120));
addSlot(new SpellbookSlot(craftMatrix, 4, 227, 65)); 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 @Override
@ -161,7 +161,7 @@ public class SpellBookContainer extends Container {
return EquinePredicates.MAGI.test(player); 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) { public SpellbookSlot(Inventory inventoryIn, int index, int xPosition, int yPosition) {
super(inventoryIn, index, xPosition, yPosition); super(inventoryIn, index, xPosition, yPosition);

View file

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

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ducks;
import com.minelittlepony.unicopia.entity.ItemEntityCapabilities; import com.minelittlepony.unicopia.entity.ItemEntityCapabilities;
public interface IItemEntity extends RaceContainerHolder<ItemEntityCapabilities> { public interface IItemEntity extends PonyContainer<ItemEntityCapabilities> {
int getAge(); 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 @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)); 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 prop PlayerExtension for the player doing the crafting
* @param stack ItemStack crafted * @param stack ItemStack crafted
*/ */
boolean matches(IPageOwner owner, T event); boolean matches(PageOwner owner, T event);
default void require(JsonObject json, String memberName) { default void require(JsonObject json, String memberName) {
if (!json.has(memberName)) { if (!json.has(memberName)) {

View file

@ -21,7 +21,7 @@ public interface Page extends Comparable<Page> {
* Tests unlock conditions for this page. * Tests unlock conditions for this page.
* Returns true if the owner is permitted to read 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. * Gets the texture.

View file

@ -76,7 +76,7 @@ class PageInstance implements Page {
} }
@Override @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); 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. * Interface for things that own and can unlock pages.
* *
*/ */
public interface IPageOwner extends Transmittable { public interface PageOwner extends Transmittable {
@Nonnull @Nonnull
Map<Identifier, PageState> getPageStates(); Map<Identifier, PageState> getPageStates();

View file

@ -19,7 +19,7 @@ public class PageStateCondition implements IUnlockCondition<IUnlockEvent> {
} }
@Override @Override
public boolean matches(IPageOwner owner, IUnlockEvent event) { public boolean matches(PageOwner owner, IUnlockEvent event) {
Page ipage = Pages.instance().getByName(page); Page ipage = Pages.instance().getByName(page);
if (ipage != null) { 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); 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() pages.values().stream()
.filter(page -> page.canUnlock(owner, event)) .filter(page -> page.canUnlock(owner, event))
.forEach(page -> unlockPage(owner, page, unlockListener)); .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 (owner.getPageState(page).isLocked()) {
if (unlockListener == null || unlockListener.onPageUnlocked(page)) { if (unlockListener == null || unlockListener.onPageUnlocked(page)) {
owner.setPageState(page, PageState.UNREAD); owner.setPageState(page, PageState.UNREAD);

View file

@ -16,7 +16,7 @@ import net.minecraft.item.ItemStack;
*/ */
public class SpellCraftingEvent { 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); Pages.instance().triggerUnlockEvent(owner, new Event(stack), unlockListener);
} }
@ -49,7 +49,7 @@ public class SpellCraftingEvent {
} }
@Override @Override
public boolean matches(IPageOwner prop, Event event) { public boolean matches(PageOwner prop, Event event) {
if (!event.stack.isEmpty() && event.stack.getItem() instanceof MagicGemItem) { if (!event.stack.isEmpty() && event.stack.getItem() instanceof MagicGemItem) {
return ((MagicGemItem)event.stack.getItem()).getAffinity() == affinity return ((MagicGemItem)event.stack.getItem()).getAffinity() == affinity
&& SpellRegistry.getKeyFromStack(event.stack).equals(spell); && 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.EquinePredicates;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UBlocks; import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.UParticles; import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloudEntity; import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloudEntity;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.util.particles.ParticleEmitter; 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.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); 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; BlockSoundGroup soundtype = BlockSoundGroup.WOOL;
player.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); 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) { public ItemEntity dropItem(ItemConvertible stack, int amount) {
ItemEntity item = super.dropItem(stack, amount); ItemEntity item = super.dropItem(stack, amount);
SpeciesList.instance().getEntity(item).setSpecies(Race.PEGASUS); Ponylike.of(item).setSpecies(Race.PEGASUS);
item.setNoGravity(true); item.setNoGravity(true);
item.setVelocity(0, 0, 0); item.setVelocity(0, 0, 0);

View file

@ -7,9 +7,9 @@ import javax.annotation.Nullable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UParticles; import com.minelittlepony.unicopia.UParticles;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.block.Blocks; 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()) { if (player.canConsume(false) || player.getHealth() < player.getHealthMaximum()) {
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player); 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 (passenger instanceof LivingEntity) {
if (player.hasStatusEffect(StatusEffects.NAUSEA)) { 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 java.util.EnumSet;
import com.minelittlepony.unicopia.magic.ICaster; import com.minelittlepony.unicopia.magic.Caster;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
@ -19,7 +19,7 @@ import net.minecraft.world.ViewableWorld;
public class FollowCasterGoal<T extends MobEntity> extends Goal { public class FollowCasterGoal<T extends MobEntity> extends Goal {
protected final ICaster<?> caster; protected final Caster<?> caster;
protected final MobEntity entity; protected final MobEntity entity;
@ -38,7 +38,7 @@ public class FollowCasterGoal<T extends MobEntity> extends Goal {
private float oldWaterCost; 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.caster = caster;
this.entity = (MobEntity)caster.getEntity(); 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.Race;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.IAffine; import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.IAttachedEffect; import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
import com.minelittlepony.unicopia.magic.ICaster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.IMagicEffect; import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync; 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.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.nbt.CompoundTag; 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); 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 @Override
public void setEffect(IMagicEffect effect) { public void setEffect(MagicEffect effect) {
effectDelegate.set(effect); effectDelegate.set(effect);
} }
@Override @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); return effectDelegate.get(type, update);
} }
@ -58,7 +58,7 @@ public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, IC
@Override @Override
public void onUpdate() { public void onUpdate() {
if (hasEffect()) { if (hasEffect()) {
IAttachedEffect effect = getEffect(IAttachedEffect.class, true); AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true);
if (effect != null) { if (effect != null) {
if (entity.getEntityWorld().isClient()) { if (entity.getEntityWorld().isClient()) {
@ -98,15 +98,15 @@ public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, IC
@Override @Override
public Affinity getAffinity() { public Affinity getAffinity() {
if (getOwner() instanceof IAffine) { if (getOwner() instanceof Affine) {
return ((IAffine)getOwner()).getAffinity(); return ((Affine)getOwner()).getAffinity();
} }
return Affinity.NEUTRAL; return Affinity.NEUTRAL;
} }
@Override @Override
public void toNBT(CompoundTag compound) { public void toNBT(CompoundTag compound) {
IMagicEffect effect = getEffect(); MagicEffect effect = getEffect();
if (effect != null) { if (effect != null) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect)); compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));

View file

@ -1,12 +1,16 @@
package com.minelittlepony.unicopia.entity; package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Race; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.util.InbtSerialisable;
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.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public interface IEntity extends InbtSerialisable, Updatable { public interface Ponylike extends NbtSerialisable, Updatable {
Race getSpecies(); Race getSpecies();
void setSpecies(Race race); void setSpecies(Race race);
@ -56,4 +60,11 @@ public interface IEntity extends InbtSerialisable, Updatable {
default void onJump() { 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 java.util.UUID;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.ICaster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.IMagicEffect; import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.ITossedEffect; import com.minelittlepony.unicopia.magic.TossedMagicEffect;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.util.projectile.IAdvancedProjectile; import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.ITossable; import com.minelittlepony.unicopia.util.projectile.Tossable;
import com.minelittlepony.unicopia.util.projectile.ITossableItem; import com.minelittlepony.unicopia.util.projectile.TossableItem;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
@ -39,7 +39,7 @@ import net.minecraft.world.World;
* *
* Can also carry a spell if needed. * 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<Float> DAMAGE = DataTracker.registerData(ProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<Boolean> HYDROPHOBIC = DataTracker.registerData(ProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN); 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 @Override
public void setEffect(ITossedEffect effect) { public void setEffect(TossedMagicEffect effect) {
setEffect((IMagicEffect)effect); setEffect((MagicEffect)effect);
} }
@Override @Override
public void setEffect(IMagicEffect effect) { public void setEffect(MagicEffect effect) {
effectDelegate.set(effect); effectDelegate.set(effect);
if (effect != null) { if (effect != null) {
@ -130,7 +130,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, IAd
} }
@Override @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); return effectDelegate.get(type, update);
} }
@ -260,15 +260,15 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, IAd
protected void onHitBlock(BlockHitResult hit) { protected void onHitBlock(BlockHitResult hit) {
Item item = getItem().getItem(); Item item = getItem().getItem();
if (item instanceof ITossableItem) { if (item instanceof TossableItem) {
((ITossableItem)item).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos())); ((TossableItem)item).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));
} }
if (hasEffect()) { if (hasEffect()) {
IMagicEffect effect = getEffect(); MagicEffect effect = getEffect();
if (effect instanceof ITossable) { if (effect instanceof Tossable) {
((ITossable<?>)effect).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos())); ((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) { protected void onHitEntity(EntityHitResult hit) {
Entity entity = hit.getEntity(); Entity entity = hit.getEntity();
if (entity instanceof IAdvancedProjectile) { if (entity instanceof AdvancedProjectile) {
return; return;
} }

View file

@ -7,6 +7,6 @@ import net.minecraft.entity.Entity;
* *
* @param <T> The type of owner * @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; 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.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.client.network.packet.GameStateChangeS2CPacket;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
@ -25,7 +25,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; 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); 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 @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.Race;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.ICastable; import com.minelittlepony.unicopia.magic.Castable;
import com.minelittlepony.unicopia.magic.ICaster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.IMagicEffect; import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.EffectSync;
@ -43,7 +43,7 @@ import net.minecraft.world.GameRules;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion.DestructionType; 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; private LivingEntity owner = null;
@ -99,7 +99,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
} }
@Override @Override
public void setEffect(@Nullable IMagicEffect effect) { public void setEffect(@Nullable MagicEffect effect) {
effectDelegate.set(effect); effectDelegate.set(effect);
if (effect != null) { if (effect != null) {
@ -114,7 +114,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
@Nullable @Nullable
@Override @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); return effectDelegate.get(type, update);
} }
@ -294,8 +294,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND); ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND);
if (currentItem != null if (currentItem != null
&& currentItem.getItem() instanceof ICastable && currentItem.getItem() instanceof Castable
&& ((ICastable)currentItem.getItem()).canFeed(this, currentItem) && ((Castable)currentItem.getItem()).canFeed(this, currentItem)
&& tryLevelUp(currentItem)) { && tryLevelUp(currentItem)) {
if (!player.abilities.creativeMode) { 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.ability.Abilities;
import com.minelittlepony.unicopia.entity.Updatable; import com.minelittlepony.unicopia.entity.Updatable;
import com.minelittlepony.unicopia.network.MsgPlayerAbility; import com.minelittlepony.unicopia.network.MsgPlayerAbility;
import com.minelittlepony.unicopia.util.InbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.nbt.CompoundTag; 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. * Ticks of warmup before an ability is triggered.
@ -36,7 +36,7 @@ class AbilityDelegate implements AbilityReceiver, Updatable, InbtSerialisable {
@Nullable @Nullable
private Ability<?> activeAbility = null; private Ability<?> activeAbility = null;
public AbilityDelegate(IPlayer player) { public AbilityDelegate(Pony player) {
this.player = 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.ability.HeightPredicate;
import com.minelittlepony.unicopia.entity.FlightControl; import com.minelittlepony.unicopia.entity.FlightControl;
import com.minelittlepony.unicopia.entity.Updatable; 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.mixin.MixinEntity;
import com.minelittlepony.unicopia.util.InbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.MutableVector; import com.minelittlepony.unicopia.util.MutableVector;
import net.minecraft.entity.Entity; 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.MathHelper;
import net.minecraft.util.math.Vec3d; 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; private static final float MAXIMUM_FLIGHT_EXPERIENCE = 1500;
@ -41,18 +41,18 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
private float gravity = 0; private float gravity = 0;
public GravityDelegate(IPlayer player) { public GravityDelegate(Pony player) {
this.player = player; this.player = player;
} }
@Override @Override
public boolean checkCanFly(IPlayer player) { public boolean checkCanFly(Pony player) {
if (player.getOwner().abilities.creativeMode) { if (player.getOwner().abilities.creativeMode) {
return true; return true;
} }
if (player.hasEffect()) { if (player.hasEffect()) {
IMagicEffect effect = player.getEffect(); MagicEffect effect = player.getEffect();
if (!effect.isDead() && effect instanceof FlightPredicate) { if (!effect.isDead() && effect instanceof FlightPredicate) {
return ((FlightPredicate)effect).checkCanFly(player); return ((FlightPredicate)effect).checkCanFly(player);
} }
@ -61,14 +61,14 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
return player.getSpecies().canFly(); return player.getSpecies().canFly();
} }
protected boolean isRainboom(IPlayer player) { protected boolean isRainboom(Pony player) {
return Math.sqrt(getHorizontalMotion(player.getOwner())) > 0.4F; return Math.sqrt(getHorizontalMotion(player.getOwner())) > 0.4F;
} }
@Override @Override
public float getTargetEyeHeight(IPlayer player) { public float getTargetEyeHeight(Pony player) {
if (player.hasEffect()) { if (player.hasEffect()) {
IMagicEffect effect = player.getEffect(); MagicEffect effect = player.getEffect();
if (!effect.isDead() && effect instanceof HeightPredicate) { if (!effect.isDead() && effect instanceof HeightPredicate) {
float val = ((HeightPredicate)effect).getTargetEyeHeight(player); float val = ((HeightPredicate)effect).getTargetEyeHeight(player);
if (val > 0) { if (val > 0) {
@ -85,9 +85,9 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
} }
@Override @Override
public float getTargetBodyHeight(IPlayer player) { public float getTargetBodyHeight(Pony player) {
if (player.hasEffect()) { if (player.hasEffect()) {
IMagicEffect effect = player.getEffect(); MagicEffect effect = player.getEffect();
if (!effect.isDead() && effect instanceof HeightPredicate) { if (!effect.isDead() && effect instanceof HeightPredicate) {
float val = ((HeightPredicate)effect).getTargetBodyHeight(player); float val = ((HeightPredicate)effect).getTargetBodyHeight(player);
if (val > 0) { if (val > 0) {

View file

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

View file

@ -1,23 +1,20 @@
package com.minelittlepony.unicopia.entity.player; package com.minelittlepony.unicopia.entity.player;
import java.util.Map;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UEffects; import com.minelittlepony.unicopia.UEffects;
import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.UnicopiaCore; import com.minelittlepony.unicopia.UnicopiaCore;
import com.minelittlepony.unicopia.ability.AbilityReceiver; 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.FlightControl;
import com.minelittlepony.unicopia.entity.Trap; import com.minelittlepony.unicopia.entity.Trap;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.IAttachedEffect; import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
import com.minelittlepony.unicopia.magic.IHeldEffect; import com.minelittlepony.unicopia.magic.HeldMagicEffect;
import com.minelittlepony.unicopia.magic.IMagicEffect; import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.IMagicalItem; import com.minelittlepony.unicopia.magic.MagicalItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities; import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
@ -42,13 +39,12 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.Unit; import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Difficulty; 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<Integer> PLAYER_RACE = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
private static final TrackedData<Float> ENERGY = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT); 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; private boolean invisible = false;
public PlayerCapabilities(PlayerEntity player) { public PlayerImpl(PlayerEntity player) {
this.entity = player; this.entity = player;
player.getDataTracker().startTracking(PLAYER_RACE, Race.EARTH.ordinal()); player.getDataTracker().startTracking(PLAYER_RACE, Race.EARTH.ordinal());
@ -102,7 +98,7 @@ public class PlayerCapabilities implements IPlayer {
@Override @Override
public void setSpecies(Race race) { public void setSpecies(Race race) {
race = SpeciesList.instance().validate(race, entity); race = race.validate(entity);
entity.getDataTracker().set(PLAYER_RACE, race.ordinal()); entity.getDataTracker().set(PLAYER_RACE, race.ordinal());
@ -145,7 +141,7 @@ public class PlayerCapabilities implements IPlayer {
@Nullable @Nullable
@Override @Override
public IHeldEffect getHeldEffect(ItemStack stack) { public HeldMagicEffect getHeldEffect(ItemStack stack) {
if (!getSpecies().canCast()) { if (!getSpecies().canCast()) {
heldEffectDelegate.set(null); heldEffectDelegate.set(null);
@ -153,7 +149,7 @@ public class PlayerCapabilities implements IPlayer {
return null; 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))) { if (heldEffect == null || !heldEffect.getName().equals(SpellRegistry.getKeyFromStack(stack))) {
heldEffect = SpellRegistry.instance().getHeldFrom(stack); heldEffect = SpellRegistry.instance().getHeldFrom(stack);
@ -193,6 +189,11 @@ public class PlayerCapabilities implements IPlayer {
return powers; return powers;
} }
@Override
public PageOwner getPages() {
return pageStates;
}
@Override @Override
public GravityDelegate getGravity() { public GravityDelegate getGravity() {
return gravity; return gravity;
@ -247,7 +248,7 @@ public class PlayerCapabilities implements IPlayer {
gravity.onUpdate(); gravity.onUpdate();
if (hasEffect()) { if (hasEffect()) {
IAttachedEffect effect = getEffect(IAttachedEffect.class, true); AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true);
if (effect != null) { if (effect != null) {
if (entity.getEntityWorld().isClient()) { if (entity.getEntityWorld().isClient()) {
@ -262,10 +263,10 @@ public class PlayerCapabilities implements IPlayer {
ItemStack stack = entity.getStackInHand(Hand.MAIN_HAND); ItemStack stack = entity.getStackInHand(Hand.MAIN_HAND);
IHeldEffect effect = getHeldEffect(stack); HeldMagicEffect effect = getHeldEffect(stack);
if (effect != null) { 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); effect.updateInHand(this, affinity);
} }
@ -299,7 +300,7 @@ public class PlayerCapabilities implements IPlayer {
@Override @Override
public boolean onProjectileImpact(ProjectileEntity projectile) { public boolean onProjectileImpact(ProjectileEntity projectile) {
if (hasEffect()) { if (hasEffect()) {
IMagicEffect effect = getEffect(); MagicEffect effect = getEffect();
if (!effect.isDead() && effect.handleProjectileImpact(projectile)) { if (!effect.isDead() && effect.handleProjectileImpact(projectile)) {
return true; return true;
} }
@ -346,7 +347,7 @@ public class PlayerCapabilities implements IPlayer {
return Either.left(SleepFailureReason.OTHER_PROBLEM); 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); return Either.left(SleepFailureReason.NOT_SAFE);
} }
@ -391,7 +392,7 @@ public class PlayerCapabilities implements IPlayer {
compound.put("powers", powers.toNBT()); compound.put("powers", powers.toNBT());
compound.put("gravity", gravity.toNBT()); compound.put("gravity", gravity.toNBT());
IMagicEffect effect = getEffect(); MagicEffect effect = getEffect();
if (effect != null) { if (effect != null) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect)); compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));
@ -415,13 +416,13 @@ public class PlayerCapabilities implements IPlayer {
} }
@Override @Override
public void copyFrom(IPlayer oldPlayer) { public void copyFrom(Pony oldPlayer) {
setEffect(oldPlayer.getEffect()); setEffect(oldPlayer.getEffect());
setSpecies(oldPlayer.getSpecies()); setSpecies(oldPlayer.getSpecies());
} }
@Override @Override
public void setEffect(@Nullable IMagicEffect effect) { public void setEffect(@Nullable MagicEffect effect) {
effectDelegate.set(effect); effectDelegate.set(effect);
sendCapabilities(true); sendCapabilities(true);
@ -434,7 +435,7 @@ public class PlayerCapabilities implements IPlayer {
@Nullable @Nullable
@Override @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); return effectDelegate.get(type, update);
} }
@ -456,9 +457,4 @@ public class PlayerCapabilities implements IPlayer {
public void setCurrentLevel(int level) { 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.google.common.collect.Maps;
import com.minelittlepony.unicopia.entity.Updatable; import com.minelittlepony.unicopia.entity.Updatable;
import com.minelittlepony.unicopia.magic.IDependable; import com.minelittlepony.unicopia.magic.AddictiveMagicalItem;
import com.minelittlepony.unicopia.magic.IMagicalItem; import com.minelittlepony.unicopia.magic.MagicalItem;
import com.minelittlepony.unicopia.util.InbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -17,12 +17,12 @@ import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
public class PlayerInventory implements Updatable, InbtSerialisable { public class PlayerInventory implements Updatable, NbtSerialisable {
private final Map<IDependable, Entry> dependencies = Maps.newHashMap(); 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; this.player = player;
} }
@ -32,7 +32,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
* *
* Bad things might happen when it's removed. * Bad things might happen when it's removed.
*/ */
public synchronized void enforceDependency(IDependable item) { public synchronized void enforceDependency(AddictiveMagicalItem item) {
if (dependencies.containsKey(item)) { if (dependencies.containsKey(item)) {
dependencies.get(item).reinforce(); dependencies.get(item).reinforce();
} else { } else {
@ -43,7 +43,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
/** /**
* Returns how long the player has been wearing the given item. * 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)) { if (dependencies.containsKey(item)) {
return dependencies.get(item).ticksAttached; return dependencies.get(item).ticksAttached;
} }
@ -56,7 +56,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
* *
* Zero means not dependent at all / not wearing. * Zero means not dependent at all / not wearing.
*/ */
public synchronized float getNeedfulness(IDependable item) { public synchronized float getNeedfulness(AddictiveMagicalItem item) {
if (dependencies.containsKey(item)) { if (dependencies.containsKey(item)) {
return dependencies.get(item).needfulness; return dependencies.get(item).needfulness;
} }
@ -67,10 +67,10 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
@Override @Override
public synchronized void onUpdate() { 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()) { while (iterator.hasNext()) {
Map.Entry<IDependable, Entry> entry = iterator.next(); Map.Entry<AddictiveMagicalItem, Entry> entry = iterator.next();
Entry item = entry.getValue(); Entry item = entry.getValue();
@ -85,7 +85,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
/** /**
* Checks if the player is wearing the specified magical artifact. * 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()) { for (ItemStack i : player.getOwner().getArmorItems()) {
if (!i.isEmpty() && i.getItem() == item) { if (!i.isEmpty() && i.getItem() == item) {
return true; 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; int ticksAttached = 0;
float needfulness = 1; float needfulness = 1;
IDependable item; AddictiveMagicalItem item;
Entry() { Entry() {
} }
Entry(IDependable key) { Entry(AddictiveMagicalItem key) {
this.item = key; this.item = key;
} }
@ -175,7 +175,7 @@ public class PlayerInventory implements Updatable, InbtSerialisable {
Item item = Registry.ITEM.get(new Identifier(compound.getString("item"))); 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.HashMap;
import java.util.Map; 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.enchanting.PageState;
import com.minelittlepony.unicopia.util.InbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Identifier; 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<>(); private final Map<Identifier, PageState> pageStates = new HashMap<>();
@Override @Override
@ -23,7 +23,6 @@ public class PlayerPageStats implements InbtSerialisable, IPageOwner {
} }
@Override @Override
public void toNBT(CompoundTag compound) { public void toNBT(CompoundTag compound) {
if (!pageStates.isEmpty()) { if (!pageStates.isEmpty()) {

View file

@ -4,11 +4,12 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager; import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.ability.AbilityReceiver; 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.FlightControl;
import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.entity.RaceContainer; import com.minelittlepony.unicopia.entity.RaceContainer;
import com.minelittlepony.unicopia.magic.ICaster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.IHeldEffect; import com.minelittlepony.unicopia.magic.HeldMagicEffect;
import com.minelittlepony.unicopia.network.Transmittable; import com.minelittlepony.unicopia.network.Transmittable;
import com.minelittlepony.util.IInterpolator; import com.minelittlepony.util.IInterpolator;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -24,7 +25,7 @@ import net.minecraft.util.math.BlockPos;
* *
* This is the core of unicopia. * 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. * 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(); IInterpolator getInterpolator();
PageOwner getPages();
/** /**
* Gets the amount of exertion this player has put toward any given activity. * Gets the amount of exertion this player has put toward any given activity.
* This is simillar to tiredness. * This is simillar to tiredness.
@ -92,7 +95,7 @@ public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEnti
setEnergy(getEnergy() + energy / 100F); setEnergy(getEnergy() + energy / 100F);
} }
void copyFrom(IPlayer oldPlayer); void copyFrom(Pony oldPlayer);
/** /**
* Called when the player steps on clouds. * 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. * Returns null if the passed item has no held effect.
*/ */
@Nullable @Nullable
IHeldEffect getHeldEffect(ItemStack stack); HeldMagicEffect getHeldEffect(ItemStack stack);
/** /**
* Called when this player falls. * Called when this player falls.
@ -129,6 +132,11 @@ public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEnti
return InteractionManager.instance().isClientPlayer(getOwner()); return InteractionManager.instance().isClientPlayer(getOwner());
} }
@Nullable
static Pony of(@Nullable PlayerEntity player) {
return Ponylike.<Pony>of(player);
}
static boolean equal(GameProfile one, GameProfile two) { static boolean equal(GameProfile one, GameProfile two) {
return one == two || (one != null && two != null && one.getId().equals(two.getId())); 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 java.util.Random;
import com.minelittlepony.unicopia.CloudType; import com.minelittlepony.unicopia.CloudType;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UBlocks; import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.MossItem; import com.minelittlepony.unicopia.item.MossItem;
import com.minelittlepony.unicopia.util.HoeUtil; import com.minelittlepony.unicopia.util.HoeUtil;
@ -116,6 +116,6 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
@Override @Override
public boolean canTill(ItemUsageContext context) { 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 javax.annotation.Nullable;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.ducks.IItemEntity; import com.minelittlepony.unicopia.ducks.IItemEntity;
import com.minelittlepony.unicopia.entity.ItemEntityCapabilities; 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.Affinity;
import com.minelittlepony.unicopia.magic.IDependable; import com.minelittlepony.unicopia.magic.AddictiveMagicalItem;
import com.minelittlepony.unicopia.util.AwaitTickQueue; import com.minelittlepony.unicopia.util.AwaitTickQueue;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
@ -48,7 +47,7 @@ import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion.DestructionType; 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[] { private static final UUID[] MODIFIERS = new UUID[] {
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
@ -70,7 +69,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
@Override @Override
public ActionResult onGroundTick(IItemEntity item) { public ActionResult onGroundTick(IItemEntity item) {
ItemEntity entity = item.getRaceContainer().getOwner(); ItemEntity entity = item.get().getOwner();
World world = entity.world; World world = entity.world;
@ -119,7 +118,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
@Override @Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) { 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) { if (iplayer != null) {
int attachedTime = iplayer.getInventory().getTicksAttached(this); int attachedTime = iplayer.getInventory().getTicksAttached(this);
@ -160,7 +159,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
player.getHungerManager().add(1, 0); player.getHungerManager().add(1, 0);
} }
IPlayer iplayer = SpeciesList.instance().getPlayer(player); Pony iplayer = Pony.of(player);
float attachedTime = iplayer.getInventory().getTicksAttached(this); float attachedTime = iplayer.getInventory().getTicksAttached(this);
@ -227,7 +226,7 @@ public class AlicornAmuletItem extends ArmorItem implements IDependable, ItemEnt
} }
@Override @Override
public void onRemoved(IPlayer player, float needfulness) { public void onRemoved(Pony player, float needfulness) {
float attachedTime = player.getInventory().getTicksAttached(this) / 100F; float attachedTime = player.getInventory().getTicksAttached(this) / 100F;

View file

@ -69,7 +69,7 @@ public class AppleItem extends Item implements Toxic, ItemEntityCapabilities.Tic
@Override @Override
public ActionResult onGroundTick(IItemEntity item) { public ActionResult onGroundTick(IItemEntity item) {
ItemEntity entity = item.getRaceContainer().getOwner(); ItemEntity entity = item.get().getOwner();
if (!entity.removed && item.getAge() > item.getPickupDelay()) { 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.BagOfHoldingContainer;
import com.minelittlepony.unicopia.container.BagOfHoldingInventory; import com.minelittlepony.unicopia.container.BagOfHoldingInventory;
import com.minelittlepony.unicopia.magic.Affinity; 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 com.minelittlepony.unicopia.util.VecHelper;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry; 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.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BagOfHoldingItem extends Item implements IMagicalItem { public class BagOfHoldingItem extends Item implements MagicalItem {
public BagOfHoldingItem() { public BagOfHoldingItem() {
super(new Settings().maxCount(1).group(ItemGroup.TRANSPORTATION)); super(new Settings().maxCount(1).group(ItemGroup.TRANSPORTATION));

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.item; package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.entity.CloudEntity; 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.block.DispenserBlock;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
@ -20,7 +20,7 @@ import net.minecraft.util.math.Position;
import net.minecraft.world.RayTraceContext; import net.minecraft.world.RayTraceContext;
import net.minecraft.world.World; 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; 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.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.IDispenceable; import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
import com.minelittlepony.unicopia.magic.IMagicEffect; import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -16,7 +16,7 @@ import net.minecraft.world.explosion.Explosion.DestructionType;
public class CursedMagicGemItem extends MagicGemItem { public class CursedMagicGemItem extends MagicGemItem {
@Override @Override
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, IDispenceable effect) { public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect) {
BlockPos pos = source.getBlockPos(); BlockPos pos = source.getBlockPos();
World world = source.getWorld(); World world = source.getWorld();
@ -37,7 +37,7 @@ public class CursedMagicGemItem extends MagicGemItem {
} }
@Override @Override
public CastResult onCastSpell(ItemUsageContext context, IMagicEffect effect) { public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) {
CastResult result = super.onCastSpell(context, effect); CastResult result = super.onCastSpell(context, effect);
if (result != CastResult.NONE) { if (result != CastResult.NONE) {

View file

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

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable; 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.BlockState;
import net.minecraft.block.DispenserBlock; import net.minecraft.block.DispenserBlock;
@ -50,7 +50,7 @@ public class ExtendedShearsItem extends ShearsItem {
public ExtendedShearsItem() { public ExtendedShearsItem() {
super(new Item.Settings().maxDamage(238).group(ItemGroup.TOOLS)); 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(Items.SHEARS, dispenserBehavior);
DispenserBlock.registerBehavior(this, 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.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.ICastable; import com.minelittlepony.unicopia.magic.Castable;
import com.minelittlepony.unicopia.magic.IDispenceable; import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
import com.minelittlepony.unicopia.magic.IMagicEffect; import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.magic.IUseable; import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
@ -34,7 +34,7 @@ import net.minecraft.util.Rarity;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World; import net.minecraft.world.World;
public class MagicGemItem extends Item implements ICastable { public class MagicGemItem extends Item implements Castable {
public MagicGemItem() { public MagicGemItem() {
super(new Settings() super(new Settings()
@ -50,7 +50,7 @@ public class MagicGemItem extends Item implements ICastable {
} }
@Override @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); Direction facing = source.getBlockState().get(DispenserBlock.FACING);
BlockPos pos = source.getBlockPos().offset(facing); BlockPos pos = source.getBlockPos().offset(facing);
@ -58,9 +58,9 @@ public class MagicGemItem extends Item implements ICastable {
} }
@Override @Override
public CastResult onCastSpell(ItemUsageContext context, IMagicEffect effect) { public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) {
if (effect instanceof IUseable) { if (effect instanceof Useable) {
return ((IUseable)effect).onUse(context, getAffinity(context.getStack())); return ((Useable)effect).onUse(context, getAffinity(context.getStack()));
} }
return CastResult.PLACE; return CastResult.PLACE;
@ -83,7 +83,7 @@ public class MagicGemItem extends Item implements ICastable {
return ActionResult.FAIL; return ActionResult.FAIL;
} }
IMagicEffect effect = SpellRegistry.instance().getSpellFrom(stack); MagicEffect effect = SpellRegistry.instance().getSpellFrom(stack);
if (effect == null) { if (effect == null) {
return ActionResult.FAIL; return ActionResult.FAIL;
@ -123,7 +123,7 @@ public class MagicGemItem extends Item implements ICastable {
return new TypedActionResult<>(ActionResult.FAIL, stack); return new TypedActionResult<>(ActionResult.FAIL, stack);
} }
IUseable effect = SpellRegistry.instance().getUseActionFrom(stack); Useable effect = SpellRegistry.instance().getUseActionFrom(stack);
if (effect != null) { if (effect != null) {
CastResult result = effect.onUse(stack, getAffinity(stack), player, world, VecHelper.getLookedAtEntity(player, 5)); 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 @Override
public boolean canFeed(SpellcastEntity entity, ItemStack stack) { public boolean canFeed(SpellcastEntity entity, ItemStack stack) {
IMagicEffect effect = entity.getEffect(); MagicEffect effect = entity.getEffect();
return effect != null return effect != null
&& entity.getAffinity() == getAffinity() && entity.getAffinity() == getAffinity()

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable; 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.ToxicItem;
import com.minelittlepony.unicopia.toxin.Toxicity; import com.minelittlepony.unicopia.toxin.Toxicity;
import com.minelittlepony.unicopia.util.collection.ReversableStateMapList; import com.minelittlepony.unicopia.util.collection.ReversableStateMapList;
@ -50,7 +50,7 @@ public class MossItem extends ToxicItem {
int amount = 1; 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); amount = world.random.nextInt(4);
} }

View file

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

View file

@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.SpearEntity; import com.minelittlepony.unicopia.entity.SpearEntity;
import com.minelittlepony.unicopia.magic.ICaster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.projectile.IAdvancedProjectile; import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.ITossableItem; import com.minelittlepony.unicopia.util.projectile.TossableItem;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.EquipmentSlot;
@ -21,7 +21,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Position; import net.minecraft.util.math.Position;
import net.minecraft.world.World; import net.minecraft.world.World;
public class SpearItem extends Item implements ITossableItem { public class SpearItem extends Item implements TossableItem {
public SpearItem(Settings settings) { public SpearItem(Settings settings) {
super(settings); super(settings);
@ -84,18 +84,18 @@ public class SpearItem extends Item implements ITossableItem {
@Nullable @Nullable
@Override @Override
public IAdvancedProjectile createProjectile(World world, PlayerEntity player) { public AdvancedProjectile createProjectile(World world, PlayerEntity player) {
return new SpearEntity(world, player); return new SpearEntity(world, player);
} }
@Nullable @Nullable
@Override @Override
public IAdvancedProjectile createProjectile(World world, Position pos) { public AdvancedProjectile createProjectile(World world, Position pos) {
return null; return null;
} }
@Override @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.EquinePredicates;
import com.minelittlepony.unicopia.UEntities; import com.minelittlepony.unicopia.UEntities;
import com.minelittlepony.unicopia.entity.SpellbookEntity; 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.block.DispenserBlock;
import net.minecraft.entity.player.PlayerEntity; 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.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
public class SpellbookItem extends BookItem implements IDispensable { public class SpellbookItem extends BookItem implements Dispensable {
public SpellbookItem() { public SpellbookItem() {
super(new Item.Settings() super(new Item.Settings()

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.item; 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.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -20,7 +20,7 @@ public class SugaryItem extends Item {
@Override @Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) { public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) {
if (sugarAmount != 0 && entity instanceof PlayerEntity) { 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); 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. * Interface for things that have an affine alignment.
*/ */
public interface IAffine { public interface Affine {
/** /**
* Gets the current alignment. * Gets the current alignment.
* Good/Bad/Neutral * Good/Bad/Neutral

View file

@ -1,13 +1,13 @@
package com.minelittlepony.unicopia.magic; package com.minelittlepony.unicopia.magic;
public interface IAttachedEffect extends IMagicEffect { public interface AttachedMagicEffect extends MagicEffect {
/** /**
* Called every tick when attached to a player. * Called every tick when attached to a player.
* *
* @param source The entity we are currently attached to. * @param source The entity we are currently attached to.
* @return true to keep alive * @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. * 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. * @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.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface ICastable extends IMagicalItem, IDispensable { public interface Castable extends MagicalItem, Dispensable {
@Override @Override
default TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) { default TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) {
IDispenceable effect = SpellRegistry.instance().getDispenseActionFrom(stack); DispenceableMagicEffect effect = SpellRegistry.instance().getDispenseActionFrom(stack);
if (effect == null) { if (effect == null) {
return new TypedActionResult<>(ActionResult.FAIL, stack); return new TypedActionResult<>(ActionResult.FAIL, stack);
@ -36,16 +36,16 @@ public interface ICastable extends IMagicalItem, IDispensable {
return new TypedActionResult<>(ActionResult.SUCCESS, stack); 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); boolean canFeed(SpellcastEntity spell, ItemStack stack);
/** /**
* Called to cast a spell. The result is an entity spawned with the spell attached. * 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); SpellcastEntity spell = new SpellcastEntity(null, world);
spell.setAffinity(getAffinity(stack)); 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. * 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. * Gets the active effect for this caster.
*/ */
@Nullable @Nullable
default IMagicEffect getEffect(boolean update) { default MagicEffect getEffect(boolean update) {
return getEffect(null, 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. * Returns null if no such effect exists for this caster.
*/ */
@Nullable @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. * Gets the active effect for this caster updating it if needed.
*/ */
@Nullable @Nullable
default IMagicEffect getEffect() { default MagicEffect getEffect() {
return getEffect(true); return getEffect(true);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
default <T extends IMagicEffect> Optional<T> getEffect(Class<T> type) { default <T extends MagicEffect> Optional<T> getEffect(Class<T> type) {
IMagicEffect effect = getEffect(); MagicEffect effect = getEffect();
if (effect == null || effect.isDead() || !type.isAssignableFrom(effect.getClass())) { if (effect == null || effect.isDead() || !type.isAssignableFrom(effect.getClass())) {
return Optional.empty(); return Optional.empty();
@ -122,11 +122,11 @@ public interface ICaster<E extends LivingEntity> extends Owned<E>, ILevelled, IA
return getOwner().getHealth() > 0; return getOwner().getHealth() > 0;
} }
default Stream<ICaster<?>> findAllSpellsInRange(double radius) { default Stream<Caster<?>> findAllSpellsInRange(double radius) {
return CasterUtils.findAllSpellsInRange(this, radius); return CasterUtils.findAllSpellsInRange(this, radius);
} }
default Stream<ICaster<?>> findAllSpellsInRange(Box bb) { default Stream<Caster<?>> findAllSpellsInRange(Box bb) {
return CasterUtils.findAllSpellsInRange(this, bb); return CasterUtils.findAllSpellsInRange(this, bb);
} }

View file

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

View file

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

View file

@ -1,15 +1,15 @@
package com.minelittlepony.unicopia.magic; 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. * 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. * Called every tick when held in a player's inventory.
* *
* @param source The entity we are currently attached to. * @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. * Object with levelling capabilities.
*/ */
public interface ILevelled { public interface Levelled {
/** /**
* Maximum level this spell can reach or -1 for unlimited. * Maximum level this spell can reach or -1 for unlimited.

View file

@ -1,14 +1,14 @@
package com.minelittlepony.unicopia.magic; package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; 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; import net.minecraft.entity.projectile.ProjectileEntity;
/** /**
* Interface for a magic spells * 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. * 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. * Gets the highest level this spell can be safely operated at.
* Gems may go higher, however chance of explosion/exhaustion increases with every level. * 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. * 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. * 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. * @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. * 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. * @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. * 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. * Returns a new, deep-copied instance of this spell.
*/ */
default IMagicEffect copy() { default MagicEffect copy() {
return SpellRegistry.instance().copyInstance(this); return SpellRegistry.instance().copyInstance(this);
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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