2015-05-19 00:45:45 +02:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package appeng.parts.automation;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.world.WorldServer;
|
|
|
|
import net.minecraftforge.common.util.FakePlayer;
|
|
|
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
|
|
|
import appeng.client.texture.CableBusTextures;
|
|
|
|
|
|
|
|
|
|
|
|
public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
|
|
|
|
{
|
|
|
|
private final static IIcon ACTIVE_ICON = CableBusTextures.BlockIdentityAnnihilationPlaneOn.getIcon();
|
|
|
|
|
|
|
|
private static final float SILK_TOUCH_FACTOR = 16;
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public PartIdentityAnnihilationPlane( final ItemStack is )
|
2015-05-19 00:45:45 +02:00
|
|
|
{
|
|
|
|
super( is );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly( Side.CLIENT )
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderStatic( final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer )
|
2015-05-19 00:45:45 +02:00
|
|
|
{
|
|
|
|
this.renderStaticWithIcon( x, y, z, rh, renderer, ACTIVE_ICON );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
protected boolean isAnnihilationPlane( final TileEntity blockTileEntity, final ForgeDirection side )
|
2015-05-19 00:45:45 +02:00
|
|
|
{
|
|
|
|
if( blockTileEntity instanceof IPartHost )
|
|
|
|
{
|
|
|
|
final IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
|
|
|
return p != null && p.getClass() == this.getClass();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
protected float calculateEnergyUsage( final WorldServer w, final int x, final int y, final int z, final List<ItemStack> items )
|
2015-05-19 00:45:45 +02:00
|
|
|
{
|
|
|
|
final float requiredEnergy = super.calculateEnergyUsage( w, x, y, z, items );
|
|
|
|
|
|
|
|
return requiredEnergy * SILK_TOUCH_FACTOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
protected List<ItemStack> obtainBlockDrops( final WorldServer w, final int x, final int y, final int z )
|
2015-05-19 00:45:45 +02:00
|
|
|
{
|
|
|
|
final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft( w );
|
|
|
|
final Block block = w.getBlock( x, y, z );
|
|
|
|
final int blockMeta = w.getBlockMetadata( x, y, z );
|
|
|
|
|
|
|
|
if( block.canSilkHarvest( w, fakePlayer, x, y, z, blockMeta ) )
|
|
|
|
{
|
|
|
|
final List<ItemStack> out = new ArrayList<ItemStack>( 1 );
|
|
|
|
final Item item = Item.getItemFromBlock( block );
|
|
|
|
|
|
|
|
if( item != null )
|
|
|
|
{
|
|
|
|
int meta = 0;
|
|
|
|
if( item.getHasSubtypes() )
|
|
|
|
{
|
|
|
|
meta = blockMeta;
|
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
final ItemStack itemstack = new ItemStack( item, 1, meta );
|
2015-05-19 00:45:45 +02:00
|
|
|
out.add( itemstack );
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return super.obtainBlockDrops( w, x, y, z );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|