Friendly Modifiers
This commit is contained in:
parent
d5c3d9e3ef
commit
5f6990edaf
@ -37,7 +37,7 @@ import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
* @dependencies: IC2 API
|
||||
*/
|
||||
|
||||
@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.dev.42", dependencies = "required-after:Forge@[7.7.1.675,)")
|
||||
@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.dev.43", dependencies = "required-after:Forge@[7.7.1.675,)")
|
||||
@NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.util.network.TPacketHandler.class)
|
||||
public class TConstruct
|
||||
{
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidEvent;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
public class CastingBasinLogic extends InventoryLogic implements ILiquidTank, ITankContainer, ISidedInventory
|
||||
@ -191,10 +192,29 @@ public class CastingBasinLogic extends InventoryLogic implements ILiquidTank, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain (int maxDrain, boolean doDrain) //Doesn't actually drain
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public LiquidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (liquid == null || liquid.itemID <= 0) return null;
|
||||
if (liquid.amount <= 0) return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if (liquid.amount < used) used = liquid.amount;
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
LiquidStack drained = new LiquidStack(liquid.itemID, used, liquid.itemMeta);
|
||||
|
||||
// Reset liquid if emptied
|
||||
if (liquid.amount <= 0) liquid = null;
|
||||
|
||||
if (doDrain)
|
||||
LiquidEvent.fireEvent(new LiquidEvent.LiquidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this));
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankPressure ()
|
||||
@ -219,16 +239,16 @@ public class CastingBasinLogic extends InventoryLogic implements ILiquidTank, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public LiquidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(0, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain (int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public LiquidStack drain (int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks (ForgeDirection direction)
|
||||
@ -345,24 +365,29 @@ public class CastingBasinLogic extends InventoryLogic implements ILiquidTank, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return new int[] { 1 };
|
||||
else
|
||||
return new int[] { 0 };
|
||||
}
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (liquid != null)
|
||||
return false;
|
||||
|
||||
if (slot == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (slot == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package mods.tinker.tconstruct.blocks.logic;
|
||||
import mods.tinker.tconstruct.TConstruct;
|
||||
import mods.tinker.tconstruct.library.blocks.InventoryLogic;
|
||||
import mods.tinker.tconstruct.library.crafting.CastingRecipe;
|
||||
import mods.tinker.tconstruct.library.crafting.LiquidCasting;
|
||||
import mods.tinker.tconstruct.library.util.IPattern;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@ -17,353 +16,379 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidEvent;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
public class CastingTableLogic extends InventoryLogic implements ILiquidTank, ITankContainer, ISidedInventory
|
||||
{
|
||||
public LiquidStack liquid;
|
||||
int castingDelay = 0;
|
||||
int renderOffset = 0;
|
||||
int capacity = 0;
|
||||
boolean needsUpdate;
|
||||
boolean init = true;
|
||||
int tick;
|
||||
public LiquidStack liquid;
|
||||
int castingDelay = 0;
|
||||
int renderOffset = 0;
|
||||
int capacity = 0;
|
||||
boolean needsUpdate;
|
||||
boolean init = true;
|
||||
int tick;
|
||||
|
||||
public CastingTableLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
public CastingTableLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName () //Not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getInvName () //Not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName () //Still not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected String getDefaultName () //Still not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) //Definitely not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) //Definitely not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Tank */
|
||||
@Override
|
||||
public LiquidStack getLiquid ()
|
||||
{
|
||||
return this.liquid;
|
||||
}
|
||||
/* Tank */
|
||||
@Override
|
||||
public LiquidStack getLiquid ()
|
||||
{
|
||||
return this.liquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public int updateCapacity () //Only used to initialize
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
public int updateCapacity () //Only used to initialize
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
ItemStack inv = inventory[0];
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv.getItemDamage()) * 0.5;
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv.getItemDamage()) * 0.5;
|
||||
|
||||
else
|
||||
ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv);
|
||||
else
|
||||
ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int updateCapacity (int capacity)
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ItemStack inv = inventory[0];
|
||||
public int updateCapacity (int capacity)
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv.getItemDamage()) * 0.5;
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
else
|
||||
ret = capacity;
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv.getItemDamage()) * 0.5;
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
ret = capacity;
|
||||
|
||||
@Override
|
||||
public int fill (LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (this.liquid == null)
|
||||
@Override
|
||||
public int fill (LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
return 0;
|
||||
|
||||
if (this.liquid == null)
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(resource, inventory[0]);
|
||||
if (recipe == null)
|
||||
return 0;
|
||||
this.capacity = updateCapacity(recipe.castingMetal.amount);
|
||||
|
||||
if (inventory[1] == null)
|
||||
{
|
||||
LiquidStack copyLiquid = resource.copy();
|
||||
|
||||
if (copyLiquid.amount > this.capacity)
|
||||
{
|
||||
copyLiquid.amount = this.capacity;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (copyLiquid.amount == this.capacity)
|
||||
{
|
||||
castingDelay = recipe.coolTime;
|
||||
}
|
||||
renderOffset = copyLiquid.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
this.liquid = copyLiquid;
|
||||
needsUpdate = true;
|
||||
}
|
||||
return copyLiquid.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (resource.isLiquidEqual(this.liquid))
|
||||
{
|
||||
if (resource.amount + this.liquid.amount >= this.capacity) //Start timer here
|
||||
{
|
||||
int roomInTank = this.capacity - liquid.amount;
|
||||
if (doFill && roomInTank > 0)
|
||||
{
|
||||
renderOffset = roomInTank;
|
||||
castingDelay = TConstruct.tableCasting.getCastingDelay(this.liquid, inventory[0]);
|
||||
this.liquid.amount = this.capacity;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return roomInTank;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
this.liquid.amount += resource.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged () //Isn't actually called?
|
||||
{
|
||||
super.onInventoryChanged();
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (liquid == null || liquid.itemID <= 0) return null;
|
||||
if (liquid.amount <= 0) return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if (liquid.amount < used) used = liquid.amount;
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(resource, inventory[0]);
|
||||
if (recipe == null)
|
||||
return 0;
|
||||
this.capacity = updateCapacity(recipe.castingMetal.amount);
|
||||
|
||||
if (inventory[1] == null)
|
||||
{
|
||||
LiquidStack copyLiquid = resource.copy();
|
||||
|
||||
if (copyLiquid.amount > this.capacity)
|
||||
{
|
||||
copyLiquid.amount = this.capacity;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (copyLiquid.amount == this.capacity)
|
||||
{
|
||||
castingDelay = recipe.coolTime;
|
||||
}
|
||||
renderOffset = copyLiquid.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
this.liquid = copyLiquid;
|
||||
needsUpdate = true;
|
||||
}
|
||||
return copyLiquid.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
else if (resource.isLiquidEqual(this.liquid))
|
||||
{
|
||||
if (resource.amount + this.liquid.amount >= this.capacity) //Start timer here
|
||||
{
|
||||
int roomInTank = this.capacity - liquid.amount;
|
||||
if (doFill && roomInTank > 0)
|
||||
{
|
||||
renderOffset = roomInTank;
|
||||
castingDelay = TConstruct.tableCasting.getCastingDelay(this.liquid, inventory[0]);
|
||||
this.liquid.amount = this.capacity;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return roomInTank;
|
||||
}
|
||||
LiquidStack drained = new LiquidStack(liquid.itemID, used, liquid.itemMeta);
|
||||
|
||||
else
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
this.liquid.amount += resource.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
// Reset liquid if emptied
|
||||
if (liquid.amount <= 0) liquid = null;
|
||||
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (doDrain)
|
||||
LiquidEvent.fireEvent(new LiquidEvent.LiquidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this));
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged () //Isn't actually called?
|
||||
{
|
||||
super.onInventoryChanged();
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return drained;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
return stack;
|
||||
}
|
||||
@Override
|
||||
public int getTankPressure ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain (int maxDrain, boolean doDrain) //Doesn't actually drain
|
||||
{
|
||||
return null;
|
||||
}
|
||||
/* Tank Container */
|
||||
|
||||
@Override
|
||||
public int getTankPressure ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int fill (ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
//if (from == ForgeDirection.UP)
|
||||
return fill(0, resource, doFill);
|
||||
//return 0;
|
||||
}
|
||||
|
||||
/* Tank Container */
|
||||
@Override
|
||||
public int fill (int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
return fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
//if (from == ForgeDirection.UP)
|
||||
return fill(0, resource, doFill);
|
||||
//return 0;
|
||||
}
|
||||
@Override
|
||||
public LiquidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(0, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
return fill(resource, doFill);
|
||||
}
|
||||
@Override
|
||||
public LiquidStack drain (int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ILiquidTank[] getTanks (ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[] { this };
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain (int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ILiquidTank getTank (ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks (ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[] { this };
|
||||
}
|
||||
public int getLiquidAmount ()
|
||||
{
|
||||
return liquid.amount - renderOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank (ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (castingDelay > 0)
|
||||
{
|
||||
//System.out.println("Casting");
|
||||
castingDelay--;
|
||||
if (castingDelay == 0)
|
||||
castLiquid();
|
||||
}
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public int getLiquidAmount ()
|
||||
{
|
||||
return liquid.amount - renderOffset;
|
||||
}
|
||||
tick++;
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
tick = 0;
|
||||
if (needsUpdate)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (castingDelay > 0)
|
||||
{
|
||||
//System.out.println("Casting");
|
||||
castingDelay--;
|
||||
if (castingDelay == 0)
|
||||
castLiquid();
|
||||
}
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
public void castLiquid ()
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]);
|
||||
if (recipe != null)
|
||||
{
|
||||
inventory[1] = recipe.getResult();
|
||||
if (recipe.consumeCast)
|
||||
inventory[0] = null;
|
||||
liquid = null;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
tick++;
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
tick = 0;
|
||||
if (needsUpdate)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
/* NBT */
|
||||
|
||||
public void castLiquid ()
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]);
|
||||
if (recipe != null)
|
||||
{
|
||||
inventory[1] = recipe.getResult();
|
||||
if (recipe.consumeCast)
|
||||
inventory[0] = null;
|
||||
liquid = null;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
this.liquid = new LiquidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta"));
|
||||
else
|
||||
this.liquid = null;
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
if (tags.getBoolean("Initialized"))
|
||||
this.capacity = tags.getInteger("Capacity");
|
||||
else
|
||||
this.capacity = updateCapacity();
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
this.liquid = new LiquidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta"));
|
||||
else
|
||||
this.liquid = null;
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
if (tags.getBoolean("Initialized"))
|
||||
this.capacity = tags.getInteger("Capacity");
|
||||
else
|
||||
this.capacity = updateCapacity();
|
||||
}
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
tags.setInteger("itemID", liquid.itemID);
|
||||
tags.setInteger("amount", liquid.amount);
|
||||
tags.setInteger("itemMeta", liquid.itemMeta);
|
||||
}
|
||||
tags.setBoolean("Initialized", init);
|
||||
tags.setInteger("Capacity", capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
tags.setInteger("itemID", liquid.itemID);
|
||||
tags.setInteger("amount", liquid.amount);
|
||||
tags.setInteger("itemMeta", liquid.itemMeta);
|
||||
}
|
||||
tags.setBoolean("Initialized", init);
|
||||
tags.setInteger("Capacity", capacity);
|
||||
}
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (liquid != null)
|
||||
return false;
|
||||
|
||||
if (slot == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return new int[] { 1 };
|
||||
else
|
||||
return new int[] { 0 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (slot == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
9
mods/tinker/tconstruct/blocks/logic/RedwireLogic.java
Normal file
9
mods/tinker/tconstruct/blocks/logic/RedwireLogic.java
Normal file
@ -0,0 +1,9 @@
|
||||
package mods.tinker.tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class RedwireLogic extends TileEntity
|
||||
{
|
||||
byte facesUsed;
|
||||
byte type;
|
||||
}
|
@ -539,6 +539,8 @@ public class TContent implements IFuelHandler
|
||||
|
||||
ItemStack silkyJewel = new ItemStack(materials, 1, 26);
|
||||
tb.registerToolMod(new ModButtertouch(new ItemStack[] {silkyJewel}, 12));
|
||||
|
||||
TConstructRegistry.registerActiveToolMod(new TActiveOmniMod());
|
||||
|
||||
/* Smeltery */
|
||||
ItemStack ingotcast = new ItemStack(metalPattern, 1, 0);
|
||||
@ -609,7 +611,7 @@ public class TContent implements IFuelHandler
|
||||
basinCasting.addCastingRecipe(new ItemStack(Block.obsidian), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 11), null, true, 100);// obsidian
|
||||
basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 9), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 12), null, true, 100); //steel
|
||||
|
||||
basinCasting.addCastingRecipe(new ItemStack(speedBlock, 1, 0), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue / 9, 3), new ItemStack(Block.gravel), true, 100); //steel
|
||||
basinCasting.addCastingRecipe(new ItemStack(speedBlock, 1, 0), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue / 9, 3), new ItemStack(Block.gravel), true, 100); //brownstone
|
||||
|
||||
//Ore
|
||||
Smeltery.addMelting(Block.oreIron, 0, 600, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
|
||||
|
57
mods/tinker/tconstruct/library/ActiveToolMod.java
Normal file
57
mods/tinker/tconstruct/library/ActiveToolMod.java
Normal file
@ -0,0 +1,57 @@
|
||||
package mods.tinker.tconstruct.library;
|
||||
|
||||
import mods.tinker.tconstruct.library.tools.ToolCore;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ActiveToolMod
|
||||
{
|
||||
/* Updating */
|
||||
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Harvesting */
|
||||
public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean afterBlockBreak()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Attacking */
|
||||
|
||||
public int baseAttackDamage(int earlyModDamage, int damage, ToolCore tool, ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Calculated after sprinting and enchant bonuses
|
||||
public float knockback(float modKnockback, float currentKnockback, ToolCore tool, ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public int attackDamage(int modDamage, int currentDamage, ToolCore tool, ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void lateAttackEntity()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Damage tool */
|
||||
public boolean damageTool(ItemStack stack, int damage, EntityLiving entity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package mods.tinker.tconstruct.library;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import mods.tinker.tconstruct.library.crafting.Detailing;
|
||||
import mods.tinker.tconstruct.library.crafting.LiquidCasting;
|
||||
@ -22,10 +23,13 @@ public class TConstructRegistry
|
||||
public static ArrayList<ToolCore> tools = new ArrayList<ToolCore>(20);
|
||||
public static HashMap<Integer, ToolMaterial> toolMaterials = new HashMap<Integer, ToolMaterial>(40);
|
||||
public static HashMap<String, ToolMaterial> toolMaterialStrings = new HashMap<String, ToolMaterial>(40);
|
||||
|
||||
public static LinkedList<ActiveToolMod> activeModifiers = new LinkedList<ActiveToolMod>();
|
||||
|
||||
public static TabTools toolTab;
|
||||
public static TabTools materialTab;
|
||||
public static TabTools blockTab;
|
||||
@Deprecated
|
||||
public static Item toolRod;
|
||||
|
||||
//Tools
|
||||
@ -132,4 +136,9 @@ public class TConstructRegistry
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerActiveToolMod(ActiveToolMod mod)
|
||||
{
|
||||
activeModifiers.add(mod);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mods.tinker.tconstruct.library.ActiveToolMod;
|
||||
import mods.tinker.tconstruct.library.TConstructRegistry;
|
||||
import mods.tinker.tconstruct.library.util.PiercingEntityDamage;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
@ -50,7 +52,7 @@ public class AbilityHelper
|
||||
|
||||
if (random.nextInt(10) < 10 - durability)
|
||||
{
|
||||
damageTool(stack, 1, tags, player, false, true);
|
||||
damageTool(stack, 1, tags, player, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -68,8 +70,15 @@ public class AbilityHelper
|
||||
boolean broken = toolTags.getBoolean("Broken");
|
||||
|
||||
int durability = tags.getCompoundTag("InfiTool").getInteger("Damage");
|
||||
float shoddy = tags.getCompoundTag("InfiTool").getFloat("Shoddy");
|
||||
float damageModifier = -shoddy * durability / 100f;
|
||||
float stonebound = tags.getCompoundTag("InfiTool").getFloat("Shoddy");
|
||||
float stoneboundDamage = -stonebound * durability / 100f;
|
||||
|
||||
int earlyModDamage = 0;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
earlyModDamage = mod.baseAttackDamage(earlyModDamage, damage, tool, stack, player, entity);
|
||||
}
|
||||
damage += earlyModDamage;
|
||||
|
||||
if (player.isPotionActive(Potion.damageBoost))
|
||||
{
|
||||
@ -90,7 +99,7 @@ public class AbilityHelper
|
||||
knockback += EnchantmentHelper.getKnockbackModifier(player, (EntityLiving) entity);
|
||||
}
|
||||
|
||||
damage += damageModifier;
|
||||
damage += stoneboundDamage;
|
||||
|
||||
if (player.isSprinting())
|
||||
{
|
||||
@ -102,6 +111,20 @@ public class AbilityHelper
|
||||
damage *= lunge;
|
||||
}
|
||||
}
|
||||
|
||||
float modKnockback = 0f;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
modKnockback = mod.knockback(modKnockback, knockback, tool, stack, player, entity);
|
||||
}
|
||||
knockback += modKnockback;
|
||||
|
||||
int modDamage = 0;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
modDamage = mod.attackDamage(modDamage, damage, tool, stack, player, entity);
|
||||
}
|
||||
damage += modDamage;
|
||||
|
||||
if (damage > 0 || enchantDamage > 0)
|
||||
{
|
||||
@ -249,36 +272,39 @@ public class AbilityHelper
|
||||
public static void damageTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
damageTool(stack, dam, tags, entity, ignoreCharge, true);
|
||||
damageTool(stack, dam, tags, entity, ignoreCharge);
|
||||
}
|
||||
|
||||
public static void healTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge, boolean updateDamageBar)
|
||||
public static void healTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
damageTool(stack, -dam, tags, entity, ignoreCharge, updateDamageBar);
|
||||
damageTool(stack, -dam, tags, entity, ignoreCharge);
|
||||
}
|
||||
|
||||
public static void damageTool (ItemStack stack, int dam, NBTTagCompound tags, EntityLiving entity, boolean ignoreCharge, boolean updateDamageBar)
|
||||
public static void damageTool (ItemStack stack, int dam, NBTTagCompound tags, EntityLiving entity, boolean ignoreCharge)
|
||||
{
|
||||
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode)
|
||||
return;
|
||||
|
||||
if (ignoreCharge || !damageElectricTool(stack, tags, entity))
|
||||
{
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.damageTool(stack, dam, entity));
|
||||
return;
|
||||
}
|
||||
int damage = tags.getCompoundTag("InfiTool").getInteger("Damage");
|
||||
int damageTrue = damage + dam;
|
||||
int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
|
||||
if (damageTrue <= 0)
|
||||
{
|
||||
tags.getCompoundTag("InfiTool").setInteger("Damage", 0);
|
||||
if (updateDamageBar)
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
else if (damageTrue > maxDamage)
|
||||
{
|
||||
breakTool(stack, tags, entity);
|
||||
if (updateDamageBar)
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
@ -287,7 +313,7 @@ public class AbilityHelper
|
||||
tags.getCompoundTag("InfiTool").setInteger("Damage", damage + dam);
|
||||
int toolDamage = (damage * 100 / maxDamage) + 1;
|
||||
int stackDamage = stack.getItemDamage();
|
||||
if (updateDamageBar && toolDamage != stackDamage)
|
||||
if (toolDamage != stackDamage)
|
||||
{
|
||||
stack.setItemDamage((damage * 100 / maxDamage) + 1);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mods.tinker.tconstruct.library.tools;
|
||||
|
||||
import mods.tinker.tconstruct.library.ActiveToolMod;
|
||||
import mods.tinker.tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
@ -43,58 +45,14 @@ public abstract class DualHarvestTool extends HarvestTool
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel") && shlvl <= tags.getInteger("HarvestLevel2"))
|
||||
{
|
||||
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
|
||||
{
|
||||
ItemStack smeltStack = new ItemStack(block.idDropped(block.blockID, random, 0), 1, block.damageDropped(meta));
|
||||
if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null)
|
||||
return false;
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
|
||||
if (result != null)
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
onBlockDestroyed(stack, world, bID, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStack spawnme = result.copy();
|
||||
if (!(result.getItem() instanceof ItemBlock))
|
||||
{
|
||||
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
|
||||
if (loot > 0)
|
||||
{
|
||||
spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
|
||||
}
|
||||
}
|
||||
EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme);
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player));
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
|
||||
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float f = (float) x + random.nextFloat();
|
||||
float f1 = (float) y + random.nextFloat();
|
||||
float f2 = (float) z + random.nextFloat();
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return cancelHarvest;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mods.tinker.tconstruct.library.tools;
|
||||
|
||||
import mods.tinker.tconstruct.common.TContent;
|
||||
import mods.tinker.tconstruct.library.ActiveToolMod;
|
||||
import mods.tinker.tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
@ -19,121 +21,94 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
public abstract class HarvestTool extends ToolCore
|
||||
{
|
||||
|
||||
public HarvestTool(int itemID, int baseDamage)
|
||||
{
|
||||
super(itemID, baseDamage);
|
||||
}
|
||||
public HarvestTool(int itemID, int baseDamage)
|
||||
{
|
||||
super(itemID, baseDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
TContent.modL.midStreamModify(stack);
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
/*NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
int bID = player.worldObj.getBlockId(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = Block.blocksList[bID];
|
||||
if (block == null || bID < 1)
|
||||
return false;
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
|
||||
{
|
||||
ItemStack smeltStack = new ItemStack(block.idDropped(block.blockID, random, 0), 1, block.damageDropped(meta));
|
||||
if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null)
|
||||
return false;
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
|
||||
if (result != null)
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
onBlockDestroyed(stack, world, bID, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStack spawnme = result.copy();
|
||||
if (!(result.getItem() instanceof ItemBlock))
|
||||
{
|
||||
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
|
||||
if (loot > 0)
|
||||
{
|
||||
spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
|
||||
}
|
||||
}
|
||||
EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme);
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
int bID = player.worldObj.getBlockId(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = Block.blocksList[bID];
|
||||
if (block == null || bID < 1)
|
||||
return false;
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
onBlockDestroyed(stack, world, bID, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
return cancelHarvest;
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
onBlockDestroyed(stack, world, bID, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
@Override
|
||||
public float getStrVsBlock (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
|
||||
Material[] materials = getEffectiveMaterials();
|
||||
for (int i = 0; i < materials.length; i++)
|
||||
{
|
||||
if (materials[i] == block.blockMaterial)
|
||||
{
|
||||
float speed = tags.getInteger("MiningSpeed");
|
||||
speed /= 100f;
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
int durability = tags.getInteger("Damage");
|
||||
Material[] materials = getEffectiveMaterials();
|
||||
for (int i = 0; i < materials.length; i++)
|
||||
{
|
||||
if (materials[i] == block.blockMaterial)
|
||||
{
|
||||
float speed = tags.getInteger("MiningSpeed");
|
||||
speed /= 100f;
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
int durability = tags.getInteger("Damage");
|
||||
|
||||
float shoddy = tags.getFloat("Shoddy");
|
||||
speed += shoddy * durability / 100f;
|
||||
float shoddy = tags.getFloat("Shoddy");
|
||||
speed += shoddy * durability / 100f;
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
return speed;
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
return super.getStrVsBlock(stack, block, meta);
|
||||
}
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
return speed;
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
return super.getStrVsBlock(stack, block, meta);
|
||||
}
|
||||
|
||||
public boolean canHarvestBlock (Block block)
|
||||
{
|
||||
if (block.blockMaterial.isToolNotRequired())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (Material m : getEffectiveMaterials())
|
||||
{
|
||||
if (m == block.blockMaterial)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toolCategories()
|
||||
{
|
||||
return new String[] { "harvest" };
|
||||
}
|
||||
public boolean canHarvestBlock (Block block)
|
||||
{
|
||||
if (block.blockMaterial.isToolNotRequired())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (Material m : getEffectiveMaterials())
|
||||
{
|
||||
if (m == block.blockMaterial)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract Material[] getEffectiveMaterials ();
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "harvest" };
|
||||
}
|
||||
|
||||
protected abstract String getHarvestType ();
|
||||
protected abstract Material[] getEffectiveMaterials ();
|
||||
|
||||
protected abstract String getHarvestType ();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import mods.tinker.tconstruct.library.ActiveToolMod;
|
||||
import mods.tinker.tconstruct.library.TConstructRegistry;
|
||||
import mods.tinker.tconstruct.library.crafting.ToolBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
@ -47,9 +48,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
* Others:
|
||||
* Accessory: Base and tag, above head. Sword guards, binding, etc
|
||||
* Effects: Render tag, top layer. Fancy effects like moss or diamond edge.
|
||||
* Render order: Handle > Head > Accessory > Effect1 > Effect2 > Effect3
|
||||
* Render order: Handle > Head > Accessory > Effect1 > Effect2 > Effect3 > etc
|
||||
* Unbreaking: Reinforced in-game, 10% chance to not use durability per level
|
||||
* Shoddy/Spiny: Mines faster or slower and does less or more attack.
|
||||
* Stonebound: Mines faster as the tool takes damage, but has less attack
|
||||
* Spiny: Opposite of stonebound
|
||||
*
|
||||
* Modifiers have their own tags.
|
||||
* @see ToolMod
|
||||
@ -464,19 +466,10 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox
|
||||
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
if (!world.isRemote && entity instanceof EntityLiving && !((EntityLiving) entity).isSwingInProgress)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey("Moss"))
|
||||
{
|
||||
int chance = tags.getInteger("Moss");
|
||||
int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 750 : 1500;
|
||||
if (random.nextInt(check) < chance)
|
||||
{
|
||||
AbilityHelper.healTool(stack, 1, (EntityLiving) entity, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
mod.updateTool(this, stack, world, entity);
|
||||
}
|
||||
}
|
||||
|
||||
/* Tool uses */
|
||||
@ -488,72 +481,20 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
int bID = player.worldObj.getBlockId(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = Block.blocksList[bID];
|
||||
if (block == null || bID < 1 || bID > 4095)
|
||||
return false;
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player));
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
|
||||
{
|
||||
ItemStack smeltStack = new ItemStack(block.idDropped(meta, random, 0), 1, block.damageDropped(meta));
|
||||
if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null)
|
||||
return false;
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
|
||||
if (result != null)
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
onBlockDestroyed(stack, world, bID, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStack spawnme = result.copy();
|
||||
if (!(result.getItem() instanceof ItemBlock))
|
||||
{
|
||||
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
|
||||
if (loot > 0)
|
||||
{
|
||||
spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
|
||||
}
|
||||
}
|
||||
EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme);
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float f = (float) x + random.nextFloat();
|
||||
float f1 = (float) y + random.nextFloat();
|
||||
float f2 = (float) z + random.nextFloat();
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return cancelHarvest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed (ItemStack itemstack, World world, int bID, int x, int y, int z, EntityLiving player)
|
||||
public boolean onBlockDestroyed (ItemStack itemstack, World world, int blockID, int x, int y, int z, EntityLiving player)
|
||||
{
|
||||
return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, player, random);
|
||||
return AbilityHelper.onBlockChanged(itemstack, world, blockID, x, y, z, player, random);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,12 +98,12 @@ public abstract class Weapon extends ToolCore
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
TContent.modL.midStreamModify(stack);
|
||||
return super.onLeftClickEntity(stack, player, entity);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String[] toolCategories()
|
||||
|
128
mods/tinker/tconstruct/modifiers/TActiveOmniMod.java
Normal file
128
mods/tinker/tconstruct/modifiers/TActiveOmniMod.java
Normal file
@ -0,0 +1,128 @@
|
||||
package mods.tinker.tconstruct.modifiers;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mods.tinker.tconstruct.common.TContent;
|
||||
import mods.tinker.tconstruct.library.ActiveToolMod;
|
||||
import mods.tinker.tconstruct.library.tools.AbilityHelper;
|
||||
import mods.tinker.tconstruct.library.tools.HarvestTool;
|
||||
import mods.tinker.tconstruct.library.tools.ToolCore;
|
||||
import mods.tinker.tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TActiveOmniMod extends ActiveToolMod
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
|
||||
{
|
||||
if (!world.isRemote && entity instanceof EntityLiving && !((EntityLiving) entity).isSwingInProgress)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey("Moss"))
|
||||
{
|
||||
int chance = tags.getInteger("Moss");
|
||||
int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 750 : 1500;
|
||||
if (random.nextInt(check) < chance)
|
||||
{
|
||||
AbilityHelper.healTool(stack, 1, (EntityLiving) entity, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Harvesting */
|
||||
@Override
|
||||
public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (player.capabilities.isCreativeMode)
|
||||
return false;
|
||||
|
||||
if (tool instanceof HarvestTool)
|
||||
TContent.modL.midStreamModify(stack);
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
int bID = player.worldObj.getBlockId(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = Block.blocksList[bID];
|
||||
if (block == null || bID < 1 || bID > 4095)
|
||||
return false;
|
||||
|
||||
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
|
||||
{
|
||||
ItemStack smeltStack = new ItemStack(block.idDropped(meta, random, 0), 1, block.damageDropped(meta));
|
||||
if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null)
|
||||
return false;
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
|
||||
if (result != null)
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
tool.onBlockDestroyed(stack, world, bID, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStack spawnme = result.copy();
|
||||
if (!(result.getItem() instanceof ItemBlock))
|
||||
{
|
||||
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
|
||||
if (loot > 0)
|
||||
{
|
||||
spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
|
||||
}
|
||||
}
|
||||
EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme);
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float f = (float) x + random.nextFloat();
|
||||
float f1 = (float) y + random.nextFloat();
|
||||
float f2 = (float) z + random.nextFloat();
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Attacking */
|
||||
|
||||
@Override
|
||||
public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
if (tool instanceof Weapon)
|
||||
TContent.modL.midStreamModify(stack);
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,26 +1,19 @@
|
||||
package mods.tinker.tconstruct.util.player;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mods.tinker.tconstruct.client.TProxyClient;
|
||||
import mods.tinker.tconstruct.common.TContent;
|
||||
import mods.tinker.tconstruct.library.tools.AbilityHelper;
|
||||
import mods.tinker.tconstruct.util.PHConstruct;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumEntitySize;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
@ -28,290 +21,303 @@ import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class TPlayerHandler implements IPlayerTracker
|
||||
{
|
||||
/* Player */
|
||||
//public int hunger;
|
||||
public ConcurrentHashMap<String, TPlayerStats> playerStats = new ConcurrentHashMap<String, TPlayerStats>();
|
||||
/* Player */
|
||||
//public int hunger;
|
||||
public ConcurrentHashMap<String, TPlayerStats> playerStats = new ConcurrentHashMap<String, TPlayerStats>();
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin (EntityPlayer entityplayer)
|
||||
{
|
||||
//Lookup player
|
||||
TFoodStats food = new TFoodStats();
|
||||
food.readStats(entityplayer.foodStats);
|
||||
entityplayer.foodStats = food;
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
if (!tags.hasKey("TConstruct"))
|
||||
{
|
||||
tags.setCompoundTag("TConstruct", new NBTTagCompound());
|
||||
}
|
||||
TPlayerStats stats = new TPlayerStats();
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
stats.armor = new ArmorExtended();
|
||||
stats.armor.init(entityplayer);
|
||||
stats.armor.loadFromNBT(entityplayer);
|
||||
@Override
|
||||
public void onPlayerLogin (EntityPlayer entityplayer)
|
||||
{
|
||||
//Lookup player
|
||||
TFoodStats food = new TFoodStats();
|
||||
food.readStats(entityplayer.foodStats);
|
||||
entityplayer.foodStats = food;
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
if (!tags.hasKey("TConstruct"))
|
||||
{
|
||||
tags.setCompoundTag("TConstruct", new NBTTagCompound());
|
||||
}
|
||||
TPlayerStats stats = new TPlayerStats();
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
stats.armor = new ArmorExtended();
|
||||
stats.armor.init(entityplayer);
|
||||
stats.armor.loadFromNBT(entityplayer);
|
||||
|
||||
stats.level = entityplayer.experienceLevel;
|
||||
stats.health = entityplayer.maxHealth;
|
||||
stats.hunger = entityplayer.getFoodStats().getFoodLevel();
|
||||
stats.beginnerManual = tags.getCompoundTag("TConstruct").getBoolean("beginnerManual");
|
||||
stats.materialManual = tags.getCompoundTag("TConstruct").getBoolean("materialManual");
|
||||
stats.smelteryManual = tags.getCompoundTag("TConstruct").getBoolean("smelteryManual");
|
||||
if (!stats.beginnerManual)
|
||||
{
|
||||
tags.getCompoundTag("TConstruct").setBoolean("beginnerManual", true);
|
||||
ItemStack diary = new ItemStack(TContent.manualBook);
|
||||
if (!entityplayer.inventory.addItemStackToInventory(diary))
|
||||
{
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, diary);
|
||||
}
|
||||
}
|
||||
stats.level = entityplayer.experienceLevel;
|
||||
stats.health = entityplayer.maxHealth;
|
||||
stats.hunger = entityplayer.getFoodStats().getFoodLevel();
|
||||
stats.beginnerManual = tags.getCompoundTag("TConstruct").getBoolean("beginnerManual");
|
||||
stats.materialManual = tags.getCompoundTag("TConstruct").getBoolean("materialManual");
|
||||
stats.smelteryManual = tags.getCompoundTag("TConstruct").getBoolean("smelteryManual");
|
||||
if (!stats.beginnerManual)
|
||||
{
|
||||
tags.getCompoundTag("TConstruct").setBoolean("beginnerManual", true);
|
||||
ItemStack diary = new ItemStack(TContent.manualBook);
|
||||
if (!entityplayer.inventory.addItemStackToInventory(diary))
|
||||
{
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, diary);
|
||||
}
|
||||
}
|
||||
|
||||
playerStats.put(entityplayer.username, stats);
|
||||
}
|
||||
playerStats.put(entityplayer.username, stats);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogout (EntityPlayer entityplayer)
|
||||
{
|
||||
if (entityplayer != null)
|
||||
{
|
||||
getPlayerStats(entityplayer.username).armor.saveToNBT(entityplayer);
|
||||
playerStats.remove(entityplayer.username);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPlayerLogout (EntityPlayer entityplayer)
|
||||
{
|
||||
savePlayerStats(entityplayer, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedDimension (EntityPlayer entityplayer)
|
||||
{
|
||||
//Nothing?
|
||||
@Override
|
||||
public void onPlayerChangedDimension (EntityPlayer entityplayer)
|
||||
{
|
||||
savePlayerStats(entityplayer, false);
|
||||
}
|
||||
|
||||
}
|
||||
void savePlayerStats (EntityPlayer player, boolean clean)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
TPlayerStats stats = getPlayerStats(player.username);
|
||||
if (stats != null)
|
||||
{
|
||||
stats.armor.saveToNBT(player);
|
||||
if (clean)
|
||||
playerStats.remove(player.username);
|
||||
}
|
||||
else //Revalidate all players
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn (EntityPlayer entityplayer)
|
||||
{
|
||||
//Boom!
|
||||
TPlayerStats stats = getPlayerStats(entityplayer.username);
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
@Override
|
||||
public void onPlayerRespawn (EntityPlayer entityplayer)
|
||||
{
|
||||
//Boom!
|
||||
TPlayerStats stats = getPlayerStats(entityplayer.username);
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
|
||||
TFoodStats food = new TFoodStats();
|
||||
entityplayer.foodStats = food;
|
||||
TFoodStats food = new TFoodStats();
|
||||
entityplayer.foodStats = food;
|
||||
|
||||
if (PHConstruct.keepLevels)
|
||||
entityplayer.experienceLevel = stats.level;
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().addStats(-1 * (20 - stats.hunger), 0);
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagCompound tTag = new NBTTagCompound();
|
||||
tTag.setBoolean("beginnerManual", stats.beginnerManual);
|
||||
tTag.setBoolean("materialManual", stats.materialManual);
|
||||
tTag.setBoolean("smelteryManual", stats.smelteryManual);
|
||||
tags.setCompoundTag("TConstruct", tTag);
|
||||
if (PHConstruct.keepLevels)
|
||||
entityplayer.experienceLevel = stats.level;
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().addStats(-1 * (20 - stats.hunger), 0);
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagCompound tTag = new NBTTagCompound();
|
||||
tTag.setBoolean("beginnerManual", stats.beginnerManual);
|
||||
tTag.setBoolean("materialManual", stats.materialManual);
|
||||
tTag.setBoolean("smelteryManual", stats.smelteryManual);
|
||||
tags.setCompoundTag("TConstruct", tTag);
|
||||
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
//TProxyClient.controlInstance.resetControls();
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().setFoodLevel(stats.hunger);
|
||||
}
|
||||
}
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
//TProxyClient.controlInstance.resetControls();
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().setFoodLevel(stats.hunger);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void livingFall (LivingFallEvent evt) //Only for negating fall damage
|
||||
{
|
||||
if (evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
/*Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
TProxyClient.controlInstance.landOnGround();
|
||||
}*/
|
||||
//else
|
||||
//System.out.println("Server side");
|
||||
@ForgeSubscribe
|
||||
public void livingFall (LivingFallEvent evt) //Only for negating fall damage
|
||||
{
|
||||
if (evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
/*Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
TProxyClient.controlInstance.landOnGround();
|
||||
}*/
|
||||
//else
|
||||
//System.out.println("Server side");
|
||||
|
||||
evt.distance -= 1;
|
||||
//evt.distance = 0;
|
||||
//TPlayerStats stats = playerStats.get(((EntityPlayer)evt.entityLiving).username);
|
||||
//stats.prevMotionY = evt.entityLiving.motionY;
|
||||
//evt.entityLiving.motionY = 10.2;
|
||||
}
|
||||
}
|
||||
evt.distance -= 1;
|
||||
//evt.distance = 0;
|
||||
//TPlayerStats stats = playerStats.get(((EntityPlayer)evt.entityLiving).username);
|
||||
//stats.prevMotionY = evt.entityLiving.motionY;
|
||||
//evt.entityLiving.motionY = 10.2;
|
||||
}
|
||||
}
|
||||
|
||||
/*@ForgeSubscribe
|
||||
public void livingUpdate (LivingUpdateEvent evt)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT && evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) evt.entityLiving;
|
||||
TPlayerStats stats = playerStats.get(player.username);
|
||||
if (player.onGround != stats.prevOnGround)
|
||||
{
|
||||
if (player.onGround)// && -stats.prevMotionY > 0.1)
|
||||
//player.motionY = 0.5;
|
||||
player.motionY = -stats.prevMotionY * 0.8;
|
||||
//player.motionY *= -1.2;
|
||||
stats.prevOnGround = player.onGround;
|
||||
//if ()
|
||||
|
||||
//System.out.println("Fall: "+player.fallDistance);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*@ForgeSubscribe
|
||||
public void livingUpdate (LivingUpdateEvent evt)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT && evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) evt.entityLiving;
|
||||
TPlayerStats stats = playerStats.get(player.username);
|
||||
if (player.onGround != stats.prevOnGround)
|
||||
{
|
||||
if (player.onGround)// && -stats.prevMotionY > 0.1)
|
||||
//player.motionY = 0.5;
|
||||
player.motionY = -stats.prevMotionY * 0.8;
|
||||
//player.motionY *= -1.2;
|
||||
stats.prevOnGround = player.onGround;
|
||||
//if ()
|
||||
|
||||
//System.out.println("Fall: "+player.fallDistance);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@ForgeSubscribe
|
||||
public void playerDrops (PlayerDropsEvent evt)
|
||||
{
|
||||
TPlayerStats stats = getPlayerStats(evt.entityPlayer.username);
|
||||
stats.level = evt.entityPlayer.experienceLevel / 2;
|
||||
//stats.health = 20;
|
||||
int hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
|
||||
if (hunger < 6)
|
||||
stats.hunger = 6;
|
||||
else
|
||||
stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
|
||||
}
|
||||
@ForgeSubscribe
|
||||
public void playerDrops (PlayerDropsEvent evt)
|
||||
{
|
||||
TPlayerStats stats = getPlayerStats(evt.entityPlayer.username);
|
||||
stats.level = evt.entityPlayer.experienceLevel / 2;
|
||||
//stats.health = 20;
|
||||
int hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
|
||||
if (hunger < 6)
|
||||
stats.hunger = 6;
|
||||
else
|
||||
stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
|
||||
}
|
||||
|
||||
/* Find the right player */
|
||||
public TPlayerStats getPlayerStats (String username)
|
||||
{
|
||||
TPlayerStats stats = playerStats.get(username);
|
||||
//System.out.println("Stats: "+stats);
|
||||
if (stats == null)
|
||||
{
|
||||
stats = new TPlayerStats();
|
||||
playerStats.put(username, stats);
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
/* Find the right player */
|
||||
public TPlayerStats getPlayerStats (String username)
|
||||
{
|
||||
TPlayerStats stats = playerStats.get(username);
|
||||
//System.out.println("Stats: "+stats);
|
||||
if (stats == null)
|
||||
{
|
||||
stats = new TPlayerStats();
|
||||
playerStats.put(username, stats);
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
public EntityPlayer getEntityPlayer (String username)
|
||||
{
|
||||
TPlayerStats stats = playerStats.get(username);
|
||||
if (stats == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stats.player.get();
|
||||
}
|
||||
}
|
||||
public EntityPlayer getEntityPlayer (String username)
|
||||
{
|
||||
TPlayerStats stats = playerStats.get(username);
|
||||
if (stats == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stats.player.get();
|
||||
}
|
||||
}
|
||||
|
||||
/* Modify Player */
|
||||
public void updateSize (String user, float offset)
|
||||
{
|
||||
/*EntityPlayer player = getEntityPlayer(user);
|
||||
setEntitySize(0.6F, offset, player);
|
||||
player.yOffset = offset - 0.18f;*/
|
||||
}
|
||||
/* Modify Player */
|
||||
public void updateSize (String user, float offset)
|
||||
{
|
||||
/*EntityPlayer player = getEntityPlayer(user);
|
||||
setEntitySize(0.6F, offset, player);
|
||||
player.yOffset = offset - 0.18f;*/
|
||||
}
|
||||
|
||||
public static void setEntitySize (float width, float height, Entity entity)
|
||||
{
|
||||
//System.out.println("Size: " + height);
|
||||
if (width != entity.width || height != entity.height)
|
||||
{
|
||||
entity.width = width;
|
||||
entity.height = height;
|
||||
entity.boundingBox.maxX = entity.boundingBox.minX + (double) entity.width;
|
||||
entity.boundingBox.maxZ = entity.boundingBox.minZ + (double) entity.width;
|
||||
entity.boundingBox.maxY = entity.boundingBox.minY + (double) entity.height;
|
||||
}
|
||||
public static void setEntitySize (float width, float height, Entity entity)
|
||||
{
|
||||
//System.out.println("Size: " + height);
|
||||
if (width != entity.width || height != entity.height)
|
||||
{
|
||||
entity.width = width;
|
||||
entity.height = height;
|
||||
entity.boundingBox.maxX = entity.boundingBox.minX + (double) entity.width;
|
||||
entity.boundingBox.maxZ = entity.boundingBox.minZ + (double) entity.width;
|
||||
entity.boundingBox.maxY = entity.boundingBox.minY + (double) entity.height;
|
||||
}
|
||||
|
||||
float que = width % 2.0F;
|
||||
float que = width % 2.0F;
|
||||
|
||||
if ((double) que < 0.375D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_1;
|
||||
}
|
||||
else if ((double) que < 0.75D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_2;
|
||||
}
|
||||
else if ((double) que < 1.0D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_3;
|
||||
}
|
||||
else if ((double) que < 1.375D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_4;
|
||||
}
|
||||
else if ((double) que < 1.75D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_5;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_6;
|
||||
}
|
||||
//entity.yOffset = height;
|
||||
}
|
||||
if ((double) que < 0.375D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_1;
|
||||
}
|
||||
else if ((double) que < 0.75D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_2;
|
||||
}
|
||||
else if ((double) que < 1.0D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_3;
|
||||
}
|
||||
else if ((double) que < 1.375D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_4;
|
||||
}
|
||||
else if ((double) que < 1.75D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_5;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_6;
|
||||
}
|
||||
//entity.yOffset = height;
|
||||
}
|
||||
|
||||
Random rand = new Random();
|
||||
Random rand = new Random();
|
||||
|
||||
/* Bows */
|
||||
/*@ForgeSubscribe
|
||||
public void arrowShoot (ArrowLooseEvent event)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
int j = event.charge;
|
||||
/* Bows */
|
||||
/*@ForgeSubscribe
|
||||
public void arrowShoot (ArrowLooseEvent event)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
int j = event.charge;
|
||||
|
||||
boolean flag = event.entityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, event.bow) > 0;
|
||||
boolean flag = event.entityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, event.bow) > 0;
|
||||
|
||||
if (flag || event.entityPlayer.inventory.hasItem(Item.arrow.itemID))
|
||||
{
|
||||
float f = (float) j / 20.0F;
|
||||
f = (f * f + f * 2.0F) / 3.0F;
|
||||
if (flag || event.entityPlayer.inventory.hasItem(Item.arrow.itemID))
|
||||
{
|
||||
float f = (float) j / 20.0F;
|
||||
f = (f * f + f * 2.0F) / 3.0F;
|
||||
|
||||
if ((double) f < 0.1D)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((double) f < 0.1D)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (f > 1.0F)
|
||||
{
|
||||
f = 1.0F;
|
||||
}
|
||||
if (f > 1.0F)
|
||||
{
|
||||
f = 1.0F;
|
||||
}
|
||||
|
||||
EntityArrow entityarrow = new EntityArrow(event.entityPlayer.worldObj, event.entityPlayer, f * 2.0F);
|
||||
EntityArrow entityarrow = new EntityArrow(event.entityPlayer.worldObj, event.entityPlayer, f * 2.0F);
|
||||
|
||||
if (f == 1.0F)
|
||||
{
|
||||
entityarrow.setIsCritical(true);
|
||||
}
|
||||
if (f == 1.0F)
|
||||
{
|
||||
entityarrow.setIsCritical(true);
|
||||
}
|
||||
|
||||
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, event.bow);
|
||||
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, event.bow);
|
||||
|
||||
entityarrow.setDamage(1.5D + k * 0.45D);
|
||||
entityarrow.setDamage(1.5D + k * 0.45D);
|
||||
|
||||
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, event.bow);
|
||||
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, event.bow);
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
entityarrow.setKnockbackStrength(l);
|
||||
}
|
||||
if (l > 0)
|
||||
{
|
||||
entityarrow.setKnockbackStrength(l);
|
||||
}
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, event.bow) > 0)
|
||||
{
|
||||
entityarrow.setFire(100);
|
||||
}
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, event.bow) > 0)
|
||||
{
|
||||
entityarrow.setFire(100);
|
||||
}
|
||||
|
||||
event.bow.damageItem(1, event.entityPlayer);
|
||||
event.entityPlayer.worldObj.playSoundAtEntity(event.entityPlayer, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
|
||||
event.bow.damageItem(1, event.entityPlayer);
|
||||
event.entityPlayer.worldObj.playSoundAtEntity(event.entityPlayer, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
entityarrow.canBePickedUp = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.entityPlayer.inventory.consumeInventoryItem(Item.arrow.itemID);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
entityarrow.canBePickedUp = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.entityPlayer.inventory.consumeInventoryItem(Item.arrow.itemID);
|
||||
}
|
||||
|
||||
if (!event.entityPlayer.worldObj.isRemote)
|
||||
{
|
||||
event.entityPlayer.worldObj.spawnEntityInWorld(entityarrow);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (!event.entityPlayer.worldObj.isRemote)
|
||||
{
|
||||
event.entityPlayer.worldObj.spawnEntityInWorld(entityarrow);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user