1.15.2 -> 1.16

This commit is contained in:
Sollace 2020-06-26 11:44:47 +02:00
parent 85df9737e7
commit 00f677c157
292 changed files with 1952 additions and 2227 deletions

View file

@ -1,6 +1,6 @@
plugins {
id 'java-library'
id 'fabric-loom' version '0.2.6-SNAPSHOT'
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'maven-publish'
}

View file

@ -2,21 +2,21 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.15.2
yarn_mappings=1.15.2+build.7:v2
loader_version=0.7.6+build.180
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16-rc1
yarn_mappings=1.16-rc1+build.4:v2
loader_version=0.8.8+build.202
fabric_version=0.12.5+build.367-1.16
# Mod Properties
group=com.minelittlepony
displayname=Unicopia
authors=Sollace
description=Magical Abilities for Mine Little Pony!
version=0.3.1
version=0.4
release=SNAPSHOT
# Dependencies
fabric_version=0.4.29+
modmenu_version=1.8.+
minelp_version=4.0.7-1.15.2
kirin_version=1.5.2-1.15.2
modmenu_version=1.12.+
minelp_version=4.1-1.16-rc1-1.16
kirin_version=1.6.4-1.16-rc1-1.16

View file

@ -1,57 +0,0 @@
package com.minelittlepony.model.anim;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.minelittlepony.util.chron.ChronicCache;
import com.minelittlepony.util.chron.Touchable;
//#MineLittlePony#
public class BasicEasingInterpolator extends Touchable<BasicEasingInterpolator> implements IInterpolator {
private static ChronicCache<UUID, BasicEasingInterpolator> instanceCache = new ChronicCache<>();
/**
* Gets or creates a new basic, linear interpolator for the provided id.
*/
public static IInterpolator getInstance(UUID id) {
return instanceCache.retrieve(id, BasicEasingInterpolator::new);
}
public BasicEasingInterpolator() {
}
private BasicEasingInterpolator(UUID id) {
}
private final Map<String, Float> properties = new HashMap<String, Float>();
private float getLast(String key, float to) {
if (properties.containsKey(key)) {
return properties.get(key);
}
return to;
}
@Override
public float interpolate(String key, float to, float scalingFactor) {
float from = getLast(key, to);
from += (to - from) / scalingFactor;
if (Float.isNaN(from) || Float.isInfinite(from)) {
System.err.println("Error: Animation frame for " + key + " is NaN or Infinite.");
from = to;
}
properties.put(key, from);
return from;
}
}

View file

@ -1,7 +0,0 @@
package com.minelittlepony.model.anim;
// #MineLittlePony#
@FunctionalInterface
public interface IInterpolator {
float interpolate(String key, float to, float scalingFactor);
}

View file

@ -1,48 +0,0 @@
package com.minelittlepony.transform;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper;
import com.minelittlepony.util.math.MathUtil;
//#MineLittlePony#
public abstract class MotionCompositor {
protected double calculateRoll(PlayerEntity player, double motionX, double motionY, double motionZ) {
// since model roll should probably be calculated from model rotation rather than entity rotation...
double roll = MathUtil.sensibleAngle(player.prevRenderYawOffset - player.renderYawOffset);
double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ);
float modelYaw = MathUtil.sensibleAngle(player.renderYawOffset);
// detecting that we're flying backwards and roll must be inverted
if (Math.abs(MathUtil.sensibleAngle((float) Math.toDegrees(Math.atan2(motionX, motionZ)) + modelYaw)) > 90) {
roll *= -1;
}
// ayyy magic numbers (after 5 - an approximation of nice looking coefficients calculated by hand)
// roll might be zero, in which case Math.pow produces +Infinity. Anything x Infinity = NaN.
double pow = roll != 0 ? Math.pow(Math.abs(roll), -0.191) : 0;
roll *= horMotion * 5 * (3.6884f * pow);
assert !Float.isNaN((float)roll);
return MathHelper.clamp(roll, -54, 54);
}
protected double calculateIncline(PlayerEntity player, double motionX, double motionY, double motionZ) {
double dist = Math.sqrt(motionX * motionX + motionZ * motionZ);
double angle = Math.atan2(motionY, dist);
if (!player.capabilities.isFlying) {
angle /= 2;
}
angle = MathUtil.clampLimit(angle, Math.PI / 3);
return Math.toDegrees(angle);
}
}

View file

@ -1,18 +0,0 @@
package com.minelittlepony.util.chron;
import java.util.HashMap;
import java.util.function.Function;
//#MineLittlePony#
public class ChronicCache<K, V extends Touchable<V>> extends HashMap<K, V> {
private static final long serialVersionUID = 6454924015818181978L;
public V retrieve(K key, Function<? super K, ? extends V> mappingFunction) {
V result = computeIfAbsent(key, mappingFunction).touch();
entrySet().removeIf(entry -> entry.getValue().hasExpired());
return result;
}
}

View file

@ -1,17 +0,0 @@
package com.minelittlepony.util.chron;
//#MineLittlePony#
public abstract class Touchable<T extends Touchable<T>> {
private long expirationPeriod;
public boolean hasExpired() {
return expirationPeriod <= System.currentTimeMillis();
}
@SuppressWarnings("unchecked")
public T touch() {
expirationPeriod = System.currentTimeMillis() + 30000;
return (T)this;
}
}

View file

@ -1,33 +0,0 @@
package com.minelittlepony.util.math;
import net.minecraft.util.math.MathHelper;
//#MineLittlePony#
public class MathUtil {
public static double clampLimit(double num, double limit) {
return MathHelper.clamp(num, -limit, limit);
}
public static float sensibleAngle(float angle) {
angle %= 360;
if (angle > 180) angle -= 360;
if (angle < -180) angle += 360;
return angle;
}
public static float interpolateDegress(float prev, float current, float partialTicks) {
float difference = current - prev;
while (difference < -180) difference += 360;
while (difference >= 180) difference -= 360;
return prev + partialTicks * difference;
}
public static float interpolateRadians(float prev, float current, float partialTicks) {
return (float)Math.toRadians(interpolateDegress(prev, current, partialTicks));
}
}

View file

@ -1,37 +0,0 @@
package com.minelittlepony.util.render;
import net.minecraft.client.model.ModelBox;
import net.minecraft.client.model.ModelRenderer;
//#MineLittlePony#
public abstract class Box<T extends ModelRenderer> extends ModelBox {
protected final T parent;
public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta) {
super(renderer, texU, texV, x, y, z, dx, dy, dz, delta);
parent = renderer;
}
public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta, boolean mirror) {
super(renderer, texU, texV, x, y, z, dx, dy, dz, delta, mirror);
parent = renderer;
}
/**
* Creates a new vertex mapping the given (x, y, z) coordinates to a texture offset.
*/
protected Vertex vert(float x, float y, float z, int texX, int texY) {
return new Vertex(x, y, z, texX, texY);
}
/**
* Creates a new quad with the given spacial vertices.
*/
protected Quad quad(int startX, int width, int startY, int height, Vertex ...verts) {
return new Quad(verts,
startX, startY,
startX + width, startY + height,
parent.textureWidth, parent.textureHeight);
}
}

View file

@ -1,22 +0,0 @@
package com.minelittlepony.util.render;
import net.minecraft.client.renderer.GlStateManager;
//#MineLittlePony#
public interface Color {
static float r(int color) {
return (color >> 16 & 255) / 255F;
}
static float g(int color) {
return (color >> 8 & 255) / 255F;
}
static float b(int color) {
return (color & 255) / 255F;
}
static void glColor(int color, float alpha) {
GlStateManager.color(Color.r(color), Color.g(color), Color.b(color), alpha);
}
}

View file

@ -1,10 +0,0 @@
package com.minelittlepony.util.render;
import net.minecraft.client.model.TexturedQuad;
//#MineLittlePony#
public class Quad extends TexturedQuad {
Quad(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) {
super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight);
}
}

View file

@ -1,20 +0,0 @@
package com.minelittlepony.util.render;
import net.minecraft.client.model.PositionTextureVertex;
//#MineLittlePony#
public class Vertex extends PositionTextureVertex {
public Vertex(float x, float y, float z, float texX, float texY) {
super(x, y, z, texX, texY);
}
private Vertex(Vertex old, float texX, float texY) {
super(old, texX, texY);
}
@Override
public Vertex setTexturePosition(float texX, float texY) {
return new Vertex(this, texX, texY);
}
}

View file

@ -2,9 +2,9 @@ package com.minelittlepony.unicopia;
import java.util.function.Predicate;
import com.minelittlepony.unicopia.entity.CloudEntity;
import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.gas.Gas;
import com.minelittlepony.unicopia.equine.Ponylike;
import com.minelittlepony.unicopia.world.block.gas.Gas;
import com.minelittlepony.unicopia.world.entity.CloudEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;

View file

@ -1,6 +1,4 @@
package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Race;
package com.minelittlepony.unicopia;
/**
* This interface is for any entities that are categorised as inanimated,

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia;
/**
* Interface for things that can be owned.

View file

@ -46,7 +46,8 @@ public class TreeTraverser {
if (level < 3 && !done.contains(pos)) {
done.add(pos);
BlockPos.Mutable result = new BlockPos.Mutable(ascendTree(w, log, pos, true));
BlockPos.Mutable result = new BlockPos.Mutable();
result.set(ascendTree(w, log, pos, true));
PosHelper.all(pos, p -> {
if (variantAndBlockEquals(w.getBlockState(pos.east()), log)) {
@ -84,7 +85,7 @@ public class TreeTraverser {
}
public static Optional<BlockPos> descendTree(World w, BlockState log, BlockPos pos) {
return descendTreePart(new HashSet<BlockPos>(), w, log, new BlockPos.Mutable(pos));
return descendTreePart(new HashSet<BlockPos>(), w, log, new BlockPos.Mutable(pos.getX(), pos.getY(), pos.getZ()));
}
private static Optional<BlockPos> descendTreePart(Set<BlockPos> done, World w, BlockState log, BlockPos.Mutable pos) {
@ -94,12 +95,11 @@ public class TreeTraverser {
done.add(pos.toImmutable());
while (variantAndBlockEquals(w.getBlockState(pos.down()), log)) {
pos.setOffset(Direction.DOWN);
done.add(pos.toImmutable());
done.add(pos.move(Direction.DOWN).toImmutable());
}
PosHelper.all(pos.toImmutable(), p -> {
descendTreePart(done, w, log, new BlockPos.Mutable(p)).filter(a -> a.getY() < pos.getY()).ifPresent(pos::set);
descendTreePart(done, w, log, new BlockPos.Mutable(p.getX(), p.getY(), p.getZ())).filter(a -> a.getY() < pos.getY()).ifPresent(pos::set);
}, Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST);
done.add(pos.toImmutable());

View file

@ -2,8 +2,8 @@ package com.minelittlepony.unicopia;
import java.util.stream.Collectors;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.util.Weighted;
import com.minelittlepony.unicopia.world.item.UItems;
import java.util.Arrays;
import java.util.HashSet;
@ -19,35 +19,42 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public final class TreeType {
// XXX: move to datapack
// TODO: move to datapack
private static final Set<TreeType> REGISTRY = new HashSet<>();
private static final Supplier<ItemStack> ROTTEN = () -> new ItemStack(UItems.ROTTEN_APPLE);
private static final Supplier<ItemStack> SWEET = () -> new ItemStack(UItems.SWEET_APPLE);
private static final Supplier<ItemStack> GREEN = () -> new ItemStack(UItems.GREEN_APPLE);
private static final Supplier<ItemStack> ZAP = () -> new ItemStack(UItems.ZAP_APPLE);
private static final Supplier<ItemStack> SOUR = () -> new ItemStack(UItems.SOUR_APPLE);
private static final Supplier<ItemStack> RED = () -> new ItemStack(Items.APPLE);
public static final TreeType NONE = new TreeType("none", new Weighted<Supplier<ItemStack>>());
public static final TreeType OAK = new TreeType("oak", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.GREEN_APPLE))
.put(3, () -> new ItemStack(Items.APPLE)), Blocks.OAK_LOG, Blocks.OAK_LEAVES);
.put(1, ROTTEN)
.put(2, GREEN)
.put(3, RED), Blocks.OAK_LOG, Blocks.OAK_LEAVES);
public static final TreeType BIRCH = new TreeType("birch", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(5, () -> new ItemStack(UItems.GREEN_APPLE)), Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES);
.put(1, ROTTEN)
.put(2, SWEET)
.put(5, GREEN), Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES);
public static final TreeType SPRUCE = new TreeType("spruce", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.SOUR_APPLE))
.put(2, () -> new ItemStack(UItems.GREEN_APPLE))
.put(3, () -> new ItemStack(UItems.SWEET_APPLE))
.put(4, () -> new ItemStack(UItems.ROTTEN_APPLE)), Blocks.SPRUCE_LOG, Blocks.SPRUCE_LEAVES);
.put(1, SOUR)
.put(2, GREEN)
.put(3, SWEET)
.put(4, ROTTEN), Blocks.SPRUCE_LOG, Blocks.SPRUCE_LEAVES);
public static final TreeType ACACIA = new TreeType("acacia", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(5, () -> new ItemStack(UItems.GREEN_APPLE)), Blocks.ACACIA_LOG, Blocks.ACACIA_LEAVES);
.put(1, ROTTEN)
.put(2, SWEET)
.put(5, GREEN), Blocks.ACACIA_LOG, Blocks.ACACIA_LEAVES);
public static final TreeType JUNGLE = new TreeType("jungle", new Weighted<Supplier<ItemStack>>()
.put(5, () -> new ItemStack(UItems.GREEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(1, () -> new ItemStack(UItems.SOUR_APPLE)), Blocks.JUNGLE_LOG, Blocks.JUNGLE_LEAVES);
.put(5, GREEN)
.put(2, SWEET)
.put(1, ZAP), Blocks.JUNGLE_LOG, Blocks.JUNGLE_LEAVES);
public static final TreeType DARK_OAK = new TreeType("dark_oak", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(5, () -> new ItemStack(UItems.ZAP_APPLE)), Blocks.DARK_OAK_LOG, Blocks.DARK_OAK_LEAVES);
.put(1, ROTTEN)
.put(2, SWEET)
.put(5, ZAP), Blocks.DARK_OAK_LOG, Blocks.DARK_OAK_LEAVES);
private final String name;
private final Set<Identifier> blocks;

View file

@ -2,26 +2,12 @@ package com.minelittlepony.unicopia;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.loot.LootTable;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.minelittlepony.unicopia.advancement.BOHDeathCriterion;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.command.Commands;
import com.minelittlepony.unicopia.container.UContainers;
import com.minelittlepony.unicopia.enchanting.Pages;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.mixin.CriterionsRegistry;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.recipe.URecipes;
import com.minelittlepony.unicopia.structure.UStructures;
import com.minelittlepony.unicopia.world.UnicopiaWorld;
public class Unicopia implements ModInitializer {
@ -45,26 +31,9 @@ public class Unicopia implements ModInitializer {
Channel.bootstrap();
UTags.bootstrap();
Commands.bootstrap();
UBlocks.bootstrap();
UItems.bootstrap();
UContainers.bootstrap();
UStructures.bootstrap();
URecipes.bootstrap();
CriterionsRegistry.register(BOHDeathCriterion.INSTANCE);
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance());
WorldTickCallback.EVENT.register(AwaitTickQueue::tick);
LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> {
if (!"minecraft".contentEquals(id.getNamespace())) {
return;
}
Identifier modId = new Identifier("unicopiamc", id.getPath());
LootTable table = manager.getSupplier(modId);
if (table != LootTable.EMPTY) {
supplier.withPools(((FabricLootSupplier)table).getPools());
}
});
UnicopiaWorld.bootstrap();
}
}

View file

@ -5,13 +5,14 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.MutableRegistry;
import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.util.registry.Registry;
public interface Abilities {
Map<AbilitySlot, Set<Ability<?>>> BY_SLOT = new EnumMap<>(AbilitySlot.class);
MutableRegistry<Ability<?>> REGISTRY = new SimpleRegistry<>();
Registry<Ability<?>> REGISTRY = Registries.createSimple(new Identifier("unicopia", "abilities"));
// unicorn / alicorn
Ability<?> TELEPORT = register(new UnicornTeleportAbility(), "teleport", AbilitySlot.SECONDARY);
@ -35,6 +36,6 @@ public interface Abilities {
static <T extends Ability<?>> T register(T power, String name, AbilitySlot slot) {
Identifier id = new Identifier("unicopia", name);
BY_SLOT.computeIfAbsent(slot, s -> new HashSet<>()).add(power);
return REGISTRY.add(id, power);
return Registry.register(REGISTRY, id, power);
}
}

View file

@ -4,7 +4,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import net.minecraft.world.World;

View file

@ -6,7 +6,7 @@ import java.util.Optional;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.util.NbtSerialisable;

View file

@ -2,13 +2,13 @@ package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.World;

View file

@ -3,10 +3,10 @@ package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InAnimate;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.InAnimate;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.VecHelper;

View file

@ -7,7 +7,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.particles.ParticleUtils;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
@ -59,7 +59,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
}
private boolean canFeed(Pony player) {
return player.getOwner().getHealth() < player.getOwner().getMaximumHealth() || player.getOwner().canConsume(false);
return player.getOwner().getHealth() < player.getOwner().getMaxHealth() || player.getOwner().canConsume(false);
}
private boolean canDrain(Entity e) {
@ -92,7 +92,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
public void apply(Pony iplayer, Hit data) {
PlayerEntity player = iplayer.getOwner();
float maximumHealthGain = player.getMaximumHealth() - player.getHealth();
float maximumHealthGain = player.getMaxHealth() - player.getHealth();
int maximumFoodGain = player.canConsume(false) ? (20 - player.getHungerManager().getFoodLevel()) : 0;
if (maximumHealthGain > 0 || maximumFoodGain > 0) {

View file

@ -1,54 +0,0 @@
package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.ChangelingTrapSpell;
// TODO: Make this a throwable item instead
@Deprecated
public class ChangelingTrapAbility implements Ability<Hit> {
@Override
public int getWarmupTime(Pony player) {
return 0;
}
@Override
public int getCooldownTime(Pony player) {
return 30;
}
@Override
public boolean canUse(Race playerSpecies) {
return playerSpecies == Race.CHANGELING;
}
@Nullable
@Override
public Hit tryActivate(Pony player) {
return Hit.INSTANCE;
}
@Override
public Hit.Serializer<Hit> getSerializer() {
return Hit.SERIALIZER;
}
@Override
public void apply(Pony player, Hit data) {
new ChangelingTrapSpell().toss(player);
}
@Override
public void preApply(Pony player, AbilitySlot slot) {
}
@Override
public void postApply(Pony player, AbilitySlot slot) {
}
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Pos;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.VecHelper;

View file

@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.TreeTraverser;
import com.minelittlepony.unicopia.TreeType;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Multi;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper;
@ -23,14 +23,14 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.LogBlock;
import net.minecraft.entity.EntityContext;
import net.minecraft.block.ShapeContext;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particle.BlockStateParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
@ -76,7 +76,7 @@ public class EarthPonyStompAbility implements Ability<Multi> {
BlockPos pos = ((BlockHitResult)mop).getBlockPos();
BlockState state = player.getWorld().getBlockState(pos);
if (state.getBlock() instanceof LogBlock) {
if (state.getBlock().isIn(BlockTags.LOGS)) {
pos = TreeTraverser.descendTree(player.getWorld(), state, pos).get();
if (TreeTraverser.measureTree(player.getWorld(), state, pos) > 0) {
return new Multi(pos, 1);
@ -84,7 +84,7 @@ public class EarthPonyStompAbility implements Ability<Multi> {
}
}
if (!player.getOwner().onGround && !player.getOwner().abilities.flying) {
if (!player.getOwner().isOnGround() && !player.getOwner().abilities.flying) {
player.getOwner().addVelocity(0, -6, 0);
return new Multi(Vec3i.ZERO, 0);
}
@ -121,7 +121,7 @@ public class EarthPonyStompAbility implements Ability<Multi> {
DamageSource damage = MagicalDamageSource.causePlayerDamage("smash", player);
double amount = (4 * player.getAttributeInstance(EntityAttributes.ATTACK_DAMAGE).getValue()) / (float)dist;
double amount = (4 * player.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE).getValue()) / (float)dist;
if (i instanceof PlayerEntity) {
Race race = Pony.of((PlayerEntity)i).getSpecies();
@ -151,7 +151,7 @@ public class EarthPonyStompAbility implements Ability<Multi> {
iplayer.subtractEnergyCost(rad);
} else if (data.hitType == 1) {
boolean harmed = player.getHealth() < player.getMaximumHealth();
boolean harmed = player.getHealth() < player.getMaxHealth();
if (harmed && player.world.random.nextInt(30) == 0) {
iplayer.subtractEnergyCost(3);
@ -179,14 +179,13 @@ public class EarthPonyStompAbility implements Ability<Multi> {
BlockState state = w.getBlockState(pos);
if (!state.isAir() && w.getBlockState(pos.up()).isAir()) {
WorldEvent.DESTROY_BLOCK.play(w, pos, state);
WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state);
}
}
@Override
public void preApply(Pony player, AbilitySlot slot) {
player.getMagicalReserves().addExertion(40);
player.getOwner().attemptSprintingParticles();
}
@Override
@ -247,7 +246,7 @@ public class EarthPonyStompAbility implements Ability<Multi> {
BlockState state = w.getBlockState(pos);
if (state.getBlock() instanceof LeavesBlock && w.getBlockState(pos.down()).isAir()) {
WorldEvent.DESTROY_BLOCK.play(w, pos, state);
WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state);
drops.add(new ItemEntity(w,
pos.getX() + w.random.nextFloat(),
pos.getY() - 0.5,
@ -264,10 +263,10 @@ public class EarthPonyStompAbility implements Ability<Multi> {
}
private static BlockPos getSolidBlockBelow(BlockPos pos, World w) {
while (World.isValid(pos)) {
while (!World.isHeightInvalid(pos)) {
pos = pos.down();
if (Block.isFaceFullSquare(w.getBlockState(pos).getCollisionShape(w, pos, EntityContext.absent()), Direction.UP)) {
if (Block.isFaceFullSquare(w.getBlockState(pos).getCollisionShape(w, pos, ShapeContext.absent()), Direction.UP)) {
return pos;
}
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
/**
* Predicate for abilities to control whether a player can fly.

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
/**
* Predicate for abilities to control what the player's physical height is.

View file

@ -5,7 +5,7 @@ import java.util.Optional;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Numeric;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.VecHelper;
@ -51,15 +51,15 @@ public class PegasusCloudInteractionAbility implements Ability<Numeric> {
});
}
protected Optional<ICloudEntity> findTarget(Pony player) {
if (player.getOwner().hasVehicle() && player.getOwner().getVehicle() instanceof ICloudEntity) {
return Optional.ofNullable((ICloudEntity)player.getOwner().getVehicle());
protected Optional<Interactable> findTarget(Pony player) {
if (player.getOwner().hasVehicle() && player.getOwner().getVehicle() instanceof Interactable) {
return Optional.ofNullable((Interactable)player.getOwner().getVehicle());
}
Entity e = VecHelper.getLookedAtEntity(player.getOwner(), 18);
if (e instanceof ICloudEntity) {
return Optional.of((ICloudEntity)e);
if (e instanceof Interactable) {
return Optional.of((Interactable)e);
}
return Optional.empty();
@ -75,7 +75,7 @@ public class PegasusCloudInteractionAbility implements Ability<Numeric> {
player.spawnParticles(UParticles.RAIN_DROPS, 5);
}
public interface ICloudEntity {
public interface Interactable {
void handlePegasusInteration(int interationType);
}
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
import com.google.common.collect.Streams;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.spell.ShieldSpell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Pos;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.VecHelper;
@ -12,9 +12,9 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.FenceBlock;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.WallBlock;
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability.data;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.network.PacketByteBuf;
public class Hit {

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability.data;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.math.Vec3i;
public class Multi extends Pos {

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.data;
import com.google.gson.annotations.Expose;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.network.PacketByteBuf;
public class Numeric extends Hit {
public static final Serializer<Numeric> SERIALIZER = Numeric::new;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability.data;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.math.BlockPos;
public class Pos extends Hit {

View file

@ -6,7 +6,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity;
import com.mojang.authlib.GameProfile;

View file

@ -8,14 +8,11 @@ import java.util.Set;
import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.ability.AbilitySlot;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.util.Identifier;
class KeyBindingsHandler {
private final String KEY_CATEGORY = "unicopia.category.name";
@ -25,20 +22,13 @@ class KeyBindingsHandler {
private final Set<KeyBinding> pressed = new HashSet<>();
public KeyBindingsHandler() {
KeyBindingRegistry.INSTANCE.addCategory(KEY_CATEGORY);
addKeybind(GLFW.GLFW_KEY_O, AbilitySlot.PRIMARY);
addKeybind(GLFW.GLFW_KEY_P, AbilitySlot.SECONDARY);
addKeybind(GLFW.GLFW_KEY_L, AbilitySlot.TERTIARY);
}
public void addKeybind(int code, AbilitySlot slot) {
KeyBindingRegistry.INSTANCE.addCategory(KEY_CATEGORY);
FabricKeyBinding b = FabricKeyBinding.Builder.create(new Identifier("unicopia", slot.name().toLowerCase()), InputUtil.Type.KEYSYM, code, KEY_CATEGORY).build();
KeyBindingRegistry.INSTANCE.register(b);
keys.put(b, slot);
keys.put(KeyBindingHelper.registerKeyBinding(new KeyBinding("key.unicopia" + slot.name().toLowerCase(), code, KEY_CATEGORY)), slot);
}
public void tick(MinecraftClient client) {

View file

@ -1,65 +1,22 @@
package com.minelittlepony.unicopia.client;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.client.gui.UScreens;
import com.minelittlepony.unicopia.client.particle.ChangelingMagicParticle;
import com.minelittlepony.unicopia.client.particle.DiskParticle;
import com.minelittlepony.unicopia.client.particle.MagicParticle;
import com.minelittlepony.unicopia.client.particle.RaindropsParticle;
import com.minelittlepony.unicopia.client.particle.SphereParticle;
import com.minelittlepony.unicopia.client.render.ButterflyEntityRenderer;
import com.minelittlepony.unicopia.client.render.CloudEntityRenderer;
import com.minelittlepony.unicopia.client.render.CucoonEntityRenderer;
import com.minelittlepony.unicopia.client.render.RainbowEntityRenderer;
import com.minelittlepony.unicopia.client.render.SpearEntityRenderer;
import com.minelittlepony.unicopia.client.render.SpellbookEntityRender;
import com.minelittlepony.unicopia.client.render.SpellcastEntityRenderer;
import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.particles.UParticles;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import com.minelittlepony.unicopia.world.client.UWorldClient;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
public interface URenderers {
static void bootstrap() {
EntityRendererRegistry.INSTANCE.register(UEntities.CLOUD, CloudEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.WILD_CLOUD, CloudEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.CONSTRUCTION_CLOUD, CloudEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.RACING_CLOUD, CloudEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.MAGIC_SPELL, SpellcastEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer()));
EntityRendererRegistry.INSTANCE.register(UEntities.SPELLBOOK, SpellbookEntityRender::new);
EntityRendererRegistry.INSTANCE.register(UEntities.RAINBOW, RainbowEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.BUTTERFLY, ButterflyEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.CUCOON, CucoonEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_SPEAR, SpearEntityRenderer::new);
ParticleFactoryRegistry.getInstance().register(UParticles.UNICORN_MAGIC, MagicParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.CHANGELING_MAGIC, ChangelingMagicParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.RAIN_DROPS, RaindropsParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle::new);
ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle::new);
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(),
UBlocks.ENCHANTED_TORCH, UBlocks.ENCHANTED_WALL_TORCH,
UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR,
UBlocks.APPLE_SAPLING, UBlocks.ALFALFA_CROPS,
UBlocks.TOMATO_PLANT, UBlocks.CLOUDSDALE_TOMATO_PLANT
);
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(),
UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND,
UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS,
UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB, UBlocks.ENCHANTED_CLOUD_STAIRS,
UBlocks.SLIME_DRIP, UBlocks.SLIME_LAYER
);
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutoutMipped(),
UBlocks.APPLE_LEAVES
);
UScreens.bootstrap();
UWorldClient.bootstrap();
}
}

View file

@ -6,14 +6,15 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.container.SpellbookResultSlot;
import com.minelittlepony.unicopia.ducks.Colourful;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.mixin.client.DefaultTexturesRegistry;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
import com.minelittlepony.unicopia.world.block.UBlocks;
import com.minelittlepony.unicopia.world.container.SpellbookResultSlot;
import com.minelittlepony.unicopia.world.item.UItems;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;

View file

@ -1,107 +0,0 @@
package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.common.client.gui.element.Scrollbar;
import com.minelittlepony.unicopia.container.BagOfHoldingContainer;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
public class BagOfHoldingScreen extends ContainerScreen<BagOfHoldingContainer> {
private static final Identifier CHEST_GUI_TEXTURE = new Identifier("textures/gui/container/generic_54.png");
private final int inventoryRows;
private final int playerRows;
private final Scrollbar scrollbar = new Scrollbar();
public BagOfHoldingScreen(int sync, Identifier id, PlayerEntity player, PacketByteBuf buf) {
super(new BagOfHoldingContainer(sync, id, player, buf), player.inventory, buf.readText());
playerRows = playerInventory.getInvSize() / 9;
inventoryRows = (container.slots.size() / 9) - 1;
}
@Override
public void init() {
super.init();
scrollbar.reposition(
x + containerWidth,
y,
containerHeight,
(inventoryRows + 1) * 18 + 17);
children.add(scrollbar);
}
@Override
public void onClose() {
super.onClose();
minecraft.player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 0.5F, 0.5F);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
renderBackground();
scrollbar.render(mouseX, mouseY, partialTicks);
int scroll = -scrollbar.getScrollAmount();
GlStateManager.pushMatrix();
GlStateManager.translatef(0, scroll, 0);
super.render(mouseX, mouseY - scroll, partialTicks);
int h = height;
height = Integer.MAX_VALUE;
drawMouseoverTooltip(mouseX, mouseY - scroll);
height = h;
GlStateManager.popMatrix();
}
@Override
public boolean mouseClicked(double x, double y, int button) {
return super.mouseClicked(x, y + scrollbar.getScrollAmount(), button);
}
@Override
public boolean mouseDragged(double x, double y, int button, double dx, double dy) {
if (scrollbar.isMouseOver(x, y)) {
return scrollbar.mouseDragged(x, y + scrollbar.getScrollAmount(), button, dx, dy);
}
return super.mouseDragged(x, y + scrollbar.getScrollAmount(), button, dx, dy);
}
@Override
public boolean mouseReleased(double x, double y, int button) {
return super.mouseReleased(x, y + scrollbar.getScrollAmount(), button);
}
@Override
protected void drawForeground(int mouseX, int mouseY) {
font.draw(title.asString(), 8, 6, 0x404040);
}
@Override
protected void drawBackground(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color4f(1, 1, 1, 1);
minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
int midX = (width - containerWidth) / 2;
int midY = (height - containerHeight) / 2;
blit(midX, midY, 0, 0, containerWidth, 18);
for (int i = 0; i < inventoryRows - (playerRows - 1); i++) {
blit(midX, midY + (18 * (i + 1)), 0, 18, containerWidth, 18);
}
blit(midX, midY + (18 * (inventoryRows - (playerRows - 2))) - 1, 0, 131, containerWidth, 98);
}
}

View file

@ -1,13 +0,0 @@
package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.unicopia.container.UContainers;
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
public interface UScreens {
static void bootstrap() {
ScreenProviderRegistry.INSTANCE.registerFactory(UContainers.BAG_OF_HOLDING, BagOfHoldingScreen::new);
ScreenProviderRegistry.INSTANCE.registerFactory(UContainers.SPELL_BOOK, SpellBookScreen::new);
}
}

View file

@ -5,14 +5,14 @@ import net.fabricmc.api.Environment;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.world.World;
public class ChangelingMagicParticle extends MagicParticle {
private final SpriteProvider provider;
public ChangelingMagicParticle(SpriteProvider provider, World world, double x, double y, double z, double dx, double dy, double dz) {
public ChangelingMagicParticle(SpriteProvider provider, ClientWorld world, double x, double y, double z, double dx, double dy, double dz) {
super(world, x, y, z, dx, dy, dz, 1, 1, 1);
this.provider = provider;
@ -39,7 +39,7 @@ public class ChangelingMagicParticle extends MagicParticle {
}
@Override
public Particle createParticle(DefaultParticleType effect, World world, double x, double y, double z, double dx, double dy, double dz) {
public Particle createParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double dx, double dy, double dz) {
MagicParticle particle = new MagicParticle(world, x, y, z, dx, dy, dz);
particle.setSprite(provider);
return particle;

View file

@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.client.render.model;
package com.minelittlepony.unicopia.client.particle;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.Matrix4f;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Matrix4f;
public class DiskModel extends SphereModel {

View file

@ -1,6 +1,5 @@
package com.minelittlepony.unicopia.client.particle;
import com.minelittlepony.unicopia.client.render.model.DiskModel;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import net.minecraft.client.MinecraftClient;
@ -9,7 +8,7 @@ import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.world.World;
import net.minecraft.client.world.ClientWorld;
public class DiskParticle extends SphereParticle {
@ -19,7 +18,7 @@ public class DiskParticle extends SphereParticle {
protected float rotY;
protected float rotZ;
public DiskParticle(SphereParticleEffect effect, World w, double x, double y, double z, double rX, double rY, double rZ) {
public DiskParticle(SphereParticleEffect effect, ClientWorld w, double x, double y, double z, double rX, double rY, double rZ) {
super(effect, w, x, y, z, 0, 0, 0);
rotX = (float)rX;

View file

@ -9,14 +9,14 @@ import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.world.World;
import net.minecraft.client.world.ClientWorld;
public class MagicParticle extends SpriteBillboardParticle {
private double startX;
private double startY;
private double startZ;
MagicParticle(World w, double x, double y, double z, double vX, double vY, double vZ, float r, float g, float b) {
MagicParticle(ClientWorld w, double x, double y, double z, double vX, double vY, double vZ, float r, float g, float b) {
super(w, x, y, z);
velocityX = vX;
velocityY = vY;
@ -32,7 +32,7 @@ public class MagicParticle extends SpriteBillboardParticle {
colorBlue = b;
}
MagicParticle(World w, double x, double y, double z, double vX, double vY, double vZ) {
MagicParticle(ClientWorld w, double x, double y, double z, double vX, double vY, double vZ) {
this(w, x, y, z, vX, vY, vZ, 1, 1, 1);
colorAlpha = 0.7F;
@ -106,7 +106,7 @@ public class MagicParticle extends SpriteBillboardParticle {
}
@Override
public Particle createParticle(MagicParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) {
public Particle createParticle(MagicParticleEffect effect, ClientWorld world, double x, double y, double z, double dx, double dy, double dz) {
MagicParticle particle = effect.hasTint() ?
new MagicParticle(world, x, y, z, dx, dy, dz, effect.getRed(), effect.getGreen(), effect.getBlue())
: new MagicParticle(world, x, y, z, dx, dy, dz);

View file

@ -4,12 +4,12 @@ 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.client.world.ClientWorld;
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) {
public RaindropsParticle(ClientWorld world, double x, double y, double z, double dx, double dy, double dz) {
super(world, x, y, z);
velocityY = -0.1;
maxAge += 19;
@ -34,7 +34,7 @@ public class RaindropsParticle extends RainSplashParticle {
}
@Override
public Particle createParticle(DefaultParticleType defaultParticleType_1, World world, double x, double y, double z, double dx, double dy, double dz) {
public Particle createParticle(DefaultParticleType defaultParticleType_1, ClientWorld 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;

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.client.render.model;
package com.minelittlepony.unicopia.client.particle;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.Matrix4f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.util.math.Vector4f;

View file

@ -7,16 +7,15 @@ import net.minecraft.client.render.Camera;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import com.minelittlepony.unicopia.client.render.RenderLayers;
import com.minelittlepony.unicopia.client.render.model.SphereModel;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.particles.ParticleHandle.Attachment;
import com.minelittlepony.unicopia.particles.ParticleHandle.Link;
import com.minelittlepony.unicopia.world.client.render.RenderLayers;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import com.minelittlepony.util.Color;
import com.minelittlepony.common.util.Color;
public class SphereParticle extends Particle implements Attachment {
@ -36,7 +35,7 @@ public class SphereParticle extends Particle implements Attachment {
private static final SphereModel model = new SphereModel();
public SphereParticle(SphereParticleEffect effect, World w, double x, double y, double z, double vX, double vY, double vZ) {
public SphereParticle(SphereParticleEffect effect, ClientWorld w, double x, double y, double z, double vX, double vY, double vZ) {
this(effect, w, x, y, z);
this.velocityX = vX;
@ -44,7 +43,7 @@ public class SphereParticle extends Particle implements Attachment {
this.velocityZ = vZ;
}
public SphereParticle(SphereParticleEffect effect, World w, double x, double y, double z) {
public SphereParticle(SphereParticleEffect effect, ClientWorld w, double x, double y, double z) {
super(w, x, y, z);
this.radius = effect.getRadius();

View file

@ -1,16 +1,17 @@
package com.minelittlepony.unicopia.command;
import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.MinecraftServer;
public class Commands {
public static void bootstrap() {
CommandRegistry.INSTANCE.register(false, SpeciesCommand::register);
CommandRegistry.INSTANCE.register(false, RacelistCommand::register);
CommandRegistry.INSTANCE.register(false, GravityCommand::register);
CommandRegistry.INSTANCE.register(false, DisguiseCommand::register);
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
SpeciesCommand.register(dispatcher);
RacelistCommand.register(dispatcher);
GravityCommand.register(dispatcher);
DisguiseCommand.register(dispatcher);
});
Object game = FabricLoader.getInstance().getGameInstance();
if (game instanceof MinecraftServer) {
((MinecraftServer)game).setFlightEnabled(true);

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.command;
import java.util.function.Function;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -72,7 +72,7 @@ public class DisguiseCommand {
source.sendFeedback(new TranslatableText("commands.disguise.success.other", player.getName(), entity.getName()), true);
} else {
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(new TranslatableText("commands.disguise.success.self", entity.getName()));
player.sendMessage(new TranslatableText("commands.disguise.success.self", entity.getName()), false);
}
source.sendFeedback(new TranslatableText("commands.disguise.success.otherself", player.getName(), entity.getName()), true);
}
@ -87,7 +87,7 @@ public class DisguiseCommand {
});
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(new TranslatableText("commands.disguise.removed"));
player.sendMessage(new TranslatableText("commands.disguise.removed"), false);
}
return 0;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.command;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -44,7 +44,7 @@ class GravityCommand {
if (source.getPlayer() != player) {
translationKey += ".other";
}
player.sendMessage(new TranslatableText(translationKey, player.getName(), gravity));
player.sendMessage(new TranslatableText(translationKey, player.getName(), gravity), false);
return 0;
}
@ -58,7 +58,7 @@ class GravityCommand {
iplayer.setDirty();
if (isSelf) {
player.sendMessage(new TranslatableText(translationKey, gravity));
player.sendMessage(new TranslatableText(translationKey, gravity), false);
}
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);

View file

@ -50,14 +50,9 @@ class RacelistCommand {
translationKey += ".failed";
}
Text formattedName = new TranslatableText(race.name().toLowerCase());
formattedName.getStyle().setColor(Formatting.GOLD);
Text comp = new TranslatableText(translationKey, formattedName);
comp.getStyle().setColor(Formatting.GREEN);
player.sendMessage(comp);
Text formattedName = new TranslatableText(race.name().toLowerCase()).styled(s -> s.withColor(Formatting.GOLD));
player.sendMessage(new TranslatableText(translationKey, formattedName).styled(s -> s.withColor(Formatting.GREEN)), false);
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), formattedName), true);
return 0;

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.command;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -10,6 +10,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
@ -57,12 +58,12 @@ class SpeciesCommand {
source.sendFeedback(new TranslatableText("commands.race.success.other", player.getName(), formattedName), true);
} else {
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(new TranslatableText("commands.race.success.self"));
player.sendMessage(new TranslatableText("commands.race.success.self"), false);
}
source.sendFeedback(new TranslatableText("commands.race.success.otherself", player.getName(), formattedName), true);
}
} else if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(new TranslatableText("commands.race.permission"));
player.sendMessage(new TranslatableText("commands.race.permission"), false);
}
return 0;
@ -74,22 +75,17 @@ class SpeciesCommand {
String name = "commands.race.tell.";
name += isSelf ? "self" : "other";
Text race = new TranslatableText(spec.getTranslationKey());
Text message = new TranslatableText(name);
race.getStyle().setColor(Formatting.GOLD);
message.append(race);
player.sendMessage(message);
player.sendMessage(new TranslatableText(name)
.append(new TranslatableText(spec.getTranslationKey())
.styled(s -> s.withColor(Formatting.GOLD))), false);
return 0;
}
static int list(PlayerEntity player) {
player.sendMessage(new TranslatableText("commands.race.list"));
player.sendMessage(new TranslatableText("commands.race.list"), false);
Text message = new LiteralText("");
MutableText message = new LiteralText("");
boolean first = true;
for (Race i : Race.values()) {
@ -99,9 +95,7 @@ class SpeciesCommand {
}
}
message.getStyle().setColor(Formatting.GOLD);
player.sendMessage(message);
player.sendMessage(message.styled(s -> s.withColor(Formatting.GOLD)), false);
return 0;
}
@ -109,17 +103,9 @@ class SpeciesCommand {
static int describe(PlayerEntity player, Race species) {
String name = species.name().toLowerCase();
Text line1 = new TranslatableText(String.format("commands.race.describe.%s.1", name));
line1.getStyle().setColor(Formatting.YELLOW);
player.sendMessage(line1);
player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.2", name)));
Text line3 = new TranslatableText(String.format("commands.race.describe.%s.3", name));
line3.getStyle().setColor(Formatting.RED);
player.sendMessage(line3);
player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.1", name)).styled(s -> s.withColor(Formatting.YELLOW)), false);
player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.2", name)), false);
player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.3", name)).styled(s -> s.withColor(Formatting.RED)), false);
return 0;
}

View file

@ -1,19 +0,0 @@
package com.minelittlepony.unicopia.container;
import net.minecraft.container.Container;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.Inventory;
public class SpellBookInventory extends CraftingInventory {
private final Inventory craftResult;
public SpellBookInventory(Inventory resultMatrix, Container eventHandler, int width, int height) {
super(eventHandler, width, height);
craftResult = resultMatrix;
}
public Inventory getCraftResultMatrix() {
return craftResult;
}
}

View file

@ -1,20 +0,0 @@
package com.minelittlepony.unicopia.container;
import net.fabricmc.fabric.api.container.ContainerFactory;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.minecraft.container.Container;
import net.minecraft.util.Identifier;
public interface UContainers {
Identifier BAG_OF_HOLDING = register("bag_of_holding", BagOfHoldingContainer::new);
Identifier SPELL_BOOK = register("spell_book", SpellBookContainer::new);
static Identifier register(String name, ContainerFactory<Container> factory) {
Identifier id = new Identifier("unicopia", name);
ContainerProviderRegistry.INSTANCE.registerFactory(id, factory);
return id;
}
static void bootstrap() { }
}

View file

@ -1,7 +0,0 @@
package com.minelittlepony.unicopia.ducks;
@Deprecated
// XXX: 1.16 Use the vanilla BlockTag once mojang adds it
public interface Climbable {
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ducks;
import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.equine.ItemImpl;
public interface IItemEntity extends PonyContainer<ItemImpl> {

View file

@ -4,7 +4,7 @@ import java.util.Optional;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.equine.Ponylike;
import com.minelittlepony.unicopia.magic.Caster;
import net.minecraft.entity.Entity;

View file

@ -1,5 +0,0 @@
package com.minelittlepony.unicopia.enchanting;
public interface IUnlockEvent {
}

View file

@ -1,75 +0,0 @@
package com.minelittlepony.unicopia.entity;
import java.util.List;
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.EndBiome;
import net.minecraft.world.biome.ForestBiome;
import net.minecraft.world.biome.MountainsBiome;
import net.minecraft.world.biome.NetherBiome;
import net.minecraft.world.biome.OceanBiome;
import net.minecraft.world.biome.PlainsBiome;
import net.minecraft.world.biome.RiverBiome;
public interface UEntities {
EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new)
.size(EntityDimensions.changing(0.6F, 0.6F)));
EntityType<SpellcastEntity> MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new)
.size(EntityDimensions.changing(0.6F, 0.25F)));
EntityType<CloudEntity> CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new)
.size(CloudEntity.BASE_DIMENSIONS));
EntityType<WildCloudEntity> WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new)
.size(CloudEntity.BASE_DIMENSIONS));
EntityType<RacingCloudEntity> RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new)
.size(CloudEntity.BASE_DIMENSIONS));
EntityType<ConstructionCloudEntity> CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new)
.size(CloudEntity.BASE_DIMENSIONS));
EntityType<RainbowEntity> RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new)
.size(EntityDimensions.fixed(1, 1)));
EntityType<CucoonEntity> CUCOON = register("cucoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CucoonEntity::new)
.size(EntityDimensions.changing(1.5F, 1.6F)));
EntityType<ButterflyEntity> BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new)
.size(EntityDimensions.fixed(1, 1)));
EntityType<ProjectileEntity> THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.<ProjectileEntity>create(EntityCategory.MISC, ProjectileEntity::new)
.trackable(100, 2)
.size(EntityDimensions.fixed(0.25F, 0.25F)));
EntityType<SpearEntity> THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.<SpearEntity>create(EntityCategory.MISC, SpearEntity::new)
.trackable(100, 2)
.size(EntityDimensions.fixed(0.6F, 0.6F)));
static <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), builder.build());
}
static void bootstrap() {
Registry.BIOME.forEach(biome -> {
if (!(biome instanceof NetherBiome || biome instanceof EndBiome)) {
addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), biome instanceof OceanBiome ? WildCloudEntity.SPAWN_ENTRY_OCEAN : WildCloudEntity.SPAWN_ENTRY_LAND);
addifAbsent(biome.getEntitySpawnList(EntityCategory.CREATURE), RainbowEntity.SPAWN_ENTRY);
}
if (biome instanceof PlainsBiome
|| biome instanceof RiverBiome
|| biome instanceof MountainsBiome
|| biome instanceof ForestBiome) {
addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), ButterflyEntity.SPAWN_ENTRY);
}
});
}
static <T> void addifAbsent(List<T> entries, T entry) {
if (!entries.contains(entry)) {
entries.add(entry);
}
}
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia.equine;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.magic.Affinity;

View file

@ -1,5 +1,6 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia.equine;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.util.Copieable;
import net.minecraft.block.Block;
@ -40,7 +41,7 @@ public class EntityPhysics<T extends Ponylike<?> & Owned<? extends Entity>> impl
Entity entity = pony.getOwner();
entity.onGround = false;
entity.setOnGround(false);
BlockPos pos = new BlockPos(
MathHelper.floor(entity.getX()),
@ -51,12 +52,12 @@ public class EntityPhysics<T extends Ponylike<?> & Owned<? extends Entity>> impl
if (entity.world.getBlockState(pos).isAir()) {
BlockPos below = pos.down();
Block block = entity.world.getBlockState(below).getBlock();
if (block.matches(BlockTags.FENCES) || block.matches(BlockTags.WALLS) || block instanceof FenceGateBlock) {
entity.onGround = true;
if (block.isIn(BlockTags.FENCES) || block.isIn(BlockTags.WALLS) || block instanceof FenceGateBlock) {
entity.setOnGround(true);
return below;
}
} else {
pony.getOwner().onGround = true;
pony.getOwner().setOnGround(true);
}
return pos;

View file

@ -1,5 +1,6 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia.equine;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ducks.IItemEntity;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia.equine;
import com.minelittlepony.unicopia.util.NbtSerialisable;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia.equine;
import javax.annotation.Nullable;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia.equine;
import net.minecraft.entity.Entity;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import net.minecraft.util.math.Vec3d;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
public interface MagicReserves {
/**

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
public class ManaContainer implements MagicReserves {
private final Pony pony;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
/**
* Interface for controlling flight.

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import java.util.UUID;
@ -15,7 +15,7 @@ import net.minecraft.entity.player.PlayerEntity;
class PlayerAttributes {
static final EntityAttribute EXTENDED_REACH_DISTANCE = new ClampedEntityAttribute(null, "player.reachDistance", 0, 0, 10);
static final EntityAttribute EXTENDED_REACH_DISTANCE = new ClampedEntityAttribute("player.reachDistance", 0, 0, 10);
private static final EntityAttributeModifier EARTH_PONY_STRENGTH =
new EntityAttributeModifier(UUID.fromString("777a5505-521e-480b-b9d5-6ea54f259564"), "Earth Pony Strength", 0.6, Operation.MULTIPLY_TOTAL);
@ -30,10 +30,10 @@ class PlayerAttributes {
((Walker)entity.abilities).setWalkSpeed(0.1F - (float)pony.getInventory().getCarryingWeight());
toggleAttribute(entity, EntityAttributes.ATTACK_DAMAGE, EARTH_PONY_STRENGTH, race.canUseEarth());
toggleAttribute(entity, EntityAttributes.KNOCKBACK_RESISTANCE, EARTH_PONY_STRENGTH, race.canUseEarth());
toggleAttribute(entity, EntityAttributes.MOVEMENT_SPEED, PEGASUS_SPEED, race.canFly());
toggleAttribute(entity, EntityAttributes.ATTACK_SPEED, PEGASUS_SPEED, race.canFly());
toggleAttribute(entity, EntityAttributes.GENERIC_ATTACK_DAMAGE, EARTH_PONY_STRENGTH, race.canUseEarth());
toggleAttribute(entity, EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, EARTH_PONY_STRENGTH, race.canUseEarth());
toggleAttribute(entity, EntityAttributes.GENERIC_MOVEMENT_SPEED, PEGASUS_SPEED, race.canFly());
toggleAttribute(entity, EntityAttributes.GENERIC_ATTACK_SPEED, PEGASUS_SPEED, race.canFly());
toggleAttribute(entity, EXTENDED_REACH_DISTANCE, PEGASUS_REACH, race.canFly());
}
@ -43,12 +43,10 @@ class PlayerAttributes {
if (enable) {
if (!instance.hasModifier(modifier)) {
instance.addModifier(modifier);
instance.addPersistentModifier(modifier);
}
} else {
if (instance.hasModifier(modifier)) {
instance.removeModifier(modifier);
}
instance.tryRemoveModifier(modifier.getId());
}
}
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import com.minelittlepony.util.MotionCompositor;
import com.minelittlepony.common.util.animation.MotionCompositor;
import net.minecraft.util.math.Vec3d;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import com.minelittlepony.unicopia.ability.HeightPredicate;
import com.minelittlepony.unicopia.magic.Spell;

View file

@ -1,14 +1,12 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import java.util.Iterator;
import java.util.Map;
import com.google.common.collect.Maps;
import com.minelittlepony.unicopia.container.HeavyInventory;
import com.minelittlepony.unicopia.item.MagicGemItem;
import com.minelittlepony.unicopia.magic.item.AddictiveMagicitem;
import com.minelittlepony.unicopia.magic.item.MagicItem;
import com.minelittlepony.unicopia.magic.AffineItem;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.world.container.HeavyInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -20,7 +18,7 @@ import net.minecraft.util.Tickable;
import net.minecraft.util.registry.Registry;
public class PlayerInventory implements Tickable, NbtSerialisable {
private final Map<AddictiveMagicitem, Entry> dependencies = Maps.newHashMap();
private final Map<AffineItem, Entry> dependencies = Maps.newHashMap();
private final Pony player;
@ -36,7 +34,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
*
* Bad things might happen when it's removed.
*/
public synchronized void enforceDependency(AddictiveMagicitem item) {
public synchronized void enforceDependency(AffineItem item) {
if (dependencies.containsKey(item)) {
dependencies.get(item).reinforce();
} else {
@ -47,7 +45,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
/**
* Returns how long the player has been wearing the given item.
*/
public synchronized int getTicksAttached(AddictiveMagicitem item) {
public synchronized int getTicksAttached(AffineItem item) {
if (dependencies.containsKey(item)) {
return dependencies.get(item).ticksAttached;
}
@ -60,7 +58,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
*
* Zero means not dependent at all / not wearing.
*/
public synchronized float getNeedfulness(AddictiveMagicitem item) {
public synchronized float getNeedfulness(AffineItem item) {
if (dependencies.containsKey(item)) {
return dependencies.get(item).needfulness;
}
@ -72,10 +70,10 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
public synchronized void tick() {
carryingWeight = HeavyInventory.getContentsTotalWorth(player.getOwner().inventory, false);
Iterator<Map.Entry<AddictiveMagicitem, Entry>> iterator = dependencies.entrySet().iterator();
Iterator<Map.Entry<AffineItem, Entry>> iterator = dependencies.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<AddictiveMagicitem, Entry> entry = iterator.next();
Map.Entry<AffineItem, Entry> entry = iterator.next();
Entry item = entry.getValue();
@ -90,14 +88,14 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
/**
* Checks if the player is wearing the specified magical artifact.
*/
public boolean isWearing(MagicItem item) {
public boolean isWearing(AffineItem item) {
for (ItemStack i : player.getOwner().getArmorItems()) {
if (!i.isEmpty() && i.getItem() == item) {
return true;
}
}
return item instanceof MagicGemItem;
return item.alwaysActive();
}
public boolean matches(Tag<Item> tag) {
@ -147,13 +145,13 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
float needfulness = 1;
AddictiveMagicitem item;
AffineItem item;
Entry() {
}
Entry(AddictiveMagicitem key) {
Entry(AffineItem key) {
this.item = key;
}
@ -186,7 +184,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
Item item = Registry.ITEM.get(new Identifier(compound.getString("item")));
this.item = item instanceof AddictiveMagicitem ? (AddictiveMagicitem)item : null;
this.item = item instanceof AffineItem ? (AffineItem)item : null;
}
}
}

View file

@ -1,12 +1,12 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import java.util.HashMap;
import java.util.Map;
import com.minelittlepony.unicopia.enchanting.PageOwner;
import com.minelittlepony.unicopia.enchanting.PageState;
import com.minelittlepony.unicopia.util.Copieable;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.world.recipe.enchanting.PageOwner;
import com.minelittlepony.unicopia.world.recipe.enchanting.PageState;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Identifier;

View file

@ -1,11 +1,11 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import java.util.Random;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.FlightPredicate;
import com.minelittlepony.unicopia.entity.EntityPhysics;
import com.minelittlepony.unicopia.equine.EntityPhysics;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.NbtSerialisable;
@ -105,7 +105,7 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
entity.abilities.allowFlying = checkCanFly();
if (!creative) {
entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.onGround && !entity.isTouchingWater();
entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.isOnGround() && !entity.isTouchingWater();
}
isFlying = entity.abilities.flying && !creative;
@ -174,9 +174,9 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
}
if (pony.getPhysics().isGravityNegative()) {
entity.onGround = !entity.world.isAir(new BlockPos(entity.getX(), entity.getY() + entity.getHeight() + 0.5F, entity.getZ()));
entity.setOnGround(!entity.world.isAir(new BlockPos(entity.getX(), entity.getY() + entity.getHeight() + 0.5F, entity.getZ())));
if (entity.onGround) {
if (entity.isOnGround()) {
entity.abilities.flying = false;
isFlying = false;
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.entity.player;
package com.minelittlepony.unicopia.equine.player;
import javax.annotation.Nullable;
@ -7,16 +7,15 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
import com.minelittlepony.unicopia.ducks.PonyContainer;
import com.minelittlepony.unicopia.enchanting.PageOwner;
import com.minelittlepony.unicopia.entity.Physics;
import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.entity.Trap;
import com.minelittlepony.unicopia.equine.Physics;
import com.minelittlepony.unicopia.equine.Ponylike;
import com.minelittlepony.unicopia.equine.Trap;
import com.minelittlepony.unicopia.magic.AffineItem;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.HeldSpell;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.item.MagicItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.EffectSync;
@ -25,13 +24,14 @@ import com.minelittlepony.unicopia.network.Transmittable;
import com.minelittlepony.unicopia.toxin.Toxicity;
import com.minelittlepony.unicopia.toxin.Toxin;
import com.minelittlepony.unicopia.util.Copieable;
import com.minelittlepony.util.BasicEasingInterpolator;
import com.minelittlepony.util.IInterpolator;
import com.minelittlepony.unicopia.world.recipe.enchanting.PageOwner;
import com.minelittlepony.common.util.animation.LinearInterpolator;
import com.minelittlepony.common.util.animation.Interpolator;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Either;
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
@ -41,6 +41,7 @@ import net.minecraft.entity.player.PlayerEntity.SleepFailureReason;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand;
@ -67,7 +68,7 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
private final EffectSync effectDelegate = new EffectSync(this, EFFECT);
private final EffectSync heldEffectDelegate = new EffectSync(this, HELD_EFFECT);
private final IInterpolator interpolator = new BasicEasingInterpolator();
private final Interpolator interpolator = new LinearInterpolator();
private float nextStepDistance = 1;
@ -84,8 +85,10 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
player.getDataTracker().startTracking(RACE, Race.EARTH.ordinal());
player.getDataTracker().startTracking(EFFECT, new CompoundTag());
player.getDataTracker().startTracking(HELD_EFFECT, new CompoundTag());
}
player.getAttributes().register(PlayerAttributes.EXTENDED_REACH_DISTANCE);
public static void registerAttributes(DefaultAttributeContainer.Builder builder) {
builder.add(PlayerAttributes.EXTENDED_REACH_DISTANCE);
}
@Override
@ -183,7 +186,7 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
return camera;
}
public IInterpolator getInterpolator() {
public Interpolator getInterpolator() {
return interpolator;
}
@ -239,7 +242,7 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
HeldSpell effect = getHeldSpell(stack);
if (effect != null) {
Affinity affinity = stack.getItem() instanceof MagicItem ? ((MagicItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
Affinity affinity = stack.getItem() instanceof AffineItem ? ((AffineItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
effect.updateInHand(this, affinity);
}
@ -312,7 +315,7 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
if (getInventory().matches(UTags.CURSED_ARTEFACTS)) {
if (!isClient()) {
entity.addChatMessage(new TranslatableText("tile.bed.youAreAMonster"), true);
entity.sendMessage(new TranslatableText("tile.bed.youAreAMonster"), true);
}
return Either.left(SleepFailureReason.OTHER_PROBLEM);
}

View file

@ -1,11 +1,10 @@
package com.minelittlepony.unicopia.magic.item;
package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.equine.player.Pony;
import net.minecraft.item.ItemStack;
public interface MagicItem extends Affine {
public interface AffineItem extends Affine {
/**
* Gets the affinity of this magical artifact. Either good, bad, or unaligned.
* What this returns may have effects on the behaviour of certain spells and effects.
@ -13,4 +12,10 @@ public interface MagicItem extends Affine {
default Affinity getAffinity(ItemStack stack) {
return getAffinity();
}
default void onRemoved(Pony player, float needfulness) {
}
boolean alwaysActive();
}

View file

@ -29,9 +29,7 @@ public enum Affinity {
}
public Text getName() {
Text text = new TranslatableText("affinity." + getTranslationKey());
text.getStyle().setColor(getColourCode());
return text;
return new TranslatableText("affinity." + getTranslationKey()).styled(s -> s.withColor(getColourCode()));
}
public int getCorruption() {

View file

@ -7,8 +7,7 @@ import java.util.stream.Stream;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.AwaitTickQueue;
import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.entity.Owned;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.particles.ParticleSource;
import com.minelittlepony.unicopia.util.VecHelper;
@ -24,7 +23,7 @@ import net.minecraft.world.World;
/**
* Interface for any magically capable entities that can cast and persist spells.
*/
public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affine, IMagicals, ParticleSource {
public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affine, Magical, ParticleSource {
EffectSync getPrimarySpellSlot();

View file

@ -8,7 +8,6 @@ import javax.annotation.Nullable;
import com.google.common.collect.Streams;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.ducks.PonyContainer;
import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import net.minecraft.entity.Entity;
@ -75,7 +74,7 @@ public class CasterUtils {
return Optional.of((Caster<?>)entity);
}
if (entity instanceof LivingEntity && !(entity instanceof IMagicals)) {
if (entity instanceof LivingEntity && !(entity instanceof Magical)) {
return PonyContainer.of(entity).map(PonyContainer::getCaster);
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
/**
* Represents a passive spell that does something when held in the player's hand.

View file

@ -1,9 +1,9 @@
package com.minelittlepony.unicopia.entity;
package com.minelittlepony.unicopia.magic;
/**
* Any entities with magical abilities.
* Casters are automatically considered magic, for obvious reasons.
*/
public interface IMagicals {
public interface Magical {
}

View file

@ -2,12 +2,12 @@ package com.minelittlepony.unicopia.magic;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.ProjectileEntity;
import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import com.minelittlepony.unicopia.util.projectile.Projectile;
import com.minelittlepony.unicopia.util.projectile.Tossable;
import com.minelittlepony.unicopia.world.entity.MagicProjectileEntity;
import com.minelittlepony.unicopia.world.entity.UEntities;
import com.minelittlepony.unicopia.world.item.UItems;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
@ -42,7 +42,7 @@ public interface ThrowableSpell extends Spell, Tossable<Caster<?>> {
* Returns the resulting projectile entity for customization (or null if on the client).
*/
@Nullable
default AdvancedProjectile toss(Caster<?> caster) {
default Projectile toss(Caster<?> caster) {
World world = caster.getWorld();
Entity entity = caster.getOwner();
@ -50,7 +50,7 @@ public interface ThrowableSpell extends Spell, Tossable<Caster<?>> {
world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
if (caster.isLocal()) {
AdvancedProjectile projectile = new ProjectileEntity(UEntities.THROWN_ITEM, world, caster.getOwner());
Projectile projectile = new MagicProjectileEntity(UEntities.THROWN_ITEM, world, caster.getOwner());
projectile.setItem(getCastAppearance(caster));
projectile.setThrowDamage(getThrowDamage(caster));

View file

@ -1,10 +0,0 @@
package com.minelittlepony.unicopia.magic.item;
import com.minelittlepony.unicopia.entity.player.Pony;
/**
* A magical item with addictive properties.
*/
public interface AddictiveMagicitem extends MagicItem {
void onRemoved(Pony player, float needfulness);
}

View file

@ -5,8 +5,9 @@ import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.world.entity.SpellcastEntity;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.world.ServerWorld;

View file

@ -5,7 +5,7 @@ import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.EtherialListener;
@ -73,7 +73,7 @@ public class AttractiveSpell extends ShieldSpell implements EtherialListener {
@Override
protected void applyRadialEffect(Caster<?> source, Entity target, double distance, double radius) {
Vec3d pos = homingPos == null ? source.getOriginVector() : new Vec3d(homingPos);
Vec3d pos = homingPos == null ? source.getOriginVector() : Vec3d.of(homingPos);
double force = 2.5F / distance;

View file

@ -3,16 +3,16 @@ package com.minelittlepony.unicopia.magic.spell;
import java.util.Optional;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.entity.CucoonEntity;
import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.Magical;
import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.util.WorldEvent;
import com.minelittlepony.unicopia.world.block.UBlocks;
import com.minelittlepony.unicopia.world.entity.CucoonEntity;
import com.minelittlepony.unicopia.world.entity.UEntities;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -88,7 +88,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell
if (checkStruggleCondition(caster)) {
previousTrappedPosition = origin;
struggleCounter--;
WorldEvent.DESTROY_BLOCK.play(caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState());
WorldEvent.play(WorldEvent.DESTROY_BLOCK, caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState());
setDirty(true);
}
@ -105,7 +105,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell
double yMotion = entity.getVelocity().y;
if (!entity.onGround && yMotion > 0) {
if (!entity.isOnGround() && yMotion > 0) {
yMotion = 0;
}
entity.setVelocity(0, yMotion, 0);
@ -120,7 +120,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell
entity.hurtTime = 2;
entity.horizontalCollision = true;
entity.collided = true;
entity.verticalCollision = true;
if (entity instanceof PlayerEntity) {
((PlayerEntity)entity).abilities.flying = false;
@ -135,7 +135,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell
onDestroyed(caster);
setDirty(true);
WorldEvent.DESTROY_BLOCK.play(caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState());
WorldEvent.play(WorldEvent.DESTROY_BLOCK, caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState());
}
}
@ -191,7 +191,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell
}
protected boolean canAffect(Entity e) {
return !(e instanceof IMagicals)
return !(e instanceof Magical)
&& e instanceof LivingEntity
&& !e.hasVehicle();
}

View file

@ -1,12 +1,12 @@
package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.EtherialListener;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.world.entity.SpellcastEntity;
import com.minelittlepony.unicopia.util.shape.Line;
import net.minecraft.util.math.Box;

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.magic.spell;
import java.util.Random;
import java.util.function.Consumer;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
@ -12,6 +11,7 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;
import com.minelittlepony.unicopia.world.entity.SpellcastEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.Fertilizable;
@ -129,14 +129,14 @@ public class DarknessSpell extends AbstractLinkedSpell {
}
private void applyLight(Caster<?> source, LivingEntity entity) {
if (entity.getHealth() < entity.getMaximumHealth()) {
if (entity.getHealth() < entity.getMaxHealth()) {
entity.heal(1);
}
}
private void applyDark(Caster<?> source, LivingEntity entity) {
if (isAreaOccupied(source, entity.getPosVector())) {
if (isAreaOccupied(source, entity.getPos())) {
return;
}
@ -144,8 +144,8 @@ public class DarknessSpell extends AbstractLinkedSpell {
entity.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 100, 3));
Vec3d origin = source.getOriginVector();
Vec3d to = entity.getPosVector();
double distance = origin.distanceTo(entity.getPosVector());
Vec3d to = entity.getPos();
double distance = origin.distanceTo(to);
if (entity.world.random.nextInt(30) == 0) {
double appliedForce = distance / 10 + entity.world.random.nextInt(3);
@ -193,7 +193,7 @@ public class DarknessSpell extends AbstractLinkedSpell {
});
source.findAllEntitiesInRange(radius * 1.5F).filter(this::isLightholder).forEach(e -> {
Vec3d pos = shape.computePoint(source.getWorld().random).add(e.getPosVector().add(0, e.getEyeHeight(e.getPose()), 0));
Vec3d pos = shape.computePoint(source.getWorld().random).add(e.getPos().add(0, e.getEyeHeight(e.getPose()), 0));
spawnSphere(source, pos, 0xFFFFFF, 1);
});

View file

@ -6,11 +6,11 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.FlightPredicate;
import com.minelittlepony.unicopia.ability.HeightPredicate;
import com.minelittlepony.unicopia.entity.Owned;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.AttachableSpell;
@ -206,7 +206,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
// Set first because position calculations rely on it
to.age = from.age;
to.removed = from.removed;
to.onGround = from.onGround;
to.setOnGround(from.isOnGround());
if (isAttachedEntity(entity)) {
@ -246,9 +246,9 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
if (to instanceof PlayerEntity) {
PlayerEntity l = (PlayerEntity)to;
l.field_7500 = l.getX();
l.field_7521 = l.getY();
l.field_7499 = l.getZ();
l.capeX = l.getX();
l.capeY = l.getY();
l.capeZ = l.getZ();
}
to.setVelocity(from.getVelocity());
@ -277,11 +277,12 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
l.handSwingProgress = from.handSwingProgress;
l.lastHandSwingProgress = from.lastHandSwingProgress;
l.handSwingTicks = from.handSwingTicks;
l.isHandSwinging = from.isHandSwinging;
l.handSwinging = from.handSwinging;
l.hurtTime = from.hurtTime;
l.deathTime = from.deathTime;
l.field_20347 = from.field_20347;
l.stuckStingerTimer = from.stuckStingerTimer;
l.stuckArrowTimer = from.stuckArrowTimer;
l.setHealth(from.getHealth());
for (EquipmentSlot i : EquipmentSlot.values()) {
@ -549,7 +550,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
}
static abstract class PlayerAccess extends PlayerEntity {
public PlayerAccess() { super(null, null); }
public PlayerAccess() { super(null, null, null); }
static TrackedData<Byte> getModelBitFlag() {
return PLAYER_MODEL_PARTS;
}

View file

@ -3,16 +3,16 @@ package com.minelittlepony.unicopia.magic.spell;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.Magical;
import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.blockstate.StateMaps;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;
@ -120,7 +120,7 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe
if (id != Blocks.AIR) {
if (id == Blocks.ICE || id == Blocks.PACKED_ICE) {
world.setBlockState(pos, (world.dimension.doesWaterVaporize() ? Blocks.AIR : Blocks.WATER).getDefaultState());
world.setBlockState(pos, (world.getDimension().isUltrawarm() ? Blocks.AIR : Blocks.WATER).getDefaultState());
playEffect(world, pos);
return true;
@ -139,14 +139,14 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe
sendPower(world, pos, power, 3, 0);
return true;
} else if (state.matches(BlockTags.SAND) && world.random.nextInt(10) == 0) {
} else if (state.isIn(BlockTags.SAND) && world.random.nextInt(10) == 0) {
if (isSurroundedBySand(world, pos)) {
world.setBlockState(pos, Blocks.GLASS.getDefaultState());
playEffect(world, pos);
return true;
}
} else if (state.matches(BlockTags.LEAVES)) {
} else if (state.isIn(BlockTags.LEAVES)) {
if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
world.setBlockState(pos.up(), Blocks.FIRE.getDefaultState());
@ -178,7 +178,7 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe
protected boolean applyEntitySingle(Entity owner, World world, Entity e) {
if ((!e.equals(owner) ||
(owner instanceof PlayerEntity && !EquinePredicates.PLAYER_UNICORN.test(owner))) && !(e instanceof ItemEntity)
&& !(e instanceof IMagicals)) {
&& !(e instanceof Magical)) {
e.setOnFireFor(60);
e.damage(getDamageCause(e, (LivingEntity)owner), 0.1f);
playEffect(world, e.getBlockPos());

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.HeldSpell;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.HeldSpell;

View file

@ -2,8 +2,6 @@ package com.minelittlepony.unicopia.magic.spell;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.block.UMaterials;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster;
@ -12,8 +10,10 @@ import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.blockstate.StateMaps;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;
import com.minelittlepony.unicopia.world.block.UMaterials;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -122,7 +122,7 @@ public class IceSpell extends AbstractRangedAreaSpell implements Useable, Dispen
world.setBlockState(pos, converted, 3);
} else if (state.getMaterial() != UMaterials.CLOUD && world.isTopSolid(pos, owner)
|| (id == Blocks.SNOW)
|| state.matches(BlockTags.LEAVES)) {
|| state.isIn(BlockTags.LEAVES)) {
incrementIce(world, pos.up());
} else if (state.getMaterial() == Material.ICE && world.random.nextInt(10) == 0) {
if (isSurroundedByIce(world, pos)) {

View file

@ -1,10 +1,10 @@
package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.blockstate.StateMaps;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;

View file

@ -24,7 +24,7 @@ public class NecromancySpell extends AbstractRangedAreaSpell {
private final List<EntityType<? extends LivingEntity>> spawns = Lists.newArrayList(
EntityType.ZOMBIE,
EntityType.HUSK,
EntityType.ZOMBIE_PIGMAN
EntityType.ZOMBIFIED_PIGLIN
);
@Override
@ -91,7 +91,7 @@ public class NecromancySpell extends AbstractRangedAreaSpell {
zombie.setVelocity(0, 0.3, 0);
WorldEvent.DOOR_BROKEN.play(source.getWorld(), zombie.getBlockPos());
source.getWorld().syncWorldEvent(WorldEvent.ZOMBIE_BREAK_WOODEN_DOOR, zombie.getBlockPos(), 0);
source.getWorld().spawnEntity(zombie);
}

View file

@ -6,18 +6,18 @@ import java.util.UUID;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.Magical;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;
import com.minelittlepony.unicopia.world.entity.SpellcastEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
@ -185,7 +185,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
}
protected boolean canTeleport(Entity i) {
return !(i instanceof IMagicals) && i.netherPortalCooldown == 0;
return !(i instanceof Magical) && i.netherPortalCooldown == 0;
}
protected void teleportEntity(Caster<?> source, PortalSpell dest, Entity i) {

View file

@ -2,13 +2,13 @@ package com.minelittlepony.unicopia.magic.spell;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
import com.minelittlepony.unicopia.util.blockstate.StateMaps;
import com.minelittlepony.unicopia.util.projectile.Projectile;
import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.block.BlockState;
@ -67,8 +67,8 @@ public class ScorchSpell extends FireSpell implements ThrowableSpell {
@Override
@Nullable
public AdvancedProjectile toss(Caster<?> caster) {
AdvancedProjectile projectile = ThrowableSpell.super.toss(caster);
public Projectile toss(Caster<?> caster) {
Projectile projectile = ThrowableSpell.super.toss(caster);
if (projectile != null) {
projectile.setGravity(false);

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