From 900f5e6de032e3d8ffafe6472d3729f7ef805409 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 17 Feb 2019 19:22:11 +0200 Subject: [PATCH] Added the alicorn amulet --- .../minelittlepony/unicopia/init/UItems.java | 6 +- .../unicopia/item/IDependable.java | 7 + .../unicopia/item/ItemAlicornAmulet.java | 239 ++++++++++++++++++ .../minelittlepony/unicopia/player/IFood.java | 11 + .../unicopia/player/IInventory.java | 32 +++ .../unicopia/player/IPlayer.java | 5 + .../unicopia/player/IRaceContainer.java | 7 +- .../unicopia/player/IUpdatable.java | 11 +- .../player/PlayerAbilityDelegate.java | 5 +- .../unicopia/player/PlayerCapabilities.java | 12 +- .../unicopia/player/PlayerFood.java | 3 +- .../player/PlayerGravityDelegate.java | 5 +- .../unicopia/player/PlayerInventory.java | 155 ++++++++++++ .../minelittlepony/unicopia/world/UWorld.java | 4 +- .../resources/assets/unicopia/lang/en_US.lang | 5 +- .../unicopia/models/item/alicorn_amulet.json | 18 ++ .../textures/items/alicorn_amulet.png | Bin 0 -> 549 bytes .../textures/items/alicorn_amulet_overlay.png | Bin 0 -> 603 bytes 18 files changed, 503 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/item/IDependable.java create mode 100644 src/main/java/com/minelittlepony/unicopia/item/ItemAlicornAmulet.java create mode 100644 src/main/java/com/minelittlepony/unicopia/player/IInventory.java create mode 100644 src/main/java/com/minelittlepony/unicopia/player/PlayerInventory.java create mode 100644 src/main/resources/assets/unicopia/models/item/alicorn_amulet.json create mode 100644 src/main/resources/assets/unicopia/textures/items/alicorn_amulet.png create mode 100644 src/main/resources/assets/unicopia/textures/items/alicorn_amulet_overlay.png diff --git a/src/main/java/com/minelittlepony/unicopia/init/UItems.java b/src/main/java/com/minelittlepony/unicopia/init/UItems.java index 94c2772c..071669c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/init/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/init/UItems.java @@ -1,5 +1,6 @@ package com.minelittlepony.unicopia.init; +import com.minelittlepony.unicopia.item.ItemAlicornAmulet; import com.minelittlepony.unicopia.item.ItemApple; import com.minelittlepony.unicopia.item.ItemAppleMultiType; import com.minelittlepony.unicopia.item.ItemCereal; @@ -109,6 +110,7 @@ public class UItems { public static final ItemSpell curse = new ItemCurse(Unicopia.MODID, "corrupted_gem"); public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding"); + public static final ItemAlicornAmulet alicorn_amulet = new ItemAlicornAmulet(Unicopia.MODID, "alicorn_amulet"); public static final ItemSpellbook spellbook = new ItemSpellbook(Unicopia.MODID, "spellbook"); public static final Item staff_meadow_brook = new ItemStaff(Unicopia.MODID, "staff_meadow_brook").setMaxDamage(2); @@ -212,7 +214,7 @@ public class UItems { cloud_farmland, mist_door, anvil, bag_of_holding, spell, curse, spellbook, mug, enchanted_torch, - staff_meadow_brook, + staff_meadow_brook, alicorn_amulet, alfalfa_seeds, alfalfa_leaves, cereal, sugar_cereal, sugar_block, @@ -242,7 +244,7 @@ public class UItems { cloud_farmland, mist_door, anvil, bag_of_holding, spell, curse, spellbook, mug, enchanted_torch, - staff_meadow_brook, + staff_meadow_brook, alicorn_amulet, alfalfa_seeds, alfalfa_leaves, cereal, sugar_cereal, sugar_block, diff --git a/src/main/java/com/minelittlepony/unicopia/item/IDependable.java b/src/main/java/com/minelittlepony/unicopia/item/IDependable.java new file mode 100644 index 00000000..9b8bca3e --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/item/IDependable.java @@ -0,0 +1,7 @@ +package com.minelittlepony.unicopia.item; + +import com.minelittlepony.unicopia.player.IPlayer; + +public interface IDependable extends IMagicalItem { + void onRemoved(IPlayer player, float needfulness); +} diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemAlicornAmulet.java b/src/main/java/com/minelittlepony/unicopia/item/ItemAlicornAmulet.java new file mode 100644 index 00000000..f204ff65 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemAlicornAmulet.java @@ -0,0 +1,239 @@ +package com.minelittlepony.unicopia.item; + +import java.util.List; +import java.util.UUID; + +import javax.annotation.Nullable; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.minelittlepony.unicopia.UClient; +import com.minelittlepony.unicopia.player.IPlayer; +import com.minelittlepony.unicopia.player.PlayerSpeciesList; +import com.minelittlepony.unicopia.spell.SpellAffinity; +import com.minelittlepony.util.MagicalDamageSource; +import com.minelittlepony.util.vector.VecHelper; + +import net.minecraft.client.resources.I18n; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.MoverType; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.StringUtils; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.World; + +public class ItemAlicornAmulet extends ItemArmor implements IDependable { + + private static final UUID[] ARMOR_MODIFIERS = new UUID[] { + UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), + UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), + UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), + UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150") + }; + + public ItemAlicornAmulet(String domain, String name) { + super(ArmorMaterial.GOLD, 1, EntityEquipmentSlot.CHEST); + + setTranslationKey(name); + setRegistryName(domain, name); + } + + @Override + public SpellAffinity getAffinity() { + return SpellAffinity.BAD; + } + + @Override + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + return toRepair.getItem() == repair.getItem(); + } + + @Override + public boolean onEntityItemUpdate(EntityItem entity) { + + World world = entity.world; + + double x = entity.posX + world.rand.nextFloat() - 0.5; + double z = entity.posZ + world.rand.nextFloat() - 0.5; + double y = entity.posY + world.rand.nextFloat(); + + EnumParticleTypes particle = world.rand.nextBoolean() ? EnumParticleTypes.SMOKE_LARGE : EnumParticleTypes.FLAME; + + world.spawnParticle(particle, x, y, z, 0, 0, 0); + + if (world.rand.nextInt(500) == 0) { + world.playSound(null, entity.getPosition(), SoundEvents.AMBIENT_CAVE, SoundCategory.HOSTILE, 0.5F, 1); + } + + Vec3d position = entity.getPositionVector(); + VecHelper.findAllEntitiesInRange(entity, world, entity.getPosition(), 10) + .filter(e -> e instanceof EntityPlayer) + .sorted((a, b) -> (int)(a.getPositionVector().distanceTo(position) - b.getPositionVector().distanceTo(position))) + .findFirst() + .ifPresent(player -> interactWithPlayer(entity, (EntityPlayer)player)); + + return false; + } + + protected void interactWithPlayer(EntityItem entity, EntityPlayer player) { + double diffX = player.posX - entity.posX; + double diffY = player.posY - entity.posY; + double diffZ = player.posZ - entity.posZ; + + entity.move(MoverType.SELF, diffX / 50, diffY / 50, diffZ / 50); + + if (!player.world.isRemote && !entity.isDead) { + if (player.getPositionVector().distanceTo(entity.getPositionVector()) < 3) { + if (entity.world.rand.nextInt(150) == 0) { + player.setItemStackToSlot(getEquipmentSlot(), entity.getItem()); + entity.setPickupDelay(1000); + entity.setDead(); + } + } + } + } + + @Override + public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + IPlayer iplayer = UClient.instance().getIPlayer(); + + if (iplayer != null) { + int attachedTime = iplayer.getInventory().getTicksAttached(this); + if (attachedTime > 0) { + tooltip.add(I18n.format(this.getTranslationKey() + ".tagline", StringUtils.ticksToElapsedTime(attachedTime))); + } + } + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + + NBTTagCompound compound = stack.getTagCompound(); + + int hideFlags = 0; + + if (!compound.hasKey("HideFlags") || ((hideFlags = compound.getInteger("HideFlags")) & 2) == 0) { + compound.setInteger("HideFlags", hideFlags | 2); + } + + return super.getItemStackDisplayName(stack); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { + if (player.getHealth() < player.getMaxHealth()) { + player.heal(0.5F); + } else if (player.canEat(false)) { + player.getFoodStats().addStats(1, 0); + } + + IPlayer iplayer = PlayerSpeciesList.instance().getPlayer(player); + + if (iplayer.getExertion() < 1) { + iplayer.addExertion(2); + } + if (iplayer.getEnergy() < 0.005F) { + iplayer.addEnergy(2); + } + + int attachedTime = iplayer.getInventory().getTicksAttached(this); + + if (attachedTime == 1) { + world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.PLAYERS, 3, 1); + } + + if (attachedTime > 0 && attachedTime % 100 == 0) { + world.playSound(null, player.getPosition(), SoundEvents.MUSIC_NETHER, SoundCategory.PLAYERS, 3, 1); + } + + if (attachedTime > 1000) { + if (world.rand.nextInt(700) == 0) { + player.dropItem(false); + } + } + + if (attachedTime > 3000) { + if (world.rand.nextInt(300) == 0) { + player.motionX += world.rand.nextFloat() - 0.5F; + } + + if (world.rand.nextInt(300) == 0) { + player.motionZ += world.rand.nextFloat() - 0.5F; + } + } + + if (attachedTime > 6000) { + if (world.rand.nextInt(300) == 0) { + player.rotationYaw += 180; + } + } + + if (attachedTime > 13000) { + if (world.rand.nextInt(300) == 0) { + DamageSource source = MagicalDamageSource.causePlayerDamage("alicorn_amulet", player); + + player.attackEntityFrom(source, 0.5F); + } + } + + iplayer.getInventory().enforceDependency(this); + } + + @Override + public void onRemoved(IPlayer player, float needfulness) { + + float attachedTime = player.getInventory().getTicksAttached(this) / 100F; + + DamageSource source = MagicalDamageSource.causePlayerDamage("alicorn_amulet", player.getOwner()); + DifficultyInstance difficulty = player.getWorld().getDifficultyForLocation(player.getOrigin()); + float amount = (attachedTime * (1 + needfulness)) * (1 + difficulty.getClampedAdditionalDifficulty()); + + player.getOwner().attackEntityFrom(source, amount); + + if (attachedTime > 120) { + player.getOwner().knockBack(player.getOwner(), 1, 1, 1); + } + } + + @Override + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ActionResult result = super.onItemRightClick(world, player, hand); + + + + return result; + } + + @Override + public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { + Multimap multimap = HashMultimap.create();; + + if (equipmentSlot == armorType) { + UUID modifierId = ARMOR_MODIFIERS[equipmentSlot.getIndex()]; + + multimap.put(SharedMonsterAttributes.ARMOR.getName(), new AttributeModifier(modifierId, "Armor modifier", Integer.MAX_VALUE, 0)); + multimap.put(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName(), new AttributeModifier(modifierId, "Armor toughness", 20, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(modifierId, "Strength modifier", 50, 0)); + } + + return multimap; + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/player/IFood.java b/src/main/java/com/minelittlepony/unicopia/player/IFood.java index c17ebda6..15ffef1e 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/IFood.java +++ b/src/main/java/com/minelittlepony/unicopia/player/IFood.java @@ -3,9 +3,20 @@ package com.minelittlepony.unicopia.player; import net.minecraft.item.ItemStack; public interface IFood { + + /** + * Start eating a piece of food. + * @param stack + */ void begin(ItemStack stack); + /** + * Ends eating. Eating was cancelled. + */ void end(); + /** + * Finish eating. *burp* + */ void finish(); } diff --git a/src/main/java/com/minelittlepony/unicopia/player/IInventory.java b/src/main/java/com/minelittlepony/unicopia/player/IInventory.java new file mode 100644 index 00000000..02d045a7 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/player/IInventory.java @@ -0,0 +1,32 @@ +package com.minelittlepony.unicopia.player; + +import com.minelittlepony.unicopia.item.IDependable; +import com.minelittlepony.unicopia.item.IMagicalItem; + +public interface IInventory { + + /** + * 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. + */ + void enforceDependency(IDependable item); + + /** + * Checks if the player is wearing the specified magical artifact. + */ + boolean isWearing(IMagicalItem item); + + /** + * Returns how long the player has been wearing the given item. + */ + int getTicksAttached(IDependable item); + + /** + * Returns how dependent the player has become on the given item. + * + * Zero means not dependent at all / not wearing. + */ + float getNeedfulness(IDependable item); +} diff --git a/src/main/java/com/minelittlepony/unicopia/player/IPlayer.java b/src/main/java/com/minelittlepony/unicopia/player/IPlayer.java index c310b491..791d08c8 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/IPlayer.java +++ b/src/main/java/com/minelittlepony/unicopia/player/IPlayer.java @@ -45,6 +45,11 @@ public interface IPlayer extends ICaster, IRaceContainer The type of owner */ -public interface IRaceContainer extends InbtSerialisable { +public interface IRaceContainer extends InbtSerialisable, IUpdatable { Race getPlayerSpecies(); void setPlayerSpecies(Race race); void onDimensionalTravel(int destinationDimension); - /** - * Called to update this container's logic - */ - void onUpdate(); - /** * Called at the beginning of a player's update cycle. */ diff --git a/src/main/java/com/minelittlepony/unicopia/player/IUpdatable.java b/src/main/java/com/minelittlepony/unicopia/player/IUpdatable.java index 2cda63ba..9cb82c3c 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/IUpdatable.java +++ b/src/main/java/com/minelittlepony/unicopia/player/IUpdatable.java @@ -1,5 +1,12 @@ package com.minelittlepony.unicopia.player; -public interface IUpdatable { - void onUpdate(T sender); +/** + * Interface for objects that receive regular updates. + */ +@FunctionalInterface +public interface IUpdatable { + /** + * Called to update the internal logic. + */ + void onUpdate(); } diff --git a/src/main/java/com/minelittlepony/unicopia/player/PlayerAbilityDelegate.java b/src/main/java/com/minelittlepony/unicopia/player/PlayerAbilityDelegate.java index 76a817a7..9172ebf1 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/PlayerAbilityDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/player/PlayerAbilityDelegate.java @@ -11,10 +11,9 @@ import com.minelittlepony.unicopia.power.IPower; import com.minelittlepony.unicopia.power.PowersRegistry; import com.minelittlepony.unicopia.util.serialisation.InbtSerialisable; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -class PlayerAbilityDelegate implements IAbilityReceiver, IUpdatable, InbtSerialisable { +class PlayerAbilityDelegate implements IAbilityReceiver, IUpdatable, InbtSerialisable { private final IPlayer player; @@ -84,7 +83,7 @@ class PlayerAbilityDelegate implements IAbilityReceiver, IUpdatable ability = getUsableAbility(); if (ability == null) { diff --git a/src/main/java/com/minelittlepony/unicopia/player/PlayerCapabilities.java b/src/main/java/com/minelittlepony/unicopia/player/PlayerCapabilities.java index 44349e6d..9d7b3989 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/PlayerCapabilities.java +++ b/src/main/java/com/minelittlepony/unicopia/player/PlayerCapabilities.java @@ -60,6 +60,8 @@ class PlayerCapabilities implements IPlayer { private final PlayerFood food = new PlayerFood(this); + private final PlayerInventory inventory = new PlayerInventory(this); + private final EffectSync effectDelegate = new EffectSync<>(this, EFFECT); private final IInterpolator interpolator = new BasicEasingInterpolator(); @@ -198,8 +200,9 @@ class PlayerCapabilities implements IPlayer { @Override public void onUpdate() { - powers.onUpdate(entity); - gravity.onUpdate(entity); + powers.onUpdate(); + gravity.onUpdate(); + inventory.onUpdate(); if (hasEffect()) { if (entity.getEntityWorld().isRemote) { @@ -270,6 +273,11 @@ class PlayerCapabilities implements IPlayer { return food; } + @Override + public IInventory getInventory() { + return inventory; + } + @Override public void onEat(ItemStack stack, @Nullable ItemFood food) { if (getPlayerSpecies() == Race.CHANGELING) { diff --git a/src/main/java/com/minelittlepony/unicopia/player/PlayerFood.java b/src/main/java/com/minelittlepony/unicopia/player/PlayerFood.java index a994e5cf..aa3a797c 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/PlayerFood.java +++ b/src/main/java/com/minelittlepony/unicopia/player/PlayerFood.java @@ -10,10 +10,12 @@ class PlayerFood implements IFood { private ItemStack eatingStack = ItemStack.EMPTY; + public PlayerFood(IPlayer player) { this.player = player; } + @Override public void begin(ItemStack stack) { eatingStack = ItemStack.EMPTY; @@ -38,5 +40,4 @@ class PlayerFood implements IFood { player.onEat(eatingStack, (ItemFood)eatingStack.getItem()); } } - } diff --git a/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java b/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java index a0a0d277..c7b7423c 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java @@ -21,7 +21,7 @@ import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -class PlayerGravityDelegate implements IUpdatable, IGravity, InbtSerialisable, IFlyingPredicate, IPlayerHeightPredicate { +class PlayerGravityDelegate implements IUpdatable, IGravity, InbtSerialisable, IFlyingPredicate, IPlayerHeightPredicate { private final IPlayer player; @@ -98,7 +98,8 @@ class PlayerGravityDelegate implements IUpdatable, IGravity, InbtS @Override - public void onUpdate(EntityPlayer entity) { + public void onUpdate() { + EntityPlayer entity = player.getOwner(); entity.capabilities.allowFlying = checkCanFly(player); diff --git a/src/main/java/com/minelittlepony/unicopia/player/PlayerInventory.java b/src/main/java/com/minelittlepony/unicopia/player/PlayerInventory.java new file mode 100644 index 00000000..8005261f --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/player/PlayerInventory.java @@ -0,0 +1,155 @@ +package com.minelittlepony.unicopia.player; + +import java.util.Iterator; +import java.util.Map; + +import com.google.common.collect.Maps; +import com.minelittlepony.unicopia.item.IDependable; +import com.minelittlepony.unicopia.item.IMagicalItem; +import com.minelittlepony.unicopia.util.serialisation.InbtSerialisable; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class PlayerInventory implements IInventory, IUpdatable, InbtSerialisable { + private final Map dependencies = Maps.newHashMap(); + + private final IPlayer player; + + PlayerInventory(IPlayer player) { + this.player = player; + } + + @Override + public synchronized void enforceDependency(IDependable item) { + if (dependencies.containsKey(item)) { + dependencies.get(item).reinforce(); + } else { + dependencies.put(item, new Entry(item)); + } + } + + @Override + public synchronized int getTicksAttached(IDependable item) { + if (dependencies.containsKey(item)) { + return dependencies.get(item).ticksAttached; + } + + return 0; + } + + @Override + public synchronized float getNeedfulness(IDependable item) { + if (dependencies.containsKey(item)) { + return dependencies.get(item).needfulness; + } + + return 0; + } + + @Override + public synchronized void onUpdate() { + + Iterator> iterator = dependencies.entrySet().iterator(); + + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + + Entry item = entry.getValue(); + + item.onUpdate(); + + if (item.needfulness <= 0.001) { + iterator.remove(); + } + } + } + + @Override + public boolean isWearing(IMagicalItem item) { + for (ItemStack i : player.getOwner().getArmorInventoryList()) { + if (!i.isEmpty() && i.getItem() == item) { + return true; + } + } + + return false; + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagList items = new NBTTagList(); + + for (Entry entry : dependencies.values()) { + items.appendTag(entry.toNBT()); + } + + compound.setTag("dependencies", items); + } + + @SuppressWarnings("unchecked") + @Override + public void readFromNBT(NBTTagCompound compound) { + dependencies.clear(); + + compound.getTagList("dependencies", 10).forEach(res -> { + Entry entry = new Entry(); + + entry.readFromNBT((NBTTagCompound)res); + + if (entry.item != null) { + dependencies.put(entry.item, entry); + } + }); + } + + class Entry implements IUpdatable, InbtSerialisable { + int ticksAttached = 0; + + float needfulness = 1; + + IDependable item; + + Entry() { + + } + + Entry(IDependable key) { + this.item = key; + } + + void reinforce() { + needfulness = Math.min(30, needfulness + 1); + } + + @Override + public void onUpdate() { + if (isWearing(item)) { + ticksAttached ++; + needfulness *= 0.9F; + } else { + item.onRemoved(player, needfulness); + needfulness = 0; + } + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + compound.setInteger("ticksAttached", ticksAttached); + compound.setFloat("needfulness", needfulness); + compound.setString("item", ((Item)item).getRegistryName().toString()); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + ticksAttached = compound.getInteger("ticksAttached"); + needfulness = compound.getFloat("needfulness"); + + Item item = Item.getByNameOrId(compound.getString("item")); + + this.item = item instanceof IDependable ? (IDependable)item : null; + } + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/world/UWorld.java b/src/main/java/com/minelittlepony/unicopia/world/UWorld.java index 13d6dd70..7435e473 100644 --- a/src/main/java/com/minelittlepony/unicopia/world/UWorld.java +++ b/src/main/java/com/minelittlepony/unicopia/world/UWorld.java @@ -6,7 +6,6 @@ import java.util.Random; import com.google.common.collect.Queues; import com.minelittlepony.jumpingcastle.Exceptions; import com.minelittlepony.unicopia.Unicopia; -import com.minelittlepony.unicopia.player.IUpdatable; import com.minelittlepony.unicopia.structure.CloudDungeon; import com.minelittlepony.unicopia.structure.GroundDungeon; @@ -20,7 +19,7 @@ import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraftforge.fml.common.IWorldGenerator; import net.minecraftforge.fml.common.registry.GameRegistry; -public class UWorld implements IWorldGenerator, IUpdatable { +public class UWorld implements IWorldGenerator { private static final UWorld instance = new UWorld(); @@ -52,7 +51,6 @@ public class UWorld implements IWorldGenerator, IUpdatable { MapGenStructureIO.registerStructureComponent(GroundDungeon.class, "unicopia:ground_dungeon"); } - @Override public void onUpdate(World world) { synchronized (locker) { Runnable task; diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index 2333cc9f..ef3c13ff 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -29,6 +29,8 @@ item.cloud_anvil.name=Anvilhead Anvil item.staff_meadow_brook.name=Meadow Brook's Staff item.staff_meadow_brook.tagline=It's a big stick +item.alicorn_amulet.name=The Alicorn Amulet +item.alicorn_amulet.tagline=Time Worn: %s item.gem.name=Gem item.gem.enchanted.name=Gem of %s @@ -227,6 +229,7 @@ unicopia.power.disguise=Secondary Changeling ability unicopia.gui.title.bagofholding=Bag of Holding +death.attack.alicorn_amulet=%1$s was driven insane death.attack.darkness=%1$s went missing death.attack.feed=%1$s was drained of all life death.attack.feed.player=%1$s died to feed %2$s @@ -244,7 +247,7 @@ death.attack.food_poisoning=%1$s died of food poisoning death.attack.food_poisoning.player=%1$s poisoned %1$s' to death advancements.adventure.bag_of_holding.title=Read the Manual -advancements.adventure.bag_of_holding.description=Successfuly die using the Bag of Holding +advancements.adventure.bag_of_holding.description=Successfully die using the Bag of Holding advancements.adventure.bag_of_holding_2.title=Oops! I did it again advancements.adventure.bag_of_holding_2.description=Die by the Bag of Holding a second time diff --git a/src/main/resources/assets/unicopia/models/item/alicorn_amulet.json b/src/main/resources/assets/unicopia/models/item/alicorn_amulet.json new file mode 100644 index 00000000..ec3915b1 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/alicorn_amulet.json @@ -0,0 +1,18 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "unicopia:items/alicorn_amulet" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/src/main/resources/assets/unicopia/textures/items/alicorn_amulet.png b/src/main/resources/assets/unicopia/textures/items/alicorn_amulet.png new file mode 100644 index 0000000000000000000000000000000000000000..85abe0453b8b2add8b4905241276793996c55678 GIT binary patch literal 549 zcmV+=0^0qFP)TVs31&#<71d$~HQ%E7uA&a37lwhPK{R>Jc#&qdyZ|#^a89HfevuG=1 z$r6%+z@nz$KoX3MLgODv$PfZ1249EvuCg5p{ldZbPT%+5-P1!#$@F@@vLcgxazDL< zl#*n*t_wgvj%CiWR1d(5jSW$&)h6asuIo-R{3!+gaCu4IwgITu>(gQ~1rV1?QmLD! zNk5L|<8+$02M2sC6v!IJjDW(V06Jl)54zp1%-c3u!(gXaoB&m;RSoWhA(~)&Z4H3! zyF1yBW9~;Inn6I;Fu1|4~KtE^nG8b&26itTB)4>)awCo-frs|rSAK_5RT*M-WfN6CYytExr) z?Qzs-Xx|=;a*{;V_mdMYqG$sAAb}79$8j`?X_^cM11_S7Z(%qypPF{IQmNqkJ~_)0 n{W#X(qeerhB>wXT|69KR+!_|fVSTNM00000NkvXXu0mjf(QpM{ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/unicopia/textures/items/alicorn_amulet_overlay.png b/src/main/resources/assets/unicopia/textures/items/alicorn_amulet_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..b1186e31f3f9a8bcc86f6cfdb36eb70aa23a4b0c GIT binary patch literal 603 zcmV-h0;K(kP)KLZ*U+s!PAz6~$9cIRu+`&V51dreiQV3o|u(k*iECqkn z<24T+h}Wp!9kkA&s=bYqC>v)JdA#L_0|3aCGsDqc3Q#w-<~IRf9|(Z=>!{xy@HdCb zSP#4b4~2FL#0gM7dE-H>f%bG^JcwtYy-1TDh!^10>$L~yHD+VW+1$%ZbtP}YFqBcz zOtl9Iw5y)t{lu0?8dnXg^v|Z^UV7CpxS#0x-jPt6>WhdzH@5b3g z?$T$90K~<1-|eYKyZZULbqn9W20$v}d3Hbm001CkNK#Dz0D2_=0Dyx40Qvs_0D$QL z0Cg|`0P0`>06Lfe02gnPU&TfM007HLL_t(|+JwkS(@FPkTB%g$vq~Ho9 zqTvFD8w4b-Kt)f((!YyeQjmOljOaHC=djRE^LrZFgzUcq}002ovPDHLkV1jTD2^atX literal 0 HcmV?d00001