Break blocks on clientside. Eliminates server latency.

This commit is contained in:
Bernhard Bonigl committed 2014-08-23 22:04:07 +02:00
1 parent 72e6bce2bf
commit 699b0f5796
2 files changed
+33 -32

No files matched your search

@@ -4,8 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
@@ -14,6 +17,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetHandler;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.stats.StatList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
@@ -220,24 +225,20 @@ public class Scythe extends Weapon
}
else
{
if (!world.isRemote)
{
// Workaround for dropping experience
int exp = localBlock.getExpDrop(world, localMeta, fortune);
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos, true))
{
localBlock.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
localBlock.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
// Workaround for dropping experience
if (!butter)
localBlock.dropXpOnBlockBreak(world, xPos, yPos, zPos, exp);
}
}
else
// Workaround for dropping experience
int exp = localBlock.getExpDrop(world, localMeta, fortune);
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos, true))
{
localBlock.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
localBlock.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
// Workaround for dropping experience
if (!butter)
localBlock.dropXpOnBlockBreak(world, xPos, yPos, zPos, exp);
}
}
if (localHardness > 0f)