2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
2015-06-13 17:06:24 +02:00
|
|
|
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
2014-11-14 12:02:52 +01:00
|
|
|
*
|
|
|
|
* 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>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.block.solids;
|
|
|
|
|
2015-04-02 15:52:00 +02:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.Random;
|
2015-08-06 18:31:46 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.item.Item;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
2015-09-16 18:03:07 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.exceptions.MissingDefinition;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.client.render.blocks.RenderQuartzOre;
|
|
|
|
import appeng.core.features.AEFeature;
|
|
|
|
|
2015-04-02 15:52:00 +02:00
|
|
|
|
2014-05-11 18:22:10 +02:00
|
|
|
public class OreQuartz extends AEBaseBlock
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
private int boostBrightnessLow;
|
|
|
|
private int boostBrightnessHigh;
|
|
|
|
private boolean enhanceBrightness;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public OreQuartz()
|
|
|
|
{
|
2015-04-04 00:42:19 +02:00
|
|
|
super( Material.rock );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setHardness( 3.0F );
|
|
|
|
this.setResistance( 5.0F );
|
|
|
|
this.boostBrightnessLow = 0;
|
|
|
|
this.boostBrightnessHigh = 1;
|
|
|
|
this.enhanceBrightness = false;
|
2015-04-04 01:26:35 +02:00
|
|
|
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-01-30 03:47:55 +01:00
|
|
|
@Override
|
2015-09-16 18:03:07 +02:00
|
|
|
@SideOnly( Side.CLIENT )
|
|
|
|
protected RenderQuartzOre getRenderer()
|
2014-01-30 03:47:55 +01:00
|
|
|
{
|
2015-09-16 18:03:07 +02:00
|
|
|
return new RenderQuartzOre();
|
2014-01-30 03:47:55 +01:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public int getMixedBrightnessForBlock( final IBlockAccess par1iBlockAccess, final int par2, final int par3, final int par4 )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
int j1 = super.getMixedBrightnessForBlock( par1iBlockAccess, par2, par3, par4 );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.enhanceBrightness )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
j1 = Math.max( j1 >> 20, j1 >> 4 );
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( j1 > 4 )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
j1 += this.boostBrightnessHigh;
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
j1 += this.boostBrightnessLow;
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( j1 > 15 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2013-12-27 23:59:59 +01:00
|
|
|
j1 = 15;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
return j1 << 20 | j1 << 4;
|
|
|
|
}
|
|
|
|
return j1;
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public int quantityDropped( final Random rand )
|
2015-04-02 15:52:00 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return 1 + rand.nextInt( 2 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Nullable
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public Item getItemDropped( final int id, final Random rand, final int meta )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
return crystalItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void dropBlockAsItemWithChance( final World w, final int x, final int y, final int z, final int blockID, final float something, final int meta )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
super.dropBlockAsItemWithChance( w, x, y, z, blockID, something, meta );
|
|
|
|
|
|
|
|
if( this.getItemDropped( blockID, w.rand, meta ) != Item.getItemFromBlock( this ) )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
this.dropXpOnBlockBreak( w, x, y, z, xp );
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public int damageDropped( final int id )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
|
|
|
return crystalStack.getItemDamage();
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public int quantityDroppedWithBonus( final int fortune, final Random rand )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( 0, rand, fortune ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
int j = rand.nextInt( fortune + 2 ) - 1;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( j < 0 )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
|
2015-04-02 15:52:00 +02:00
|
|
|
return this.quantityDropped( rand ) * ( j + 1 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this.quantityDropped( rand );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
void setBoostBrightnessLow( final int boostBrightnessLow )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.boostBrightnessLow = boostBrightnessLow;
|
|
|
|
}
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
void setBoostBrightnessHigh( final int boostBrightnessHigh )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.boostBrightnessHigh = boostBrightnessHigh;
|
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setEnhanceBrightness( final boolean enhanceBrightness )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.enhanceBrightness = enhanceBrightness;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|