Fix to-do
This commit is contained in:
parent
02473d4585
commit
3010afa351
1 changed files with 21 additions and 21 deletions
|
@ -33,8 +33,8 @@ import net.minecraft.block.state.BlockStateContainer;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
|
@ -46,14 +46,14 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import reborncore.api.IToolHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.items.tools.ItemWrench;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.tiles.cable.TileCable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 19/05/2017.
|
||||
|
@ -88,24 +88,24 @@ public class BlockCable extends BlockContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
if(stack.getItem() instanceof ItemWrench && !world.isRemote){ //TODO use new api
|
||||
ItemStack itemStack = new ItemStack(this, 1, getMetaFromState(state));
|
||||
Random rand = new Random();
|
||||
|
||||
float dX = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float dY = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float dZ = rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ,
|
||||
itemStack.copy());
|
||||
|
||||
float factor = 0.05F;
|
||||
entityItem.motionX = rand.nextGaussian() * factor;
|
||||
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
|
||||
entityItem.motionZ = rand.nextGaussian() * factor;
|
||||
world.spawnEntity(entityItem);
|
||||
world.setBlockToAir(pos);
|
||||
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof IToolHandler && playerIn.isSneaking()) {
|
||||
IToolHandler toolHandler = (IToolHandler) stack.getItem();
|
||||
if (toolHandler.handleTool(stack, pos, world, playerIn, facing, false)) {
|
||||
ItemStack drop = state.getValue(TYPE).getStack();
|
||||
if (drop == null) {
|
||||
return false;
|
||||
}
|
||||
if (!drop.isEmpty()) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
world.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, ModSounds.BLOCK_DISMANTLE,
|
||||
SoundCategory.BLOCKS, 0.6F, 1F);
|
||||
if (!world.isRemote) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onBlockActivated(world, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue