mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Naming convention changes
This commit is contained in:
parent
c8a216ef24
commit
09ae83dfe5
30 changed files with 190 additions and 199 deletions
|
@ -13,9 +13,9 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
// TODO: forge events
|
@Deprecated
|
||||||
public class BlockInteractions {
|
public class CustomDrops {
|
||||||
|
// TODO: replace with a loot table
|
||||||
public void addAuxiliaryDrops(World world, BlockState state, BlockPos pos, List<ItemStack> drops, int fortune) {
|
public void addAuxiliaryDrops(World world, BlockState state, BlockPos pos, List<ItemStack> drops, int fortune) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.apache.logging.log4j.Logger;
|
||||||
import com.minelittlepony.common.util.GamePaths;
|
import com.minelittlepony.common.util.GamePaths;
|
||||||
import com.minelittlepony.jumpingcastle.api.Channel;
|
import com.minelittlepony.jumpingcastle.api.Channel;
|
||||||
import com.minelittlepony.jumpingcastle.api.JumpingCastle;
|
import com.minelittlepony.jumpingcastle.api.JumpingCastle;
|
||||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
import com.minelittlepony.unicopia.ability.Abilities;
|
||||||
import com.minelittlepony.unicopia.command.Commands;
|
import com.minelittlepony.unicopia.command.Commands;
|
||||||
import com.minelittlepony.unicopia.enchanting.Pages;
|
import com.minelittlepony.unicopia.enchanting.Pages;
|
||||||
import com.minelittlepony.unicopia.enchanting.recipe.AffineIngredients;
|
import com.minelittlepony.unicopia.enchanting.recipe.AffineIngredients;
|
||||||
|
@ -48,7 +48,7 @@ public class UnicopiaCore implements ModInitializer {
|
||||||
UItems.bootstrap();
|
UItems.bootstrap();
|
||||||
UContainers.bootstrap();
|
UContainers.bootstrap();
|
||||||
UStructures.bootstrap();
|
UStructures.bootstrap();
|
||||||
PowersRegistry.instance().init();
|
Abilities.getInstance().init();
|
||||||
|
|
||||||
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance());
|
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance());
|
||||||
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(AffineIngredients.instance());
|
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(AffineIngredients.instance());
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
|
||||||
|
public final class Abilities {
|
||||||
|
|
||||||
|
private static final Abilities INSTANCE = new Abilities();
|
||||||
|
|
||||||
|
public static Abilities getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Map<Integer, List<Ability<? extends Ability.IData>>> keyToPowerMap = new HashMap<>();
|
||||||
|
|
||||||
|
private final Map<String, Ability<? extends Ability.IData>> powerNamesMap = new HashMap<>();
|
||||||
|
|
||||||
|
private Abilities() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
register(new UnicornTeleportAbility());
|
||||||
|
register(new UnicornCastingAbility());
|
||||||
|
register(new EarthPonyGrowAbility());
|
||||||
|
register(new ChangelingFeedAbility());
|
||||||
|
register(new PegasusCarryAbility());
|
||||||
|
register(new PegasusCloudInteractionAbility());
|
||||||
|
register(new ChangelingTrapAbility());
|
||||||
|
register(new EarthPonyStompAbility());
|
||||||
|
register(new ChangelingDisguiseAbility());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasRegisteredPower(int keyCode) {
|
||||||
|
return keyToPowerMap.containsKey(keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<Ability<? extends Ability.IData>> getCapablePowerFromKey(int keyCode, Race race) {
|
||||||
|
return getKeyCodePool(keyCode).stream()
|
||||||
|
.filter(power -> power.canUse(race))
|
||||||
|
.findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<Ability<? extends Ability.IData>> getPowerFromName(String name) {
|
||||||
|
return Optional.ofNullable(powerNamesMap.get(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Ability<? extends Ability.IData>> getKeyCodePool(int keyCode) {
|
||||||
|
return keyToPowerMap.computeIfAbsent(keyCode, ArrayList::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(Ability<? extends Ability.IData> power) {
|
||||||
|
getKeyCodePool(power.getKeyCode()).add(power);
|
||||||
|
powerNamesMap.put(power.getKeyName(), power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Ability<? extends Ability.IData>> getValues() {
|
||||||
|
return powerNamesMap.values();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,13 +2,15 @@ package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
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.IPlayer;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IPower<T extends IPower.IData> extends IKeyBinding {
|
public interface Ability<T extends Ability.IData> extends IKeyBinding {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default String getKeyCategory() {
|
default String getKeyCategory() {
|
||||||
|
@ -77,4 +79,44 @@ public interface IPower<T extends IPower.IData> extends IKeyBinding {
|
||||||
public interface IData {
|
public interface IData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Pos implements Ability.IData {
|
||||||
|
@Expose
|
||||||
|
public int x;
|
||||||
|
|
||||||
|
@Expose
|
||||||
|
public int y;
|
||||||
|
|
||||||
|
@Expose
|
||||||
|
public int z;
|
||||||
|
|
||||||
|
public Pos(int x, int y, int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pos(BlockPos pos) {
|
||||||
|
x = pos.getX();
|
||||||
|
y = pos.getY();
|
||||||
|
z = pos.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos pos() {
|
||||||
|
return new BlockPos(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Hit implements Ability.IData {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Numeric implements IData {
|
||||||
|
@Expose
|
||||||
|
public int type;
|
||||||
|
|
||||||
|
public Numeric(int t) {
|
||||||
|
type = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.ability.Ability;
|
||||||
|
|
||||||
|
public interface AbilityReceiver {
|
||||||
|
|
||||||
|
void tryUseAbility(Ability<?> power);
|
||||||
|
|
||||||
|
void tryClearAbility();
|
||||||
|
|
||||||
|
int getRemainingCooldown();
|
||||||
|
}
|
|
@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
/**
|
/**
|
||||||
* Changeling ability to disguise themselves as other players.
|
* Changeling ability to disguise themselves as other players.
|
||||||
*/
|
*/
|
||||||
public class PowerDisguise extends PowerFeed {
|
public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
|
@ -28,7 +28,7 @@ import net.minecraft.particle.ParticleTypes;
|
||||||
/**
|
/**
|
||||||
* Changeling ability to restore health from mobs
|
* Changeling ability to restore health from mobs
|
||||||
*/
|
*/
|
||||||
public class PowerFeed implements IPower<Hit> {
|
public class ChangelingFeedAbility implements Ability<Ability.Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
|
@ -8,7 +8,7 @@ import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||||
import com.minelittlepony.unicopia.magic.spell.ChangelingTrapSpell;
|
import com.minelittlepony.unicopia.magic.spell.ChangelingTrapSpell;
|
||||||
|
|
||||||
public class PowerEngulf implements IPower<Hit> {
|
public class ChangelingTrapAbility implements Ability<Ability.Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
|
@ -20,7 +20,7 @@ import net.minecraft.world.World;
|
||||||
/**
|
/**
|
||||||
* Earth Pony ability to grow crops
|
* Earth Pony ability to grow crops
|
||||||
*/
|
*/
|
||||||
public class PowerGrow implements IPower<Location> {
|
public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
||||||
|
@ -48,23 +48,23 @@ public class PowerGrow implements IPower<Location> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location tryActivate(IPlayer player) {
|
public Pos tryActivate(IPlayer 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) {
|
||||||
return new Location(((BlockHitResult)ray).getBlockPos());
|
return new Pos(((BlockHitResult)ray).getBlockPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<Location> getPackageType() {
|
public Class<Pos> getPackageType() {
|
||||||
return Location.class;
|
return Pos.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(IPlayer player, Location data) {
|
public void apply(IPlayer player, Pos data) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (BlockPos pos : BlockPos.iterate(
|
for (BlockPos pos : BlockPos.iterate(
|
|
@ -43,7 +43,7 @@ import net.minecraft.world.World;
|
||||||
/**
|
/**
|
||||||
* Earth Pony stomping ability
|
* Earth Pony stomping ability
|
||||||
*/
|
*/
|
||||||
public class PowerStomp implements IPower<PowerStomp.Data> {
|
public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data> {
|
||||||
|
|
||||||
private final double rad = 4;
|
private final double rad = 4;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PowerStomp.Data tryActivate(IPlayer player) {
|
public EarthPonyStompAbility.Data tryActivate(IPlayer 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) {
|
||||||
|
@ -101,8 +101,8 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<PowerStomp.Data> getPackageType() {
|
public Class<EarthPonyStompAbility.Data> getPackageType() {
|
||||||
return PowerStomp.Data.class;
|
return EarthPonyStompAbility.Data.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockPos getSolidBlockBelow(BlockPos pos, World w) {
|
public static BlockPos getSolidBlockBelow(BlockPos pos, World w) {
|
||||||
|
@ -472,7 +472,7 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class Data extends Location {
|
protected static class Data extends Ability.Pos {
|
||||||
@Expose
|
@Expose
|
||||||
public int hitType;
|
public int hitType;
|
||||||
|
|
|
@ -7,6 +7,6 @@ import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||||
*
|
*
|
||||||
* This overrides what the race specifies.
|
* This overrides what the race specifies.
|
||||||
*/
|
*/
|
||||||
public interface IFlyingPredicate {
|
public interface FlightPredicate {
|
||||||
boolean checkCanFly(IPlayer player);
|
boolean checkCanFly(IPlayer player);
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||||
*
|
*
|
||||||
* This overrides the default.
|
* This overrides the default.
|
||||||
*/
|
*/
|
||||||
public interface IHeightPredicate {
|
public interface HeightPredicate {
|
||||||
float getTargetEyeHeight(IPlayer player);
|
float getTargetEyeHeight(IPlayer player);
|
||||||
|
|
||||||
float getTargetBodyHeight(IPlayer player);
|
float getTargetBodyHeight(IPlayer player);
|
|
@ -1,5 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
|
||||||
|
|
||||||
public class Hit implements IPower.IData {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.IPower;
|
|
||||||
|
|
||||||
public interface IAbilityReceiver {
|
|
||||||
|
|
||||||
void tryUseAbility(IPower<?> power);
|
|
||||||
|
|
||||||
void tryClearAbility();
|
|
||||||
|
|
||||||
int getRemainingCooldown();
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public class Location implements IPower.IData {
|
|
||||||
|
|
||||||
@Expose
|
|
||||||
public int x;
|
|
||||||
|
|
||||||
@Expose
|
|
||||||
public int y;
|
|
||||||
|
|
||||||
@Expose
|
|
||||||
public int z;
|
|
||||||
|
|
||||||
public Location(int x, int y, int z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location(BlockPos pos) {
|
|
||||||
x = pos.getX();
|
|
||||||
y = pos.getY();
|
|
||||||
z = pos.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos pos() {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
|
||||||
|
|
||||||
public class Numeric implements IPower.IData {
|
|
||||||
|
|
||||||
@Expose
|
|
||||||
public int type;
|
|
||||||
|
|
||||||
public Numeric(int t) {
|
|
||||||
type = t;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.world.World;
|
||||||
/**
|
/**
|
||||||
* Pegasi ability to pick up and carry other players
|
* Pegasi ability to pick up and carry other players
|
||||||
*/
|
*/
|
||||||
public class PowerCarry implements IPower<Hit> {
|
public class PegasusCarryAbility implements Ability<Ability.Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
|
@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.util.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
public class PowerCloudBase implements IPower<Numeric> {
|
public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
|
@ -1,65 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
|
||||||
|
|
||||||
public class PowersRegistry {
|
|
||||||
|
|
||||||
private static final PowersRegistry INSTANCE = new PowersRegistry();
|
|
||||||
|
|
||||||
public static PowersRegistry instance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Map<Integer, List<IPower<? extends IPower.IData>>> keyToPowerMap = new HashMap<>();
|
|
||||||
|
|
||||||
private final Map<String, IPower<? extends IPower.IData>> powerNamesMap = new HashMap<>();
|
|
||||||
|
|
||||||
private PowersRegistry() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
register(new PowerTeleport());
|
|
||||||
register(new PowerMagic());
|
|
||||||
register(new PowerGrow());
|
|
||||||
register(new PowerFeed());
|
|
||||||
register(new PowerCarry());
|
|
||||||
register(new PowerCloudBase());
|
|
||||||
register(new PowerEngulf());
|
|
||||||
register(new PowerStomp());
|
|
||||||
register(new PowerDisguise());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasRegisteredPower(int keyCode) {
|
|
||||||
return keyToPowerMap.containsKey(keyCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<IPower<? extends IPower.IData>> getCapablePowerFromKey(int keyCode, Race race) {
|
|
||||||
return getKeyCodePool(keyCode).stream()
|
|
||||||
.filter(power -> power.canUse(race))
|
|
||||||
.findFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<IPower<? extends IPower.IData>> getPowerFromName(String name) {
|
|
||||||
return Optional.ofNullable(powerNamesMap.get(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<IPower<? extends IPower.IData>> getKeyCodePool(int keyCode) {
|
|
||||||
return keyToPowerMap.computeIfAbsent(keyCode, ArrayList::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register(IPower<? extends IPower.IData> power) {
|
|
||||||
getKeyCodePool(power.getKeyCode()).add(power);
|
|
||||||
powerNamesMap.put(power.getKeyName(), power);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<IPower<? extends IPower.IData>> getValues() {
|
|
||||||
return powerNamesMap.values();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.magic.spell.ShieldSpell;
|
||||||
* A magic casting ability for unicorns.
|
* A magic casting ability for unicorns.
|
||||||
* (only shields for now)
|
* (only shields for now)
|
||||||
*/
|
*/
|
||||||
public class PowerMagic implements IPower<Hit> {
|
public class UnicornCastingAbility implements Ability<Ability.Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
|
@ -27,7 +27,7 @@ import net.minecraft.world.World;
|
||||||
/**
|
/**
|
||||||
* Unicorn teleport ability
|
* Unicorn teleport ability
|
||||||
*/
|
*/
|
||||||
public class PowerTeleport implements IPower<Location> {
|
public class UnicornTeleportAbility implements Ability<Ability.Pos> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
||||||
|
@ -55,7 +55,7 @@ public class PowerTeleport implements IPower<Location> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location tryActivate(IPlayer player) {
|
public Pos tryActivate(IPlayer 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();
|
||||||
|
@ -104,18 +104,18 @@ public class PowerTeleport implements IPower<Location> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Location(pos.getX(), pos.getY(), pos.getZ());
|
return new Pos(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<Location> getPackageType() {
|
public Class<Pos> getPackageType() {
|
||||||
return Location.class;
|
return Pos.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(IPlayer iplayer, Location data) {
|
public void apply(IPlayer 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();
|
|
@ -6,7 +6,7 @@ import java.util.Set;
|
||||||
import com.minelittlepony.unicopia.IKeyBinding;
|
import com.minelittlepony.unicopia.IKeyBinding;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
import com.minelittlepony.unicopia.ability.Abilities;
|
||||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||||
|
@ -45,11 +45,11 @@ class KeyBindingsHandler {
|
||||||
if (i.isPressed()) {
|
if (i.isPressed()) {
|
||||||
|
|
||||||
if (pressed.add(i)) {
|
if (pressed.add(i)) {
|
||||||
if (!PowersRegistry.instance().hasRegisteredPower(i.getDefaultKeyCode().getKeyCode())) {
|
if (!Abilities.getInstance().hasRegisteredPower(i.getDefaultKeyCode().getKeyCode())) {
|
||||||
removed.add(i);
|
removed.add(i);
|
||||||
System.out.println("Error: Keybinding(" + i.getLocalizedName() + ") does not have a registered pony power. Keybinding will be removed from event.");
|
System.out.println("Error: Keybinding(" + i.getLocalizedName() + ") does not have a registered pony power. Keybinding will be removed from event.");
|
||||||
} else {
|
} else {
|
||||||
PowersRegistry.instance()
|
Abilities.getInstance()
|
||||||
.getCapablePowerFromKey(i.getDefaultKeyCode().getKeyCode(), iplayer.getSpecies())
|
.getCapablePowerFromKey(i.getDefaultKeyCode().getKeyCode(), iplayer.getSpecies())
|
||||||
.ifPresent(iplayer.getAbilities()::tryUseAbility);
|
.ifPresent(iplayer.getAbilities()::tryUseAbility);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
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.PowersRegistry;
|
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.IPlayer;
|
||||||
|
@ -143,7 +143,7 @@ public class UnicopiaCoreClient extends InteractionManager implements ClientModI
|
||||||
|
|
||||||
ClientTickCallback.EVENT.register(this::tick);
|
ClientTickCallback.EVENT.register(this::tick);
|
||||||
ClientReadyCallback.EVENT.register(client -> {
|
ClientReadyCallback.EVENT.register(client -> {
|
||||||
PowersRegistry.instance().getValues().forEach(keyboard::addKeybind);
|
Abilities.getInstance().getValues().forEach(keyboard::addKeybind);
|
||||||
});
|
});
|
||||||
|
|
||||||
//BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem"));
|
//BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem"));
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
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.PowerCloudBase.ICloudEntity;
|
import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloudEntity;
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,16 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.jumpingcastle.api.Target;
|
import com.minelittlepony.jumpingcastle.api.Target;
|
||||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||||
import com.minelittlepony.unicopia.ability.IAbilityReceiver;
|
import com.minelittlepony.unicopia.ability.AbilityReceiver;
|
||||||
import com.minelittlepony.unicopia.ability.IPower;
|
import com.minelittlepony.unicopia.ability.Ability;
|
||||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
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.InbtSerialisable;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
class AbilityDelegate implements AbilityReceiver, Updatable, InbtSerialisable {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
private boolean triggered;
|
private boolean triggered;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private IPower<?> activeAbility = null;
|
private Ability<?> activeAbility = null;
|
||||||
|
|
||||||
public AbilityDelegate(IPlayer player) {
|
public AbilityDelegate(IPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -48,7 +48,7 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tryUseAbility(IPower<?> power) {
|
public void tryUseAbility(Ability<?> power) {
|
||||||
if (canSwitchStates()) {
|
if (canSwitchStates()) {
|
||||||
setAbility(power);
|
setAbility(power);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void setAbility(@Nullable IPower<?> power) {
|
protected synchronized void setAbility(@Nullable Ability<?> power) {
|
||||||
if (activeAbility != power) {
|
if (activeAbility != power) {
|
||||||
triggered = false;
|
triggered = false;
|
||||||
activeAbility = power;
|
activeAbility = power;
|
||||||
|
@ -71,7 +71,7 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected synchronized IPower<?> getUsableAbility() {
|
protected synchronized Ability<?> getUsableAbility() {
|
||||||
if (!(activeAbility == null || (triggered && warmup == 0 && cooldown == 0)) && activeAbility.canUse(player.getSpecies())) {
|
if (!(activeAbility == null || (triggered && warmup == 0 && cooldown == 0)) && activeAbility.canUse(player.getSpecies())) {
|
||||||
return activeAbility;
|
return activeAbility;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
IPower<?> ability = getUsableAbility();
|
Ability<?> ability = getUsableAbility();
|
||||||
|
|
||||||
if (ability == null) {
|
if (ability == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -129,7 +129,7 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
compound.putInt("warmup", warmup);
|
compound.putInt("warmup", warmup);
|
||||||
compound.putInt("cooldown", cooldown);
|
compound.putInt("cooldown", cooldown);
|
||||||
|
|
||||||
IPower<?> ability = getUsableAbility();
|
Ability<?> ability = getUsableAbility();
|
||||||
|
|
||||||
if (ability != null) {
|
if (ability != null) {
|
||||||
compound.putString("activeAbility", ability.getKeyName());
|
compound.putString("activeAbility", ability.getKeyName());
|
||||||
|
@ -145,7 +145,7 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
cooldown = compound.getInt("cooldown");
|
cooldown = compound.getInt("cooldown");
|
||||||
|
|
||||||
if (compound.containsKey("activeAbility")) {
|
if (compound.containsKey("activeAbility")) {
|
||||||
PowersRegistry.instance()
|
Abilities.getInstance()
|
||||||
.getPowerFromName(compound.getString("activeAbility"))
|
.getPowerFromName(compound.getString("activeAbility"))
|
||||||
.ifPresent(p -> activeAbility = p);
|
.ifPresent(p -> activeAbility = p);
|
||||||
}
|
}
|
||||||
|
@ -155,8 +155,8 @@ class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
* Attempts to activate the current stored ability.
|
* Attempts to activate the current stored ability.
|
||||||
* Returns true if the ability suceeded, otherwise false.
|
* Returns true if the ability suceeded, otherwise false.
|
||||||
*/
|
*/
|
||||||
protected boolean activateAbility(@Nonnull IPower<?> ability) {
|
protected boolean activateAbility(@Nonnull Ability<?> ability) {
|
||||||
IPower.IData data = ability.tryActivate(player);
|
Ability.IData data = ability.tryActivate(player);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
UnicopiaCore.getConnection().send(new MsgPlayerAbility(player.getOwner(), ability, data), Target.SERVER);
|
UnicopiaCore.getConnection().send(new MsgPlayerAbility(player.getOwner(), ability, data), Target.SERVER);
|
||||||
|
|
|
@ -5,8 +5,8 @@ import java.util.Random;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.UParticles;
|
import com.minelittlepony.unicopia.UParticles;
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.ability.IFlyingPredicate;
|
import com.minelittlepony.unicopia.ability.FlightPredicate;
|
||||||
import com.minelittlepony.unicopia.ability.IHeightPredicate;
|
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.IMagicEffect;
|
||||||
|
@ -24,7 +24,7 @@ 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, IFlyingPredicate, IHeightPredicate {
|
public class GravityDelegate implements Updatable, FlightControl, InbtSerialisable, FlightPredicate, HeightPredicate {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
|
||||||
|
|
||||||
if (player.hasEffect()) {
|
if (player.hasEffect()) {
|
||||||
IMagicEffect effect = player.getEffect();
|
IMagicEffect effect = player.getEffect();
|
||||||
if (!effect.isDead() && effect instanceof IFlyingPredicate) {
|
if (!effect.isDead() && effect instanceof FlightPredicate) {
|
||||||
return ((IFlyingPredicate)effect).checkCanFly(player);
|
return ((FlightPredicate)effect).checkCanFly(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
|
||||||
public float getTargetEyeHeight(IPlayer player) {
|
public float getTargetEyeHeight(IPlayer player) {
|
||||||
if (player.hasEffect()) {
|
if (player.hasEffect()) {
|
||||||
IMagicEffect effect = player.getEffect();
|
IMagicEffect effect = player.getEffect();
|
||||||
if (!effect.isDead() && effect instanceof IHeightPredicate) {
|
if (!effect.isDead() && effect instanceof HeightPredicate) {
|
||||||
float val = ((IHeightPredicate)effect).getTargetEyeHeight(player);
|
float val = ((HeightPredicate)effect).getTargetEyeHeight(player);
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,8 @@ public class GravityDelegate implements Updatable, FlightControl, InbtSerialisab
|
||||||
public float getTargetBodyHeight(IPlayer player) {
|
public float getTargetBodyHeight(IPlayer player) {
|
||||||
if (player.hasEffect()) {
|
if (player.hasEffect()) {
|
||||||
IMagicEffect effect = player.getEffect();
|
IMagicEffect effect = player.getEffect();
|
||||||
if (!effect.isDead() && effect instanceof IHeightPredicate) {
|
if (!effect.isDead() && effect instanceof HeightPredicate) {
|
||||||
float val = ((IHeightPredicate)effect).getTargetBodyHeight(player);
|
float val = ((HeightPredicate)effect).getTargetBodyHeight(player);
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.entity.player;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.ability.IAbilityReceiver;
|
import com.minelittlepony.unicopia.ability.AbilityReceiver;
|
||||||
import com.minelittlepony.unicopia.enchanting.IPageOwner;
|
import com.minelittlepony.unicopia.enchanting.IPageOwner;
|
||||||
import com.minelittlepony.unicopia.entity.FlightControl;
|
import com.minelittlepony.unicopia.entity.FlightControl;
|
||||||
import com.minelittlepony.unicopia.entity.RaceContainer;
|
import com.minelittlepony.unicopia.entity.RaceContainer;
|
||||||
|
@ -29,7 +29,7 @@ public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEnti
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
IAbilityReceiver getAbilities();
|
AbilityReceiver getAbilities();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the gravity delegate responsible for updating flight states
|
* Gets the gravity delegate responsible for updating flight states
|
||||||
|
|
|
@ -9,7 +9,7 @@ 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.IAbilityReceiver;
|
import com.minelittlepony.unicopia.ability.AbilityReceiver;
|
||||||
import com.minelittlepony.unicopia.enchanting.PageState;
|
import com.minelittlepony.unicopia.enchanting.PageState;
|
||||||
import com.minelittlepony.unicopia.entity.FlightControl;
|
import com.minelittlepony.unicopia.entity.FlightControl;
|
||||||
import com.minelittlepony.unicopia.entity.Trap;
|
import com.minelittlepony.unicopia.entity.Trap;
|
||||||
|
@ -189,7 +189,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAbilityReceiver getAbilities() {
|
public AbilityReceiver getAbilities() {
|
||||||
return powers;
|
return powers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.UParticles;
|
import com.minelittlepony.unicopia.UParticles;
|
||||||
import com.minelittlepony.unicopia.ability.IFlyingPredicate;
|
import com.minelittlepony.unicopia.ability.FlightPredicate;
|
||||||
import com.minelittlepony.unicopia.ability.IHeightPredicate;
|
import com.minelittlepony.unicopia.ability.HeightPredicate;
|
||||||
import com.minelittlepony.unicopia.entity.Owned;
|
import com.minelittlepony.unicopia.entity.Owned;
|
||||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||||
import com.minelittlepony.unicopia.magic.Affinity;
|
import com.minelittlepony.unicopia.magic.Affinity;
|
||||||
|
@ -45,7 +45,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class DisguiseSpell extends AbstractSpell implements IAttachedEffect, ISuppressable, IFlyingPredicate, IHeightPredicate {
|
public class DisguiseSpell extends AbstractSpell implements IAttachedEffect, ISuppressable, FlightPredicate, HeightPredicate {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private String entityId = "";
|
private String entityId = "";
|
||||||
|
|
|
@ -8,8 +8,8 @@ import com.google.gson.annotations.Expose;
|
||||||
import com.minelittlepony.jumpingcastle.api.Channel;
|
import com.minelittlepony.jumpingcastle.api.Channel;
|
||||||
import com.minelittlepony.jumpingcastle.api.Message;
|
import com.minelittlepony.jumpingcastle.api.Message;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.ability.IPower;
|
import com.minelittlepony.unicopia.ability.Ability;
|
||||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
import com.minelittlepony.unicopia.ability.Abilities;
|
||||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -30,13 +30,13 @@ public class MsgPlayerAbility implements Message, Message.Handler<MsgPlayerAbili
|
||||||
@Expose
|
@Expose
|
||||||
private String abilityJson;
|
private String abilityJson;
|
||||||
|
|
||||||
public MsgPlayerAbility(PlayerEntity player, IPower<?> power, IPower.IData data) {
|
public MsgPlayerAbility(PlayerEntity player, Ability<?> power, Ability.IData data) {
|
||||||
senderId = player.getUuid();
|
senderId = player.getUuid();
|
||||||
powerIdentifier = power.getKeyName();
|
powerIdentifier = power.getKeyName();
|
||||||
abilityJson = gson.toJson(data, power.getPackageType());
|
abilityJson = gson.toJson(data, power.getPackageType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends IPower.IData> void apply(IPower<T> power, Channel channel) {
|
private <T extends Ability.IData> void apply(Ability<T> power, Channel channel) {
|
||||||
MinecraftServer server = channel.getServer();
|
MinecraftServer server = channel.getServer();
|
||||||
IPlayer player = SpeciesList.instance().getPlayer(server.getPlayerManager().getPlayer(senderId));
|
IPlayer player = SpeciesList.instance().getPlayer(server.getPlayerManager().getPlayer(senderId));
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
@ -50,6 +50,6 @@ public class MsgPlayerAbility implements Message, Message.Handler<MsgPlayerAbili
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPayload(MsgPlayerAbility message, Channel channel) {
|
public void onPayload(MsgPlayerAbility message, Channel channel) {
|
||||||
PowersRegistry.instance().getPowerFromName(powerIdentifier).ifPresent(power -> apply(power, channel));
|
Abilities.getInstance().getPowerFromName(powerIdentifier).ifPresent(power -> apply(power, channel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue