Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make chisel ice consistent with vanilla ice
- Loading branch information
1 parent
4f68b28
commit 83bb7fd
Showing
2 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/main/java/team/chisel/common/block/BlockCarvableIce.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package team.chisel.common.block; | ||
|
||
import java.util.Random; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.EnumPushReaction; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.init.Enchantments; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.stats.StatList; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.EnumSkyBlock; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import team.chisel.api.block.VariationData; | ||
|
||
@ParametersAreNonnullByDefault | ||
public class BlockCarvableIce extends BlockCarvable { | ||
|
||
public BlockCarvableIce(Material material, int index, int max, VariationData[] variations) { | ||
super(material, index, max, variations); | ||
this.slipperiness = 0.98F; | ||
this.setTickRandomly(true); | ||
} | ||
|
||
// From BlockIce - Do Not Edit | ||
|
||
@Override | ||
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) { | ||
player.addStat(StatList.getBlockStats(this)); | ||
player.addExhaustion(0.005F); | ||
|
||
if (this.canSilkHarvest(worldIn, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0) { | ||
java.util.List<ItemStack> items = new java.util.ArrayList<ItemStack>(); | ||
items.add(this.getSilkTouchDrop(state)); | ||
|
||
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player); | ||
for (ItemStack is : items) | ||
spawnAsEntity(worldIn, pos, is); | ||
} else { | ||
if (worldIn.provider.doesWaterVaporize()) { | ||
worldIn.setBlockToAir(pos); | ||
return; | ||
} | ||
|
||
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack); | ||
harvesters.set(player); | ||
this.dropBlockAsItem(worldIn, pos, state, i); | ||
harvesters.set(null); | ||
Material material = worldIn.getBlockState(pos.down()).getMaterial(); | ||
|
||
if (material.blocksMovement() || material.isLiquid()) { | ||
worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public int quantityDropped(Random random) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { | ||
if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11 - this.getDefaultState().getLightOpacity()) { | ||
this.turnIntoWater(worldIn, pos); | ||
} | ||
} | ||
|
||
protected void turnIntoWater(World worldIn, BlockPos pos) { | ||
if (worldIn.provider.doesWaterVaporize()) { | ||
worldIn.setBlockToAir(pos); | ||
} else { | ||
this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); | ||
worldIn.setBlockState(pos, Blocks.WATER.getDefaultState()); | ||
worldIn.neighborChanged(pos, Blocks.WATER, pos); | ||
} | ||
} | ||
|
||
@Override | ||
public EnumPushReaction getMobilityFlag(IBlockState state) { | ||
return EnumPushReaction.NORMAL; | ||
} | ||
|
||
// From BlockBreakable - Do Not Edit | ||
|
||
@Override | ||
public boolean isOpaqueCube(IBlockState state) { | ||
return false; | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
@Override | ||
@Deprecated | ||
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { | ||
IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side)); | ||
Block block = iblockstate.getBlock(); | ||
return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); | ||
} | ||
} |