Added variable incense - issue with build needs to be resolved in build.gradle
This commit is contained in:
parent
f1ebade718
commit
c71edfb937
13 changed files with 360 additions and 32 deletions
|
@ -16,6 +16,8 @@ public class BlockCrucible extends BlockContainer
|
|||
public BlockCrucible()
|
||||
{
|
||||
super(Material.anvil);
|
||||
this.setHardness(2.0f);
|
||||
this.setResistance(1.5f);
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.setBlockName("blockCrucible");
|
||||
}
|
||||
|
@ -29,7 +31,7 @@ public class BlockCrucible extends BlockContainer
|
|||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 0.8F, 0.6F);
|
||||
this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 0.6F, 0.6F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.sacrifice.IIncense;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemIncense extends Item implements IIncense
|
||||
{
|
||||
private static final String[] ITEM_NAMES = new String[]{"Woodash"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public static int minValue;
|
||||
public static int maxValue;
|
||||
public static int itemDuration;
|
||||
|
||||
public ItemIncense()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 64;
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
icons = new IIcon[ITEM_NAMES.length];
|
||||
|
||||
for (int i = 0; i < ITEM_NAMES.length; ++i)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon("AlchemicalWizardry:" + "baseIncenseItem" + ITEM_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
list.add(StatCollector.translateToLocal("tooltip.alchemy.usedinincense"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ITEM_NAMES.length - 1);
|
||||
return ("" + "item.bloodMagicIncenseItem." + ITEM_NAMES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
int j = MathHelper.clamp_int(meta, 0, ITEM_NAMES.length - 1);
|
||||
return icons[j];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
for (int meta = 0; meta < ITEM_NAMES.length; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinLevel(ItemStack stack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel(ItemStack stack)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIncenseDuration(ItemStack stack)
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRedColour(ItemStack stack)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGreenColour(ItemStack stack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlueColour(ItemStack stack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ import net.minecraft.item.EnumAction;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
@ -18,6 +17,7 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.alchemicalWizardry.api.sacrifice.PlayerSacrificeHandler;
|
||||
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -65,12 +65,12 @@ public class SacrificialDagger extends Item
|
|||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemInUseCount)
|
||||
{
|
||||
if(itemInUseCount < 32)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// if(itemInUseCount < 32)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
PlayerSacrificeHandler.sacrificePlayerHealth(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -211,7 +211,7 @@ public class SacrificialDagger extends Item
|
|||
|
||||
public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player)
|
||||
{
|
||||
return !world.isRemote && player.isPotionActive(Potion.regeneration);
|
||||
return !world.isRemote && (PlayerSacrificeHandler.getPlayerIncense(player) > 0);
|
||||
}
|
||||
|
||||
public boolean canUseForSacrifice(ItemStack stack)
|
||||
|
|
|
@ -125,7 +125,6 @@ public class DivinationSigil extends Item implements ArmourUpgrade, IReagentMani
|
|||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 400, 9, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,17 +6,20 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
|
||||
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityBloodLightProjectile;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBloodLightSigil extends EnergyItems implements IHolding
|
||||
public class ItemBloodLightSigil extends EnergyItems implements IHolding, ArmourUpgrade
|
||||
{
|
||||
private int tickDelay = 100;
|
||||
|
||||
|
@ -117,4 +120,22 @@ public class ItemBloodLightSigil extends EnergyItems implements IHolding
|
|||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 400, 9, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
|
@ -9,6 +11,8 @@ import net.minecraft.network.Packet;
|
|||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.sacrifice.IIncense;
|
||||
import WayofTime.alchemicalWizardry.api.sacrifice.PlayerSacrificeHandler;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
|
||||
public class TECrucible extends TEInventory
|
||||
{
|
||||
|
@ -17,6 +21,10 @@ public class TECrucible extends TEInventory
|
|||
public float bColour;
|
||||
|
||||
public int ticksRemaining = 0;
|
||||
public int minValue = 0;
|
||||
public int maxValue = 0;
|
||||
|
||||
public int state = 0; //0 is when it gives off gray particles, 1 is when it gives off white particles (player can't use this incense anymore), 2 is the normal colour of the incense, 3 means no particles (it is out)
|
||||
|
||||
public TECrucible()
|
||||
{
|
||||
|
@ -33,6 +41,9 @@ public class TECrucible extends TEInventory
|
|||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(worldObj.isRemote)
|
||||
return;
|
||||
|
||||
if(ticksRemaining <= 0)
|
||||
{
|
||||
ItemStack stack = this.getStackInSlot(0);
|
||||
|
@ -45,28 +56,100 @@ public class TECrucible extends TEInventory
|
|||
bColour = incense.getBlueColour(stack);
|
||||
ticksRemaining = incense.getIncenseDuration(stack);
|
||||
|
||||
minValue = incense.getMinLevel(stack);
|
||||
maxValue = incense.getMaxLevel(stack);
|
||||
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize <= 0)
|
||||
{
|
||||
this.setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ticksRemaining > 0)
|
||||
{
|
||||
List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 3, 3);
|
||||
|
||||
if(playerList != null && !playerList.isEmpty())
|
||||
{
|
||||
boolean stateChanged = false;
|
||||
boolean allAreGood = true;
|
||||
|
||||
for(EntityPlayer player : playerList)
|
||||
{
|
||||
if(ticksRemaining > 0 && PlayerSacrificeHandler.incrementIncense(player, minValue, maxValue))
|
||||
{
|
||||
ticksRemaining--;
|
||||
if(state != 2)
|
||||
{
|
||||
state = 2;
|
||||
stateChanged = true;
|
||||
}
|
||||
|
||||
allAreGood = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(allAreGood && state != 1)
|
||||
{
|
||||
state = 1;
|
||||
stateChanged = true;
|
||||
}
|
||||
|
||||
if(stateChanged)
|
||||
{
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(state != 0)
|
||||
{
|
||||
state = 0;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
ticksRemaining--;
|
||||
if(state != 0)
|
||||
{
|
||||
state = 0;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void spawnClientParticle(World world, int x, int y, int z, Random rand)
|
||||
{
|
||||
world.spawnParticle("reddust", x + 0.5D + rand.nextGaussian() / 8, y + 0.5D, z + 0.5D + rand.nextGaussian() / 8, rColour, gColour, bColour);
|
||||
switch(state)
|
||||
{
|
||||
case 0:
|
||||
world.spawnParticle("reddust", x + 0.5D + rand.nextGaussian() / 8, y + 0.5D, z + 0.5D + rand.nextGaussian() / 8, 0.15, 0.15, 0.15);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
world.spawnParticle("reddust", x + 0.5D + rand.nextGaussian() / 8, y + 0.5D, z + 0.5D + rand.nextGaussian() / 8, 0.9, 0.9, 0.9);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
world.spawnParticle("reddust", x + 0.5D + rand.nextGaussian() / 8, y + 0.5D, z + 0.5D + rand.nextGaussian() / 8, rColour, gColour, bColour);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
//No particles - it is out
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
|
||||
tag.setInteger("ticksRemaining", ticksRemaining);
|
||||
tag.setInteger("minValue", minValue);
|
||||
tag.setInteger("maxValue", maxValue);
|
||||
|
||||
this.writeClientNBT(tag);
|
||||
}
|
||||
|
||||
|
@ -74,16 +157,12 @@ public class TECrucible extends TEInventory
|
|||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
this.readClientNBT(tag);
|
||||
}
|
||||
|
||||
public void readClientNBT(NBTTagCompound tag)
|
||||
{
|
||||
rColour = tag.getFloat("rColour");
|
||||
gColour = tag.getFloat("gColour");
|
||||
bColour = tag.getFloat("bColour");
|
||||
|
||||
|
||||
ticksRemaining = tag.getInteger("ticksRemaining");
|
||||
minValue = tag.getInteger("minValue");
|
||||
maxValue = tag.getInteger("maxValue");
|
||||
|
||||
this.readClientNBT(tag);
|
||||
}
|
||||
|
||||
public void writeClientNBT(NBTTagCompound tag)
|
||||
|
@ -91,10 +170,18 @@ public class TECrucible extends TEInventory
|
|||
tag.setFloat("rColour", rColour);
|
||||
tag.setFloat("gColour", gColour);
|
||||
tag.setFloat("bColour", bColour);
|
||||
|
||||
tag.setInteger("ticksRemaining", ticksRemaining);
|
||||
tag.setInteger("state", state);
|
||||
}
|
||||
|
||||
public void readClientNBT(NBTTagCompound tag)
|
||||
{
|
||||
rColour = tag.getFloat("rColour");
|
||||
gColour = tag.getFloat("gColour");
|
||||
bColour = tag.getFloat("bColour");
|
||||
state = tag.getInteger("state");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
|
@ -107,7 +194,7 @@ public class TECrucible extends TEInventory
|
|||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
super.onDataPacket(net, packet);
|
||||
readClientNBT(packet.func_148857_g());
|
||||
readClientNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,4 +202,10 @@ public class TECrucible extends TEInventory
|
|||
{
|
||||
return "TECrucible";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack)
|
||||
{
|
||||
return stack != null ? stack.getItem() instanceof IIncense : false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue