Blood Letter's Pack + Coat of Arms
This commit is contained in:
parent
4b7ad55016
commit
9a6d8d6d60
|
@ -24,6 +24,7 @@ public class NBTHolder {
|
|||
public static final String NBT_ALTAR_ACTIVE = "isActive";
|
||||
public static final String NBT_ALTAR_LIQUID_REQ = "liquidRequired";
|
||||
public static final String NBT_ALTAR_FILLABLE = "canBeFilled";
|
||||
public static final String NBT_STORED_LP = "storedLP";
|
||||
|
||||
public static ItemStack checkNBT(ItemStack stack) {
|
||||
if (stack.getTagCompound() == null)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
/**
|
||||
* Any item that implements this interface will not be pulled into the Altar
|
||||
* on right click.
|
||||
*/
|
||||
public interface IAltarManipulator {
|
||||
}
|
|
@ -192,10 +192,8 @@ public class NetworkHelper {
|
|||
|
||||
public static void hurtPlayer(EntityPlayer user, float damage) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F);
|
||||
user.setHealth((user.getHealth() - damage));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
user.onDeath(BloodMagicAPI.getDamageSource());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
|
@ -48,40 +49,33 @@ public class BlockAltar extends BlockContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
TileAltar altar = (TileAltar) world.getTileEntity(pos);
|
||||
|
||||
if (altar == null || player.isSneaking())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack playerItem = player.getCurrentEquippedItem();
|
||||
|
||||
if (playerItem != null)
|
||||
{
|
||||
if (playerItem.getItem() instanceof IAltarReader)
|
||||
{
|
||||
if (playerItem != null) {
|
||||
if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) {
|
||||
playerItem.getItem().onItemRightClick(playerItem, world, player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (altar.getStackInSlot(0) == null && playerItem != null)
|
||||
{
|
||||
if (altar.getStackInSlot(0) == null && playerItem != null) {
|
||||
ItemStack newItem = playerItem.copy();
|
||||
newItem.stackSize = 1;
|
||||
--playerItem.stackSize;
|
||||
playerItem.stackSize--;
|
||||
altar.setInventorySlotContents(0, newItem);
|
||||
// altar.startCycle();
|
||||
}
|
||||
else if (altar.getStackInSlot(0) != null && playerItem == null)
|
||||
{
|
||||
} else if (altar.getStackInSlot(0) != null && playerItem == null) {
|
||||
player.inventory.addItemStackToInventory(altar.getStackInSlot(0));
|
||||
altar.setInventorySlotContents(0, null);
|
||||
altar.clear();
|
||||
// altar.setActive();
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(pos);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package WayofTime.bloodmagic.item.gear;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.NBTHolder;
|
||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator {
|
||||
|
||||
public final int CONVERSION = 100; // How much LP per heart
|
||||
public final int CAPACITY = 10000; // Max LP storage
|
||||
|
||||
public ItemPackSacrifice() {
|
||||
super(ArmorMaterial.CHAIN, 0, 1);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".pack.sacrifice");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (world.isRemote)
|
||||
return stack;
|
||||
|
||||
MovingObjectPosition position = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
|
||||
if (position == null) {
|
||||
return super.onItemRightClick(stack, world, player);
|
||||
} else {
|
||||
if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||
|
||||
if (!(tile instanceof TileAltar))
|
||||
return super.onItemRightClick(stack, world, player);
|
||||
|
||||
TileAltar altar = (TileAltar) tile;
|
||||
|
||||
if(!altar.isActive()) {
|
||||
int amount = this.getStoredLP(stack);
|
||||
|
||||
if(amount > 0) {
|
||||
int filledAmount = altar.fillMainTank(amount);
|
||||
amount -= filledAmount;
|
||||
setStoredLP(stack, amount);
|
||||
world.markBlockForUpdate(position.getBlockPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return BloodMagic.DOMAIN + "models/armor/bloodPack_layer_1.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
list.add(TextHelper.localize("tooltip.BloodMagic.pack.sacrifice.desc"));
|
||||
list.add(TextHelper.localize("tooltip.BloodMagic.pack.stored", getStoredLP(stack)));
|
||||
}
|
||||
|
||||
public void addLP(ItemStack stack, int toAdd) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
|
||||
if (toAdd < 0)
|
||||
toAdd = 0;
|
||||
|
||||
if (toAdd > CAPACITY)
|
||||
toAdd = CAPACITY;
|
||||
|
||||
setStoredLP(stack, getStoredLP(stack) + toAdd);
|
||||
}
|
||||
|
||||
public void setStoredLP(ItemStack stack, int lp) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
stack.getTagCompound().setInteger(NBTHolder.NBT_STORED_LP, lp);
|
||||
}
|
||||
|
||||
public int getStoredLP(ItemStack stack) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
return stack.getTagCompound().getInteger(NBTHolder.NBT_STORED_LP);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package WayofTime.bloodmagic.item.gear;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.NBTHolder;
|
||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator{
|
||||
|
||||
public final int CONVERSION = 100; // How much LP per half heart
|
||||
public final int CAPACITY = 10000; // Max LP storage
|
||||
public final int INTERVAL = 20; // How often the pack syphons
|
||||
public final float HEALTHREQ = 0.5f; // How much health is required for the pack to syphon (0 - 1)
|
||||
|
||||
public ItemPackSelfSacrifice() {
|
||||
super(ArmorMaterial.CHAIN, 0, 1);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".pack.selfSacrifice");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (world.isRemote)
|
||||
return stack;
|
||||
|
||||
MovingObjectPosition position = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
|
||||
if (position == null) {
|
||||
return super.onItemRightClick(stack, world, player);
|
||||
} else {
|
||||
if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||
|
||||
if (!(tile instanceof TileAltar))
|
||||
return super.onItemRightClick(stack, world, player);
|
||||
|
||||
TileAltar altar = (TileAltar) tile;
|
||||
|
||||
if(!altar.isActive()) {
|
||||
int amount = this.getStoredLP(stack);
|
||||
|
||||
if(amount > 0) {
|
||||
int filledAmount = altar.fillMainTank(amount);
|
||||
amount -= filledAmount;
|
||||
setStoredLP(stack, amount);
|
||||
world.markBlockForUpdate(position.getBlockPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
if (world.isRemote || player.capabilities.isCreativeMode)
|
||||
return;
|
||||
|
||||
boolean shouldSyphon = player.getHealth() / player.getMaxHealth() > HEALTHREQ && getStoredLP(stack) < CAPACITY;
|
||||
|
||||
if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0) {
|
||||
NetworkHelper.hurtPlayer(player, 1.0F);
|
||||
addLP(stack, CONVERSION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return BloodMagic.DOMAIN + "models/armor/bloodPack_layer_1.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
list.add(TextHelper.localize("tooltip.BloodMagic.pack.selfSacrifice.desc"));
|
||||
list.add(TextHelper.localize("tooltip.BloodMagic.pack.stored", getStoredLP(stack)));
|
||||
}
|
||||
|
||||
public void addLP(ItemStack stack, int toAdd) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
|
||||
if (toAdd < 0)
|
||||
toAdd = 0;
|
||||
|
||||
if (toAdd > CAPACITY)
|
||||
toAdd = CAPACITY;
|
||||
|
||||
setStoredLP(stack, getStoredLP(stack) + toAdd);
|
||||
}
|
||||
|
||||
public void setStoredLP(ItemStack stack, int lp) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
stack.getTagCompound().setInteger(NBTHolder.NBT_STORED_LP, lp);
|
||||
}
|
||||
|
||||
public int getStoredLP(ItemStack stack) {
|
||||
stack = NBTHolder.checkNBT(stack);
|
||||
return stack.getTagCompound().getInteger(NBTHolder.NBT_STORED_LP);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package WayofTime.bloodmagic.registry;
|
||||
|
||||
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
||||
import WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
|
@ -34,6 +36,8 @@ public class ModItems {
|
|||
public static Item activationCrystal;
|
||||
|
||||
public static Item sacrificialDagger;
|
||||
public static Item packSelfSacrifice;
|
||||
public static Item packSacrifice;
|
||||
|
||||
public static Item sigilDivination;
|
||||
public static Item sigilAir;
|
||||
|
@ -67,6 +71,8 @@ public class ModItems {
|
|||
activationCrystal = registerItem(new ItemActivationCrystal());
|
||||
|
||||
sacrificialDagger = registerItem(new ItemSacrificialDagger());
|
||||
packSacrifice = registerItem(new ItemPackSacrifice());
|
||||
packSelfSacrifice = registerItem(new ItemPackSelfSacrifice());
|
||||
|
||||
sigilDivination = registerItem(new ItemSigilDivination());
|
||||
sigilAir = registerItem(new ItemSigilAir());
|
||||
|
@ -99,6 +105,8 @@ public class ModItems {
|
|||
|
||||
renderHelper.itemRender(sacrificialDagger, 0);
|
||||
renderHelper.itemRender(sacrificialDagger, 1);
|
||||
renderHelper.itemRender(packSacrifice);
|
||||
renderHelper.itemRender(packSelfSacrifice);
|
||||
|
||||
renderHelper.itemRender(sigilDivination);
|
||||
renderHelper.itemRender(sigilAir);
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package WayofTime.bloodmagic.ritual.imperfect;
|
||||
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ritual.imperfect.IImperfectRitualStone;
|
||||
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
public class ImperfectRitualDay extends ImperfectRitual {
|
||||
|
||||
public ImperfectRitualDay() {
|
||||
super("day", new BlockStack(Blocks.gold_block), 5000, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) {
|
||||
|
||||
if (!imperfectRitualStone.getWorld().isRemote)
|
||||
imperfectRitualStone.getWorld().setWorldTime((imperfectRitualStone.getWorld().getWorldTime() / 24000) * 24000);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -311,6 +311,13 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
|||
worldObj.markBlockForUpdate(pos);
|
||||
}
|
||||
|
||||
public int fillMainTank(int amount) {
|
||||
int filledAmount = Math.min(capacity - fluid.amount, amount);
|
||||
fluid.amount += filledAmount;
|
||||
|
||||
return filledAmount;
|
||||
}
|
||||
|
||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
|
||||
if (this.lockdownDuration > 0) {
|
||||
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
||||
|
|
|
@ -1,16 +1,41 @@
|
|||
package WayofTime.bloodmagic.util.handler;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityDeath(LivingHurtEvent event) {
|
||||
|
||||
int chestIndex = 2;
|
||||
|
||||
if (event.source.getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.source.getEntity())) {
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
|
||||
if (player.getCurrentArmor(chestIndex) != null && player.getCurrentArmor(chestIndex).getItem() instanceof ItemPackSacrifice) {
|
||||
ItemPackSacrifice pack = (ItemPackSacrifice) player.getCurrentArmor(chestIndex).getItem();
|
||||
|
||||
boolean shouldSyphon = pack.getStoredLP(player.getCurrentArmor(chestIndex)) < pack.CAPACITY;
|
||||
int totalLP = Math.round(event.ammount * pack.CONVERSION);
|
||||
|
||||
if (shouldSyphon)
|
||||
pack.addLP(player.getCurrentArmor(chestIndex), totalLP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBucketFill(FillBucketEvent event) {
|
||||
if (event.current.getItem() != Items.bucket)
|
||||
|
|
|
@ -8,6 +8,8 @@ item.BloodMagic.activationCrystal.creative.name=Creative Activation Crystal
|
|||
|
||||
item.BloodMagic.sacrificialDagger.normal.name=Sacrificial Dagger
|
||||
item.BloodMagic.sacrificialDagger.creative.name=Creative Sacrificial Dagger
|
||||
item.BloodMagic.pack.selfSacrifice.name=Blood Letter's Pack
|
||||
item.BloodMagic.pack.sacrifice.name=Coat of Arms
|
||||
|
||||
item.BloodMagic.bucket.lifeEssence.name=Bucket of Life
|
||||
|
||||
|
@ -84,6 +86,7 @@ tile.BloodMagic.bloodstonebrick.large.name=Large Bloodstone Brick
|
|||
tooltip.BloodMagic.orb.desc=Stores raw Life Essence
|
||||
tooltip.BloodMagic.orb.owner=Added by: %s
|
||||
tooltip.BloodMagic.currentOwner=Owner: %s
|
||||
|
||||
tooltip.BloodMagic.sigil.air.desc=&oI feel lighter already...
|
||||
tooltip.BloodMagic.sigil.bloodLight.desc=&oI see a light!
|
||||
tooltip.BloodMagic.sigil.compression.desc=&oHands of Diamonds
|
||||
|
@ -91,9 +94,14 @@ tooltip.BloodMagic.sigil.divination.desc=&oPeer into the soul
|
|||
tooltip.BloodMagic.sigil.divination.currentAltarTier=Current Tier: %d
|
||||
tooltip.BloodMagic.sigil.divination.currentEssence=Current Essence: %d LP
|
||||
tooltip.BloodMagic.sigil.divination.currentAltarCapacity=Current Capacity: %d LP
|
||||
tooltip.BloodMagic.sigil.water.desc=Infinite water, anyone?
|
||||
tooltip.BloodMagic.sigil.lava.desc=HOT! DO NOT EAT
|
||||
tooltip.BloodMagic.sigil.void.desc=Better than a Swiffer®!
|
||||
tooltip.BloodMagic.sigil.water.desc=&oInfinite water, anyone?
|
||||
tooltip.BloodMagic.sigil.lava.desc=&oHOT! DO NOT EAT
|
||||
tooltip.BloodMagic.sigil.void.desc=&oBetter than a Swiffer®!
|
||||
|
||||
tooltip.BloodMagic.pack.selfSacrifice.desc=This pack really chafes...
|
||||
tooltip.BloodMagic.pack.sacrifice.desc=Description
|
||||
tooltip.BloodMagic.pack.stored=Stored: %d LP
|
||||
|
||||
tooltip.BloodMagic.activationCrystal.weak=Activates low-level rituals
|
||||
tooltip.BloodMagic.activationCrystal.awakened=Activates more powerful rituals
|
||||
tooltip.BloodMagic.activationCrystal.creative=Creative Only - Activates any ritual
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent":"bloodmagic:item/ItemModelBase",
|
||||
"textures": {
|
||||
"layer0":"bloodmagic:items/BloodPack"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent":"bloodmagic:item/ItemModelBase",
|
||||
"textures": {
|
||||
"layer0":"bloodmagic:items/BloodPack"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue