Skip to content

Commit

Permalink
Implement sugar, implement spell affinities, fix some issues with the…
Browse files Browse the repository at this point in the history
… ice gem
  • Loading branch information
Sollace committed Jan 22, 2019
1 parent cd0b86f commit 35851d3
Show file tree
Hide file tree
Showing 34 changed files with 484 additions and 162 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/minelittlepony/unicopia/UItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public class UItems {
.setTranslationKey("alfalfa_leaves")
.setRegistryName(Unicopia.MODID, "alfalfa_leaves");

public static final Item cereal = new ItemCereal(Unicopia.MODID, "cereal", 9, 0.8F);
public static final Item sugar_cereal = new ItemCereal(Unicopia.MODID, "sugar_cereal", 20, -2).setAlwaysEdible();
public static final Item cereal = new ItemCereal(Unicopia.MODID, "cereal", 9, 0.8F).setSugarAmount(1);
public static final Item sugar_cereal = new ItemCereal(Unicopia.MODID, "sugar_cereal", 20, -2).setSugarAmount(110).setAlwaysEdible();

public static final ItemTomato tomato = new ItemTomato(Unicopia.MODID, "tomato", 4, 34);
public static final ItemTomato cloudsdale_tomato = new ItemTomato(Unicopia.MODID, "cloudsdale_tomato", 16, 4);
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/minelittlepony/unicopia/Unicopia.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
import com.minelittlepony.unicopia.player.IPlayer;
import com.minelittlepony.unicopia.player.IView;
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
import com.minelittlepony.unicopia.power.PowersRegistry;
import com.minelittlepony.unicopia.util.crafting.CraftingManager;
Expand Down Expand Up @@ -205,7 +206,11 @@ public static void setupPlayerCamera(EntityViewRenderEvent.CameraSetup event) {
EntityPlayer player = Minecraft.getMinecraft().player;

if (player != null) {
event.setRoll((float)PlayerSpeciesList.instance().getPlayer(player).getCamera().calculateRoll(player));
IView view = PlayerSpeciesList.instance().getPlayer(player).getCamera();

event.setRoll(view.calculateRoll());
event.setPitch(view.calculatePitch(event.getPitch()));
event.setYaw(view.calculateYaw(event.getYaw()));
}
}

Expand Down Expand Up @@ -322,11 +327,7 @@ public static void onPlayerRightClick(PlayerInteractEvent.RightClickItem event)

@SubscribeEvent
public static void modifyFOV(FOVUpdateEvent event) {
float fov = event.getFov();

fov += PlayerSpeciesList.instance().getPlayer(event.getEntity()).getExertion() / 5;

event.setNewfov(fov);
event.setNewfov(PlayerSpeciesList.instance().getPlayer(event.getEntity()).getCamera().calculateFieldOfView(event.getFov()));
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/minelittlepony/unicopia/entity/EntitySpell.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.spell.ICaster;
import com.minelittlepony.unicopia.spell.IMagicEffect;
import com.minelittlepony.unicopia.spell.SpellAffinity;
import com.minelittlepony.unicopia.spell.SpellRegistry;

import net.minecraft.block.SoundType;
Expand Down Expand Up @@ -45,6 +46,9 @@ public class EntitySpell extends EntityLiving implements IMagicals, ICaster<Enti
private static final DataParameter<NBTTagCompound> EFFECT = EntityDataManager
.createKey(EntitySpell.class, DataSerializers.COMPOUND_TAG);

private static final DataParameter<Integer> AFFINITY = EntityDataManager
.createKey(EntitySpell.class, DataSerializers.VARINT);

private final EffectSync<EntityLivingBase> effectDelegate = new EffectSync<>(this, EFFECT);

public EntitySpell(World w) {
Expand All @@ -64,6 +68,15 @@ public boolean isInRangeToRenderDist(double distance) {
return super.isInRangeToRenderDist(distance);
}

@Override
public SpellAffinity getAffinity() {
return SpellAffinity.values()[dataManager.get(AFFINITY)];
}

public void setAffinity(SpellAffinity affinity) {
dataManager.set(AFFINITY, affinity.ordinal());
}

@Override
public void setEffect(IMagicEffect effect) {
effectDelegate.set(effect);
Expand All @@ -80,6 +93,7 @@ protected void entityInit() {
dataManager.register(LEVEL, 0);
dataManager.register(EFFECT, new NBTTagCompound());
dataManager.register(OWNER, "");
dataManager.register(AFFINITY, SpellAffinity.NEUTRAL.ordinal());
}

public ItemStack onPlayerMiddleClick(EntityPlayer player) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.forgebullshit;

import com.minelittlepony.unicopia.InbtSerialisable;
import com.minelittlepony.unicopia.player.IPlayer;
import com.minelittlepony.unicopia.player.IRaceContainer;
import com.minelittlepony.unicopia.util.serialisation.InbtSerialisable;

import net.minecraft.entity.Entity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.util.List;
import java.util.function.BiFunction;

import com.minelittlepony.unicopia.InbtSerialisable;
import com.minelittlepony.unicopia.advancements.UAdvancements;
import com.minelittlepony.unicopia.item.IMagicalItem;
import com.minelittlepony.unicopia.util.serialisation.InbtSerialisable;
import com.minelittlepony.util.MagicalDamageSource;

import net.minecraft.block.Block;
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/minelittlepony/unicopia/item/ICastable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ public interface ICastable extends IMagicalItem {

boolean canFeed(EntitySpell spell, ItemStack stack);

/**
* Called to cast a spell. The result is an entity spawned with the spell attached.
*/
default EntitySpell castContainedSpell(World world, BlockPos pos, ItemStack stack, IMagicEffect effect) {
EntitySpell spell = new EntitySpell(world);

spell.setAffinity(getAffinity(stack));
spell.setEffect(effect);
spell.setLocationAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0);
world.spawnEntity(spell);

return spell;
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/minelittlepony/unicopia/item/IMagicalItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.minelittlepony.unicopia.item;

import com.minelittlepony.unicopia.spell.SpellAffinity;

import net.minecraft.item.ItemStack;

public interface IMagicalItem {
/**
* If true this item serves as host to its own inner dimensional space.
Expand All @@ -8,4 +12,12 @@ public interface IMagicalItem {
default boolean hasInnerSpace() {
return false;
}

/**
* Gets the affinity of this magical artifact. Either good, bad, or unaligned.
* What this returns may have effects on the behaviour of certain spells and effects.
*/
default SpellAffinity getAffinity(ItemStack stack) {
return SpellAffinity.NEUTRAL;
}
}
21 changes: 19 additions & 2 deletions src/main/java/com/minelittlepony/unicopia/item/ItemCereal.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.minelittlepony.unicopia.item;

import com.minelittlepony.unicopia.player.PlayerSpeciesList;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemCereal extends ItemFood {

private int sugarAmount;

public ItemCereal(String domain, String name, int amount, float saturation) {
super(amount, saturation, false);

Expand All @@ -19,8 +24,20 @@ public ItemCereal(String domain, String name, int amount, float saturation) {
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
super.onItemUseFinish(stack, worldIn, entityLiving);

this.setAlwaysEdible();

return new ItemStack(Items.BOWL);
}

@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
super.onFoodEaten(stack, worldIn, player);

if (sugarAmount != 0) {
PlayerSpeciesList.instance().getPlayer(player).addEnergy(sugarAmount);
}
}

public ItemCereal setSugarAmount(int sugar) {
sugarAmount = sugar;
return this;
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/minelittlepony/unicopia/item/ItemCurse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.minelittlepony.unicopia.spell.IDispenceable;
import com.minelittlepony.unicopia.spell.IMagicEffect;
import com.minelittlepony.unicopia.spell.SpellAffinity;
import com.minelittlepony.unicopia.spell.SpellCastResult;
import com.minelittlepony.util.MagicalDamageSource;

Expand Down Expand Up @@ -49,4 +50,9 @@ public SpellCastResult onCastSpell(EntityPlayer player, World world, BlockPos po

return result;
}

@Override
public SpellAffinity getAffinity(ItemStack stack) {
return SpellAffinity.BAD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}

@Override
public boolean hasInnerSpace() {
return true;
}

public class Inventory implements IInteractionObject {

private String customname = null;
Expand Down Expand Up @@ -163,9 +168,4 @@ public String getGuiID() {
return "unicopia:itemofholding";
}
}

@Override
public boolean hasInnerSpace() {
return true;
}
}
Loading

0 comments on commit 35851d3

Please sign in to comment.