Skip to content

Commit

Permalink
Merge branch 'master' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Nov 25, 2014
2 parents 2a275c4 + e1101fa commit 6ea6419
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
11 changes: 1 addition & 10 deletions src/main/java/tconstruct/armor/blocks/DryingRack.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,14 @@ boolean activateDryingRack (World world, int x, int y, int z, EntityPlayer playe
{
ItemStack decrStack = logic.decrStackSize(0, 1);
if (decrStack != null)
addItemToInventory(player, world, x, y, z, decrStack);
AbilityHelper.spawnItemAtPlayer(player, decrStack);
}

world.markBlockForUpdate(x, y, z);
}
return true;
}

public void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack)
{
if(!player.inventory.addItemStackToInventory(stack))
{
// drop the rest as an item
AbilityHelper.spawnItemAtPlayer(player, stack);
}
}

@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/tconstruct/library/tools/AbilityHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import tconstruct.TConstruct;
import tconstruct.library.*;
import tconstruct.library.util.PiercingEntityDamage;

Expand Down Expand Up @@ -599,10 +600,20 @@ public static void spawnItemAtPlayer (EntityPlayer player, ItemStack 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);
if (!(player instanceof FakePlayer))
entityitem.onCollideWithPlayer(player);
// try to put it into the players inventory
if(player instanceof FakePlayer || !player.inventory.addItemStackToInventory(stack)) // note that the addItemStackToInventory is not called for fake players
{
// drop the rest as an entity
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 it got picked up, we're playing the sound
else {
player.worldObj.playSoundAtEntity(player, "random.pop", 0.2F, ((TConstruct.random.nextFloat() - TConstruct.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
player.inventory.markDirty();
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,7 @@ public void interact(EntityPlayer player)

// try to transfer thes tack to the player inventory
ItemStack output = event.item;
if(!player.inventory.addItemStackToInventory(output))
{
// drop the rest as an item
AbilityHelper.spawnItemAtPlayer(player, output);
}
// added to inventory, update inventory
else
player.inventory.markDirty();
AbilityHelper.spawnItemAtPlayer(player, output);

// remove inventory contents, since we spilled the full contents of the slot
inventory[slot] = null;
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/tconstruct/world/blocks/OreberryBush.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.*;
import net.minecraftforge.common.*;
import net.minecraftforge.common.util.ForgeDirection;
import tconstruct.TConstruct;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.world.TinkerWorld;
Expand Down Expand Up @@ -175,24 +176,18 @@ public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int x, int y,
@Override
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player)
{
if (!world.isRemote)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
{
world.setBlock(x, y, z, this, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TinkerWorld.oreBerries, 1, meta % 4 + itemMeat));
}
}
harvest(world, x,y,z, player);
}

/* Right-click harvests berries */
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
/*if (world.isRemote)
return false;*/
return harvest(world, x,y,z, player);
}

public boolean harvest(World world, int x, int y, int z, EntityPlayer player)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
{
Expand All @@ -201,7 +196,6 @@ public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer

world.setBlock(x, y, z, this, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TinkerWorld.oreBerries, random.nextInt(3) + 1, meta % 4 + itemMeat));
return true;
}

return false;
Expand Down

0 comments on commit 6ea6419

Please sign in to comment.