Skip to content

Commit

Permalink
Make chisel ice consistent with vanilla ice
Browse files Browse the repository at this point in the history
  • Loading branch information
tterrag1098 committed Jul 28, 2019
1 parent 4f68b28 commit 83bb7fd
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/team/chisel/Features.java
Expand Up @@ -63,6 +63,7 @@
import team.chisel.common.block.BlockCarvable;
import team.chisel.common.block.BlockCarvableCarpet;
import team.chisel.common.block.BlockCarvableFalling;
import team.chisel.common.block.BlockCarvableIce;
import team.chisel.common.block.BlockCarvablePane;
import team.chisel.common.block.ItemChiselBlock;
import team.chisel.common.block.TileAutoChisel;
Expand Down Expand Up @@ -1747,9 +1748,7 @@ void addBlocks(ChiselBlockFactory factory) {
void addBlocks(ChiselBlockFactory factory) {
Carving.chisel.addVariation("ice", CarvingUtils.variationFor(Blocks.ICE.getDefaultState(), -1));

BlockCreator<BlockCarvable> iceCreator = (mat, index, maxVariation, data) -> new BlockCarvable(mat, index, maxVariation, data) { {
this.slipperiness = 0.98F;
} };
BlockCreator<BlockCarvable> iceCreator = BlockCarvableIce::new;

factory.newBlock(Material.ICE, "ice", new ChiselBlockProvider<>(iceCreator, BlockCarvable.class)).opaque(false)
.newVariation("cracked")
Expand Down Expand Up @@ -1787,7 +1786,7 @@ void addBlocks(ChiselBlockFactory factory) {
.next("cuts")
.addOreDict("ice")
.addOreDict("blockIce")
.build(b -> b.setHardness(0.5F).setLightOpacity(3).setSoundType(SoundType.GLASS));
.build(b -> b.setHardness(0.5F).setLightOpacity(3).setSoundType(SoundType.GLASS).setHarvestLevel("pickaxe", 0));

factory.newBlock(Material.ICE, "icepillar", new ChiselBlockProvider<>(iceCreator, BlockCarvable.class)).opaque(false)
.setGroup("ice")
Expand Down
111 changes: 111 additions & 0 deletions src/main/java/team/chisel/common/block/BlockCarvableIce.java
@@ -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);
}
}

0 comments on commit 83bb7fd

Please sign in to comment.