cleanup BlockQuartzOre and circumvent Forge bug
This commit is contained in:
parent
41711e50b9
commit
297cd16702
2 changed files with 43 additions and 92 deletions
|
@ -23,8 +23,11 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
@ -36,15 +39,8 @@ import appeng.core.AEConfig;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
|
|
||||||
|
|
||||||
public final class BlockChargedQuartzOre extends BlockQuartzOre
|
public class BlockChargedQuartzOre extends BlockQuartzOre
|
||||||
{
|
{
|
||||||
|
|
||||||
public BlockChargedQuartzOre()
|
|
||||||
{
|
|
||||||
this.setBoostBrightnessLow( 2 );
|
|
||||||
this.setBoostBrightnessHigh( 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune )
|
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune )
|
||||||
{
|
{
|
||||||
|
@ -68,6 +64,17 @@ public final class BlockChargedQuartzOre extends BlockQuartzOre
|
||||||
.getItemDamage();
|
.getItemDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getPickBlock( IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player )
|
||||||
|
{
|
||||||
|
return AEApi.instance()
|
||||||
|
.definitions()
|
||||||
|
.blocks()
|
||||||
|
.quartzOreCharged()
|
||||||
|
.maybeStack( 1 )
|
||||||
|
.orElseThrow( () -> new MissingDefinitionException( "Tried to access charged certus quartz ore, even though they are disabled" ) );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly( Side.CLIENT )
|
@SideOnly( Side.CLIENT )
|
||||||
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r )
|
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r )
|
||||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
|
@ -37,18 +36,11 @@ import appeng.block.AEBaseBlock;
|
||||||
|
|
||||||
public class BlockQuartzOre extends AEBaseBlock
|
public class BlockQuartzOre extends AEBaseBlock
|
||||||
{
|
{
|
||||||
private int boostBrightnessLow;
|
|
||||||
private int boostBrightnessHigh;
|
|
||||||
private boolean enhanceBrightness;
|
|
||||||
|
|
||||||
public BlockQuartzOre()
|
public BlockQuartzOre()
|
||||||
{
|
{
|
||||||
super( Material.ROCK );
|
super( Material.ROCK );
|
||||||
this.setHardness( 3.0F );
|
this.setHardness( 3.0F );
|
||||||
this.setResistance( 5.0F );
|
this.setResistance( 5.0F );
|
||||||
this.boostBrightnessLow = 0;
|
|
||||||
this.boostBrightnessHigh = 1;
|
|
||||||
this.enhanceBrightness = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,76 +50,7 @@ public class BlockQuartzOre extends AEBaseBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightValue( final IBlockState state, final IBlockAccess worldIn, final BlockPos pos )
|
public int quantityDropped( IBlockState state, int fortune, Random rand )
|
||||||
{
|
|
||||||
int j1 = super.getLightValue( state, worldIn, pos );
|
|
||||||
if( this.enhanceBrightness )
|
|
||||||
{
|
|
||||||
j1 = Math.max( j1 >> 20, j1 >> 4 );
|
|
||||||
|
|
||||||
if( j1 > 4 )
|
|
||||||
{
|
|
||||||
j1 += this.boostBrightnessHigh;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j1 += this.boostBrightnessLow;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( j1 > 15 )
|
|
||||||
{
|
|
||||||
j1 = 15;
|
|
||||||
}
|
|
||||||
return j1 << 20 | j1 << 4;
|
|
||||||
}
|
|
||||||
return j1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int quantityDropped( final Random rand )
|
|
||||||
{
|
|
||||||
return 1 + rand.nextInt( 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Item getItemDropped( final IBlockState state, /* is null */
|
|
||||||
final Random rand, final int fortune )
|
|
||||||
{
|
|
||||||
return AEApi.instance()
|
|
||||||
.definitions()
|
|
||||||
.materials()
|
|
||||||
.certusQuartzCrystal()
|
|
||||||
.maybeItem()
|
|
||||||
.orElseThrow( () -> new MissingDefinitionException( "Tried to access certus quartz crystal, even though they are disabled" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dropBlockAsItemWithChance( final World w, final BlockPos pos, final IBlockState state, final float chance, final int fortune )
|
|
||||||
{
|
|
||||||
super.dropBlockAsItemWithChance( w, pos, state, chance, fortune );
|
|
||||||
|
|
||||||
if( this.getItemDropped( state, w.rand, fortune ) != Item.getItemFromBlock( this ) )
|
|
||||||
{
|
|
||||||
final int xp = MathHelper.getInt( w.rand, 2, 5 );
|
|
||||||
|
|
||||||
this.dropXpOnBlockBreak( w, pos, xp );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped( final IBlockState state )
|
|
||||||
{
|
|
||||||
return AEApi.instance()
|
|
||||||
.definitions()
|
|
||||||
.materials()
|
|
||||||
.certusQuartzCrystal()
|
|
||||||
.maybeStack( 1 )
|
|
||||||
.orElseThrow( () -> new MissingDefinitionException( "Tried to access certus quartz crystal, even though they are disabled" ) )
|
|
||||||
.getItemDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int quantityDroppedWithBonus( final int fortune, final Random rand )
|
|
||||||
{
|
{
|
||||||
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( null, rand, fortune ) )
|
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( null, rand, fortune ) )
|
||||||
{
|
{
|
||||||
|
@ -146,18 +69,39 @@ public class BlockQuartzOre extends AEBaseBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBoostBrightnessLow( final int boostBrightnessLow )
|
@Override
|
||||||
|
public void dropBlockAsItemWithChance( final World w, final BlockPos pos, final IBlockState state, final float chance, final int fortune )
|
||||||
{
|
{
|
||||||
this.boostBrightnessLow = boostBrightnessLow;
|
super.dropBlockAsItemWithChance( w, pos, state, chance, fortune );
|
||||||
|
|
||||||
|
if( this.getItemDropped( state, w.rand, fortune ) != Item.getItemFromBlock( this ) )
|
||||||
|
{
|
||||||
|
final int xp = MathHelper.getInt( w.rand, 2, 5 );
|
||||||
|
|
||||||
|
this.dropXpOnBlockBreak( w, pos, xp );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBoostBrightnessHigh( final int boostBrightnessHigh )
|
@Override
|
||||||
|
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune )
|
||||||
{
|
{
|
||||||
this.boostBrightnessHigh = boostBrightnessHigh;
|
return AEApi.instance()
|
||||||
|
.definitions()
|
||||||
|
.materials()
|
||||||
|
.certusQuartzCrystal()
|
||||||
|
.maybeItem()
|
||||||
|
.orElseThrow( () -> new MissingDefinitionException( "Tried to access certus quartz crystal, even though they are disabled" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnhanceBrightness( final boolean enhanceBrightness )
|
@Override
|
||||||
|
public int damageDropped( final IBlockState state )
|
||||||
{
|
{
|
||||||
this.enhanceBrightness = enhanceBrightness;
|
return AEApi.instance()
|
||||||
|
.definitions()
|
||||||
|
.materials()
|
||||||
|
.certusQuartzCrystal()
|
||||||
|
.maybeStack( 1 )
|
||||||
|
.orElseThrow( () -> new MissingDefinitionException( "Tried to access certus quartz crystal, even though they are disabled" ) )
|
||||||
|
.getItemDamage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue