Back to basics: strip away anything that's not the core of the mod

This commit is contained in:
Sollace 2020-09-22 15:11:20 +02:00
parent 94eef4f43a
commit c1fb88faae
851 changed files with 506 additions and 22435 deletions

BIN
book.xcf

Binary file not shown.

View file

@ -3,20 +3,20 @@ org.gradle.daemon=false
# Fabric Properties
# 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
minecraft_version=1.16.2
yarn_mappings=1.16.2+build.19:v2
loader_version=0.9.1+build.205
fabric_version=0.18.0+build.397-1.16
# Mod Properties
group=com.minelittlepony
displayname=Unicopia
authors=Sollace
description=Magical Abilities for Mine Little Pony!
version=0.4
version=1
release=SNAPSHOT
# Dependencies
modmenu_version=1.12.+
minelp_version=4.1-1.16-rc1-1.16
kirin_version=1.6.4-1.16-rc1-1.16
minelp_version=4.2.1-1.16.2-SNAPSHOT
kirin_version=1.7.1-1.16.2-SNAPSHOT

View file

@ -1,128 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="241.44592mm"
height="241.44592mm"
viewBox="0 0 241.44592 241.44592"
version="1.1"
id="svg8"
sodipodi:docname="rainbow.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<defs
id="defs2">
<mask
maskUnits="userSpaceOnUse"
id="mask891">
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M -3.7233945,214.15447 C 45.480637,96.633673 161.83001,111.85648 220.14571,211.36193"
id="path893"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</mask>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath927">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M -4.2783609,209.45815 C 27.595941,225.58204 39.492563,194.31934 40.808982,191.6865 42.1254,189.05366 66.479153,155.81408 104.9844,160.09245 c 38.50525,4.27836 79.31422,47.39107 81.94706,53.64406 2.63284,6.25299 17.44255,5.59478 33.56868,-5.59478 C 236.62627,196.95217 196.9884,109.17656 107.94634,104.47375 18.904283,99.770936 -36.152661,193.33426 -4.2783609,209.45815 Z"
id="path929"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zzzzzzz" />
</clipPath>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="0.56847767"
inkscape:cx="446.57708"
inkscape:cy="401.19458"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
objecttolerance="1"
inkscape:window-width="1600"
inkscape:window-height="837"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(16.892626,19.317423)">
<g
id="g889"
mask="url(#mask891)"
clip-path="url(#clipPath927)">
<g
id="g937">
<path
style="fill:none;fill-rule:evenodd;stroke:#ff5a5a;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M -3.7233944,214.15447 C 45.480638,96.63367 161.83001,111.85648 220.14571,211.36193"
id="path823-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ff9e5a;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M -0.7614527,220.40746 C 56.341093,103.87397 159.19717,123.04604 217.51287,222.55149"
id="path823-5-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffbe80;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1.5789981,231.68901 C 58.681549,115.15552 152.6518,129.72013 210.9675,229.22558"
id="path823-5-1-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#f7ff80;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 9.1484066,236.95589 C 66.250956,120.4224 152.32269,142.88552 210.63839,242.39096"
id="path823-5-1-5-4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#80c9ff;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.401395,246.03534 C 72.503944,129.50186 146.72791,151.63588 205.04361,251.14131"
id="path823-5-1-5-4-8"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#be80ff;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 22.806252,250.84622 C 75.30134,134.64185 142.6141,162.04155 200.9298,261.54697"
id="path823-5-1-5-4-8-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -8,6 +8,7 @@ import java.util.Queue;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
public class AwaitTickQueue {
@ -22,13 +23,11 @@ public class AwaitTickQueue {
}
}
static void tick(World world) {
if (!world.isClient) {
synchronized (LOCKER) {
final Queue<Entry> tasks = new ArrayDeque<>();
PENDING_TASKS = PENDING_TASKS.stream().filter(e -> e.tick(world, tasks)).collect(Collectors.toList());
tasks.forEach(e -> e.run(world));
}
static void tick(ServerWorld world) {
synchronized (LOCKER) {
final Queue<Entry> tasks = new ArrayDeque<>();
PENDING_TASKS = PENDING_TASKS.stream().filter(e -> e.tick(world, tasks)).collect(Collectors.toList());
tasks.forEach(e -> e.run(world));
}
}

View file

@ -2,37 +2,18 @@ package com.minelittlepony.unicopia;
import java.util.function.Predicate;
import com.minelittlepony.unicopia.equine.Ponylike;
import com.minelittlepony.unicopia.world.block.gas.Gas;
import com.minelittlepony.unicopia.world.entity.CloudEntity;
import com.minelittlepony.unicopia.entity.Equine;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
public interface EquinePredicates {
Predicate<Entity> IS_CLOUD = e -> e instanceof CloudEntity;
Predicate<Entity> IS_PLAYER = e -> e instanceof PlayerEntity;
Predicate<Entity> IS_VALID_ITEM = entity -> entity instanceof ItemEntity && entity.isAlive() && entity.age > 1;
Predicate<Entity> RACE_INTERACT_WITH_CLOUDS = entity -> Ponylike.of(entity).getSpecies().canInteractWithClouds();
Predicate<Entity> RACE_INTERACT_WITH_CLOUDS = entity -> Equine.of(entity).getSpecies().canInteractWithClouds();
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(entity -> Ponylike.of(entity).getSpecies().canCast());
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(entity -> Ponylike.of(entity).getSpecies() == Race.CHANGELING);
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(entity -> Equine.of(entity).getSpecies().canCast());
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(entity -> Equine.of(entity).getSpecies() == Race.CHANGELING);
Predicate<Entity> PLAYER_PEGASUS = IS_PLAYER.and(entity -> ((PlayerEntity)entity).abilities.creativeMode || RACE_INTERACT_WITH_CLOUDS.test(entity));
Predicate<Entity> ITEM_INTERACT_WITH_CLOUDS = IS_VALID_ITEM.and(RACE_INTERACT_WITH_CLOUDS.or(e -> {
return CloudEntity.getFeatherEnchantStrength(((ItemEntity)e).getStack()) > 0
|| (((ItemEntity)e).getStack().getItem() instanceof BlockItem
&& ((BlockItem)((ItemEntity)e).getStack().getItem()).getBlock() instanceof Gas);
}));
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = PLAYER_PEGASUS.or(ITEM_INTERACT_WITH_CLOUDS);
Predicate<Entity> ENTITY_WALK_ON_CLOUDS = entity -> entity instanceof LivingEntity && CloudEntity.getFeatherEnchantStrength((LivingEntity)entity) > 0;
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUD_BLOCKS = IS_CLOUD.or(PLAYER_PEGASUS).or(ENTITY_WALK_ON_CLOUDS).or(ITEM_INTERACT_WITH_CLOUDS).or(entity -> {
return entity != null && EquinePredicates.ENTITY_INTERACT_WITH_CLOUD_BLOCKS.test(entity.getVehicle());
});
}

View file

@ -1,12 +0,0 @@
package com.minelittlepony.unicopia;
/**
* This interface is for any entities that are categorised as inanimated,
* or part of a terrain effect.
*
* These typically can't be interacted with by players unless under certain cirumstances.
*
*/
public interface InAnimate {
boolean canInteract(Race race);
}

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.util.dummy.DummyPlayerEntity;
import com.minelittlepony.unicopia.util.dummy.DummyServerPlayerEntity;
import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity;
import com.minelittlepony.unicopia.entity.player.dummy.DummyServerPlayerEntity;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.Entity;

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;

View file

@ -0,0 +1,25 @@
package com.minelittlepony.unicopia;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public interface UEntities {
EntityType<MagicProjectileEntity> THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.<MagicProjectileEntity>create(SpawnGroup.MISC, MagicProjectileEntity::new)
.trackable(100, 2)
.dimensions(EntityDimensions.fixed(0.25F, 0.25F)));
static <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
EntityType<T> type = builder.build();
return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), type);
}
static void bootstrap() {}
}

View file

@ -6,35 +6,9 @@ import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
public interface UTags {
Tag<Item> CURSED_ARTEFACTS = register("cursed_artefacts");
Tag<Item> HAMMERPACE_IMMUNE = register("hammerspace_immune");
Tag<Item> APPLES = register("apples");
Tag<Item> FRESH_TOMATOES = register("fresh_tomatoes");
Tag<Item> FESH_APPLES = register("fresh_apples");
Tag<Item> SHARDS = register("shards");
Tag<Item> SHELLS = register("shells");
Tag<Item> FIRE_ELEMENTALS = register("fire_elementals");
Tag<Item> ICE_ELEMENTALS = register("ice_elementals");
Tag<Item> LIGHT_ELEMENTALS = register("light_elementals");
Tag<Item> DARK_ELEMENTALS = register("dark_elementals");
Tag<Item> LIFE_ELEMENTALS = register("life_elementals");
Tag<Item> ROTTING_ELEMENTALS = register("rotting_elementals");
Tag<Item> BLOOD_ELEMENTALS = register("death_elementals");
Tag<Item> UNALIGNED = register("harmonic_elementals");
Tag<Item> SIGHT_ELEMENTALS = register("sight_elementals");
Tag<Item> SOUND_ELEMENTALS = register("sound_elementals");
Tag<Item> MAGIC_ENERGIC = register("knowledge_elementals");
Tag<Item> APPLE_BLOOM_SPIRIT = register("apple_bloom_spirit");
Tag<Item> SCOOTALOO_SPIRIT = register("scootaloo_spirit");
Tag<Item> SWEETIE_BELLE_SPIRIT = register("sweetie_belle_spirit");
Tag<Item> NON_TOXIC = register("non_toxic");
Tag<Item> FAIRLY_TOXIC = register("fairly_toxic");
Tag<Item> SEVERELY_TOXIC = register("severely_toxic");

View file

@ -1,13 +1,13 @@
package com.minelittlepony.unicopia;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.minelittlepony.unicopia.command.Commands;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.world.UnicopiaWorld;
public class Unicopia implements ModInitializer {
@ -32,8 +32,8 @@ public class Unicopia implements ModInitializer {
UTags.bootstrap();
Commands.bootstrap();
WorldTickCallback.EVENT.register(AwaitTickQueue::tick);
ServerTickEvents.END_WORLD_TICK.register(AwaitTickQueue::tick);
UnicopiaWorld.bootstrap();
UItems.bootstrap();
}
}

View file

@ -25,13 +25,9 @@ public interface Abilities {
// pegasus / bat / alicorn / changeling
Ability<?> CARRY = register(new CarryAbility(), "carry", AbilitySlot.PASSIVE);
// pegasus / alicorn
Ability<?> CLOUD = register(new PegasusCloudInteractionAbility(), "cloud", AbilitySlot.TERTIARY);
// changeling
Ability<?> DISGUISE = register(new ChangelingDisguiseAbility(), "disguise", AbilitySlot.PRIMARY);
Ability<?> FEED = register(new ChangelingFeedAbility(), "feed", AbilitySlot.SECONDARY);
//Ability<?> TRAP = register(new ChangelingTrapAbility(), "trap", AbilitySlot.TERTIARY);
static <T extends Ability<?>> T register(T power, String name, AbilitySlot slot) {
Identifier id = new Identifier("unicopia", name);

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.equine.player.Pony;
import com.minelittlepony.unicopia.entity.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.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.util.NbtSerialisable;

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.entity.Entity;

View file

@ -3,12 +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.equine.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.BlockState;
@ -59,8 +57,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
.orElse(looked);
}
if (looked instanceof LightningEntity
|| (looked instanceof InAnimate && !((InAnimate)looked).canInteract(Race.CHANGELING))) {
if (looked instanceof LightningEntity) {
looked = null;
}
}

View file

@ -7,9 +7,9 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.particles.ParticleUtils;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.VecHelper;
@ -117,7 +117,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
}
public float drainFrom(PlayerEntity changeling, LivingEntity living) {
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", changeling);
DamageSource d = MagicalDamageSource.create("feed", changeling);
float damage = living.getHealth()/2;

View file

@ -3,8 +3,8 @@ 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.equine.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.BlockState;

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.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper;
@ -109,7 +109,7 @@ public class EarthPonyStompAbility implements Ability<Multi> {
player.addVelocity(0, -(ppos.getSquaredDistance(pos)), 0);
iplayer.getWorld().getEntities(player, areaOfEffect.offset(iplayer.getOriginVector())).forEach(i -> {
iplayer.getWorld().getOtherEntities(player, areaOfEffect.offset(iplayer.getOriginVector())).forEach(i -> {
double dist = Math.sqrt(pos.getSquaredDistance(i.getBlockPos()));
if (dist <= rad + 3) {
@ -119,7 +119,7 @@ public class EarthPonyStompAbility implements Ability<Multi> {
-(player.getY() - i.getY() - 2) / force + (dist < 1 ? dist : 0),
-(player.getZ() - i.getZ()) / force);
DamageSource damage = MagicalDamageSource.causePlayerDamage("smash", player);
DamageSource damage = MagicalDamageSource.create("smash", player);
double amount = (4 * player.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE).getValue()) / (float)dist;

View file

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

View file

@ -1,81 +0,0 @@
package com.minelittlepony.unicopia.ability;
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.equine.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.entity.Entity;
public class PegasusCloudInteractionAbility implements Ability<Numeric> {
@Override
public int getWarmupTime(Pony player) {
return 10;
}
@Override
public int getCooldownTime(Pony player) {
return 5;
}
@Override
public boolean canUse(Race race) {
return race.canInteractWithClouds();
}
@Override
public Numeric tryActivate(Pony player) {
return findTarget(player).map(cloud -> {
Numeric data = new Numeric(player.getOwner().inventory.selectedSlot + 1);
cloud.handlePegasusInteration(data.type);
return data;
}).orElse(null);
}
@Override
public Hit.Serializer<Numeric> getSerializer() {
return Numeric.SERIALIZER;
}
@Override
public void apply(Pony player, Numeric data) {
findTarget(player).ifPresent(cloud -> {
cloud.handlePegasusInteration(data.type);
});
}
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 Interactable) {
return Optional.of((Interactable)e);
}
return Optional.empty();
}
@Override
public void preApply(Pony player, AbilitySlot slot) {
player.spawnParticles(MagicParticleEffect.UNICORN, 10);
}
@Override
public void postApply(Pony player, AbilitySlot slot) {
player.spawnParticles(UParticles.RAIN_DROPS, 5);
}
public interface Interactable {
void handlePegasusInteration(int interationType);
}
}

View file

@ -3,10 +3,10 @@ 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.equine.player.Pony;
import com.minelittlepony.unicopia.magic.spell.ShieldSpell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.ability.magic.spell.ShieldSpell;
import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
/**
* A magic casting ability for unicorns.

View file

@ -3,8 +3,8 @@ 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.equine.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.Block;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
/**
* Interface for things that have an affine alignment.

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
/**
* A magic effect that does something when attached to an entity.

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
import java.util.Optional;
import java.util.UUID;
@ -6,10 +6,9 @@ import java.util.stream.Stream;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.AwaitTickQueue;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.particles.ParticleSource;
import com.minelittlepony.unicopia.particle.ParticleSource;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.entity.Entity;
@ -128,31 +127,18 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
default boolean subtractEnergyCost(double amount) {
getOwner().damage(DamageSource.MAGIC, (int)amount/2);
return getOwner().getHealth() > 0;
}
default Stream<Caster<?>> findAllSpellsInRange(double radius) {
return CasterUtils.findAllSpellsInRange(this, radius);
return CasterUtils.findInRange(this, radius);
}
default Stream<Caster<?>> findAllSpellsInRange(Box bb) {
return CasterUtils.findAllSpellsInRange(this, bb);
return CasterUtils.findInRange(this, bb);
}
default Stream<Entity> findAllEntitiesInRange(double radius) {
return VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), getOrigin(), radius);
}
default void notifyNearbySpells(Spell sender, BlockPos origin, double radius, int newState) {
AwaitTickQueue.scheduleTask(getWorld(), w -> {
VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), origin, radius)
.filter(i -> i instanceof EtherialListener)
.forEach(i -> ((EtherialListener)i).onNearbySpellChange(this, sender, newState));
}, 0);
}
default void notifyNearbySpells(Spell sender, double radius, int newState) {
notifyNearbySpells(sender, getOrigin(), radius, newState);
}
}

View file

@ -1,14 +1,12 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
import java.util.Optional;
import java.util.stream.Stream;
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.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.entity.PonyContainer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@ -20,7 +18,7 @@ public class CasterUtils {
/**
* Finds all surrounding spells withing range from the given caster.
*/
public static Stream<Caster<?>> findAllSpellsInRange(Caster<?> source, double radius) {
public static Stream<Caster<?>> findInRange(Caster<?> source, double radius) {
BlockPos origin = source.getOrigin();
@ -29,7 +27,7 @@ public class CasterUtils {
Box bb = new Box(begin, end);
return source.getWorld().getEntities(source.getEntity(), bb, e ->
return source.getWorld().getOtherEntities(source.getEntity(), bb, e ->
!e.removed && (e instanceof Caster || e instanceof PlayerEntity)
).stream().filter(e -> {
double dist = e.squaredDistanceTo(origin.getX(), origin.getY(), origin.getZ());
@ -42,30 +40,13 @@ public class CasterUtils {
.map(Optional::get);
}
static Stream<Caster<?>> findAllSpellsInRange(Caster<?> source, Box bb) {
return source.getWorld().getEntities(source.getEntity(), bb, e -> !e.removed && (e instanceof Caster || EquinePredicates.PLAYER_UNICORN.test(e))).stream()
static Stream<Caster<?>> findInRange(Caster<?> source, Box bb) {
return source.getWorld().getOtherEntities(source.getEntity(), bb, e -> !e.removed && (e instanceof Caster || EquinePredicates.PLAYER_UNICORN.test(e))).stream()
.map(CasterUtils::toCaster)
.filter(o -> o.isPresent() && o.get() != source)
.map(Optional::get);
}
static <T extends Spell> Optional<T> toMagicEffect(Class<T> type, @Nullable Entity entity) {
return toCaster(entity)
.filter(Caster::hasSpell)
.map(caster -> caster.getSpell(type, false))
.filter(e -> !e.isDead());
}
/**
* Determines if the passed in entity is holding the named effect.
* By holding that meant the effect must be attached to the caster associated with the entity.
*/
public static boolean isHoldingEffect(String effectName, Entity entity) {
return Streams.stream(entity.getArmorItems())
.map(SpellRegistry::getKeyFromStack)
.anyMatch(s -> s.equals(effectName));
}
/**
* Attempts to convert the passed entity into a caster using all the known methods.
*/

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
/**
* Object with levelling capabilities.

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
/**
* Any entities with magical abilities.

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.entity.projectile.ProjectileEntity;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
/**
* Magic effects that can be suppressed by other nearby effects.

View file

@ -1,28 +1,43 @@
package com.minelittlepony.unicopia.magic;
package com.minelittlepony.unicopia.ability.magic;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
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 com.minelittlepony.unicopia.UEntities;
import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.projectile.Projectile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* Magic effects that can be thrown.
*/
public interface ThrowableSpell extends Spell, Tossable<Caster<?>> {
public interface ThrowableSpell extends Spell {
@Override
/**
* Called once the projectile lands either hitting the ground or an entity.
*/
void onImpact(Caster<?> caster, BlockPos pos, BlockState state);
/**
* The amount of damage to be dealt when the projectile collides with an entity.
*/
default int getThrowDamage(Caster<?> stack) {
return 0;
}
/**
* The sound made when thrown.
*/
default SoundEvent getThrowSound(Caster<?> caster) {
return SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
}
@ -31,7 +46,7 @@ public interface ThrowableSpell extends Spell, Tossable<Caster<?>> {
* Gets the appearance to be used when projecting this spell.
*/
default ItemStack getCastAppearance(Caster<?> caster) {
Item item = getAffinity() == Affinity.BAD ? UItems.CORRUPTED_GEM : UItems.GEM;
Item item = getAffinity() == Affinity.BAD ? Items.MAGMA_CREAM : Items.SNOWBALL;
return SpellRegistry.instance().enchantStack(new ItemStack(item), getName());
}

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.AttachableSpell;
import com.minelittlepony.unicopia.ability.magic.Caster;
public abstract class AbstractRangedAreaSpell extends AbstractSpell implements AttachableSpell {

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Spell;
import net.minecraft.nbt.CompoundTag;

View file

@ -1,16 +1,14 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
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;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.VecHelper;
@ -24,7 +22,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class AttractiveSpell extends ShieldSpell implements EtherialListener {
public class AttractiveSpell extends ShieldSpell {
@Nullable
private BlockPos homingPos;
@ -102,22 +100,6 @@ public class AttractiveSpell extends ShieldSpell implements EtherialListener {
target.setVelocity(x, y, z);
}
@Override
public void onNearbySpellChange(Caster<?> source, Spell effect, int newState) {
if (effect instanceof ChargingSpell && !isDead()) {
if (newState == ADDED) {
if (homingPos == null) {
homingPos = source.getOrigin();
}
setDirty(true);
} else if (homingPos.equals(source.getOrigin())) {
setDead();
setDirty(true);
source.notifyNearbySpells(this, 5, REMOVED);
}
}
}
@Override
public void toNBT(CompoundTag compound) {
super.toNBT(compound);

View file

@ -1,25 +1,16 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.ThrowableSpell;
import com.minelittlepony.unicopia.util.shape.Sphere;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.particle.ParticleTypes;
@ -28,9 +19,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
public class AwkwardSpell extends AbstractSpell implements ThrowableSpell, Useable {
public class AwkwardSpell extends AbstractSpell implements ThrowableSpell {
@Override
public String getName() {
@ -86,16 +76,4 @@ public class AwkwardSpell extends AbstractSpell implements ThrowableSpell, Useab
// noop
}
@Override
public CastResult onUse(ItemUsageContext context, Affinity affinity) {
return CastResult.PLACE;
}
@Override
public CastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, @Nullable Entity hitEntity) {
CasterUtils.toCaster(player).ifPresent(this::toss);
return CastResult.NONE;
}
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.UUID;
@ -10,16 +10,16 @@ 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.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.Suppressable;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.AttachableSpell;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.CasterUtils;
import com.minelittlepony.unicopia.ability.magic.Spell;
import com.minelittlepony.unicopia.ability.magic.Suppressable;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.entity.SkullBlockEntity;
@ -234,9 +234,9 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
to.prevY = from.prevY;
to.prevZ = from.prevZ;
to.trackedX = from.trackedX;
to.trackedY = from.trackedY;
to.trackedZ = from.trackedZ;
to.chunkX = from.chunkX;
to.chunkY = from.chunkY;
to.chunkZ = from.chunkZ;
to.lastRenderX = from.lastRenderX;
to.lastRenderY = from.lastRenderY;
@ -550,7 +550,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
}
static abstract class PlayerAccess extends PlayerEntity {
public PlayerAccess() { super(null, null, null); }
public PlayerAccess() { super(null, null, 0, null); }
static TrackedData<Byte> getModelBitFlag() {
return PLAYER_MODEL_PARTS;
}

View file

@ -1,18 +1,13 @@
package com.minelittlepony.unicopia.magic.spell;
import javax.annotation.Nullable;
package com.minelittlepony.unicopia.ability.magic.spell;
import com.minelittlepony.unicopia.EquinePredicates;
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.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Magical;
import com.minelittlepony.unicopia.block.state.StateMaps;
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;
@ -26,22 +21,18 @@ import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
/**
* Simple fire spell that triggers an effect when used on a block.
*/
public class FireSpell extends AbstractRangedAreaSpell implements Useable, DispenceableSpell {
public class FireSpell extends AbstractRangedAreaSpell {
private static final Shape VISUAL_EFFECT_RANGE = new Sphere(false, 0.5);
private static final Shape EFFECT_RANGE = new Sphere(false, 4);
@ -63,7 +54,10 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe
@Override
public boolean update(Caster<?> source) {
return false;
return PosHelper.getAllInRegionMutable(source.getOrigin(), EFFECT_RANGE).reduce(false,
(r, i) -> applyBlocks(source.getWorld(), i),
(a, b) -> a || b)
|| applyEntities(null, source.getWorld(), source.getOrigin());
}
@Override
@ -73,47 +67,6 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe
});
}
@Override
public CastResult onUse(ItemUsageContext context, Affinity affinity) {
boolean result = false;
PlayerEntity player = context.getPlayer();
BlockPos pos = context.getBlockPos();
if (player == null || player.isSneaking()) {
result = applyBlocks(context.getWorld(), pos);
} else {
result = PosHelper.getAllInRegionMutable(pos, EFFECT_RANGE).reduce(result,
(r, i) -> applyBlocks(context.getWorld(), i),
(a, b) -> a || b);
}
if (!result) {
result = applyEntities(player, context.getWorld(), pos);
}
return result ? CastResult.DEFAULT : CastResult.NONE;
}
@Override
public CastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, @Nullable Entity hitEntity) {
if (hitEntity == null) {
return CastResult.NONE;
}
return applyEntitySingle(player, world, hitEntity) ? CastResult.DEFAULT : CastResult.NONE;
}
@Override
public CastResult onDispenced(BlockPos pos, Direction facing, BlockPointer source, Affinity affinity) {
pos = pos.offset(facing, 4);
return CastResult.cancelled(PosHelper.getAllInRegionMutable(pos, EFFECT_RANGE).reduce(false,
(r, i) -> applyBlocks(source.getWorld(), i),
(a, b) -> a || b)
|| applyEntities(null, source.getWorld(), pos));
}
protected boolean applyBlocks(World world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
Block id = state.getBlock();
@ -189,7 +142,7 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe
}
protected DamageSource getDamageCause(Entity target, LivingEntity attacker) {
return MagicalDamageSource.causeMobDamage("fire", attacker);
return MagicalDamageSource.create("fire", attacker);
}
/**

View file

@ -1,11 +1,11 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.function.Supplier;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Spell;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
public class GenericSpell extends AbstractSpell {

View file

@ -1,19 +1,13 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import javax.annotation.Nullable;
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.Useable;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.block.state.StateMaps;
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;
@ -21,18 +15,14 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.PlantBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.TntEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public class IceSpell extends AbstractRangedAreaSpell implements Useable, DispenceableSpell {
public class IceSpell extends AbstractRangedAreaSpell {
private final int rad = 3;
private final Shape effect_range = new Sphere(false, rad);
@ -54,65 +44,38 @@ public class IceSpell extends AbstractRangedAreaSpell implements Useable, Dispen
@Override
public boolean update(Caster<?> source) {
return false;
LivingEntity owner = source.getOwner();
PosHelper.getAllInRegionMutable(source.getOrigin(), effect_range)
.forEach(i -> applyBlockSingle(owner, source.getWorld(), i));
return applyEntities(source.getOwner(), source.getWorld(), source.getOrigin());
}
@Override
public void render(Caster<?> source) {
}
@Override
public CastResult onDispenced(BlockPos pos, Direction facing, BlockPointer source, Affinity affinity) {
return applyBlocks(null, source.getWorld(), pos.offset(facing, rad)) ? CastResult.NONE : CastResult.DEFAULT;
}
@Override
public CastResult onUse(ItemUsageContext context, Affinity affinity) {
if (context.getPlayer() != null && context.getPlayer().isSneaking()) {
applyBlockSingle(context.getPlayer(), context.getWorld(), context.getBlockPos());
} else {
applyBlocks(context.getPlayer(), context.getWorld(), context.getBlockPos());
}
return CastResult.DEFAULT;
}
@Override
public CastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, @Nullable Entity hitEntity) {
if (hitEntity != null && applyEntitySingle(player, hitEntity)) {
return CastResult.DEFAULT;
}
return CastResult.NONE;
}
private boolean applyBlocks(PlayerEntity owner, World world, BlockPos pos) {
PosHelper.getAllInRegionMutable(pos, effect_range).forEach(i -> applyBlockSingle(owner, world, i));
return applyEntities(owner, world, pos);
}
protected boolean applyEntities(PlayerEntity owner, World world, BlockPos pos) {
protected boolean applyEntities(LivingEntity owner, World world, BlockPos pos) {
return VecHelper.findAllEntitiesInRange(owner, world, pos, 3).filter(i ->
applyEntitySingle(owner, i)
).count() > 0;
}
protected boolean applyEntitySingle(PlayerEntity owner, Entity e) {
protected boolean applyEntitySingle(LivingEntity owner, Entity e) {
if (e instanceof TntEntity) {
e.remove();
e.getEntityWorld().setBlockState(e.getBlockPos(), Blocks.TNT.getDefaultState());
} else if (e.isOnFire()) {
e.extinguish();
} else {
e.damage(MagicalDamageSource.causePlayerDamage("cold", owner), 2);
e.damage(MagicalDamageSource.create("cold", owner), 2);
}
return true;
}
private void applyBlockSingle(PlayerEntity owner, World world, BlockPos pos) {
private void applyBlockSingle(Entity owner, World world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
Block id = state.getBlock();
@ -120,7 +83,7 @@ public class IceSpell extends AbstractRangedAreaSpell implements Useable, Dispen
if (!state.equals(converted)) {
world.setBlockState(pos, converted, 3);
} else if (state.getMaterial() != UMaterials.CLOUD && world.isTopSolid(pos, owner)
} else if (world.isTopSolid(pos, owner)
|| (id == Blocks.SNOW)
|| state.isIn(BlockTags.LEAVES)) {
incrementIce(world, pos.up());

View file

@ -1,10 +1,9 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.block.state.StateMaps;
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;
@ -12,7 +11,6 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@ -33,11 +31,6 @@ public class InfernoSpell extends FireSpell {
return 0xF00F00;
}
@Override
public CastResult onUse(ItemUsageContext context, Affinity affinity) {
return CastResult.PLACE;
}
@Override
public boolean update(Caster<?> source) {
World w = source.getWorld();
@ -78,8 +71,8 @@ public class InfernoSpell extends FireSpell {
@Override
protected DamageSource getDamageCause(Entity target, LivingEntity attacker) {
if (attacker != null && attacker.getUuid().equals(target.getUuid())) {
return MagicalDamageSource.causeMobDamage("fire.own", null);
return MagicalDamageSource.create("fire.own", null);
}
return MagicalDamageSource.causeMobDamage("fire", attacker);
return MagicalDamageSource.create("fire", attacker);
}
}

View file

@ -1,10 +1,10 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.List;
import com.google.common.collect.Lists;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.WorldEvent;
import com.minelittlepony.unicopia.util.shape.Shape;

View file

@ -1,9 +1,9 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.Suppressable;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Suppressable;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere;
@ -11,7 +11,9 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.Vec3d;
/**
* A spell for revealing changelings.
*/
public class RevealingSpell extends AbstractSpell {
@Override

View file

@ -1,14 +1,14 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import javax.annotation.Nullable;
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.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.ThrowableSpell;
import com.minelittlepony.unicopia.block.state.StateMaps;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.projectile.Projectile;
import com.minelittlepony.unicopia.util.PosHelper;
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;

View file

@ -1,19 +1,18 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.List;
import java.util.stream.Collectors;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.ParticleHandle;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import com.minelittlepony.unicopia.util.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.AttachableSpell;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleHandle;
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.util.shape.Sphere;
import com.minelittlepony.unicopia.world.entity.SpellcastEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@ -76,7 +75,7 @@ public class ShieldSpell extends AbstractRangedAreaSpell implements AttachableSp
}
public double getDrawDropOffRange(Caster<?> source) {
float multiplier = (source.getOwner() instanceof SpellcastEntity || source.getOwner().isSneaking() ? 1 : 2);
float multiplier = (source.getOwner().isSneaking() ? 1 : 2);
return (4 + (source.getCurrentLevel() * 2)) / multiplier;
}

View file

@ -1,12 +1,12 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.List;
import java.util.stream.Collectors;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.shape.Sphere;
@ -17,6 +17,9 @@ import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
/**
* A spell that pulls health from other entities and delivers it to the caster.
*/
public class SiphoningSpell extends AbstractRangedAreaSpell {
@Override
@ -102,7 +105,7 @@ public class SiphoningSpell extends AbstractRangedAreaSpell {
return MagicalDamageSource.create("drain");
}
return MagicalDamageSource.causeMobDamage("drain", actor);
return MagicalDamageSource.create("drain", actor);
}
@Override

View file

@ -1,9 +1,8 @@
package com.minelittlepony.unicopia.magic.spell;
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
@ -11,12 +10,8 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.HeldSpell;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.Spell;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@ -38,16 +33,10 @@ public class SpellRegistry {
register(AttractiveSpell::new);
register(NecromancySpell::new);
register(SiphoningSpell::new);
register(ChargingSpell::new);
register(IceSpell::new);
register(PortalSpell::new);
register(AwkwardSpell::new);
register(InfernoSpell::new);
register(RevealingSpell::new);
register(DarknessSpell::new);
register(FlameSpell::new);
register(GlowingSpell::new);
register(ChangelingTrapSpell::new);
register(ScorchSpell::new);
register(DisguiseSpell::new);
}
@ -89,25 +78,6 @@ public class SpellRegistry {
return compound;
}
private Optional<Entry<?>> getEntryFromStack(ItemStack stack) {
return Optional.ofNullable(entries.get(getKeyFromStack(stack)));
}
@Nullable
public DispenceableSpell getDispenseActionFrom(ItemStack stack) {
return getEntryFromStack(stack).map(Entry::dispensable).orElse(null);
}
@Nullable
public Useable getUseActionFrom(ItemStack stack) {
return getEntryFromStack(stack).map(Entry::useable).orElse(null);
}
@Nullable
public HeldSpell getHeldFrom(ItemStack stack) {
return getEntryFromStack(stack).map(Entry::holdable).orElse(null);
}
@Nullable
public Spell getSpellFrom(ItemStack stack) {
return getSpellFromName(getKeyFromStack(stack));
@ -178,10 +148,6 @@ public class SpellRegistry {
final int color;
final boolean canDispense;
final boolean canUse;
final boolean canHold;
final Affinity affinity;
Entry(Supplier<T> factory) throws Exception {
@ -189,9 +155,6 @@ public class SpellRegistry {
this.factory = factory;
this.color = inst.getTint();
this.canDispense = inst instanceof DispenceableSpell;
this.canUse = inst instanceof Useable;
this.canHold = inst instanceof HeldSpell;
this.affinity = inst.getAffinity();
if (inst.isCraftable()) {
@ -203,30 +166,6 @@ public class SpellRegistry {
entries.put(inst.getName(), this);
}
Useable useable() {
if (!canUse) {
return null;
}
return (Useable)create();
}
HeldSpell holdable() {
if (!canHold) {
return null;
}
return (HeldSpell)create();
}
DispenceableSpell dispensable() {
if (!canDispense) {
return null;
}
return (DispenceableSpell)create();
}
T create() {
try {
return factory.get();

View file

@ -0,0 +1 @@
package com.minelittlepony.unicopia.ability.magic.spell;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.blockstate;
package com.minelittlepony.unicopia.block.state;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.blockstate;
package com.minelittlepony.unicopia.block.state;
import java.util.ArrayList;
import java.util.function.Predicate;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.blockstate;
package com.minelittlepony.unicopia.block.state;
public interface ReversableBlockStateConverter extends BlockStateConverter {
BlockStateConverter getInverse();

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.blockstate;
package com.minelittlepony.unicopia.block.state;
class ReversableBlockStateMap extends BlockStateMap implements ReversableBlockStateConverter {
private static final long serialVersionUID = 6154365988455383098L;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.blockstate;
package com.minelittlepony.unicopia.block.state;
import java.util.function.Function;
import java.util.function.Predicate;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.blockstate;
package com.minelittlepony.unicopia.block.state;
import net.minecraft.block.Blocks;
import net.minecraft.block.FarmlandBlock;

View file

@ -6,8 +6,8 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.entity.player.dummy.DummyClientPlayerEntity;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.MinecraftClient;
@ -55,6 +55,6 @@ public class ClientInteractionManager extends InteractionManager {
@Override
public int getViewMode() {
return MinecraftClient.getInstance().options.perspective;
return MinecraftClient.getInstance().options.getPerspective().ordinal();
}
}

View file

@ -8,7 +8,7 @@ import java.util.Set;
import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.ability.AbilitySlot;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;

View file

@ -1,13 +1,16 @@
package com.minelittlepony.unicopia.client;
import com.minelittlepony.unicopia.UEntities;
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.particles.UParticles;
import com.minelittlepony.unicopia.world.client.UWorldClient;
import com.minelittlepony.unicopia.particle.UParticles;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
public interface URenderers {
static void bootstrap() {
@ -17,6 +20,6 @@ public interface URenderers {
ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle::new);
ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle::new);
UWorldClient.bootstrap();
EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer()));
}
}

View file

@ -1,34 +1,12 @@
package com.minelittlepony.unicopia.client;
import static com.minelittlepony.unicopia.EquinePredicates.PLAYER_UNICORN;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ducks.Colourful;
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;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.client.color.world.GrassColors;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.SpriteIdentifier;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
public class UnicopiaClient implements ClientModInitializer {
@ -43,49 +21,20 @@ public class UnicopiaClient implements ClientModInitializer {
URenderers.bootstrap();
ClientTickCallback.EVENT.register(this::tick);
DefaultTexturesRegistry.getDefaultTextures().add(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, SpellbookResultSlot.EMPTY_GEM_SLOT));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
PlayerEntity player = client.player;
ColorProviderRegistry.ITEM.register((stack, tint) -> {
return getLeavesColor(((BlockItem)stack.getItem()).getBlock().getDefaultState(), null, null, tint);
}, UItems.APPLE_LEAVES);
ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.APPLE_LEAVES);
ColorProviderRegistry.ITEM.register((stack, tint) -> {
if (PLAYER_UNICORN.test(MinecraftClient.getInstance().player)) {
return SpellRegistry.instance().getSpellTintFromStack(stack);
if (player != null && !player.removed) {
Race newRace = InteractionManager.instance().getPreferredRace();
if (newRace != lastPreferredRace) {
lastPreferredRace = newRace;
Channel.REQUEST_CAPABILITIES.send(new MsgRequestCapabilities(lastPreferredRace));
}
}
return 0xFFFFFF;
}, UItems.GEM, UItems.CORRUPTED_GEM);
keyboard.tick(client);
});
}
private void tick(MinecraftClient client) {
PlayerEntity player = client.player;
if (player != null && !player.removed) {
Race newRace = InteractionManager.instance().getPreferredRace();
if (newRace != lastPreferredRace) {
lastPreferredRace = newRace;
Channel.REQUEST_CAPABILITIES.send(new MsgRequestCapabilities(lastPreferredRace));
}
}
keyboard.tick(client);
}
private static int getLeavesColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tint) {
Block block = state.getBlock();
if (block instanceof Colourful) {
return ((Colourful)block).getCustomTint(state, tint);
}
if (world != null && pos != null) {
return BiomeColors.getGrassColor(world, pos);
}
return GrassColors.getColor(0.5D, 1);
}
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.world.client.gui;
package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.common.client.gui.GameGui;
import com.minelittlepony.common.client.gui.element.Button;

View file

@ -1,9 +1,9 @@
package com.minelittlepony.unicopia.world.client.gui;
package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.unicopia.ability.Abilities;
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
import com.minelittlepony.unicopia.ability.AbilitySlot;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
@ -24,7 +24,7 @@ public class UHud extends DrawableHelper {
private final MinecraftClient client = MinecraftClient.getInstance();
public void render(InGameHud hud, float tickDelta) {
public void render(InGameHud hud, MatrixStack matrices, float tickDelta) {
if (client.player == null || client.player.isSpectator()) {
return;
@ -36,8 +36,6 @@ public class UHud extends DrawableHelper {
int x = 104 + (scaledWidth - 50) / 2;
int y = 20 + scaledHeight - 70;
MatrixStack matrices = new MatrixStack();
RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.client.particle;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.client.particle;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

View file

@ -10,11 +10,11 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.MathHelper;
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.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.client.render.RenderLayers;
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleHandle.Attachment;
import com.minelittlepony.unicopia.particle.ParticleHandle.Link;
import com.minelittlepony.common.util.Color;
public class SphereParticle extends Particle implements Attachment {

View file

@ -0,0 +1,25 @@
package com.minelittlepony.unicopia.client.render;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
public final class RenderLayers extends RenderLayer {
private RenderLayers(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize,
boolean hasCrumbling, boolean translucent, Runnable startAction, Runnable endAction) {
super(name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent, startAction, endAction);
}
private static final RenderLayer MAGIC = of("mlp_magic_glow", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, 7, 256, RenderLayer.MultiPhaseParameters.builder()
.texture(NO_TEXTURE)
.writeMaskState(COLOR_MASK)
.transparency(LIGHTNING_TRANSPARENCY)
.lightmap(DISABLE_LIGHTMAP)
.cull(DISABLE_CULLING)
.build(false));
public static RenderLayer magic() {
return MAGIC;
}
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.world.client.render;
package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
@ -38,7 +38,7 @@ public class WorldRenderDelegate {
}
private void flipAngles(Entity entity) {
if (MinecraftClient.getInstance().options.perspective > 0) {
if (!MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) {
entity.prevYaw *= -1;
entity.yaw *= -1;

View file

@ -12,6 +12,7 @@ public class Commands {
GravityCommand.register(dispatcher);
DisguiseCommand.register(dispatcher);
});
@SuppressWarnings("deprecation")
Object game = FabricLoader.getInstance().getGameInstance();
if (game instanceof MinecraftServer) {
((MinecraftServer)game).setFlightEnabled(true);

View file

@ -2,15 +2,15 @@ package com.minelittlepony.unicopia.command;
import java.util.function.Function;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.arguments.EntitySummonArgumentType;
import net.minecraft.command.arguments.NbtCompoundTagArgumentType;
import net.minecraft.command.argument.EntitySummonArgumentType;
import net.minecraft.command.argument.NbtCompoundTagArgumentType;
import net.minecraft.command.suggestion.SuggestionProviders;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;

View file

@ -1,12 +1,12 @@
package com.minelittlepony.unicopia.command;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.arguments.EntityArgumentType;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;

View file

@ -1,11 +1,11 @@
package com.minelittlepony.unicopia.command;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.equine.player.Pony;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.arguments.EntityArgumentType;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;

View file

@ -1,8 +0,0 @@
package com.minelittlepony.unicopia.ducks;
import net.minecraft.block.BlockState;
@FunctionalInterface
public interface Colourful {
int getCustomTint(BlockState state, int tint);
}

View file

@ -1,12 +0,0 @@
package com.minelittlepony.unicopia.ducks;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface Farmland {
/**
* Gets the state used to represent this block as a piece of dirt.
*/
BlockState getDirtState(BlockState state, World world, BlockPos pos);
}

View file

@ -1,7 +0,0 @@
package com.minelittlepony.unicopia.ducks;
import net.minecraft.item.ItemStack;
public interface PickedItemSupplier {
ItemStack getPickedStack();
}

View file

@ -1,12 +1,12 @@
package com.minelittlepony.unicopia.equine;
package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.ability.magic.Affine;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.AttachableSpell;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Spell;
import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync;
import net.minecraft.entity.LivingEntity;
@ -15,7 +15,7 @@ import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.nbt.CompoundTag;
public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
public class Creature implements Equine<LivingEntity>, Caster<LivingEntity> {
private static final TrackedData<CompoundTag> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.equine;
package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.util.Copieable;
@ -16,7 +16,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class EntityPhysics<T extends Ponylike<?> & Owned<? extends Entity>> implements Physics, Copieable<EntityPhysics<T>> {
public class EntityPhysics<T extends Equine<?> & Owned<? extends Entity>> implements Physics, Copieable<EntityPhysics<T>> {
private float gravity = 1;

View file

@ -1,16 +1,15 @@
package com.minelittlepony.unicopia.equine;
package com.minelittlepony.unicopia.entity;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ducks.PonyContainer;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.util.Tickable;
public interface Ponylike<T extends Entity> extends NbtSerialisable, Tickable {
public interface Equine<T extends Entity> extends NbtSerialisable, Tickable {
Race getSpecies();
Physics getPhysics();
@ -55,7 +54,7 @@ public interface Ponylike<T extends Entity> extends NbtSerialisable, Tickable {
}
@Nullable
static <T extends Ponylike<?>> T of(Entity entity) {
static <T extends Equine<?>> T of(Entity entity) {
return PonyContainer.<Entity, T>of(entity)
.map(PonyContainer::get)
.orElse(null);

View file

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

View file

@ -1,8 +1,7 @@
package com.minelittlepony.unicopia.equine;
package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ducks.IItemEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.data.DataTracker;
@ -12,7 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ActionResult;
public class ItemImpl implements Ponylike<ItemEntity>, Owned<ItemEntity> {
public class ItemImpl implements Equine<ItemEntity>, Owned<ItemEntity> {
private static final TrackedData<Integer> ITEM_RACE = DataTracker.registerData(ItemEntity.class, TrackedDataHandlerRegistry.INTEGER);
private final ItemEntity owner;

View file

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

View file

@ -1,18 +1,17 @@
package com.minelittlepony.unicopia.ducks;
package com.minelittlepony.unicopia.entity;
import java.util.Optional;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.equine.Ponylike;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Caster;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
public interface PonyContainer<T extends Ponylike<?>> {
public interface PonyContainer<T extends Equine<?>> {
Ponylike<?> create();
Equine<?> create();
T get();
@ -28,7 +27,7 @@ public interface PonyContainer<T extends Ponylike<?>> {
}
@SuppressWarnings("unchecked")
static <E extends Entity, T extends Ponylike<?>> Optional<PonyContainer<T>> of(Entity entity) {
static <E extends Entity, T extends Equine<?>> Optional<PonyContainer<T>> of(Entity entity) {
if (entity instanceof PonyContainer) {
return Optional.of(((PonyContainer<T>)entity));
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,8 @@
package com.minelittlepony.unicopia.equine.player;
package com.minelittlepony.unicopia.entity.player;
import java.util.UUID;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.mixin.Walker;
import net.minecraft.entity.attribute.ClampedEntityAttribute;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeInstance;
@ -28,8 +26,6 @@ class PlayerAttributes {
PlayerEntity entity = pony.getOwner();
Race race = pony.getSpecies();
((Walker)entity.abilities).setWalkSpeed(0.1F - (float)pony.getInventory().getCarryingWeight());
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());

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.equine.player;
package com.minelittlepony.unicopia.entity.player;
import com.minelittlepony.common.util.animation.MotionCompositor;

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.equine.player;
package com.minelittlepony.unicopia.entity.player;
import com.minelittlepony.unicopia.ability.HeightPredicate;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.ability.magic.Spell;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;

View file

@ -1,13 +1,13 @@
package com.minelittlepony.unicopia.equine.player;
package com.minelittlepony.unicopia.entity.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.equine.EntityPhysics;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.ability.magic.Spell;
import com.minelittlepony.unicopia.entity.EntityPhysics;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.MutableVector;
@ -42,15 +42,6 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
dimensions = new PlayerDimensions(pony, this);
}
@Override
public float getGravityModifier() {
float modifier = super.getGravityModifier();
modifier *= (1 + pony.getInventory().getCarryingWeight() * 3);
return modifier;
}
private boolean checkCanFly() {
if (pony.getOwner().abilities.creativeMode || pony.getOwner().isSpectator()) {
return true;

View file

@ -1,30 +1,26 @@
package com.minelittlepony.unicopia.equine.player;
package com.minelittlepony.unicopia.entity.player;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
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.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.spell.SpellRegistry;
import com.minelittlepony.unicopia.ability.magic.Affinity;
import com.minelittlepony.unicopia.ability.magic.AttachableSpell;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Spell;
import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.entity.Physics;
import com.minelittlepony.unicopia.entity.PonyContainer;
import com.minelittlepony.unicopia.entity.Equine;
import com.minelittlepony.unicopia.entity.Trap;
import com.minelittlepony.unicopia.item.toxin.Toxicity;
import com.minelittlepony.unicopia.item.toxin.Toxin;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
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.unicopia.world.recipe.enchanting.PageOwner;
import com.minelittlepony.common.util.animation.LinearInterpolator;
import com.minelittlepony.common.util.animation.Interpolator;
import com.mojang.authlib.GameProfile;
@ -43,13 +39,11 @@ 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;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Transmittable, Copieable<Pony> {
public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmittable, Copieable<Pony> {
private static final TrackedData<Integer> RACE = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
static final TrackedData<Float> ENERGY = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
@ -57,16 +51,13 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
private static final TrackedData<CompoundTag> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<CompoundTag> HELD_EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private final PlayerPageStats pageStates = new PlayerPageStats(this);
private final AbilityDispatcher powers = new AbilityDispatcher(this);
private final PlayerPhysics gravity = new PlayerPhysics(this);
private final PlayerAttributes attributes = new PlayerAttributes();
private final PlayerCamera camera = new PlayerCamera(this);
private final PlayerInventory inventory = new PlayerInventory(this);
private final MagicReserves mana;
private final EffectSync effectDelegate = new EffectSync(this, EFFECT);
private final EffectSync heldEffectDelegate = new EffectSync(this, HELD_EFFECT);
private final Interpolator interpolator = new LinearInterpolator();
@ -124,24 +115,6 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
this.invisible = invisible;
}
@Nullable
public HeldSpell getHeldSpell(ItemStack stack) {
if (!getSpecies().canCast()) {
heldEffectDelegate.set(null);
return null;
}
HeldSpell heldEffect = heldEffectDelegate.get(HeldSpell.class, true);
if (heldEffect == null || !heldEffect.getName().equals(SpellRegistry.getKeyFromStack(stack))) {
heldEffect = SpellRegistry.instance().getHeldFrom(stack);
heldEffectDelegate.set(heldEffect);
}
return heldEffect;
}
@Override
public Affinity getAffinity() {
return Affinity.NEUTRAL;
@ -165,10 +138,6 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
return powers;
}
public PageOwner getPages() {
return pageStates;
}
@Override
public Physics getPhysics() {
return gravity;
@ -214,7 +183,6 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
}
powers.tick();
inventory.tick();
return false;
}
@ -237,16 +205,6 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
}
}
ItemStack stack = entity.getStackInHand(Hand.MAIN_HAND);
HeldSpell effect = getHeldSpell(stack);
if (effect != null) {
Affinity affinity = stack.getItem() instanceof AffineItem ? ((AffineItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
effect.updateInHand(this, affinity);
}
mana.addExertion(-10);
mana.addEnergy(-1);
@ -312,25 +270,9 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
}
public Either<SleepFailureReason, Unit> trySleep(BlockPos pos) {
if (getInventory().matches(UTags.CURSED_ARTEFACTS)) {
if (!isClient()) {
entity.sendMessage(new TranslatableText("tile.bed.youAreAMonster"), true);
}
return Either.left(SleepFailureReason.OTHER_PROBLEM);
}
if (findAllSpellsInRange(10).anyMatch(c -> c instanceof Pony && ((Pony)c).getInventory().matches(UTags.CURSED_ARTEFACTS))) {
return Either.left(SleepFailureReason.NOT_SAFE);
}
return Either.right(Unit.INSTANCE);
}
public PlayerInventory getInventory() {
return inventory;
}
public void onEat(ItemStack stack) {
if (getSpecies() == Race.CHANGELING) {
Toxin.POISON.afflict(getOwner(), Toxicity.SAFE, stack);
@ -349,8 +291,6 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
if (effect != null) {
compound.put("effect", SpellRegistry.toNBT(effect));
}
pageStates.toNBT(compound);
}
@Override
@ -363,15 +303,12 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
if (compound.contains("effect")) {
effectDelegate.set(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
}
pageStates.fromNBT(compound);
}
@Override
public void copyFrom(Pony oldPlayer) {
setSpell(oldPlayer.getSpell());
setSpecies(oldPlayer.getSpecies());
pageStates.copyFrom(oldPlayer.pageStates);
setDirty();
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.dummy;
package com.minelittlepony.unicopia.entity.player.dummy;
import javax.annotation.Nonnull;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.dummy;
package com.minelittlepony.unicopia.entity.player.dummy;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Owned;
@ -14,7 +14,7 @@ public class DummyPlayerEntity extends PlayerEntity implements Owned<PlayerEntit
private PlayerEntity owner;
public DummyPlayerEntity(World world, GameProfile profile) {
super(world, BlockPos.ORIGIN, profile);
super(world, BlockPos.ORIGIN, 0, profile);
}
@Override

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.dummy;
package com.minelittlepony.unicopia.entity.player.dummy;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Owned;

View file

@ -1,190 +0,0 @@
package com.minelittlepony.unicopia.equine.player;
import java.util.Iterator;
import java.util.Map;
import com.google.common.collect.Maps;
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;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.util.Tickable;
import net.minecraft.util.registry.Registry;
public class PlayerInventory implements Tickable, NbtSerialisable {
private final Map<AffineItem, Entry> dependencies = Maps.newHashMap();
private final Pony player;
private double carryingWeight;
PlayerInventory(Pony player) {
this.player = player;
}
/**
* Reinforces a players dependency on a certain magical artifact.
* A dependency will slowly drop over time if not reinforced
*
* Bad things might happen when it's removed.
*/
public synchronized void enforceDependency(AffineItem item) {
if (dependencies.containsKey(item)) {
dependencies.get(item).reinforce();
} else {
dependencies.put(item, new Entry(item));
}
}
/**
* Returns how long the player has been wearing the given item.
*/
public synchronized int getTicksAttached(AffineItem item) {
if (dependencies.containsKey(item)) {
return dependencies.get(item).ticksAttached;
}
return 0;
}
/**
* Returns how dependent the player has become on the given item.
*
* Zero means not dependent at all / not wearing.
*/
public synchronized float getNeedfulness(AffineItem item) {
if (dependencies.containsKey(item)) {
return dependencies.get(item).needfulness;
}
return 0;
}
@Override
public synchronized void tick() {
carryingWeight = HeavyInventory.getContentsTotalWorth(player.getOwner().inventory, false);
Iterator<Map.Entry<AffineItem, Entry>> iterator = dependencies.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<AffineItem, Entry> entry = iterator.next();
Entry item = entry.getValue();
item.tick();
if (item.needfulness <= 0.001) {
iterator.remove();
}
}
}
/**
* Checks if the player is wearing the specified magical artifact.
*/
public boolean isWearing(AffineItem item) {
for (ItemStack i : player.getOwner().getArmorItems()) {
if (!i.isEmpty() && i.getItem() == item) {
return true;
}
}
return item.alwaysActive();
}
public boolean matches(Tag<Item> tag) {
for (ItemStack i : player.getOwner().getArmorItems()) {
if (!i.isEmpty() && i.getItem().isIn(tag)) {
return true;
}
}
return false;
}
public double getCarryingWeight() {
return carryingWeight / 100000D;
}
@Override
public void toNBT(CompoundTag compound) {
ListTag items = new ListTag();
for (Entry entry : dependencies.values()) {
items.add(entry.toNBT());
}
compound.put("dependencies", items);
compound.putDouble("weight", carryingWeight);
}
@Override
public void fromNBT(CompoundTag compound) {
dependencies.clear();
compound.getList("dependencies", 10).forEach(res -> {
Entry entry = new Entry();
entry.fromNBT((CompoundTag)res);
if (entry.item != null) {
dependencies.put(entry.item, entry);
}
});
carryingWeight = compound.getDouble("weight");
}
class Entry implements Tickable, NbtSerialisable {
int ticksAttached = 0;
float needfulness = 1;
AffineItem item;
Entry() {
}
Entry(AffineItem key) {
this.item = key;
}
void reinforce() {
needfulness = Math.min(30, needfulness + 1);
}
@Override
public void tick() {
if (isWearing(item)) {
ticksAttached ++;
needfulness *= 0.9F;
} else if (ticksAttached > 0) {
item.onRemoved(player, needfulness);
needfulness = 0;
}
}
@Override
public void toNBT(CompoundTag compound) {
compound.putInt("ticksAttached", ticksAttached);
compound.putFloat("needfulness", needfulness);
compound.putString("item", Registry.ITEM.getId(((Item)item)).toString());
}
@Override
public void fromNBT(CompoundTag compound) {
ticksAttached = compound.getInt("ticksAttached");
needfulness = compound.getFloat("needfulness");
Item item = Registry.ITEM.get(new Identifier(compound.getString("item")));
this.item = item instanceof AffineItem ? (AffineItem)item : null;
}
}
}

View file

@ -1,73 +0,0 @@
package com.minelittlepony.unicopia.equine.player;
import java.util.HashMap;
import java.util.Map;
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;
public class PlayerPageStats implements NbtSerialisable, Copieable<PlayerPageStats>, PageOwner {
private final Map<Identifier, PageState> pageStates = new HashMap<>();
private final Pony pony;
PlayerPageStats(Pony pony) {
this.pony = pony;
}
@Override
public Map<Identifier, PageState> getPageStates() {
return pageStates;
}
@Override
public void sendCapabilities(boolean full) {
pony.sendCapabilities(full);
}
@Override
public void copyFrom(PlayerPageStats other) {
pageStates.clear();
pageStates.putAll(other.pageStates);
}
@Override
public void toNBT(CompoundTag compound) {
if (!pageStates.isEmpty()) {
CompoundTag pages = new CompoundTag();
boolean written = false;
for (Map.Entry<Identifier, PageState> entry : pageStates.entrySet()) {
if (entry.getValue() != PageState.LOCKED) {
pages.putString(entry.getKey().toString(), entry.getValue().name());
written = true;
}
}
if (written) {
compound.put("pageStates", pages);
}
}
}
@Override
public void fromNBT(CompoundTag compound) {
pageStates.clear();
if (compound.contains("pageStates")) {
CompoundTag pages = compound.getCompound("pageStates");
pages.getKeys().forEach(key -> {
PageState state = PageState.of(pages.getString(key));
if (state != PageState.LOCKED) {
pageStates.put(new Identifier(key), state);
}
});
}
}
}

View file

@ -1,11 +1,12 @@
package com.minelittlepony.unicopia.world.item;
package com.minelittlepony.unicopia.item;
import java.util.List;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.ducks.IItemEntity;
import com.minelittlepony.unicopia.equine.ItemImpl;
import com.minelittlepony.unicopia.toxin.Toxicity;
import com.minelittlepony.unicopia.entity.IItemEntity;
import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.item.toxin.Toxicity;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.world.item;
package com.minelittlepony.unicopia.item;
import java.util.function.Predicate;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.world.item;
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.ducks.IItemEntity;
import com.minelittlepony.unicopia.entity.IItemEntity;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.util.ActionResult;

View file

@ -0,0 +1,52 @@
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.item.toxin.Toxics;
import com.minelittlepony.unicopia.item.toxin.UFoodComponents;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Settings;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponents;
import net.minecraft.item.MusicDiscItem;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity;
import net.minecraft.util.registry.Registry;
public interface UItems {
AppleItem GREEN_APPLE = register("green_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
AppleItem SWEET_APPLE = register("sweet_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
AppleItem SOUR_APPLE = register("sour_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
ZapAppleItem ZAP_APPLE = register("zap_apple", new ZapAppleItem(new Item.Settings().group(ItemGroup.FOOD).food(UFoodComponents.ZAP_APPLE)));
AppleItem ROTTEN_APPLE = register("rotten_apple", new RottenAppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
AppleItem COOKED_ZAP_APPLE = register("cooked_zap_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
Item MUSIC_DISC_CRUSADE = register("music_disc_crusade", USounds.RECORD_CRUSADE);
Item MUSIC_DISC_PET = register("music_disc_pet", USounds.RECORD_PET);
Item MUSIC_DISC_POPULAR = register("music_disc_popular", USounds.RECORD_POPULAR);
Item MUSIC_DISC_FUNK = register("music_disc_funk", USounds.RECORD_FUNK);
static <T extends Item> T register(String name, T item) {
if (item instanceof BlockItem) {
((BlockItem)item).appendBlocks(Item.BLOCK_ITEMS, item);
}
return Registry.register(Registry.ITEM, new Identifier("unicopia", name), item);
}
static MusicDiscItem register(String name, SoundEvent sound) {
return register(name, new MusicDiscItem(1, sound, new Settings()
.maxCount(1)
.group(ItemGroup.MISC)
.rarity(Rarity.RARE)
) {});
}
static void bootstrap() {
Toxics.bootstrap();
}
}

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