mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-23 21:49:45 +00:00
port in everything from 1.6 but labotimizetools(will do that later this weekend)
This commit is contained in:
1 parent
aa8d70d4c4
commit
66a4ece284
21 files changed
+8806
-131
No files matched your search
@@ -523,22 +523,26 @@ public class AbilityHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnItemAtEntity (Entity entity, ItemStack stack, int delay)
|
||||
{
|
||||
if (!entity.worldObj.isRemote)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(entity.worldObj, entity.posX + 0.5D, entity.posY + 0.5D, entity.posZ + 0.5D, stack);
|
||||
entityitem.delayBeforeCanPickup = delay;
|
||||
entity.worldObj.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnItemAtPlayer (EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack);
|
||||
player.worldObj.spawnEntityInWorld(entityitem);
|
||||
if (!(player instanceof FakePlayer))
|
||||
entityitem.onCollideWithPlayer(player);
|
||||
/*
|
||||
* if (!player.inventory.addItemStackToInventory(stack)) { if
|
||||
* (!player.worldObj.isRemote) { EntityItem entityitem = new
|
||||
* EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D,
|
||||
* player.posZ + 0.5D, stack);
|
||||
* player.worldObj.spawnEntityInWorld(entityitem);
|
||||
* entityitem.onCollideWithPlayer(player); } } else {
|
||||
* player.worldObj.playSoundAtEntity(player, "random.pop", 0.2F,
|
||||
* ((random.nextFloat() - random.nextFloat()) * 0.7F + 1.0F) * 2.0F); }
|
||||
*/
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack);
|
||||
player.worldObj.spawnEntityInWorld(entityitem);
|
||||
if (!(player instanceof FakePlayer))
|
||||
entityitem.onCollideWithPlayer(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Ranged weapons */
|
||||
@@ -632,4 +636,5 @@ public class AbilityHelper
|
||||
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
@@ -194,4 +196,85 @@ public abstract class HarvestTool extends ToolCore
|
||||
protected abstract Material[] getEffectiveMaterials ();
|
||||
|
||||
protected abstract String getHarvestType ();
|
||||
|
||||
//Right-click
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
/*if (world.isRemote)
|
||||
return true;*/
|
||||
|
||||
boolean used = false;
|
||||
int hotbarSlot = player.inventory.currentItem;
|
||||
int itemSlot = hotbarSlot == 0 ? 8 : hotbarSlot + 1;
|
||||
ItemStack nearbyStack = null;
|
||||
|
||||
if (hotbarSlot < 8)
|
||||
{
|
||||
nearbyStack = player.inventory.getStackInSlot(itemSlot);
|
||||
if (nearbyStack != null)
|
||||
{
|
||||
Item item = nearbyStack.getItem();
|
||||
if (item instanceof ItemBlock)
|
||||
{
|
||||
int posX = x;
|
||||
int posY = y;
|
||||
int posZ = z;
|
||||
int playerPosX = (int) Math.floor(player.posX);
|
||||
int playerPosY = (int) Math.floor(player.posY);
|
||||
int playerPosZ = (int) Math.floor(player.posZ);
|
||||
if (side == 0)
|
||||
{
|
||||
--posY;
|
||||
}
|
||||
|
||||
if (side == 1)
|
||||
{
|
||||
++posY;
|
||||
}
|
||||
|
||||
if (side == 2)
|
||||
{
|
||||
--posZ;
|
||||
}
|
||||
|
||||
if (side == 3)
|
||||
{
|
||||
++posZ;
|
||||
}
|
||||
|
||||
if (side == 4)
|
||||
{
|
||||
--posX;
|
||||
}
|
||||
|
||||
if (side == 5)
|
||||
{
|
||||
++posX;
|
||||
}
|
||||
if (posX == playerPosX && (posY == playerPosY || posY == playerPosY + 1 || posY == playerPosY - 1) && posZ == playerPosZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
used = item.onItemUse(nearbyStack, player, world, x, y, z, side, clickX, clickY, clickZ);
|
||||
if (nearbyStack.stackSize < 1)
|
||||
{
|
||||
nearbyStack = null;
|
||||
player.inventory.setInventorySlotContents(itemSlot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (used) //Update client
|
||||
{
|
||||
Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId, itemSlot, nearbyStack);
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
*/
|
||||
|
||||
return used;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.item.ItemPotion;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
@@ -408,6 +409,10 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem
|
||||
}
|
||||
}
|
||||
}
|
||||
list.add("");
|
||||
int attack = (int) (tags.getCompoundTag("InfiTool").getInteger("Attack") * this.getDamageModifier());
|
||||
list.add("\u00A79+" + attack + " " + StatCollector.translateToLocalFormatted("attribute.name.generic.attackDamage"));
|
||||
|
||||
}
|
||||
|
||||
public static String getStyleForType (int type)
|
||||
@@ -674,87 +679,6 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
// Right-click
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
/*
|
||||
* if (world.isRemote) return true;
|
||||
*/
|
||||
|
||||
boolean used = false;
|
||||
int hotbarSlot = player.inventory.currentItem;
|
||||
int itemSlot = hotbarSlot == 0 ? 8 : hotbarSlot + 1;
|
||||
ItemStack nearbyStack = null;
|
||||
|
||||
if (hotbarSlot < 8)
|
||||
{
|
||||
nearbyStack = player.inventory.getStackInSlot(itemSlot);
|
||||
if (nearbyStack != null)
|
||||
{
|
||||
Item item = nearbyStack.getItem();
|
||||
if (item instanceof ItemBlock)
|
||||
{
|
||||
int posX = x;
|
||||
int posY = y;
|
||||
int posZ = z;
|
||||
int playerPosX = (int) Math.floor(player.posX);
|
||||
int playerPosY = (int) Math.floor(player.posY);
|
||||
int playerPosZ = (int) Math.floor(player.posZ);
|
||||
if (side == 0)
|
||||
{
|
||||
--posY;
|
||||
}
|
||||
|
||||
if (side == 1)
|
||||
{
|
||||
++posY;
|
||||
}
|
||||
|
||||
if (side == 2)
|
||||
{
|
||||
--posZ;
|
||||
}
|
||||
|
||||
if (side == 3)
|
||||
{
|
||||
++posZ;
|
||||
}
|
||||
|
||||
if (side == 4)
|
||||
{
|
||||
--posX;
|
||||
}
|
||||
|
||||
if (side == 5)
|
||||
{
|
||||
++posX;
|
||||
}
|
||||
if (posX == playerPosX && (posY == playerPosY || posY == playerPosY + 1 || posY == playerPosY - 1) && posZ == playerPosZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
used = item.onItemUse(nearbyStack, player, world, x, y, z, side, clickX, clickY, clickZ);
|
||||
if (nearbyStack.stackSize < 1)
|
||||
{
|
||||
nearbyStack = null;
|
||||
player.inventory.setInventorySlotContents(itemSlot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if (used) //Update client { Packet103SetSlot packet = new
|
||||
* Packet103SetSlot(player.openContainer.windowId, itemSlot,
|
||||
* nearbyStack);
|
||||
* ((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer
|
||||
* (packet); }
|
||||
*/
|
||||
return used;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user