You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.6 KiB
Java
96 lines
3.6 KiB
Java
package net.minecraft.block;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
|
import net.minecraft.dispenser.IBehaviorDispenseItem;
|
|
import net.minecraft.inventory.IInventory;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.tileentity.TileEntityDispenser;
|
|
import net.minecraft.tileentity.TileEntityDropper;
|
|
import net.minecraft.tileentity.TileEntityHopper;
|
|
import net.minecraft.util.Facing;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockDropper extends BlockDispenser
|
|
{
|
|
private final IBehaviorDispenseItem field_149947_P = new BehaviorDefaultDispenseItem();
|
|
private static final String __OBFID = "CL_00000233";
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerBlockIcons(IIconRegister reg)
|
|
{
|
|
this.blockIcon = reg.registerIcon("furnace_side");
|
|
this.field_149944_M = reg.registerIcon("furnace_top");
|
|
this.field_149945_N = reg.registerIcon(this.getTextureName() + "_front_horizontal");
|
|
this.field_149946_O = reg.registerIcon(this.getTextureName() + "_front_vertical");
|
|
}
|
|
|
|
protected IBehaviorDispenseItem func_149940_a(ItemStack p_149940_1_)
|
|
{
|
|
return this.field_149947_P;
|
|
}
|
|
|
|
/**
|
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
|
*/
|
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
|
{
|
|
return new TileEntityDropper();
|
|
}
|
|
|
|
protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
|
|
{
|
|
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
|
|
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
|
|
|
|
if (tileentitydispenser != null)
|
|
{
|
|
int l = tileentitydispenser.func_146017_i();
|
|
|
|
if (l < 0)
|
|
{
|
|
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
|
|
}
|
|
else
|
|
{
|
|
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
|
|
int i1 = p_149941_1_.getBlockMetadata(p_149941_2_, p_149941_3_, p_149941_4_) & 7;
|
|
IInventory iinventory = TileEntityHopper.func_145893_b(p_149941_1_, (double)(p_149941_2_ + Facing.offsetsXForSide[i1]), (double)(p_149941_3_ + Facing.offsetsYForSide[i1]), (double)(p_149941_4_ + Facing.offsetsZForSide[i1]));
|
|
ItemStack itemstack1;
|
|
|
|
if (iinventory != null)
|
|
{
|
|
itemstack1 = TileEntityHopper.func_145889_a(iinventory, itemstack.copy().splitStack(1), Facing.oppositeSide[i1]);
|
|
|
|
if (itemstack1 == null)
|
|
{
|
|
itemstack1 = itemstack.copy();
|
|
|
|
if (--itemstack1.stackSize == 0)
|
|
{
|
|
itemstack1 = null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
itemstack1 = itemstack.copy();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
itemstack1 = this.field_149947_P.dispense(blocksourceimpl, itemstack);
|
|
|
|
if (itemstack1 != null && itemstack1.stackSize == 0)
|
|
{
|
|
itemstack1 = null;
|
|
}
|
|
}
|
|
|
|
tileentitydispenser.setInventorySlotContents(l, itemstack1);
|
|
}
|
|
}
|
|
}
|
|
} |