mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Revamped the Drill to use the correct Method, made it fully work on Client and Server now
This commit is contained in:
parent
1b36e7c19a
commit
2d5ac591d8
2 changed files with 64 additions and 63 deletions
|
@ -193,14 +193,14 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
return slots;
|
||||
}
|
||||
|
||||
public void breakBlocks(ItemStack stack, int radius, World world, int x, int y, int z, EntityPlayer player){
|
||||
public boolean breakBlocks(ItemStack stack, int radius, World world, int x, int y, int z, EntityPlayer player){
|
||||
int xRange = radius;
|
||||
int yRange = radius;
|
||||
int zRange = 0;
|
||||
|
||||
MovingObjectPosition pos = WorldUtil.getNearestBlockWithDefaultReachDistance(world, player);
|
||||
if(pos == null) return false;
|
||||
|
||||
if(pos != null){
|
||||
int side = pos.sideHit;
|
||||
if(side == 0 || side == 1){
|
||||
zRange = radius;
|
||||
|
@ -216,7 +216,7 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
if(this.getEnergyStored(stack) >= use){
|
||||
this.tryHarvestBlock(world, x, y, z, false, stack, player, use);
|
||||
}
|
||||
else return;
|
||||
else return true;
|
||||
|
||||
//Break Blocks around
|
||||
if(radius > 0){
|
||||
|
@ -227,13 +227,13 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
if(this.getEnergyStored(stack) >= use){
|
||||
this.tryHarvestBlock(world, xPos, yPos, zPos, true, stack, player, use);
|
||||
}
|
||||
else return;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void tryHarvestBlock(World world, int xPos, int yPos, int zPos, boolean isExtra, ItemStack stack, EntityPlayer player, int use){
|
||||
|
@ -241,6 +241,7 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
float hardness = block.getBlockHardness(world, xPos, yPos, zPos);
|
||||
int meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
if(hardness >= 0.0F && (!isExtra || (this.canHarvestBlock(block, stack) && !block.hasTileEntity(meta)))){
|
||||
if(!world.isRemote){
|
||||
this.extractEnergy(stack, use, false);
|
||||
|
||||
block.onBlockHarvested(world, xPos, yPos, zPos, meta, player);
|
||||
|
@ -251,9 +252,13 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
if(!EnchantmentHelper.getSilkTouchModifier(player)){
|
||||
block.dropXpOnBlockBreak(world, xPos, yPos, zPos, block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player)));
|
||||
}
|
||||
|
||||
if(isExtra){
|
||||
}
|
||||
}
|
||||
else{
|
||||
world.playAuxSFX(2001, xPos, yPos, zPos, Block.getIdFromBlock(block)+(meta << 12));
|
||||
|
||||
if(block.removedByPlayer(world, player, xPos, yPos, zPos, true)){
|
||||
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -265,24 +270,22 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living){
|
||||
if(living instanceof EntityPlayer){
|
||||
EntityPlayer player = (EntityPlayer)living;
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player){
|
||||
boolean toReturn = true;
|
||||
int use = this.getEnergyUsePerBlock(stack);
|
||||
if(this.getEnergyStored(stack) >= use){
|
||||
if(!world.isRemote){
|
||||
if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) stack.addEnchantment(Enchantment.silkTouch, 1);
|
||||
else{
|
||||
if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) stack.addEnchantment(Enchantment.fortune, this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II) ? 3 : 1);
|
||||
}
|
||||
|
||||
if(!living.isSneaking() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){
|
||||
if(!player.isSneaking() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){
|
||||
if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){
|
||||
this.breakBlocks(stack, 2, world, x, y, z, player);
|
||||
toReturn = this.breakBlocks(stack, 2, player.worldObj, x, y, z, player);
|
||||
}
|
||||
else this.breakBlocks(stack, 1, world, x, y, z, player);
|
||||
else toReturn = this.breakBlocks(stack, 1, player.worldObj, x, y, z, player);
|
||||
}
|
||||
else this.breakBlocks(stack, 0, world, x, y, z, player);
|
||||
else toReturn = this.breakBlocks(stack, 0, player.worldObj, x, y, z, player);
|
||||
|
||||
NBTTagList ench = stack.getEnchantmentTagList();
|
||||
if(ench != null){
|
||||
|
@ -294,9 +297,7 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -227,7 +227,7 @@ public class WorldUtil{
|
|||
float f1 = player.prevRotationPitch+(player.rotationPitch-player.prevRotationPitch)*f;
|
||||
float f2 = player.prevRotationYaw+(player.rotationYaw-player.prevRotationYaw)*f;
|
||||
double d0 = player.prevPosX+(player.posX-player.prevPosX)*(double)f;
|
||||
double d1 = player.prevPosY+(player.posY-player.prevPosY)*(double)f+(double)player.getEyeHeight();
|
||||
double d1 = player.prevPosY+(player.posY-player.prevPosY)*(double)f+(double)(world.isRemote ? player.getEyeHeight()-player.getDefaultEyeHeight() : player.getEyeHeight());
|
||||
double d2 = player.prevPosZ+(player.posZ-player.prevPosZ)*(double)f;
|
||||
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
|
||||
float f3 = MathHelper.cos(-f2*0.017453292F-(float)Math.PI);
|
||||
|
|
Loading…
Reference in a new issue