mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Change AbilityHelper.spawnEntityAtPlayer to automatically put items into inventories by default (prevents lag-dupe) and also play sound if it got picked up.
This commit is contained in:
1 parent
6d677dcc7a
commit
aa328792f7
1 file changed
+13
-4
@@ -21,6 +21,7 @@ import net.minecraft.world.World;
|
||||
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;
|
||||
|
||||
@@ -568,10 +569,18 @@ public class AbilityHelper
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user