2013-12-27 23:59:59 +01:00
|
|
|
package appeng.block.misc;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.particle.EntityFX;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.world.World;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.AEApi;
|
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.client.render.BaseBlockRender;
|
|
|
|
import appeng.client.render.blocks.RenderBlockCharger;
|
|
|
|
import appeng.client.render.effects.LightningEffect;
|
2014-02-09 06:08:27 +01:00
|
|
|
import appeng.core.AEConfig;
|
2014-03-07 07:15:25 +01:00
|
|
|
import appeng.core.CommonHelper;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.features.AEFeature;
|
|
|
|
import appeng.helpers.ICustomCollision;
|
|
|
|
import appeng.tile.AEBaseTile;
|
|
|
|
import appeng.tile.misc.TileCharger;
|
|
|
|
import appeng.util.Platform;
|
2014-01-28 18:29:17 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class BlockCharger extends AEBaseBlock implements ICustomCollision
|
|
|
|
{
|
|
|
|
|
|
|
|
public BlockCharger() {
|
|
|
|
super( BlockCharger.class, Material.iron );
|
|
|
|
setfeature( EnumSet.of( AEFeature.Core ) );
|
|
|
|
setTileEntiy( TileCharger.class );
|
|
|
|
setLightOpacity( 2 );
|
2014-03-07 07:15:25 +01:00
|
|
|
isFullSize = isOpaque = false;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
|
|
|
{
|
|
|
|
if ( player.isSneaking() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
{
|
|
|
|
TileCharger tc = getTileEntity( w, x, y, z );
|
|
|
|
if ( tc != null )
|
|
|
|
{
|
|
|
|
tc.activate( player );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Class<? extends BaseBlockRender> getRenderer()
|
|
|
|
{
|
|
|
|
return RenderBlockCharger.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-28 18:29:17 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
|
|
|
{
|
2014-02-09 06:08:27 +01:00
|
|
|
if ( !AEConfig.instance.enableEffects )
|
2013-12-27 23:59:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( r.nextFloat() < 0.98 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
AEBaseTile tile = getTileEntity( w, x, y, z );
|
|
|
|
if ( tile instanceof TileCharger )
|
|
|
|
{
|
|
|
|
TileCharger tc = (TileCharger) tile;
|
2014-05-10 07:00:02 +02:00
|
|
|
if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( tc.getStackInSlot( 0 ) ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
double xOff = 0.0;
|
|
|
|
double yOff = 0.0;
|
|
|
|
double zOff = 0.0;
|
|
|
|
|
|
|
|
for (int bolts = 0; bolts < 3; bolts++)
|
|
|
|
{
|
2014-01-30 03:47:55 +01:00
|
|
|
if ( CommonHelper.proxy.shouldAddParticles( r ) )
|
|
|
|
{
|
|
|
|
LightningEffect fx = new LightningEffect( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
|
|
|
|
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-31 18:11:50 +01:00
|
|
|
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
TileCharger tile = getTileEntity( w, x, y, z );
|
|
|
|
if ( tile != null )
|
|
|
|
{
|
|
|
|
double twoPixels = 2.0 / 16.0;
|
|
|
|
ForgeDirection up = tile.getUp();
|
|
|
|
ForgeDirection forward = tile.getForward();
|
|
|
|
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
|
|
|
|
|
|
|
|
if ( up.offsetX != 0 )
|
|
|
|
{
|
|
|
|
bb.minX = 0;
|
|
|
|
bb.maxX = 1;
|
|
|
|
}
|
|
|
|
if ( up.offsetY != 0 )
|
|
|
|
{
|
|
|
|
bb.minY = 0;
|
|
|
|
bb.maxY = 1;
|
|
|
|
}
|
|
|
|
if ( up.offsetZ != 0 )
|
|
|
|
{
|
|
|
|
bb.minZ = 0;
|
|
|
|
bb.maxZ = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (forward)
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
bb.maxY = 1;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
bb.minY = 0;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
bb.maxZ = 1;
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
bb.minZ = 0;
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
bb.minX = 0;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
bb.maxX = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Arrays.asList( new AxisAlignedBB[] { bb } );
|
|
|
|
}
|
|
|
|
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
|
|
|
{
|
2014-06-05 05:59:56 +02:00
|
|
|
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|