Advanced diamond drill is now 3x3

This commit is contained in:
modmuss50 2017-05-27 01:49:07 +01:00
parent 672b3ac6f1
commit 3a6724b6f4
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82

View file

@ -24,18 +24,30 @@
package techreborn.items.tools;
import net.minecraft.block.Block;
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.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.common.powerSystem.PoweredItem;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModItems;
import java.util.ArrayList;
import java.util.List;
public class ItemAdvancedDrill extends ItemDrill {
public ItemAdvancedDrill() {
@ -62,4 +74,67 @@ public class ItemAdvancedDrill extends ItemDrill {
return Items.DIAMOND_PICKAXE.canHarvestBlock(blockIn) || Items.DIAMOND_SHOVEL.canHarvestBlock(blockIn);
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) {
//TODO raytrace
EnumFacing enumfacing = entityLiving.getHorizontalFacing().getOpposite();
if (entityLiving.rotationPitch < -50) {
enumfacing = EnumFacing.DOWN;
} else if (entityLiving.rotationPitch > 50) {
enumfacing = EnumFacing.UP;
}
if (enumfacing == EnumFacing.SOUTH || enumfacing == EnumFacing.NORTH) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
breakBlock(pos.add(i, j, 0), stack, worldIn, entityLiving, pos);
}
}
} else if (enumfacing == EnumFacing.EAST || enumfacing == EnumFacing.WEST) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
breakBlock(pos.add(0, j, i), stack, worldIn, entityLiving, pos);
}
}
} else if (enumfacing == EnumFacing.DOWN || enumfacing == EnumFacing.UP) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
breakBlock(pos.add(j, 0, i), stack, worldIn, entityLiving, pos);
}
}
}
return super.onBlockDestroyed(stack, worldIn, blockIn, pos, entityLiving);
}
public void breakBlock(BlockPos pos, ItemStack stack, World world, EntityLivingBase entityLiving, BlockPos oldPos) {
if (oldPos == pos) {
return;
}
if (!PoweredItem.canUseEnergy(cost, stack)) {
return;
}
IBlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
List<ItemStack> stuff = block.getDrops(world, pos, blockState, 0);
List<ItemStack> dropList = new ArrayList<>();
BlockEvent.HarvestDropsEvent event = new BlockEvent.HarvestDropsEvent(world, pos, blockState, 0, 1, dropList, (EntityPlayer) entityLiving, false);
MinecraftForge.EVENT_BUS.post(event);
for (ItemStack drop : dropList) {
if (!drop.isEmpty() && drop.getCount() > 0) {
stuff.add(drop);
}
}
for (ItemStack drop : stuff) {
if (world.isRemote) {
continue;
}
final EntityItem entityitem = new EntityItem(world, oldPos.getX(), oldPos.getY(), oldPos.getZ(), drop);
entityitem.motionX = (oldPos.getX() - oldPos.getX()) / 10.0f;
entityitem.motionY = 0.15000000596046448;
entityitem.motionZ = (oldPos.getZ() - oldPos.getZ()) / 10.0f;
world.spawnEntity(entityitem);
}
PoweredItem.useEnergy(cost, stack);
world.setBlockToAir(pos);
}
}