mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-02 03:46:43 +01:00
Core/Redux split to get out the non-essential features
This commit is contained in:
parent
995c332814
commit
85b9ddb706
313 changed files with 2251 additions and 2180 deletions
|
@ -1,51 +0,0 @@
|
||||||
package com.minelittlepony.unicopia;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.ClientInteractionManager;
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
|
|
||||||
public interface InteractionManager {
|
|
||||||
|
|
||||||
static InteractionManager instance() {
|
|
||||||
if (Unicopia.interactionManager == null) {
|
|
||||||
if (ServerInteractionManager.isClientSide()) {
|
|
||||||
Unicopia.interactionManager = new ClientInteractionManager();
|
|
||||||
} else {
|
|
||||||
Unicopia.interactionManager = new ServerInteractionManager();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Unicopia.interactionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
PlayerEntity getClientPlayer();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
default IPlayer getIPlayer() {
|
|
||||||
return SpeciesList.instance().getPlayer(getClientPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isClientPlayer(@Nullable PlayerEntity player);
|
|
||||||
|
|
||||||
int getViewMode();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Side-independent method to create a new player.
|
|
||||||
*
|
|
||||||
* Returns an implementation of PlayerEntity appropriate to the side being called on.
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
PlayerEntity createPlayer(Entity observer, GameProfile profile);
|
|
||||||
|
|
||||||
void postRenderEntity(Entity entity);
|
|
||||||
|
|
||||||
boolean renderEntity(Entity entity, float renderPartialTicks);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.minelittlepony.unicopia;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.inventory.gui.ContainerOfHolding;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
public class UContainers {
|
|
||||||
|
|
||||||
public static final Identifier BAG_OF_HOLDING = new Identifier(Unicopia.MODID, "bag_of_holding");
|
|
||||||
|
|
||||||
static void bootstrap() {
|
|
||||||
ContainerProviderRegistry.INSTANCE.registerFactory(BAG_OF_HOLDING, ContainerOfHolding::new);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
package com.minelittlepony.unicopia;
|
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
|
||||||
import com.minelittlepony.unicopia.command.Commands;
|
|
||||||
import com.minelittlepony.unicopia.enchanting.Pages;
|
|
||||||
import com.minelittlepony.unicopia.enchanting.recipe.AffineIngredients;
|
|
||||||
import com.minelittlepony.unicopia.enchanting.recipe.SpecialRecipe;
|
|
||||||
import com.minelittlepony.unicopia.enchanting.recipe.SpellRecipe;
|
|
||||||
import com.minelittlepony.unicopia.inventory.gui.SpellBookContainer;
|
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
|
||||||
import com.minelittlepony.unicopia.inventory.gui.GuiSpellBook;
|
|
||||||
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
|
|
||||||
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
|
|
||||||
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
|
||||||
import com.minelittlepony.unicopia.world.UWorld;
|
|
||||||
|
|
||||||
public class Unicopia implements ModInitializer {
|
|
||||||
public static final String MODID = "unicopia";
|
|
||||||
public static final String NAME = "@NAME@";
|
|
||||||
public static final String VERSION = "@VERSION@";
|
|
||||||
|
|
||||||
public static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
static InteractionManager interactionManager;
|
|
||||||
|
|
||||||
private static IChannel channel;
|
|
||||||
|
|
||||||
public static IChannel getConnection() {
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitialize() {
|
|
||||||
Config.init(event.getModConfigurationDirectory());
|
|
||||||
|
|
||||||
channel = JumpingCastle.subscribeTo(MODID, () -> {})
|
|
||||||
.listenFor(MsgRequestCapabilities.class)
|
|
||||||
.listenFor(MsgPlayerCapabilities.class)
|
|
||||||
.listenFor(MsgPlayerAbility.class);
|
|
||||||
|
|
||||||
PowersRegistry.instance().init();
|
|
||||||
|
|
||||||
UAdvancements.init();
|
|
||||||
|
|
||||||
craftingManager.load();
|
|
||||||
|
|
||||||
Pages.instance().load();
|
|
||||||
|
|
||||||
UBlocks.bootstrap();
|
|
||||||
UItems.bootstrap();
|
|
||||||
Commands.bootstrap();
|
|
||||||
UContainers.bootstrap();
|
|
||||||
|
|
||||||
UWorld.instance().init();
|
|
||||||
|
|
||||||
InteractionManager.instance().preInit();
|
|
||||||
InteractionManager.instance().init();
|
|
||||||
InteractionManager.instance().postInit();
|
|
||||||
|
|
||||||
UItems.fixRecipes();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
|
||||||
|
|
||||||
public class Hit implements IData {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
|
||||||
|
|
||||||
public interface IData {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.client;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
|
||||||
import com.minelittlepony.unicopia.UBlocks;
|
|
||||||
import com.minelittlepony.unicopia.client.gui.UHud;
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.ICamera;
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
|
|
||||||
class ClientHooks {
|
|
||||||
// This fixes lighting errors on the armour slots.
|
|
||||||
// #MahjongPls
|
|
||||||
public static void postEntityRender() {
|
|
||||||
GlStateManager.enableAlphaTest();
|
|
||||||
|
|
||||||
InteractionManager.instance().postRenderEntity(event.getEntity());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void preEntityRender() {
|
|
||||||
if (InteractionManager.instance().renderEntity(event.getEntity(), event.getPartialRenderTick())) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onDisplayGui(GuiScreenEvent.InitGuiEvent.Post event) {
|
|
||||||
if (event.getGui() instanceof GuiOptions || event.getGui() instanceof GuiShareToLan) {
|
|
||||||
ClientInteractionManager.addUniButton(event.getButtonList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onGameTick(TickEvent.ClientTickEvent event) {
|
|
||||||
if (event.phase == Phase.END) {
|
|
||||||
InteractionManager.instance().tick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void beforePreRenderHud(RenderGameOverlayEvent.Pre event) {
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
|
|
||||||
if (event.getType() != ElementType.ALL) {
|
|
||||||
IPlayer player = InteractionManager.instance().getIPlayer();
|
|
||||||
|
|
||||||
if (player != null && MinecraftClient.getInstance().world != null) {
|
|
||||||
UHud.instance.repositionElements(player, event.getResolution(), event.getType(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void afterPreRenderHud(RenderGameOverlayEvent.Pre event) {
|
|
||||||
if (event.isCanceled()) {
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void postRenderHud(RenderGameOverlayEvent.Post event) {
|
|
||||||
|
|
||||||
if (event.getType() == ElementType.ALL) {
|
|
||||||
IPlayer player = InteractionManager.instance().getIPlayer();
|
|
||||||
|
|
||||||
if (player != null && MinecraftClient.getInstance().world != null) {
|
|
||||||
UHud.instance.renderHud(player, event.getResolution());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerItemColours(ColorHandlerEvent.Item event) {
|
|
||||||
UItems.registerColors(event.getItemColors());
|
|
||||||
UBlocks.registerColors(event.getItemColors(), event.getBlockColors());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void modifyFOV(FOVUpdateEvent event) {
|
|
||||||
event.setNewfov(SpeciesList.instance().getPlayer(event.getEntity()).getCamera().calculateFieldOfView(event.getFov()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setupPlayerCamera(EntityViewRenderEvent.CameraSetup event) {
|
|
||||||
|
|
||||||
IPlayer player = InteractionManager.instance().getIPlayer();
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
ICamera view = player.getCamera();
|
|
||||||
|
|
||||||
event.setRoll(view.calculateRoll());
|
|
||||||
event.setPitch(view.calculatePitch(event.getPitch()));
|
|
||||||
event.setYaw(view.calculateYaw(event.getYaw()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.client.input;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ServerInteractionManager;
|
|
||||||
|
|
||||||
public final class Keyboard {
|
|
||||||
private static IKeyBindingHandler keyHandler;
|
|
||||||
|
|
||||||
public static IKeyBindingHandler getKeyHandler() {
|
|
||||||
|
|
||||||
if (keyHandler == null) {
|
|
||||||
if (ServerInteractionManager.isClientSide()) {
|
|
||||||
keyHandler = new KeyBindingsHandler();
|
|
||||||
} else {
|
|
||||||
keyHandler = bind -> {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return keyHandler;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.client.particle;
|
|
||||||
|
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.particle.ParticleEffect;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.render.model.DiskModel;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
|
|
||||||
public class ParticleDisk extends ParticleSphere {
|
|
||||||
|
|
||||||
private static final DiskModel model = new DiskModel();
|
|
||||||
|
|
||||||
protected float rotX;
|
|
||||||
protected float rotY;
|
|
||||||
protected float rotZ;
|
|
||||||
|
|
||||||
public ParticleDisk(ParticleEffect type, World w, double x, double y, double z, double rX, double rY, double rZ) {
|
|
||||||
super(w, x, y, z, radius, tint, alpha);
|
|
||||||
|
|
||||||
rotX = rX;
|
|
||||||
rotY = rY;
|
|
||||||
rotZ = rZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderParticle(BufferBuilder buffer, Entity viewer, float partialTicks, float x, float z, float yz, float xy, float xz) {
|
|
||||||
if (alpha <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color.glColor(tint, alpha);
|
|
||||||
|
|
||||||
model.setPosition(this.x, this.y, this.z);
|
|
||||||
model.render(radius);
|
|
||||||
|
|
||||||
GlStateManager.color(1, 1, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.client.particle;
|
|
||||||
|
|
||||||
import net.minecraft.client.particle.RainSplashParticle;
|
|
||||||
import net.minecraft.particle.ParticleEffect;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class ParticleRaindrops extends RainSplashParticle {
|
|
||||||
|
|
||||||
public ParticleRaindrops(ParticleEffect type, World world, double x, double y, double z, double dx, double dy, double dz) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
velocityY = -0.1;
|
|
||||||
maxAge += 19;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
super.tick();
|
|
||||||
|
|
||||||
if (onGround) {
|
|
||||||
velocityX *= 0.30000001192092896D;
|
|
||||||
velocityY = Math.random() * 0.20000000298023224D + 0.10000000149011612D;
|
|
||||||
velocityZ *= 0.30000001192092896D;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,8 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.nio.file.Files;
|
||||||
import java.io.OutputStreamWriter;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -28,12 +25,12 @@ public class Config {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init(File directory) {
|
public static void init(Path directory) {
|
||||||
File file = new File(directory, "unicopia.json");
|
Path file = directory.resolve("unicopia.json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (file.exists()) {
|
if (Files.exists(file)) {
|
||||||
try(JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file)));) {
|
try(JsonReader reader = new JsonReader(Files.newBufferedReader(file))) {
|
||||||
instance = gson.fromJson(reader, Config.class);
|
instance = gson.fromJson(reader, Config.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +46,7 @@ public class Config {
|
||||||
instance.save();
|
instance.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private File file;
|
private Path file;
|
||||||
|
|
||||||
@Expose(deserialize = false)
|
@Expose(deserialize = false)
|
||||||
private final String speciesWhiteListComment =
|
private final String speciesWhiteListComment =
|
||||||
|
@ -105,11 +102,13 @@ public class Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (file.exists()) {
|
try {
|
||||||
file.delete();
|
Files.deleteIfExists(file);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
try (JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(file)))) {
|
try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(file))) {
|
||||||
writer.setIndent(" ");
|
writer.setIndent(" ");
|
||||||
|
|
||||||
gson.toJson(this, Config.class, writer);
|
gson.toJson(this, Config.class, writer);
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
|
@ -6,36 +6,36 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
public final class EquinePredicates {
|
public interface EquinePredicates {
|
||||||
public static final Predicate<PlayerEntity> INTERACT_WITH_CLOUDS = player -> {
|
Predicate<PlayerEntity> INTERACT_WITH_CLOUDS = player -> {
|
||||||
return player != null && SpeciesList.instance().getPlayer(player).getSpecies().canInteractWithClouds();
|
return player != null && SpeciesList.instance().getPlayer(player).getSpecies().canInteractWithClouds();
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Predicate<Entity> MAGI = entity -> {
|
Predicate<Entity> MAGI = entity -> {
|
||||||
return entity instanceof PlayerEntity && SpeciesList.instance().getPlayer((PlayerEntity)entity).getSpecies().canCast();
|
return entity instanceof PlayerEntity && SpeciesList.instance().getPlayer((PlayerEntity)entity).getSpecies().canCast();
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Predicate<Entity> ITEMS = entity -> {
|
Predicate<Entity> ITEMS = entity -> {
|
||||||
return entity instanceof ItemEntity && entity.isAlive() && entity.age > 1;
|
return entity instanceof ItemEntity && entity.isAlive() && entity.age > 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final 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) && SpeciesList.instance().getEntity(item).getSpecies().canInteractWithClouds();
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = entity -> {
|
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = entity -> {
|
||||||
return entity != null && (
|
return entity != null && (
|
||||||
(entity instanceof PlayerEntity && INTERACT_WITH_CLOUDS.test((PlayerEntity)entity))
|
(entity instanceof PlayerEntity && INTERACT_WITH_CLOUDS.test((PlayerEntity)entity))
|
||||||
|| (entity instanceof ItemEntity && ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)entity))
|
|| (entity instanceof ItemEntity && ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)entity))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Predicate<Entity> BUGGY = entity -> {
|
Predicate<Entity> BUGGY = entity -> {
|
||||||
return entity instanceof PlayerEntity
|
return entity instanceof PlayerEntity
|
||||||
&& SpeciesList.instance().getPlayer((PlayerEntity)entity).getSpecies() == Race.CHANGELING;
|
&& SpeciesList.instance().getPlayer((PlayerEntity)entity).getSpecies() == Race.CHANGELING;
|
||||||
};
|
};
|
||||||
|
|
||||||
public static PlayerEntity getPlayerFromEntity(Entity entity) {
|
static PlayerEntity getPlayerFromEntity(Entity entity) {
|
||||||
if (entity instanceof PlayerEntity) {
|
if (entity instanceof PlayerEntity) {
|
||||||
return (PlayerEntity) entity;
|
return (PlayerEntity) entity;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.client.input;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
public interface IKeyBindingHandler {
|
public interface IKeyBindingHandler {
|
||||||
|
|
||||||
|
@ -9,12 +9,10 @@ public interface IKeyBindingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IKeyBinding {
|
public interface IKeyBinding {
|
||||||
|
|
||||||
String getKeyCategory();
|
String getKeyCategory();
|
||||||
|
|
||||||
String getKeyName();
|
String getKeyName();
|
||||||
|
|
||||||
int getKeyCode();
|
int getKeyCode();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,35 +1,26 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.util.dummy.DummyPlayerEntity;
|
import com.minelittlepony.unicopia.core.util.dummy.DummyPlayerEntity;
|
||||||
import com.minelittlepony.util.dummy.DummyServerPlayerEntity;
|
import com.minelittlepony.unicopia.core.util.dummy.DummyServerPlayerEntity;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
|
||||||
public class ServerInteractionManager implements InteractionManager {
|
public class InteractionManager {
|
||||||
|
|
||||||
@Deprecated
|
public static InteractionManager instance() {
|
||||||
public static boolean isClientSide() {
|
return UnicopiaCore.interactionManager;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public PlayerEntity getClientPlayer() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isClientPlayer(@Nullable PlayerEntity player) {
|
public boolean isClientPlayer(@Nullable PlayerEntity player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getViewMode() {
|
public int getViewMode() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +30,6 @@ public class ServerInteractionManager implements InteractionManager {
|
||||||
*
|
*
|
||||||
* Returns an implementation of PlayerEntity appropriate to the side being called on.
|
* Returns an implementation of PlayerEntity appropriate to the side being called on.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
||||||
if (observer.world instanceof ServerWorld) {
|
if (observer.world instanceof ServerWorld) {
|
||||||
|
@ -47,15 +37,4 @@ public class ServerInteractionManager implements InteractionManager {
|
||||||
}
|
}
|
||||||
return new DummyPlayerEntity(observer.world, profile);
|
return new DummyPlayerEntity(observer.world, profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postRenderEntity(Entity entity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderEntity(Entity entity, float renderPartialTicks) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
|
public class ServerInteractionManager {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static boolean isClientSide() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Config;
|
import com.minelittlepony.unicopia.core.Config;
|
||||||
import com.minelittlepony.unicopia.ducks.IRaceContainerHolder;
|
import com.minelittlepony.unicopia.core.ducks.IRaceContainerHolder;
|
||||||
import com.minelittlepony.unicopia.entity.IEntity;
|
import com.minelittlepony.unicopia.core.entity.IEntity;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.core.util.CustomStatusEffect;
|
||||||
import com.minelittlepony.util.MagicalDamageSource;
|
import com.minelittlepony.unicopia.core.util.MagicalDamageSource;
|
||||||
|
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
@ -11,7 +11,7 @@ import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class UEffects {
|
public class UEffects {
|
||||||
|
|
||||||
public static final StatusEffect FOOD_POISONING = new CustomStatusEffect(new Identifier(Unicopia.MODID, "food_poisoning"), StatusEffectType.BENEFICIAL, 3484199)
|
public static final StatusEffect FOOD_POISONING = new CustomStatusEffect(new Identifier(UnicopiaCore.MODID, "food_poisoning"), StatusEffectType.BENEFICIAL, 3484199)
|
||||||
.setSilent()
|
.setSilent()
|
||||||
.direct((p, e, i) -> {
|
.direct((p, e, i) -> {
|
||||||
StatusEffectInstance nausea = e.getStatusEffect(StatusEffects.NAUSEA);
|
StatusEffectInstance nausea = e.getStatusEffect(StatusEffects.NAUSEA);
|
|
@ -1,17 +1,14 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.particle.ParticleChangelingMagic;
|
|
||||||
import com.minelittlepony.unicopia.client.particle.ParticleDisk;
|
|
||||||
import com.minelittlepony.unicopia.client.particle.ParticleRaindrops;
|
|
||||||
import com.minelittlepony.unicopia.client.particle.ParticleSphere;
|
|
||||||
import com.minelittlepony.unicopia.client.particle.ParticleUnicornMagic;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.particle.DefaultParticleType;
|
import net.minecraft.particle.DefaultParticleType;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class UParticles {
|
public class UParticles {
|
||||||
|
// TODO:
|
||||||
|
interface ParticleTypeRegistry {
|
||||||
|
static ParticleTypeRegistry getTnstance() {return null;}
|
||||||
|
DefaultParticleType register(Identifier id);
|
||||||
|
}
|
||||||
public static final DefaultParticleType UNICORN_MAGIC = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "unicorn_magic"));
|
public static final DefaultParticleType UNICORN_MAGIC = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "unicorn_magic"));
|
||||||
public static final DefaultParticleType CHANGELING_MAGIC = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "changeling_magic"));
|
public static final DefaultParticleType CHANGELING_MAGIC = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "changeling_magic"));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -21,7 +21,7 @@ public class USounds {
|
||||||
public static final SoundEvent RECORD_FUNK = register("record.funk");
|
public static final SoundEvent RECORD_FUNK = register("record.funk");
|
||||||
|
|
||||||
private static SoundEvent register(String name) {
|
private static SoundEvent register(String name) {
|
||||||
Identifier id = new Identifier(Unicopia.MODID, name);
|
Identifier id = new Identifier(UnicopiaCore.MODID, name);
|
||||||
return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id));
|
return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id));
|
||||||
}
|
}
|
||||||
|
|
13
src/main/java/com/minelittlepony/unicopia/core/UTags.java
Normal file
13
src/main/java/com/minelittlepony/unicopia/core/UTags.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.tag.Tag;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class UTags {
|
||||||
|
// TODO: includes unicopia:alicorn_amulet
|
||||||
|
public static final Tag<Item> CURSED_ARTEFACTS = TagRegistry.item(new Identifier(UnicopiaCore.MODID, "cursed_artefacts"));
|
||||||
|
|
||||||
|
static void bootstrap() {}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.minelittlepony.unicopia.core;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import com.minelittlepony.common.util.GamePaths;
|
||||||
|
import com.minelittlepony.jumpingcastle.api.Channel;
|
||||||
|
import com.minelittlepony.jumpingcastle.api.JumpingCastle;
|
||||||
|
import com.minelittlepony.unicopia.core.ability.PowersRegistry;
|
||||||
|
import com.minelittlepony.unicopia.core.command.Commands;
|
||||||
|
import com.minelittlepony.unicopia.core.network.MsgPlayerAbility;
|
||||||
|
import com.minelittlepony.unicopia.core.network.MsgPlayerCapabilities;
|
||||||
|
import com.minelittlepony.unicopia.core.network.MsgRequestCapabilities;
|
||||||
|
|
||||||
|
public class UnicopiaCore implements ModInitializer {
|
||||||
|
public static final String MODID = "unicopia";
|
||||||
|
public static final String NAME = "@NAME@";
|
||||||
|
public static final String VERSION = "@VERSION@";
|
||||||
|
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
public static InteractionManager interactionManager = new InteractionManager();
|
||||||
|
|
||||||
|
private static Channel channel;
|
||||||
|
|
||||||
|
public static Channel getConnection() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
Config.init(GamePaths.getConfigDirectory());
|
||||||
|
|
||||||
|
channel = JumpingCastle.subscribeTo(MODID, () -> {})
|
||||||
|
.listenFor(MsgRequestCapabilities.class)
|
||||||
|
.listenFor(MsgPlayerCapabilities.class)
|
||||||
|
.listenFor(MsgPlayerAbility.class);
|
||||||
|
|
||||||
|
UTags.bootstrap();
|
||||||
|
Commands.bootstrap();
|
||||||
|
PowersRegistry.instance().init();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
|
public class Hit implements IPower.IData {
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.IPower;
|
import com.minelittlepony.unicopia.core.ability.IPower;
|
||||||
|
|
||||||
public interface IAbilityReceiver {
|
public interface IAbilityReceiver {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Predicate for abilities to control whether a player can fly.
|
* Predicate for abilities to control whether a player can fly.
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Predicate for abilities to control what the player's physical height is.
|
* Predicate for abilities to control what the player's physical height is.
|
|
@ -1,14 +1,14 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.IKeyBindingHandler;
|
||||||
import com.minelittlepony.unicopia.client.input.IKeyBindingHandler;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IPower<T extends IData> extends IKeyBindingHandler.IKeyBinding {
|
public interface IPower<T extends IPower.IData> extends IKeyBindingHandler.IKeyBinding {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default String getKeyCategory() {
|
default String getKeyCategory() {
|
||||||
|
@ -75,4 +75,7 @@ public interface IPower<T extends IData> extends IKeyBindingHandler.IKeyBinding
|
||||||
*/
|
*/
|
||||||
void postApply(IPlayer player);
|
void postApply(IPlayer player);
|
||||||
|
|
||||||
|
public interface IData {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class Location implements IData {
|
public class Location implements IPower.IData {
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
public int x;
|
public int x;
|
|
@ -1,8 +1,8 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
public class Numeric implements IData {
|
public class Numeric implements IPower.IData {
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
public int type;
|
public int type;
|
|
@ -1,10 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
import com.minelittlepony.util.VecHelper;
|
import com.minelittlepony.unicopia.core.util.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -13,6 +13,9 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pegasi ability to pick up and carry other players
|
||||||
|
*/
|
||||||
public class PowerCarry implements IPower<Hit> {
|
public class PowerCarry implements IPower<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -7,10 +7,10 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
import com.minelittlepony.util.MagicalDamageSource;
|
import com.minelittlepony.unicopia.core.util.MagicalDamageSource;
|
||||||
import com.minelittlepony.util.VecHelper;
|
import com.minelittlepony.unicopia.core.util.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
@ -25,6 +25,9 @@ import net.minecraft.entity.passive.SheepEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changeling ability to restore health from mobs
|
||||||
|
*/
|
||||||
public class PowerFeed implements IPower<Hit> {
|
public class PowerFeed implements IPower<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,11 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.UParticles;
|
import com.minelittlepony.unicopia.core.UParticles;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
import com.minelittlepony.util.VecHelper;
|
import com.minelittlepony.unicopia.core.util.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.BoneMealItem;
|
import net.minecraft.item.BoneMealItem;
|
||||||
|
@ -17,6 +17,9 @@ 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Earth Pony ability to grow crops
|
||||||
|
*/
|
||||||
public class PowerGrow implements IPower<Location> {
|
public class PowerGrow implements IPower<Location> {
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,11 +1,16 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import com.minelittlepony.unicopia.Race;
|
|
||||||
import com.minelittlepony.unicopia.UParticles;
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
|
||||||
import com.minelittlepony.unicopia.magic.spells.SpellShield;
|
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
|
import com.minelittlepony.unicopia.core.UParticles;
|
||||||
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
import com.minelittlepony.unicopia.core.magic.spell.ShieldSpell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A magic casting ability for unicorns.
|
||||||
|
* (only shields for now)
|
||||||
|
*/
|
||||||
public class PowerMagic implements IPower<Hit> {
|
public class PowerMagic implements IPower<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,10 +50,11 @@ public class PowerMagic implements IPower<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(IPlayer player, Hit data) {
|
public void apply(IPlayer player, Hit data) {
|
||||||
if (player.getEffect() instanceof SpellShield) {
|
// TODO: A way to pick the active effect
|
||||||
|
if (player.getEffect() instanceof ShieldSpell) {
|
||||||
player.setEffect(null);
|
player.setEffect(null);
|
||||||
} else {
|
} else {
|
||||||
player.setEffect(new SpellShield());
|
player.setEffect(new ShieldSpell());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import com.minelittlepony.unicopia.Race;
|
|
||||||
import com.minelittlepony.unicopia.UParticles;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.UParticles;
|
||||||
import com.minelittlepony.util.VecHelper;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
import com.minelittlepony.unicopia.core.util.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -23,6 +24,9 @@ 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unicorn teleport ability
|
||||||
|
*/
|
||||||
public class PowerTeleport implements IPower<Location> {
|
public class PowerTeleport implements IPower<Location> {
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,13 +1,13 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.core.ability;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.client.input.Keyboard;
|
|
||||||
|
|
||||||
public class PowersRegistry {
|
public class PowersRegistry {
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ public class PowersRegistry {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<Integer, List<IPower<? extends IData>>> keyToPowerMap = new HashMap<>();
|
private final Map<Integer, List<IPower<? extends IPower.IData>>> keyToPowerMap = new HashMap<>();
|
||||||
|
|
||||||
private final Map<String, IPower<? extends IData>> powerNamesMap = new HashMap<>();
|
private final Map<String, IPower<? extends IPower.IData>> powerNamesMap = new HashMap<>();
|
||||||
|
|
||||||
private PowersRegistry() {
|
private PowersRegistry() {
|
||||||
}
|
}
|
||||||
|
@ -27,36 +27,35 @@ public class PowersRegistry {
|
||||||
public void init() {
|
public void init() {
|
||||||
registerPower(new PowerTeleport());
|
registerPower(new PowerTeleport());
|
||||||
registerPower(new PowerMagic());
|
registerPower(new PowerMagic());
|
||||||
registerPower(new PowerStomp());
|
|
||||||
registerPower(new PowerGrow());
|
registerPower(new PowerGrow());
|
||||||
registerPower(new PowerFeed());
|
registerPower(new PowerFeed());
|
||||||
registerPower(new PowerCarry());
|
registerPower(new PowerCarry());
|
||||||
registerPower(new PowerDisguise());
|
|
||||||
registerPower(new PowerCloudBase());
|
|
||||||
registerPower(new PowerEngulf());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRegisteredPower(int keyCode) {
|
public boolean hasRegisteredPower(int keyCode) {
|
||||||
return keyToPowerMap.containsKey(keyCode);
|
return keyToPowerMap.containsKey(keyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<IPower<? extends IData>> getCapablePowerFromKey(int keyCode, Race race) {
|
public Optional<IPower<? extends IPower.IData>> getCapablePowerFromKey(int keyCode, Race race) {
|
||||||
return getKeyCodePool(keyCode).stream()
|
return getKeyCodePool(keyCode).stream()
|
||||||
.filter(power -> power.canUse(race))
|
.filter(power -> power.canUse(race))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<IPower<? extends IData>> getPowerFromName(String name) {
|
public Optional<IPower<? extends IPower.IData>> getPowerFromName(String name) {
|
||||||
return Optional.ofNullable(powerNamesMap.get(name));
|
return Optional.ofNullable(powerNamesMap.get(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IPower<? extends IData>> getKeyCodePool(int keyCode) {
|
private List<IPower<? extends IPower.IData>> getKeyCodePool(int keyCode) {
|
||||||
return keyToPowerMap.computeIfAbsent(keyCode, ArrayList::new);
|
return keyToPowerMap.computeIfAbsent(keyCode, ArrayList::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerPower(IPower<? extends IData> power) {
|
public void registerPower(IPower<? extends IPower.IData> power) {
|
||||||
getKeyCodePool(power.getKeyCode()).add(power);
|
getKeyCodePool(power.getKeyCode()).add(power);
|
||||||
powerNamesMap.put(power.getKeyName(), power);
|
powerNamesMap.put(power.getKeyName(), power);
|
||||||
Keyboard.getKeyHandler().addKeybind(power);
|
}
|
||||||
|
|
||||||
|
public Collection<IPower<? extends IPower.IData>> getValues() {
|
||||||
|
return powerNamesMap.values();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.client.input;
|
package com.minelittlepony.unicopia.core.client;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.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;
|
||||||
|
@ -40,7 +40,7 @@ public class InversionAwareKeyboardInput extends KeyboardInput {
|
||||||
this.movementSideways = proxy.movementSideways;
|
this.movementSideways = proxy.movementSideways;
|
||||||
this.movementForward = proxy.movementForward;
|
this.movementForward = proxy.movementForward;
|
||||||
|
|
||||||
IPlayer player = InteractionManager.instance().getIPlayer();
|
IPlayer player = SpeciesList.instance().getPlayer(MinecraftClient.getInstance().player);
|
||||||
|
|
||||||
if (player.getGravity().getGravitationConstant() < 0) {
|
if (player.getGravity().getGravitationConstant() < 0) {
|
||||||
boolean tmp = pressingLeft;
|
boolean tmp = pressingLeft;
|
|
@ -1,12 +1,13 @@
|
||||||
package com.minelittlepony.unicopia.client.input;
|
package com.minelittlepony.unicopia.core.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.core.IKeyBindingHandler;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
import com.minelittlepony.unicopia.core.UnicopiaCore;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.ability.PowersRegistry;
|
||||||
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -16,7 +17,7 @@ import net.minecraft.client.util.InputUtil;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
|
||||||
class KeyBindingsHandler implements IKeyBindingHandler {
|
public class KeyBindingsHandler implements IKeyBindingHandler {
|
||||||
private final MinecraftClient client = MinecraftClient.getInstance();
|
private final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
private final List<KeyBinding> bindings = new ArrayList<>();
|
private final List<KeyBinding> bindings = new ArrayList<>();
|
||||||
|
@ -28,7 +29,7 @@ class KeyBindingsHandler implements IKeyBindingHandler {
|
||||||
public void addKeybind(IKeyBinding p) {
|
public void addKeybind(IKeyBinding p) {
|
||||||
KeyBindingRegistry.INSTANCE.addCategory(p.getKeyCategory());
|
KeyBindingRegistry.INSTANCE.addCategory(p.getKeyCategory());
|
||||||
|
|
||||||
FabricKeyBinding b = FabricKeyBinding.Builder.create(new Identifier(Unicopia.MODID, p.getKeyName()), InputUtil.Type.KEYSYM, p.getKeyCode(), p.getKeyCategory()).build();
|
FabricKeyBinding b = FabricKeyBinding.Builder.create(new Identifier(UnicopiaCore.MODID, p.getKeyName()), InputUtil.Type.KEYSYM, p.getKeyCode(), p.getKeyCategory()).build();
|
||||||
KeyBindingRegistry.INSTANCE.register(b);
|
KeyBindingRegistry.INSTANCE.register(b);
|
||||||
|
|
||||||
bindings.add(b);
|
bindings.add(b);
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.client.input;
|
package com.minelittlepony.unicopia.core.client;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.Mouse;
|
import net.minecraft.client.Mouse;
|
||||||
|
@ -13,7 +13,7 @@ public class MouseControl extends Mouse {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMouse() {
|
public void updateMouse() {
|
||||||
if (InteractionManager.instance().getIPlayer().getGravity().getGravitationConstant() < 0) {
|
if (SpeciesList.instance().getPlayer(MinecraftClient.getInstance().player).getGravity().getGravitationConstant() < 0) {
|
||||||
//cursorDeltaX = -cursorDeltaX;
|
//cursorDeltaX = -cursorDeltaX;
|
||||||
//cursorDeltaY = -cursorDeltaY;
|
//cursorDeltaY = -cursorDeltaY;
|
||||||
}
|
}
|
|
@ -1,41 +1,37 @@
|
||||||
package com.minelittlepony.unicopia.client;
|
package com.minelittlepony.unicopia.core.client;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.MineLP;
|
import com.minelittlepony.common.event.ClientReadyCallback;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.jumpingcastle.api.Target;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.core.Config;
|
||||||
import com.minelittlepony.unicopia.ServerInteractionManager;
|
import com.minelittlepony.unicopia.core.IKeyBindingHandler;
|
||||||
import com.minelittlepony.unicopia.Config;
|
import com.minelittlepony.unicopia.core.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.UEntities;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.UParticles;
|
import com.minelittlepony.unicopia.core.UnicopiaCore;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.core.ability.PowersRegistry;
|
||||||
import com.minelittlepony.unicopia.client.ability.render.DisguiseRenderer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
import com.minelittlepony.unicopia.client.gui.SettingsScreen;
|
import com.minelittlepony.unicopia.core.network.MsgRequestCapabilities;
|
||||||
import com.minelittlepony.unicopia.client.input.Keyboard;
|
import com.minelittlepony.unicopia.core.util.MineLPConnector;
|
||||||
import com.minelittlepony.unicopia.client.input.MouseControl;
|
import com.minelittlepony.unicopia.core.util.dummy.DummyClientPlayerEntity;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.redux.client.render.DisguiseRenderer;
|
||||||
import com.minelittlepony.unicopia.inventory.gui.GuiOfHolding;
|
|
||||||
import com.minelittlepony.unicopia.client.input.InversionAwareKeyboardInput;
|
|
||||||
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
|
||||||
import com.minelittlepony.util.dummy.DummyClientPlayerEntity;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.input.Input;
|
import net.minecraft.client.input.Input;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.container.ContainerType;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.container.NameableContainerProvider;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
public class ClientInteractionManager extends ServerInteractionManager {
|
public class UnicopiaCoreClient extends InteractionManager implements ClientModInitializer {
|
||||||
|
|
||||||
|
private final IKeyBindingHandler keyboard = new KeyBindingsHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The race preferred by the client - as determined by mine little pony.
|
* The race preferred by the client - as determined by mine little pony.
|
||||||
|
@ -50,7 +46,7 @@ public class ClientInteractionManager extends ServerInteractionManager {
|
||||||
private static Race getclientPlayerRace() {
|
private static Race getclientPlayerRace() {
|
||||||
if (!Config.instance().ignoresMineLittlePony()
|
if (!Config.instance().ignoresMineLittlePony()
|
||||||
&& MinecraftClient.getInstance().player != null) {
|
&& MinecraftClient.getInstance().player != null) {
|
||||||
Race race = MineLP.getPlayerPonyRace();
|
Race race = MineLPConnector.getPlayerPonyRace();
|
||||||
|
|
||||||
if (!race.isDefault()) {
|
if (!race.isDefault()) {
|
||||||
return race;
|
return race;
|
||||||
|
@ -61,55 +57,39 @@ public class ClientInteractionManager extends ServerInteractionManager {
|
||||||
return Config.instance().getPrefferedRace();
|
return Config.instance().getPrefferedRace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public PlayerEntity getClientPlayer() {
|
|
||||||
return MinecraftClient.getInstance().player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public PlayerEntity getPlayerByUUID(UUID playerId) {
|
|
||||||
MinecraftClient mc = MinecraftClient.getInstance();
|
|
||||||
|
|
||||||
if (mc.player.getUuid().equals(playerId)) {
|
|
||||||
return mc.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mc.world.getPlayerByUuid(playerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
||||||
return new DummyClientPlayerEntity(observer.world, profile);
|
if (observer.world instanceof ClientWorld) {
|
||||||
|
return new DummyClientPlayerEntity((ClientWorld)observer.world, profile);
|
||||||
|
}
|
||||||
|
return super.createPlayer(observer, profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClientPlayer(@Nullable PlayerEntity player) {
|
public boolean isClientPlayer(@Nullable PlayerEntity player) {
|
||||||
if (getClientPlayer() == player) {
|
if (MinecraftClient.getInstance().player == player) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getClientPlayer() == null || player == null) {
|
if (MinecraftClient.getInstance().player == null || player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IPlayer.equal(getClientPlayer(), player);
|
return IPlayer.equal(MinecraftClient.getInstance().player, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewMode() {
|
public int getViewMode() {
|
||||||
return MinecraftClient.getInstance().gameSettings.thirdPersonView;
|
return MinecraftClient.getInstance().options.perspective;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
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);
|
IPlayer iplayer = SpeciesList.instance().getPlayer((PlayerEntity)entity);
|
||||||
|
|
||||||
if (iplayer.getGravity().getGravitationConstant() < 0) {
|
if (iplayer.getGravity().getGravitationConstant() < 0) {
|
||||||
GlStateManager.translate(0, entity.height, 0);
|
GlStateManager.translated(0, entity.getDimensions(entity.getPose()).height, 0);
|
||||||
GlStateManager.scalef(1, -1, 1);
|
GlStateManager.scalef(1, -1, 1);
|
||||||
entity.prevPitch *= -1;
|
entity.prevPitch *= -1;
|
||||||
entity.pitch *= -1;
|
entity.pitch *= -1;
|
||||||
|
@ -117,7 +97,6 @@ public class ClientInteractionManager extends ServerInteractionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderEntity(Entity entity, float renderPartialTicks) {
|
public boolean renderEntity(Entity entity, float renderPartialTicks) {
|
||||||
|
|
||||||
if (DisguiseRenderer.getInstance().renderDisguise(entity, renderPartialTicks)) {
|
if (DisguiseRenderer.getInstance().renderDisguise(entity, renderPartialTicks)) {
|
||||||
|
@ -129,7 +108,7 @@ public class ClientInteractionManager extends ServerInteractionManager {
|
||||||
|
|
||||||
if (iplayer.getGravity().getGravitationConstant() < 0) {
|
if (iplayer.getGravity().getGravitationConstant() < 0) {
|
||||||
GlStateManager.scalef(1, -1, 1);
|
GlStateManager.scalef(1, -1, 1);
|
||||||
GlStateManager.translate(0, -entity.height, 0);
|
GlStateManager.translated(0, -entity.getDimensions(entity.getPose()).height, 0);
|
||||||
entity.prevPitch *= -1;
|
entity.prevPitch *= -1;
|
||||||
entity.pitch *= -1;
|
entity.pitch *= -1;
|
||||||
}
|
}
|
||||||
|
@ -147,19 +126,18 @@ public class ClientInteractionManager extends ServerInteractionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preInit() {
|
public void onInitializeClient() {
|
||||||
UEntities.preInit();
|
|
||||||
UParticles.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
clientPlayerRace = getclientPlayerRace();
|
clientPlayerRace = getclientPlayerRace();
|
||||||
|
UnicopiaCore.interactionManager = this;
|
||||||
|
|
||||||
|
ClientTickCallback.EVENT.register(this::tick);
|
||||||
|
ClientReadyCallback.EVENT.register(client -> {
|
||||||
|
PowersRegistry.instance().getValues().forEach(keyboard::addKeybind);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void tick(MinecraftClient client) {
|
||||||
public void tick() {
|
PlayerEntity player = client.player;
|
||||||
PlayerEntity player = InteractionManager.instance().getClientPlayer();
|
|
||||||
|
|
||||||
if (player != null && !player.removed) {
|
if (player != null && !player.removed) {
|
||||||
Race newRace = getclientPlayerRace();
|
Race newRace = getclientPlayerRace();
|
||||||
|
@ -167,13 +145,11 @@ public class ClientInteractionManager extends ServerInteractionManager {
|
||||||
if (newRace != clientPlayerRace) {
|
if (newRace != clientPlayerRace) {
|
||||||
clientPlayerRace = newRace;
|
clientPlayerRace = newRace;
|
||||||
|
|
||||||
Unicopia.getConnection().send(new MsgRequestCapabilities(player, clientPlayerRace), Target.SERVER);
|
UnicopiaCore.getConnection().send(new MsgRequestCapabilities(player, clientPlayerRace), Target.SERVER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Keyboard.getKeyHandler().onKeyInput();
|
keyboard.onKeyInput();
|
||||||
|
|
||||||
MinecraftClient client = MinecraftClient.getInstance();
|
|
||||||
|
|
||||||
if (player instanceof ClientPlayerEntity) {
|
if (player instanceof ClientPlayerEntity) {
|
||||||
ClientPlayerEntity sp = (ClientPlayerEntity)player;
|
ClientPlayerEntity sp = (ClientPlayerEntity)player;
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.minelittlepony.unicopia.core.client.gui;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
|
import com.minelittlepony.unicopia.core.client.gui.UHud;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
|
class ClientHooks {
|
||||||
|
public static void beforePreRenderHud() {
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
if (client.player != null && client.world != null) {
|
||||||
|
UHud.instance.repositionElements(SpeciesList.instance().getPlayer(client.player), client.window, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void postRenderHud() {
|
||||||
|
|
||||||
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
if (client.player != null && client.world != null) {
|
||||||
|
UHud.instance.renderHud(SpeciesList.instance().getPlayer(client.player), client.window);
|
||||||
|
}
|
||||||
|
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.client.gui;
|
package com.minelittlepony.unicopia.core.client.gui;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
import net.minecraft.client.gui.DrawableHelper;
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.client.gui;
|
package com.minelittlepony.unicopia.core.client.gui;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
public interface IHudElement {
|
public interface IHudElement {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.client.gui;
|
package com.minelittlepony.unicopia.core.client.gui;
|
||||||
|
|
||||||
import com.minelittlepony.common.client.gui.GameGui;
|
import com.minelittlepony.common.client.gui.GameGui;
|
||||||
import com.minelittlepony.common.client.gui.element.Button;
|
import com.minelittlepony.common.client.gui.element.Button;
|
|
@ -1,16 +1,16 @@
|
||||||
package com.minelittlepony.unicopia.client.gui;
|
package com.minelittlepony.unicopia.core.client.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.util.Window;
|
||||||
|
|
||||||
public class UHud {
|
public class UHud {
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class UHud {
|
||||||
elements.add(new FlightExperienceBar());
|
elements.add(new FlightExperienceBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderHud(IPlayer player, ScaledResolution resolution) {
|
public void renderHud(IPlayer 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,29 +43,13 @@ public class UHud {
|
||||||
elements.forEach(this::renderElement);
|
elements.forEach(this::renderElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void repositionElements(IPlayer player, ScaledResolution resolution, ElementType type, boolean begin) {
|
public void repositionElements(IPlayer player, Window window, boolean begin) {
|
||||||
this.width = resolution.getScaledWidth();
|
this.width = window.getScaledWidth();
|
||||||
this.height = resolution.getScaledHeight();
|
this.height = window.getScaledHeight();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.begin = begin;
|
this.begin = begin;
|
||||||
|
|
||||||
if (isSurvivalElement(type)) {
|
elements.forEach(this::positionElement);
|
||||||
elements.forEach(this::positionElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isSurvivalElement(ElementType type) {
|
|
||||||
switch (type) {
|
|
||||||
case ARMOR:
|
|
||||||
case HEALTH:
|
|
||||||
case FOOD:
|
|
||||||
case AIR:
|
|
||||||
case EXPERIENCE:
|
|
||||||
case HEALTHMOUNT:
|
|
||||||
case JUMPBAR:
|
|
||||||
return true;
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void positionElement(IHudElement element) {
|
private void positionElement(IHudElement element) {
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.minelittlepony.unicopia.core.client.particle;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
|
import net.minecraft.client.render.Camera;
|
||||||
|
import net.minecraft.particle.ParticleEffect;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL14;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.core.client.render.DiskModel;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
|
public class DiskParticle extends SphereParticle {
|
||||||
|
|
||||||
|
private static final DiskModel model = new DiskModel();
|
||||||
|
|
||||||
|
protected double rotX;
|
||||||
|
protected double rotY;
|
||||||
|
protected double rotZ;
|
||||||
|
|
||||||
|
public DiskParticle(ParticleEffect type, World w,
|
||||||
|
double x, double y, double z,
|
||||||
|
float radius,
|
||||||
|
int red, int green, int blue, float alpha,
|
||||||
|
double rX, double rY, double rZ) {
|
||||||
|
super(w, x, y, z, radius, red, green, blue, alpha);
|
||||||
|
|
||||||
|
rotX = rX;
|
||||||
|
rotY = rY;
|
||||||
|
rotZ = rZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildGeometry(BufferBuilder buffer, Camera viewer, float partialTicks, float x, float z, float yz, float xy, float xz) {
|
||||||
|
if (alpha <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL14.glBlendColor(red, green, blue, alpha);
|
||||||
|
|
||||||
|
model.setPosition(this.x, this.y, this.z);
|
||||||
|
model.render(radius);
|
||||||
|
|
||||||
|
GlStateManager.color4f(1, 1, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.client.particle;
|
package com.minelittlepony.unicopia.core.client.particle;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.particle.Particle;
|
import net.minecraft.client.particle.Particle;
|
||||||
import net.minecraft.client.particle.ParticleFactory;
|
import net.minecraft.client.particle.ParticleFactory;
|
||||||
import net.minecraft.client.particle.PortalParticle;
|
import net.minecraft.client.particle.PortalParticle;
|
||||||
|
@ -15,7 +17,7 @@ public class ParticleChangelingMagic extends PortalParticle {
|
||||||
public ParticleChangelingMagic(World world, double x, double y, double z, double dx, double dy, double dz) {
|
public ParticleChangelingMagic(World world, double x, double y, double z, double dx, double dy, double dz) {
|
||||||
super(world, x, y, z, dx, dy, dz);
|
super(world, x, y, z, dx, dy, dz);
|
||||||
|
|
||||||
float intensity = rand.nextFloat() * 0.6F + 0.4F;
|
float intensity = random.nextFloat() * 0.6F + 0.4F;
|
||||||
|
|
||||||
colorRed = intensity * 0.5F;
|
colorRed = intensity * 0.5F;
|
||||||
colorGreen = intensity;
|
colorGreen = intensity;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.client.particle;
|
package com.minelittlepony.unicopia.core.client.particle;
|
||||||
|
|
||||||
import net.minecraft.client.particle.Particle;
|
import net.minecraft.client.particle.Particle;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.minelittlepony.unicopia.core.client.particle;
|
||||||
|
|
||||||
|
import net.minecraft.client.particle.Particle;
|
||||||
|
import net.minecraft.client.particle.ParticleFactory;
|
||||||
|
import net.minecraft.client.particle.RainSplashParticle;
|
||||||
|
import net.minecraft.client.particle.SpriteProvider;
|
||||||
|
import net.minecraft.particle.DefaultParticleType;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class RaindropsParticle extends RainSplashParticle {
|
||||||
|
|
||||||
|
public RaindropsParticle(World world, double x, double y, double z, double dx, double dy, double dz) {
|
||||||
|
super(world, x, y, z);
|
||||||
|
velocityY = -0.1;
|
||||||
|
maxAge += 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
|
||||||
|
if (onGround) {
|
||||||
|
velocityX *= 0.30000001192092896D;
|
||||||
|
velocityY = Math.random() * 0.20000000298023224D + 0.10000000149011612D;
|
||||||
|
velocityZ *= 0.30000001192092896D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory implements ParticleFactory<DefaultParticleType> {
|
||||||
|
private final SpriteProvider provider;
|
||||||
|
|
||||||
|
public Factory(SpriteProvider provider) {
|
||||||
|
this.provider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle createParticle(DefaultParticleType defaultParticleType_1, World world, double x, double y, double z, double dx, double dy, double dz) {
|
||||||
|
RaindropsParticle particle = new RaindropsParticle(world, x, y, z, dx, dy, dz);
|
||||||
|
particle.setSprite(provider);
|
||||||
|
return particle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,25 +1,30 @@
|
||||||
package com.minelittlepony.unicopia.client.particle;
|
package com.minelittlepony.unicopia.core.client.particle;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.particle.Particle;
|
import net.minecraft.client.particle.Particle;
|
||||||
|
import net.minecraft.client.particle.ParticleFactory;
|
||||||
import net.minecraft.client.particle.ParticleTextureSheet;
|
import net.minecraft.client.particle.ParticleTextureSheet;
|
||||||
|
import net.minecraft.client.particle.SpriteProvider;
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.particle.DefaultParticleType;
|
||||||
import net.minecraft.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL14;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.render.model.SphereModel;
|
import com.minelittlepony.unicopia.core.client.render.SphereModel;
|
||||||
import com.minelittlepony.unicopia.magic.ICaster;
|
import com.minelittlepony.unicopia.core.magic.ICaster;
|
||||||
import com.minelittlepony.unicopia.particles.ParticleConnection.IAttachableParticle;
|
import com.minelittlepony.unicopia.core.util.particles.ParticleConnection.IAttachableParticle;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
public class ParticleSphere extends Particle implements IAttachableParticle {
|
public class SphereParticle extends Particle implements IAttachableParticle {
|
||||||
|
|
||||||
protected int tint;
|
protected float red;
|
||||||
|
protected float green;
|
||||||
|
protected float blue;
|
||||||
protected float alpha;
|
protected float alpha;
|
||||||
|
|
||||||
protected float radius;
|
protected float radius;
|
||||||
|
@ -28,19 +33,25 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
||||||
|
|
||||||
private static final SphereModel model = new SphereModel();
|
private static final SphereModel model = new SphereModel();
|
||||||
|
|
||||||
public ParticleSphere(ParticleEffect type, World w, double x, double y, double z, double vX, double vY, double vZ) {
|
public SphereParticle(ParticleEffect type, World w,
|
||||||
this(w, x, y, z, args[0] / 1000F, args[1], args[2]/100F);
|
double x, double y, double z,
|
||||||
|
float radius,
|
||||||
|
int red, int green, int blue, float alpha,
|
||||||
|
double vX, double vY, double vZ) {
|
||||||
|
this(w, x, y, z, radius, red, green, blue, alpha);
|
||||||
|
|
||||||
this.velocityX = vX;
|
this.velocityX = vX;
|
||||||
this.velocityY = vY;
|
this.velocityY = vY;
|
||||||
this.velocityZ = vZ;
|
this.velocityZ = vZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleSphere(World w, double x, double y, double z, float radius, int tint, float alpha) {
|
public SphereParticle(World w, double x, double y, double z, float radius, int red, int green, int blue, float alpha) {
|
||||||
super(w, x, y, z);
|
super(w, x, y, z);
|
||||||
|
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
this.tint = tint;
|
this.red = red/255F;
|
||||||
|
this.green = green/255F;
|
||||||
|
this.blue = blue/255F;
|
||||||
this.alpha = alpha;
|
this.alpha = alpha;
|
||||||
|
|
||||||
setMaxAge(10);
|
setMaxAge(10);
|
||||||
|
@ -57,13 +68,6 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
||||||
this.caster = caster;
|
this.caster = caster;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void buildGeometry(BufferBuilder var1, Camera var2, float var3, float var4, float var5, float var6,
|
|
||||||
float var7, float var8) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParticleTextureSheet getType() {
|
public ParticleTextureSheet getType() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -91,7 +95,8 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderParticle(BufferBuilder buffer, Entity viewer, float partialTicks, float x, float z, float yz, float xy, float xz) {
|
@Override
|
||||||
|
public void buildGeometry(BufferBuilder buffer, Camera viewer, float partialTicks, float x, float z, float yz, float xy, float xz) {
|
||||||
if (alpha <= 0 || radius <= 0) {
|
if (alpha <= 0 || radius <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +110,7 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
||||||
MinecraftClient.getInstance().gameRenderer.disableLightmap();
|
MinecraftClient.getInstance().gameRenderer.disableLightmap();
|
||||||
GlStateManager.enableLighting();
|
GlStateManager.enableLighting();
|
||||||
|
|
||||||
Color.glColor(tint, alpha);
|
GL14.glBlendColor(red, green, blue, alpha);
|
||||||
|
|
||||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
GlStateManager.disableTexture();
|
GlStateManager.disableTexture();
|
||||||
|
@ -129,11 +134,32 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
||||||
radius = (float)value;
|
radius = (float)value;
|
||||||
}
|
}
|
||||||
if (key == 1) {
|
if (key == 1) {
|
||||||
tint = (int)value;
|
red = (int)value/255F;
|
||||||
|
}
|
||||||
|
if (key == 2) {
|
||||||
|
green = (int)value/255F;
|
||||||
}
|
}
|
||||||
if (key == 3) {
|
if (key == 3) {
|
||||||
|
blue = (int)value/255F;
|
||||||
|
}
|
||||||
|
if (key == 4) {
|
||||||
alpha = (float)value;
|
alpha = (float)value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Factory implements ParticleFactory<DefaultParticleType> {
|
||||||
|
private final SpriteProvider provider;
|
||||||
|
|
||||||
|
public Factory(SpriteProvider provider) {
|
||||||
|
this.provider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle createParticle(DefaultParticleType defaultParticleType_1, World world, double x, double y, double z, double dx, double dy, double dz) {
|
||||||
|
RaindropsParticle particle = new RaindropsParticle(world, x, y, z, dx, dy, dz);
|
||||||
|
particle.setSprite(provider);
|
||||||
|
return particle;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.client.render.model;
|
package com.minelittlepony.unicopia.core.client.render;
|
||||||
|
|
||||||
public class DiskModel extends SphereModel {
|
public class DiskModel extends SphereModel {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.client.render.model;
|
package com.minelittlepony.unicopia.core.client.render;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.client.render.model;
|
package com.minelittlepony.unicopia.core.client.render;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
import net.minecraft.client.util.GlAllocationUtils;
|
import net.minecraft.client.util.GlAllocationUtils;
|
||||||
|
|
||||||
|
|
||||||
public class SphereModel {
|
public class SphereModel {
|
||||||
|
|
||||||
private int displayList;
|
private int displayList;
|
||||||
|
@ -52,7 +51,7 @@ public class SphereModel {
|
||||||
glRotate(rotY, 0, 1, 0);
|
glRotate(rotY, 0, 1, 0);
|
||||||
glRotate(rotZ, 0, 0, 1);
|
glRotate(rotZ, 0, 0, 1);
|
||||||
|
|
||||||
GlStateManager.scale(scale, scale, scale);
|
GlStateManager.scalef(scale, scale, scale);
|
||||||
|
|
||||||
GlStateManager.callList(displayList);
|
GlStateManager.callList(displayList);
|
||||||
|
|
||||||
|
@ -60,7 +59,7 @@ public class SphereModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bake() {
|
private void bake() {
|
||||||
displayList = GlAllocationUtils.generateDisplayLists(1);
|
displayList = GlAllocationUtils.genLists(1);
|
||||||
GlStateManager.newList(displayList, GL11.GL_COMPILE);
|
GlStateManager.newList(displayList, GL11.GL_COMPILE);
|
||||||
|
|
||||||
drawShape();
|
drawShape();
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.client.render.model;
|
package com.minelittlepony.unicopia.core.client.render;
|
||||||
|
|
||||||
import net.minecraft.client.model.Quad;
|
import net.minecraft.client.model.Quad;
|
||||||
import net.minecraft.client.model.Vertex;
|
import net.minecraft.client.model.Vertex;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.command;
|
package com.minelittlepony.unicopia.core.command;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ public class Commands {
|
||||||
public static void bootstrap() {
|
public static void bootstrap() {
|
||||||
CommandRegistry.INSTANCE.register(false, SpeciesCommand::register);
|
CommandRegistry.INSTANCE.register(false, SpeciesCommand::register);
|
||||||
CommandRegistry.INSTANCE.register(false, RacelistCommand::register);
|
CommandRegistry.INSTANCE.register(false, RacelistCommand::register);
|
||||||
CommandRegistry.INSTANCE.register(false, DisguiseCommand::register);
|
|
||||||
CommandRegistry.INSTANCE.register(false, GravityCommand::register);
|
CommandRegistry.INSTANCE.register(false, GravityCommand::register);
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.command;
|
package com.minelittlepony.unicopia.core.command;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.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;
|
|
@ -1,10 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.command;
|
package com.minelittlepony.unicopia.core.command;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
@ -1,9 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.command;
|
package com.minelittlepony.unicopia.core.command;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.command;
|
package com.minelittlepony.unicopia.core.command;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ducks;
|
package com.minelittlepony.unicopia.core.ducks;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.ItemEntityCapabilities;
|
import com.minelittlepony.unicopia.core.entity.ItemEntityCapabilities;
|
||||||
|
|
||||||
public interface IItemEntity extends IRaceContainerHolder<ItemEntityCapabilities> {
|
public interface IItemEntity extends IRaceContainerHolder<ItemEntityCapabilities> {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.ducks;
|
package com.minelittlepony.unicopia.core.ducks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.IEntity;
|
import com.minelittlepony.unicopia.core.entity.IEntity;
|
||||||
import com.minelittlepony.unicopia.magic.ICaster;
|
import com.minelittlepony.unicopia.core.magic.ICaster;
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.enchanting;
|
package com.minelittlepony.unicopia.core.enchanting;
|
||||||
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.enchanting;
|
package com.minelittlepony.unicopia.core.enchanting;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.network.ITransmittable;
|
import com.minelittlepony.unicopia.core.network.ITransmittable;
|
||||||
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,21 +25,6 @@ public interface IPageOwner extends ITransmittable {
|
||||||
sendCapabilities(true);
|
sendCapabilities(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean hasPageStateRelative(IPage start, PageState state, int direction) {
|
|
||||||
int pos = start.getIndex();
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (getPageState(Pages.instance().getByIndex(pos)) == state) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pos += direction;
|
|
||||||
|
|
||||||
} while (pos >= 0 && pos < Pages.instance().getTotalPages());
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
default PageState getPageState(IPage page) {
|
default PageState getPageState(IPage page) {
|
||||||
return getPageStates().getOrDefault(page.getName(), page.getDefaultState());
|
return getPageStates().getOrDefault(page.getName(), page.getDefaultState());
|
||||||
}
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.minelittlepony.unicopia.core.enchanting;
|
||||||
|
|
||||||
|
public interface IUnlockEvent {
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.enchanting;
|
package com.minelittlepony.unicopia.core.enchanting;
|
||||||
|
|
||||||
public enum PageState {
|
public enum PageState {
|
||||||
LOCKED,
|
LOCKED,
|
|
@ -1,9 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for controlling flight.
|
* Interface for controlling flight.
|
||||||
*/
|
*/
|
||||||
public interface IFlight {
|
public interface FlightControl {
|
||||||
/**
|
/**
|
||||||
* True is we're currently flying.
|
* True is we're currently flying.
|
||||||
*/
|
*/
|
||||||
|
@ -14,5 +14,4 @@ public interface IFlight {
|
||||||
float getFlightDuration();
|
float getFlightDuration();
|
||||||
|
|
||||||
boolean isExperienceCritical();
|
boolean isExperienceCritical();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.util.InbtSerialisable;
|
import com.minelittlepony.unicopia.core.util.InbtSerialisable;
|
||||||
|
|
||||||
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, IUpdatable {
|
public interface IEntity extends InbtSerialisable, Updatable {
|
||||||
Race getSpecies();
|
Race getSpecies();
|
||||||
|
|
||||||
void setSpecies(Race race);
|
void setSpecies(Race race);
|
||||||
|
@ -31,7 +31,9 @@ public interface IEntity extends InbtSerialisable, IUpdatable {
|
||||||
/**
|
/**
|
||||||
* Called at the beginning of an update cycle.
|
* Called at the beginning of an update cycle.
|
||||||
*/
|
*/
|
||||||
boolean beforeUpdate();
|
default boolean beforeUpdate() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any entities with magical abilities.
|
* Any entities with magical abilities.
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is for any entities that are categorised as inanimated,
|
* This interface is for any entities that are categorised as inanimated,
|
||||||
|
@ -9,6 +9,6 @@ import com.minelittlepony.unicopia.Race;
|
||||||
* These typically can't be interacted with by players unless under certain cirumstances.
|
* These typically can't be interacted with by players unless under certain cirumstances.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IInAnimate {
|
public interface InAnimate {
|
||||||
boolean canInteract(Race race);
|
boolean canInteract(Race race);
|
||||||
}
|
}
|
|
@ -1,16 +1,14 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.ducks.IItemEntity;
|
import com.minelittlepony.unicopia.core.ducks.IItemEntity;
|
||||||
import com.minelittlepony.unicopia.entity.IOwned;
|
|
||||||
import com.minelittlepony.unicopia.entity.IRaceContainer;
|
|
||||||
|
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
|
||||||
public class ItemEntityCapabilities implements IRaceContainer<ItemEntity>, IOwned<ItemEntity> {
|
public class ItemEntityCapabilities implements RaceContainer<ItemEntity>, Owned<ItemEntity> {
|
||||||
|
|
||||||
private Race race = Race.HUMAN;
|
private Race race = Race.HUMAN;
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.entity.IRaceContainer;
|
import com.minelittlepony.unicopia.core.magic.Affinity;
|
||||||
import com.minelittlepony.unicopia.magic.Affinity;
|
import com.minelittlepony.unicopia.core.magic.IAffine;
|
||||||
import com.minelittlepony.unicopia.magic.IAffine;
|
import com.minelittlepony.unicopia.core.magic.IAttachedEffect;
|
||||||
import com.minelittlepony.unicopia.magic.IAttachedEffect;
|
import com.minelittlepony.unicopia.core.magic.ICaster;
|
||||||
import com.minelittlepony.unicopia.magic.ICaster;
|
import com.minelittlepony.unicopia.core.magic.IMagicEffect;
|
||||||
import com.minelittlepony.unicopia.magic.IMagicEffect;
|
import com.minelittlepony.unicopia.core.magic.spell.SpellRegistry;
|
||||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
import com.minelittlepony.unicopia.core.network.EffectSync;
|
||||||
import com.minelittlepony.unicopia.network.EffectSync;
|
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.data.DataTracker;
|
import net.minecraft.entity.data.DataTracker;
|
||||||
|
@ -16,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 IRaceContainer<LivingEntity>, ICaster<LivingEntity> {
|
public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, ICaster<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);
|
||||||
|
|
||||||
|
@ -56,11 +55,6 @@ public class LivingEntityCapabilities implements IRaceContainer<LivingEntity>, I
|
||||||
return effectDelegate.has();
|
return effectDelegate.has();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeUpdate() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
if (hasEffect()) {
|
if (hasEffect()) {
|
|
@ -1,11 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for things that can be owned.
|
* Interface for things that can be owned.
|
||||||
*
|
*
|
||||||
* @param <E> The type of object that owns us.
|
* @param <E> The type of object that owns us.
|
||||||
*/
|
*/
|
||||||
public interface IOwned<E> {
|
public interface Owned<E> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the owner of this object.
|
* Updates the owner of this object.
|
||||||
|
@ -19,7 +19,7 @@ public interface IOwned<E> {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static <T> IOwned<T> cast(Object o) {
|
static <T> Owned<T> cast(Object o) {
|
||||||
return (IOwned<T>)o;
|
return (Owned<T>)o;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ import net.minecraft.entity.Entity;
|
||||||
*
|
*
|
||||||
* @param <T> The type of owner
|
* @param <T> The type of owner
|
||||||
*/
|
*/
|
||||||
public interface IRaceContainer<T extends Entity> extends IEntity {
|
public interface RaceContainer<T extends Entity> extends IEntity {
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
public interface ITrap {
|
public interface Trap {
|
||||||
boolean attemptDismount(Entity passenger);
|
boolean attemptDismount(Entity passenger);
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.core.entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for objects that receive regular updates.
|
* Interface for objects that receive regular updates.
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface IUpdatable {
|
public interface Updatable {
|
||||||
/**
|
/**
|
||||||
* Called to update the internal logic.
|
* Called to update the internal logic.
|
||||||
*/
|
*/
|
|
@ -1,20 +1,20 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.jumpingcastle.api.Target;
|
||||||
import com.minelittlepony.unicopia.ability.IAbilityReceiver;
|
import com.minelittlepony.unicopia.core.UnicopiaCore;
|
||||||
import com.minelittlepony.unicopia.ability.IData;
|
import com.minelittlepony.unicopia.core.ability.IAbilityReceiver;
|
||||||
import com.minelittlepony.unicopia.ability.IPower;
|
import com.minelittlepony.unicopia.core.ability.IPower;
|
||||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
import com.minelittlepony.unicopia.core.ability.PowersRegistry;
|
||||||
import com.minelittlepony.unicopia.entity.IUpdatable;
|
import com.minelittlepony.unicopia.core.entity.Updatable;
|
||||||
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
|
import com.minelittlepony.unicopia.core.network.MsgPlayerAbility;
|
||||||
import com.minelittlepony.util.InbtSerialisable;
|
import com.minelittlepony.unicopia.core.util.InbtSerialisable;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
class AbilityDelegate implements IAbilityReceiver, IUpdatable, InbtSerialisable {
|
class AbilityDelegate implements IAbilityReceiver, Updatable, InbtSerialisable {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
|
||||||
|
@ -156,10 +156,10 @@ class AbilityDelegate implements IAbilityReceiver, IUpdatable, InbtSerialisable
|
||||||
* 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 IPower<?> ability) {
|
||||||
IData data = ability.tryActivate(player);
|
IPower.IData data = ability.tryActivate(player);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
Unicopia.getConnection().send(new MsgPlayerAbility(player.getOwner(), ability, data), Target.SERVER);
|
UnicopiaCore.getConnection().send(new MsgPlayerAbility(player.getOwner(), ability, data), Target.SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data != null;
|
return data != null;
|
|
@ -1,29 +1,22 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.UParticles;
|
import com.minelittlepony.unicopia.core.UParticles;
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.core.USounds;
|
||||||
import com.minelittlepony.unicopia.ability.IFlyingPredicate;
|
import com.minelittlepony.unicopia.core.ability.IFlyingPredicate;
|
||||||
import com.minelittlepony.unicopia.ability.IHeightPredicate;
|
import com.minelittlepony.unicopia.core.ability.IHeightPredicate;
|
||||||
import com.minelittlepony.unicopia.entity.IFlight;
|
import com.minelittlepony.unicopia.core.entity.FlightControl;
|
||||||
import com.minelittlepony.unicopia.entity.IGravity;
|
import com.minelittlepony.unicopia.core.entity.Updatable;
|
||||||
import com.minelittlepony.unicopia.entity.IUpdatable;
|
import com.minelittlepony.unicopia.core.magic.IMagicEffect;
|
||||||
import com.minelittlepony.unicopia.magic.IMagicEffect;
|
import com.minelittlepony.unicopia.core.mixin.MixinEntity;
|
||||||
import com.minelittlepony.unicopia.mixin.MixinEntity;
|
import com.minelittlepony.unicopia.core.util.InbtSerialisable;
|
||||||
import com.minelittlepony.util.InbtSerialisable;
|
import com.minelittlepony.unicopia.core.util.MutableVector;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
@ -31,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;
|
||||||
|
|
||||||
class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable, IFlyingPredicate, IHeightPredicate {
|
public class GravityDelegate implements Updatable, FlightControl, InbtSerialisable, IFlyingPredicate, IHeightPredicate {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
|
||||||
|
@ -112,12 +105,10 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
||||||
return player.getOwner().getHeight();
|
return player.getOwner().getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGraviationConstant(float constant) {
|
public void setGraviationConstant(float constant) {
|
||||||
gravity = constant;
|
gravity = constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getGravitationConstant() {
|
public float getGravitationConstant() {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +122,7 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
PlayerEntity entity = player.getOwner();
|
PlayerEntity entity = player.getOwner();
|
||||||
|
|
||||||
Vec3d velocity = entity.getVelocity();
|
MutableVector velocity = new MutableVector(entity.getVelocity());
|
||||||
|
|
||||||
if (isExperienceCritical() && player.isClient()) {
|
if (isExperienceCritical() && player.isClient()) {
|
||||||
Random rnd = player.getWorld().random;
|
Random rnd = player.getWorld().random;
|
||||||
|
@ -143,7 +134,7 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
||||||
rnd.nextGaussian() * entity.getWidth()
|
rnd.nextGaussian() * entity.getWidth()
|
||||||
);
|
);
|
||||||
|
|
||||||
ParticleTypeRegistry.getTnstance().getSpawner().spawnParticle(entity.world, UParticles.UNICORN_MAGIC, pos, velocity);
|
player.addParticle(UParticles.UNICORN_MAGIC, pos, velocity.toImmutable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,11 +176,12 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
||||||
|
|
||||||
|
|
||||||
((MixinEntity)entity).setSize(entity.getWidth(), bodyHeight);
|
((MixinEntity)entity).setSize(entity.getWidth(), bodyHeight);
|
||||||
entity.eyeHeight = eyeHeight;
|
// TODO: Change eye height
|
||||||
|
//entity.eyeHeight = eyeHeight;
|
||||||
|
|
||||||
if (gravity < 0) {
|
if (gravity < 0) {
|
||||||
if (entity.isSneaking()) {
|
if (entity.isSneaking()) {
|
||||||
entity.eyeHeight += 0.2F;
|
//entity.eyeHeight += 0.2F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,14 +266,14 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
||||||
lastTickPosX = entity.x;
|
lastTickPosX = entity.x;
|
||||||
lastTickPosZ = entity.z;
|
lastTickPosZ = entity.z;
|
||||||
|
|
||||||
entity.setVelocity(velocity);
|
entity.setVelocity(velocity.toImmutable());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEvent getWingSound() {
|
public SoundEvent getWingSound() {
|
||||||
return player.getSpecies() == Race.CHANGELING ? USounds.CHANGELING_BUZZ : USounds.WING_FLAP;
|
return player.getSpecies() == Race.CHANGELING ? USounds.CHANGELING_BUZZ : USounds.WING_FLAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveFlying(Entity player, Vec3d velocity) {
|
protected void moveFlying(Entity player, MutableVector velocity) {
|
||||||
|
|
||||||
float forward = 0.000015F * flightExperience * (float)Math.sqrt(getHorizontalMotion(player));
|
float forward = 0.000015F * flightExperience * (float)Math.sqrt(getHorizontalMotion(player));
|
||||||
int factor = gravity < 0 ? -1 : 1;
|
int factor = gravity < 0 ? -1 : 1;
|
||||||
|
@ -319,7 +311,7 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forward >= 1) {
|
if (forward >= 1) {
|
||||||
player.world.playSound(null, player.getPos(), USounds.WIND_RUSH, SoundCategory.AMBIENT, 3, 1);
|
player.world.playSound(null, player.getBlockPos(), USounds.WIND_RUSH, SoundCategory.AMBIENT, 3, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forward > 4) {
|
if (forward > 4) {
|
|
@ -1,27 +1,20 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.core.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.ability.IAbilityReceiver;
|
import com.minelittlepony.unicopia.core.ability.IAbilityReceiver;
|
||||||
import com.minelittlepony.unicopia.enchanting.IPageOwner;
|
import com.minelittlepony.unicopia.core.entity.FlightControl;
|
||||||
import com.minelittlepony.unicopia.entity.IFlight;
|
import com.minelittlepony.unicopia.core.entity.RaceContainer;
|
||||||
import com.minelittlepony.unicopia.entity.IFood;
|
import com.minelittlepony.unicopia.core.magic.ICaster;
|
||||||
import com.minelittlepony.unicopia.entity.IGravity;
|
import com.minelittlepony.unicopia.core.magic.IHeldEffect;
|
||||||
import com.minelittlepony.unicopia.entity.IInventory;
|
import com.minelittlepony.unicopia.core.network.ITransmittable;
|
||||||
import com.minelittlepony.unicopia.entity.IRaceContainer;
|
import com.minelittlepony.util.IInterpolator;
|
||||||
import com.minelittlepony.unicopia.magic.ICaster;
|
|
||||||
import com.minelittlepony.unicopia.magic.IHeldEffect;
|
|
||||||
import com.minelittlepony.unicopia.network.ITransmittable;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.Unit;
|
import net.minecraft.util.Unit;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
@ -30,7 +23,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>, IRaceContainer<PlayerEntity>, ITransmittable, IPageOwner {
|
public interface IPlayer extends ICaster<PlayerEntity>, RaceContainer<PlayerEntity>, ITransmittable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -40,22 +33,22 @@ public interface IPlayer extends ICaster<PlayerEntity>, IRaceContainer<PlayerEnt
|
||||||
/**
|
/**
|
||||||
* Gets the gravity delegate responsible for updating flight states
|
* Gets the gravity delegate responsible for updating flight states
|
||||||
*/
|
*/
|
||||||
IGravity getGravity();
|
GravityDelegate getGravity();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the flight delegate.
|
* Gets the flight delegate.
|
||||||
*/
|
*/
|
||||||
IFlight getFlight();
|
FlightControl getFlight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player's viewport.
|
* Gets the player's viewport.
|
||||||
*/
|
*/
|
||||||
ICamera getCamera();
|
PlayerCamera getCamera();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the inventory delegate for this player.
|
* Gets the inventory delegate for this player.
|
||||||
*/
|
*/
|
||||||
IInventory getInventory();
|
PlayerInventory getInventory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an animation interpolator.
|
* Gets an animation interpolator.
|
|
@ -1,11 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.inventory.gui.InventoryOfHolding;
|
import com.minelittlepony.unicopia.core.mixin.IWalker;
|
||||||
import com.minelittlepony.unicopia.mixin.IWalker;
|
import com.minelittlepony.unicopia.core.util.HeavyInventoryUtils;
|
||||||
|
|
||||||
import net.minecraft.entity.attribute.EntityAttribute;
|
import net.minecraft.entity.attribute.EntityAttribute;
|
||||||
import net.minecraft.entity.attribute.EntityAttributeInstance;
|
import net.minecraft.entity.attribute.EntityAttributeInstance;
|
||||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||||
|
@ -25,7 +24,7 @@ public class PlayerAttributes {
|
||||||
private double loadStrength = 0;
|
private double loadStrength = 0;
|
||||||
|
|
||||||
public void applyAttributes(PlayerEntity entity, Race race) {
|
public void applyAttributes(PlayerEntity entity, Race race) {
|
||||||
loadStrength = InventoryOfHolding.getContentsTotalWorth(entity.inventory, false);
|
loadStrength = HeavyInventoryUtils.getContentsTotalWorth(entity.inventory, false);
|
||||||
|
|
||||||
((IWalker)entity.abilities).setWalkSpeed(0.1F - (float)(loadStrength / 100000));
|
((IWalker)entity.abilities).setWalkSpeed(0.1F - (float)(loadStrength / 100000));
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
class PlayerCamera extends MotionCompositor implements ICamera {
|
import com.minelittlepony.util.MotionCompositor;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
public class PlayerCamera extends MotionCompositor {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
|
||||||
|
@ -10,13 +14,14 @@ class PlayerCamera extends MotionCompositor implements ICamera {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float calculateRoll() {
|
public float calculateRoll() {
|
||||||
|
|
||||||
double roll = baseRoll;
|
double roll = baseRoll;
|
||||||
|
|
||||||
if (player.getFlight().isFlying()) {
|
if (player.getFlight().isFlying()) {
|
||||||
roll -= super.calculateRoll(player.getOwner(), player.getOwner().getVelocity().motionX, player.getOwner().motionY, player.getOwner().motionZ);
|
Vec3d vel = player.getOwner().getVelocity();
|
||||||
|
|
||||||
|
roll -= super.calculateRoll(player.getOwner(), vel.x, vel.y, vel.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getGravity().getGravitationConstant() < 0) {
|
if (player.getGravity().getGravitationConstant() < 0) {
|
||||||
|
@ -31,18 +36,15 @@ class PlayerCamera extends MotionCompositor implements ICamera {
|
||||||
return (float)roll;
|
return (float)roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float calculatePitch(float pitch) {
|
public float calculatePitch(float pitch) {
|
||||||
return pitch + getEnergyAddition();
|
return pitch + getEnergyAddition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float calculateYaw(float yaw) {
|
public float calculateYaw(float yaw) {
|
||||||
return yaw + getEnergyAddition();
|
return yaw + getEnergyAddition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public double calculateFieldOfView(double fov) {
|
||||||
public float calculateFieldOfView(float fov) {
|
|
||||||
fov += player.getExertion() / 5;
|
fov += player.getExertion() / 5;
|
||||||
fov += getEnergyAddition();
|
fov += getEnergyAddition();
|
||||||
|
|
||||||
|
@ -65,12 +67,10 @@ class PlayerCamera extends MotionCompositor implements ICamera {
|
||||||
return energyAddition;
|
return energyAddition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getBaseRoll() {
|
public double getBaseRoll() {
|
||||||
return baseRoll;
|
return baseRoll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBaseRoll(double roll) {
|
public void setBaseRoll(double roll) {
|
||||||
baseRoll = roll;
|
baseRoll = roll;
|
||||||
}
|
}
|
|
@ -1,33 +1,29 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.minelittlepony.unicopia.core.Race;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.core.UEffects;
|
||||||
import com.minelittlepony.unicopia.UEffects;
|
import com.minelittlepony.unicopia.core.UTags;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.core.UnicopiaCore;
|
||||||
import com.minelittlepony.unicopia.ability.IAbilityReceiver;
|
import com.minelittlepony.unicopia.core.ability.IAbilityReceiver;
|
||||||
import com.minelittlepony.unicopia.enchanting.PageState;
|
import com.minelittlepony.unicopia.core.enchanting.IPageOwner;
|
||||||
import com.minelittlepony.unicopia.entity.CuccoonEntity;
|
import com.minelittlepony.unicopia.core.enchanting.PageState;
|
||||||
import com.minelittlepony.unicopia.entity.IFlight;
|
import com.minelittlepony.unicopia.core.entity.FlightControl;
|
||||||
import com.minelittlepony.unicopia.entity.IFood;
|
import com.minelittlepony.unicopia.core.entity.Trap;
|
||||||
import com.minelittlepony.unicopia.entity.IGravity;
|
import com.minelittlepony.unicopia.core.magic.Affinity;
|
||||||
import com.minelittlepony.unicopia.entity.IInventory;
|
import com.minelittlepony.unicopia.core.magic.IAttachedEffect;
|
||||||
import com.minelittlepony.unicopia.entity.ITrap;
|
import com.minelittlepony.unicopia.core.magic.IHeldEffect;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.core.magic.IMagicEffect;
|
||||||
import com.minelittlepony.unicopia.magic.Affinity;
|
import com.minelittlepony.unicopia.core.magic.IMagicalItem;
|
||||||
import com.minelittlepony.unicopia.magic.IAttachedEffect;
|
import com.minelittlepony.unicopia.core.magic.spell.SpellRegistry;
|
||||||
import com.minelittlepony.unicopia.magic.IHeldEffect;
|
import com.minelittlepony.unicopia.core.network.EffectSync;
|
||||||
import com.minelittlepony.unicopia.magic.IMagicEffect;
|
import com.minelittlepony.unicopia.core.network.MsgPlayerCapabilities;
|
||||||
import com.minelittlepony.unicopia.magic.items.ICastable;
|
import com.minelittlepony.util.BasicEasingInterpolator;
|
||||||
import com.minelittlepony.unicopia.magic.spells.SpellDisguise;
|
import com.minelittlepony.util.IInterpolator;
|
||||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
|
||||||
import com.minelittlepony.unicopia.network.EffectSync;
|
|
||||||
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
|
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
|
||||||
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
||||||
|
@ -44,9 +40,7 @@ import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.item.FoodComponent;
|
import net.minecraft.item.FoodComponent;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.Packet;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.stat.Stats;
|
|
||||||
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.Identifier;
|
||||||
|
@ -55,7 +49,7 @@ 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 PlayerCapabilities implements IPlayer, IPageOwner {
|
||||||
|
|
||||||
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);
|
||||||
|
@ -63,7 +57,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
private static final TrackedData<CompoundTag> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
|
private static final TrackedData<CompoundTag> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
|
||||||
private static final TrackedData<CompoundTag> HELD_EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
|
private static final TrackedData<CompoundTag> HELD_EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
|
||||||
|
|
||||||
private final Map<Identifier, PageState> pageStates = new HashMap<>();
|
private final PlayerPageStats pageStates = new PlayerPageStats();
|
||||||
|
|
||||||
private final AbilityDelegate powers = new AbilityDelegate(this);
|
private final AbilityDelegate powers = new AbilityDelegate(this);
|
||||||
|
|
||||||
|
@ -181,9 +175,9 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
|
|
||||||
if (!getWorld().isClient()) {
|
if (!getWorld().isClient()) {
|
||||||
if (full) {
|
if (full) {
|
||||||
Unicopia.getConnection().broadcast(new MsgPlayerCapabilities(this));
|
UnicopiaCore.getConnection().broadcast(new MsgPlayerCapabilities(this));
|
||||||
} else {
|
} else {
|
||||||
Unicopia.getConnection().broadcast(new MsgPlayerCapabilities(getSpecies(), getOwner()));
|
UnicopiaCore.getConnection().broadcast(new MsgPlayerCapabilities(getSpecies(), getOwner()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,17 +195,17 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IGravity getGravity() {
|
public GravityDelegate getGravity() {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IFlight getFlight() {
|
public FlightControl getFlight() {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICamera getCamera() {
|
public PlayerCamera getCamera() {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,14 +215,14 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeUpdate() {
|
public boolean beforeUpdate() {
|
||||||
if (entity.world.isClient()) {
|
if (entity.world.isClient()) {
|
||||||
if (entity.hasVehicle() && entity.isSneaking()) {
|
if (entity.hasVehicle() && entity.isSneaking()) {
|
||||||
|
|
||||||
Entity ridee = entity.getVehicle();
|
Entity ridee = entity.getVehicle();
|
||||||
|
|
||||||
if (ridee instanceof ITrap) {
|
if (ridee instanceof Trap) {
|
||||||
if (((ITrap)ridee).attemptDismount(entity)) {
|
if (((Trap)ridee).attemptDismount(entity)) {
|
||||||
entity.stopRiding();
|
entity.stopRiding();
|
||||||
} else {
|
} else {
|
||||||
entity.setSneaking(false);
|
entity.setSneaking(false);
|
||||||
|
@ -245,6 +239,8 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
|
|
||||||
powers.onUpdate();
|
powers.onUpdate();
|
||||||
inventory.onUpdate();
|
inventory.onUpdate();
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -270,7 +266,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
IHeldEffect effect = getHeldEffect(stack);
|
IHeldEffect effect = getHeldEffect(stack);
|
||||||
|
|
||||||
if (effect != null) {
|
if (effect != null) {
|
||||||
Affinity affinity = stack.getItem() instanceof ICastable ? ((ICastable)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
|
Affinity affinity = stack.getItem() instanceof IMagicalItem ? ((IMagicalItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
|
||||||
|
|
||||||
effect.updateInHand(this, affinity);
|
effect.updateInHand(this, affinity);
|
||||||
}
|
}
|
||||||
|
@ -297,8 +293,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
public void onJump() {
|
public void onJump() {
|
||||||
if (gravity.getGravitationConstant() < 0) {
|
if (gravity.getGravitationConstant() < 0) {
|
||||||
Vec3d velocity = entity.getVelocity();
|
Vec3d velocity = entity.getVelocity();
|
||||||
velocity.y *= -1;
|
entity.setVelocity(velocity.x, velocity.y * -1, velocity.z);
|
||||||
entity.setVelocity(velocity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,10 +301,8 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
public boolean onProjectileImpact(ProjectileEntity projectile) {
|
public boolean onProjectileImpact(ProjectileEntity projectile) {
|
||||||
if (hasEffect()) {
|
if (hasEffect()) {
|
||||||
IMagicEffect effect = getEffect();
|
IMagicEffect effect = getEffect();
|
||||||
if (effect instanceof SpellDisguise && !effect.isDead()) {
|
if (!effect.isDead() && effect.handleProjectileImpact(projectile)) {
|
||||||
if (((SpellDisguise)effect).getDisguise() == projectile) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,14 +340,14 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
@Override
|
@Override
|
||||||
public Either<SleepFailureReason, Unit> trySleep(BlockPos pos) {
|
public Either<SleepFailureReason, Unit> trySleep(BlockPos pos) {
|
||||||
|
|
||||||
if (getInventory().isWearing(UItems.alicorn_amulet)) {
|
if (getInventory().matches(UTags.CURSED_ARTEFACTS)) {
|
||||||
if (!isClient()) {
|
if (!isClient()) {
|
||||||
entity.addChatMessage(new TranslatableText("tile.bed.youAreAMonster"), true);
|
entity.addChatMessage(new TranslatableText("tile.bed.youAreAMonster"), true);
|
||||||
}
|
}
|
||||||
return Either.left(SleepFailureReason.OTHER_PROBLEM);
|
return Either.left(SleepFailureReason.OTHER_PROBLEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findAllSpellsInRange(10).anyMatch(c -> c instanceof IPlayer && ((IPlayer)c).getInventory().isWearing(UItems.alicorn_amulet))) {
|
if (findAllSpellsInRange(10).anyMatch(c -> c instanceof IPlayer && ((IPlayer)c).getInventory().matches(UTags.CURSED_ARTEFACTS))) {
|
||||||
return Either.left(SleepFailureReason.NOT_SAFE);
|
return Either.left(SleepFailureReason.NOT_SAFE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +355,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IInventory getInventory() {
|
public PlayerInventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,16 +372,16 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
|
|
||||||
player.getHungerManager().add(-health/2, -saturation/2);
|
player.getHungerManager().add(-health/2, -saturation/2);
|
||||||
|
|
||||||
player.addStatusEffectInstance(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true));
|
player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true));
|
||||||
} else {
|
} else {
|
||||||
player.addStatusEffectInstance(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true));
|
player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.world.getDifficulty() != Difficulty.PEACEFUL && player.world.random.nextInt(20) == 0) {
|
if (player.world.getDifficulty() != Difficulty.PEACEFUL && player.world.random.nextInt(20) == 0) {
|
||||||
player.addStatusEffectInstance(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true));
|
player.addPotionEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
player.addStatusEffectInstance(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true));
|
player.addPotionEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,21 +398,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));
|
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pageStates.isEmpty()) {
|
pageStates.toNBT(compound);
|
||||||
CompoundTag pages = new CompoundTag();
|
|
||||||
boolean written = false;
|
|
||||||
|
|
||||||
for (Map.Entry<Identifier, PageState> entry : pageStates.entrySet()) {
|
|
||||||
if (entry.getValue() != PageState.LOCKED) {
|
|
||||||
pages.putString(entry.getKey().toString(), entry.getValue().name());
|
|
||||||
written = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (written) {
|
|
||||||
compound.put("pageStates", pages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -433,18 +412,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
|
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
|
||||||
}
|
}
|
||||||
|
|
||||||
pageStates.clear();
|
pageStates.fromNBT(compound);
|
||||||
if (compound.containsKey("pageStates")) {
|
|
||||||
CompoundTag pages = compound.getCompound("pageStates");
|
|
||||||
|
|
||||||
pages.getKeys().forEach(key -> {
|
|
||||||
PageState state = PageState.of(pages.getString(key));
|
|
||||||
|
|
||||||
if (state != PageState.LOCKED) {
|
|
||||||
pageStates.put(new Identifier(key), state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -473,7 +441,6 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOwner(PlayerEntity owner) {
|
public void setOwner(PlayerEntity owner) {
|
||||||
entity = owner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -492,6 +459,7 @@ public class PlayerCapabilities implements IPlayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Identifier, PageState> getPageStates() {
|
public Map<Identifier, PageState> getPageStates() {
|
||||||
return pageStates;
|
return pageStates.getPageStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,23 +1,23 @@
|
||||||
package com.minelittlepony.unicopia.entity.capabilities;
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.minelittlepony.unicopia.entity.IInventory;
|
import com.minelittlepony.unicopia.core.entity.Updatable;
|
||||||
import com.minelittlepony.unicopia.entity.IUpdatable;
|
import com.minelittlepony.unicopia.core.magic.IDependable;
|
||||||
import com.minelittlepony.unicopia.magic.items.IDependable;
|
import com.minelittlepony.unicopia.core.magic.IMagicalItem;
|
||||||
import com.minelittlepony.unicopia.magic.items.IMagicalItem;
|
import com.minelittlepony.unicopia.core.util.InbtSerialisable;
|
||||||
import com.minelittlepony.util.InbtSerialisable;
|
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
|
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 IInventory, IUpdatable, InbtSerialisable {
|
public class PlayerInventory implements Updatable, InbtSerialisable {
|
||||||
private final Map<IDependable, Entry> dependencies = Maps.newHashMap();
|
private final Map<IDependable, Entry> dependencies = Maps.newHashMap();
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
@ -26,7 +26,12 @@ public class PlayerInventory implements IInventory, IUpdatable, InbtSerialisable
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* Reinforces a players dependency on a certain magical artifact.
|
||||||
|
* A dependency will slowly drop over time if not reinforced
|
||||||
|
*
|
||||||
|
* Bad things might happen when it's removed.
|
||||||
|
*/
|
||||||
public synchronized void enforceDependency(IDependable item) {
|
public synchronized void enforceDependency(IDependable item) {
|
||||||
if (dependencies.containsKey(item)) {
|
if (dependencies.containsKey(item)) {
|
||||||
dependencies.get(item).reinforce();
|
dependencies.get(item).reinforce();
|
||||||
|
@ -35,7 +40,9 @@ public class PlayerInventory implements IInventory, IUpdatable, InbtSerialisable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* Returns how long the player has been wearing the given item.
|
||||||
|
*/
|
||||||
public synchronized int getTicksAttached(IDependable item) {
|
public synchronized int getTicksAttached(IDependable item) {
|
||||||
if (dependencies.containsKey(item)) {
|
if (dependencies.containsKey(item)) {
|
||||||
return dependencies.get(item).ticksAttached;
|
return dependencies.get(item).ticksAttached;
|
||||||
|
@ -44,7 +51,11 @@ public class PlayerInventory implements IInventory, IUpdatable, InbtSerialisable
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* Returns how dependent the player has become on the given item.
|
||||||
|
*
|
||||||
|
* Zero means not dependent at all / not wearing.
|
||||||
|
*/
|
||||||
public synchronized float getNeedfulness(IDependable item) {
|
public synchronized float getNeedfulness(IDependable item) {
|
||||||
if (dependencies.containsKey(item)) {
|
if (dependencies.containsKey(item)) {
|
||||||
return dependencies.get(item).needfulness;
|
return dependencies.get(item).needfulness;
|
||||||
|
@ -71,7 +82,9 @@ public class PlayerInventory implements IInventory, IUpdatable, InbtSerialisable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* Checks if the player is wearing the specified magical artifact.
|
||||||
|
*/
|
||||||
public boolean isWearing(IMagicalItem item) {
|
public boolean isWearing(IMagicalItem 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) {
|
||||||
|
@ -82,6 +95,16 @@ public class PlayerInventory implements IInventory, IUpdatable, InbtSerialisable
|
||||||
return item instanceof Item;
|
return item instanceof Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean matches(Tag<Item> tag) {
|
||||||
|
for (ItemStack i : player.getOwner().getArmorItems()) {
|
||||||
|
if (!i.isEmpty() && i.getItem().isIn(tag)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(CompoundTag compound) {
|
||||||
ListTag items = new ListTag();
|
ListTag items = new ListTag();
|
||||||
|
@ -108,7 +131,7 @@ public class PlayerInventory implements IInventory, IUpdatable, InbtSerialisable
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class Entry implements IUpdatable, InbtSerialisable {
|
class Entry implements Updatable, InbtSerialisable {
|
||||||
int ticksAttached = 0;
|
int ticksAttached = 0;
|
||||||
|
|
||||||
float needfulness = 1;
|
float needfulness = 1;
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.minelittlepony.unicopia.core.entity.player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.core.enchanting.IPageOwner;
|
||||||
|
import com.minelittlepony.unicopia.core.enchanting.PageState;
|
||||||
|
import com.minelittlepony.unicopia.core.util.InbtSerialisable;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class PlayerPageStats implements InbtSerialisable, IPageOwner {
|
||||||
|
private final Map<Identifier, PageState> pageStates = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Identifier, PageState> getPageStates() {
|
||||||
|
return pageStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendCapabilities(boolean full) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toNBT(CompoundTag compound) {
|
||||||
|
if (!pageStates.isEmpty()) {
|
||||||
|
CompoundTag pages = new CompoundTag();
|
||||||
|
boolean written = false;
|
||||||
|
|
||||||
|
for (Map.Entry<Identifier, PageState> entry : pageStates.entrySet()) {
|
||||||
|
if (entry.getValue() != PageState.LOCKED) {
|
||||||
|
pages.putString(entry.getKey().toString(), entry.getValue().name());
|
||||||
|
written = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (written) {
|
||||||
|
compound.put("pageStates", pages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromNBT(CompoundTag compound) {
|
||||||
|
pageStates.clear();
|
||||||
|
if (compound.containsKey("pageStates")) {
|
||||||
|
CompoundTag pages = compound.getCompound("pageStates");
|
||||||
|
|
||||||
|
pages.getKeys().forEach(key -> {
|
||||||
|
PageState state = PageState.of(pages.getString(key));
|
||||||
|
|
||||||
|
if (state != PageState.LOCKED) {
|
||||||
|
pageStates.put(new Identifier(key), state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic.spells;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.magic.ICaster;
|
|
||||||
import com.minelittlepony.unicopia.magic.IMagicEffect;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic.spells;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type of action to perform after a spell has completed its handling.
|
* A type of action to perform after a spell has completed its handling.
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
@ -6,11 +6,11 @@ import java.util.stream.Stream;
|
||||||
import javax.annotation.Nullable;
|
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.core.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.SpeciesList;
|
import com.minelittlepony.unicopia.core.SpeciesList;
|
||||||
import com.minelittlepony.unicopia.ducks.IRaceContainerHolder;
|
import com.minelittlepony.unicopia.core.ducks.IRaceContainerHolder;
|
||||||
import com.minelittlepony.unicopia.entity.IMagicals;
|
import com.minelittlepony.unicopia.core.entity.IMagicals;
|
||||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
import com.minelittlepony.unicopia.core.magic.spell.SpellRegistry;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
|
@ -1,11 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.magic.spells;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.magic.Affinity;
|
|
||||||
import com.minelittlepony.unicopia.magic.ICaster;
|
|
||||||
import com.minelittlepony.unicopia.magic.IMagicEffect;
|
|
||||||
|
|
||||||
public class GenericSpell extends AbstractSpell {
|
public class GenericSpell extends AbstractSpell {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for things that have an affine alignment.
|
* Interface for things that have an affine alignment.
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
public interface IAttachedEffect extends IMagicEffect {
|
public interface IAttachedEffect extends IMagicEffect {
|
||||||
/**
|
/**
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -6,8 +6,9 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.IOwned;
|
import com.minelittlepony.unicopia.core.entity.Owned;
|
||||||
import com.minelittlepony.util.VecHelper;
|
import com.minelittlepony.unicopia.core.util.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
@ -19,7 +20,7 @@ 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 IOwned<E>, ILevelled, IAffine, IMagicals, IParticleSource {
|
public interface ICaster<E extends LivingEntity> extends Owned<E>, ILevelled, IAffine, IMagicals, IParticleSource {
|
||||||
|
|
||||||
void setEffect(@Nullable IMagicEffect effect);
|
void setEffect(@Nullable IMagicEffect effect);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
|
public interface IDependable extends IMagicalItem {
|
||||||
|
void onRemoved(IPlayer player, float needfulness);
|
||||||
|
}
|
|
@ -1,10 +1,8 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.magic.spells.CastResult;
|
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPointer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Position;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -20,5 +18,5 @@ public interface IDispenceable extends IMagicEffect {
|
||||||
* @param affinity The affinity of the casting artifact
|
* @param affinity The affinity of the casting artifact
|
||||||
* @return an ActionResult for the type of action to perform.
|
* @return an ActionResult for the type of action to perform.
|
||||||
*/
|
*/
|
||||||
CastResult onDispenced(BlockPos pos, Direction facing, Position source, Affinity affinity);
|
CastResult onDispenced(BlockPos pos, Direction facing, BlockPointer source, Affinity affinity);
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic.items;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.DispenserBlock;
|
import net.minecraft.block.DispenserBlock;
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
import com.minelittlepony.unicopia.core.entity.player.IPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object with levelling capabilities.
|
* Object with levelling capabilities.
|
|
@ -1,7 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
import com.minelittlepony.unicopia.core.magic.spell.SpellRegistry;
|
||||||
import com.minelittlepony.util.InbtSerialisable;
|
import com.minelittlepony.unicopia.core.util.InbtSerialisable;
|
||||||
|
|
||||||
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for a magic spells
|
* Interface for a magic spells
|
||||||
|
@ -63,6 +65,10 @@ public interface IMagicEffect extends InbtSerialisable, IAffine {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean handleProjectileImpact(ProjectileEntity projectile) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called every tick when attached to an entity.
|
* Called every tick when attached to an entity.
|
||||||
* Called on both sides.
|
* Called on both sides.
|
|
@ -1,7 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic.items;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.magic.Affinity;
|
|
||||||
import com.minelittlepony.unicopia.magic.IAffine;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
|
public interface IMagicals {
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.minelittlepony.util.shape.IShape;
|
import com.minelittlepony.unicopia.core.util.shape.IShape;
|
||||||
|
|
||||||
import net.minecraft.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic effects that can be suppressed by other nearby effects.
|
* Magic effects that can be suppressed by other nearby effects.
|
|
@ -1,9 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.magic;
|
package com.minelittlepony.unicopia.core.magic;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.magic.spells.CastResult;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue