Fix weight lens spawning falling blocks too high, and spawn some fancy particles

This commit is contained in:
Vincent Lee committed 2017-02-28 16:22:06 -06:00
1 parent ba69be2f31
commit 7a58166275
1 file changed
+11 -5
@@ -14,13 +14,17 @@ import java.util.Map;
import com.google.common.collect.ImmutableMap;
import mezz.jei.util.FakeClientWorld;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.WorldServer;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.common.core.handler.ConfigHandler;
@@ -36,15 +40,17 @@ public class LensWeight extends Lens {
if(!entity.world.isRemote && !burst.isFake() && pos.getBlockPos() != null) {
int harvestLevel = ConfigHandler.harvestLevelWeight;
Block block = entity.world.getBlockState(pos.getBlockPos()).getBlock();
IBlockState state = entity.world.getBlockState(pos.getBlockPos());
BlockPos bPos = pos.getBlockPos();
Block block = entity.world.getBlockState(bPos).getBlock();
IBlockState state = entity.world.getBlockState(bPos);
int neededHarvestLevel = block.getHarvestLevel(state);
if(entity.world.isAirBlock(pos.getBlockPos().down()) && state.getBlockHardness(entity.world, pos.getBlockPos()) != -1 && neededHarvestLevel <= harvestLevel && entity.world.getTileEntity(pos.getBlockPos()) == null && block.canSilkHarvest(entity.world, pos.getBlockPos(), state, null)) {
if(entity.world.isAirBlock(bPos.down()) && state.getBlockHardness(entity.world, bPos) != -1 && neededHarvestLevel <= harvestLevel && entity.world.getTileEntity(bPos) == null && block.canSilkHarvest(entity.world, bPos, state, null)) {
state = TECHNICAL_BLOCK_REMAP.getOrDefault(state, state);
EntityFallingBlock falling = new EntityFallingBlock(entity.world, pos.getBlockPos().getX() + 0.5, pos.getBlockPos().getY() + 0.5, pos.getBlockPos().getZ() + 0.5, state);
EntityFallingBlock falling = new EntityFallingBlock(entity.world, bPos.getX() + 0.5, bPos.getY(), bPos.getZ() + 0.5, state);
falling.fallTime = 1;
entity.world.setBlockToAir(pos.getBlockPos());
entity.world.setBlockToAir(bPos);
((WorldServer) entity.world).spawnParticle(EnumParticleTypes.FALLING_DUST, bPos.getX() + 0.5, bPos.getY() + 0.5, bPos.getZ() + 0.5, 10, 0.45, 0.45, 0.45, 5, new int[] {Block.getStateId(state)});
entity.world.spawnEntity(falling);
}
}