mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 12:59:41 +00:00
Add bin drops directly to player inventory.
If there's no space, drop them in front of the bin. Adds feature #3807
This commit is contained in:
1 parent
b3f1a9fee4
commit
0a1da00913
1 file changed
+22
-5
@@ -51,6 +51,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -59,6 +60,7 @@ import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -412,12 +414,27 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
{
|
||||
if(!bin.bottomStack.isEmpty())
|
||||
{
|
||||
if(!player.isSneaking())
|
||||
ItemStack stack;
|
||||
if(player.isSneaking())
|
||||
{
|
||||
world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, bin.removeStack().copy()));
|
||||
stack = bin.remove(1).copy();
|
||||
}
|
||||
else {
|
||||
world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, bin.remove(1).copy()));
|
||||
else
|
||||
{
|
||||
stack = bin.removeStack().copy();
|
||||
}
|
||||
|
||||
if(!player.inventory.addItemStackToInventory(stack))
|
||||
{
|
||||
BlockPos dropPos = pos.offset(bin.facing);
|
||||
Entity item = new EntityItem(world, dropPos.getX() + .5f, dropPos.getY() + .3f, dropPos.getZ() + .5f, stack);
|
||||
item.addVelocity(-item.motionX, -item.motionY, -item.motionZ);
|
||||
world.spawnEntity(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.playSound(null, pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f,
|
||||
SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1044,4 +1061,4 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
{
|
||||
return BasicBlockType.get(world.getBlockState(pos)).isBeaconBase;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user