本文整理汇总了Java中net.minecraft.network.play.client.CPacketPlayerDigging类的典型用法代码示例。如果您正苦于以下问题:Java CPacketPlayerDigging类的具体用法?Java CPacketPlayerDigging怎么用?Java CPacketPlayerDigging使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CPacketPlayerDigging类属于net.minecraft.network.play.client包,在下文中一共展示了CPacketPlayerDigging类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dissectPacket
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public void dissectPacket(Object msg) {
if (!(msg instanceof CPacketPlayerDigging)) {
return;
}
CPacketPlayerDigging packet = (CPacketPlayerDigging) msg;
if (packet.getAction() != CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK) {
// even though the name may suggest otherwise, STOP_DESTROY_BLOCK means the player successfully broke the block
return;
}
// at this point we have confirmed that some kind of block was broken, so we check what kind. We can use forge
// events for just any kind of interaction in general, but not for block breaks specificially, so we pull the item
// the player used to mine and the block he mined from the interact event
if (OreLogger.instance.getListener().getCachedMaterial() == Material.ROCK
&& OreLogger.instance.getListener().getCachedVariant() == 0) {
// confirmed stone break
sbCounter.breakOccured(OreLogger.instance.getListener().getCachedBlockPos());
}
}
示例2: breakBlockPacketSpam
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public static void breakBlockPacketSpam(BlockPos pos)
{
Vec3d eyesPos = RotationUtils.getEyesPos();
Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
for(EnumFacing side : EnumFacing.values())
{
Vec3d hitVec =
posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
// check if side is facing towards player
if(eyesPos.squareDistanceTo(hitVec) >= distanceSqPosVec)
continue;
// break block
WConnection.sendPacket(new CPacketPlayerDigging(
Action.START_DESTROY_BLOCK, pos, side));
WConnection.sendPacket(
new CPacketPlayerDigging(Action.STOP_DESTROY_BLOCK, pos, side));
return;
}
}
示例3: onUpdate
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
@Override
public void onUpdate() {
if(mc.thePlayer.capabilities.isCreativeMode){
for(int x = -size; x < size + sizeOther; x++){
for(int z = -size; z < size + sizeOther; z++){
for(int y = -size; y < size + sizeOther; y++){
boolean shouldBreakBlock = true;
int blockX = (int) (mc.thePlayer.posX + x);
int blockY = (int) (mc.thePlayer.posY + y);
int blockZ = (int) (mc.thePlayer.posZ + z);
if (Block.getIdFromBlock(mc.theWorld.getBlockState(new BlockPos(blockX, blockY, blockZ)).getBlock()) != 0){
mc.thePlayer.sendQueue.addToSendQueue(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, new BlockPos(blockX, blockY, blockZ), EnumFacing.UP));
}
}
}
}
}
}
示例4: onUpdate
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
@Override
public void onUpdate() {
BlockPos var1 = mc.objectMouseOver.getBlockPos();
if (mc.theWorld.getBlockState(var1).getMaterial() == Material.air)
return;
if (mc.playerController.isHittingBlock)
if (ncp
&& mc.gameSettings.keyBindAttack.isKeyDown())
PacketUtils.sendPacket(new CPacketPlayerDigging(Action.STOP_DESTROY_BLOCK,
mc.objectMouseOver.getBlockPos(), EnumFacing.getHorizontal(-1)));
else {
PacketUtils.sendPacket(new CPacketPlayerDigging(Action.START_DESTROY_BLOCK,
mc.objectMouseOver.getBlockPos(), EnumFacing.getHorizontal(-1)));
PacketUtils.sendPacket(new CPacketPlayerDigging(Action.STOP_DESTROY_BLOCK,
mc.objectMouseOver.getBlockPos(), EnumFacing.getHorizontal(-1)));
}
}
示例5: breakBlocksPacketSpam
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public static void breakBlocksPacketSpam(Iterable<BlockPos> blocks)
{
Vec3d eyesPos = RotationUtils.getEyesPos();
for(BlockPos pos : blocks)
{
Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
for(EnumFacing side : EnumFacing.values())
{
Vec3d hitVec =
posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
// check if side is facing towards player
if(eyesPos.squareDistanceTo(hitVec) >= distanceSqPosVec)
continue;
// break block
WConnection.sendPacket(new CPacketPlayerDigging(
Action.START_DESTROY_BLOCK, pos, side));
WConnection.sendPacket(new CPacketPlayerDigging(
Action.STOP_DESTROY_BLOCK, pos, side));
break;
}
}
}
示例6: dropItem
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
@Nullable
/**
* Drop one item out of the currently selected stack if {@code dropAll} is false. If {@code dropItem} is true the
* entire stack is dropped.
*/
public EntityItem dropItem(boolean dropAll)
{
CPacketPlayerDigging.Action cpacketplayerdigging$action = dropAll ? CPacketPlayerDigging.Action.DROP_ALL_ITEMS : CPacketPlayerDigging.Action.DROP_ITEM;
this.connection.sendPacket(new CPacketPlayerDigging(cpacketplayerdigging$action, BlockPos.ORIGIN, EnumFacing.DOWN));
return null;
}
示例7: resetBlockRemoving
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
/**
* Resets current block damage and isHittingBlock
*/
public void resetBlockRemoving()
{
if (this.isHittingBlock)
{
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
//-ZMod-----------------------------------------------------------
ZHandle.handle("afterBlockDig");
//----------------------------------------------------------------
this.isHittingBlock = false;
this.curBlockDamageMP = 0.0F;
this.mc.world.sendBlockBreakProgress(this.mc.player.getEntityId(), this.currentBlock, -1);
this.mc.player.resetCooldown();
}
}
示例8: getAction
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public static CPacketPlayerDigging.Action getAction(IDigAction action) {
if (action.equals(IDigAction.START_DESTROY_BLOCK)) {
return CPacketPlayerDigging.Action.START_DESTROY_BLOCK;
} else if (action.equals(IDigAction.STOP_DESTROY_BLOCK)) {
return CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK;
}
return null;
}
示例9: resetBlockRemoving
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
/**
* Resets current block damage and isHittingBlock
*/
public void resetBlockRemoving()
{
if (this.isHittingBlock)
{
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
this.isHittingBlock = false;
this.curBlockDamageMP = 0.0F;
this.mc.world.sendBlockBreakProgress(this.mc.player.getEntityId(), this.currentBlock, -1);
this.mc.player.resetCooldown();
}
}
示例10: dropItem
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
/**
* Drop one item out of the currently selected stack if {@code dropAll} is false. If {@code dropItem} is true the
* entire stack is dropped.
*/
@Nullable
public EntityItem dropItem(boolean dropAll)
{
CPacketPlayerDigging.Action cpacketplayerdigging$action = dropAll ? CPacketPlayerDigging.Action.DROP_ALL_ITEMS : CPacketPlayerDigging.Action.DROP_ITEM;
this.connection.sendPacket(new CPacketPlayerDigging(cpacketplayerdigging$action, BlockPos.ORIGIN, EnumFacing.DOWN));
return null;
}
示例11: resetBlockRemoving
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
/**
* Resets current block damage and field_78778_j
*/
public void resetBlockRemoving()
{
if (this.isHittingBlock)
{
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
this.isHittingBlock = false;
this.curBlockDamageMP = 0.0F;
this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, -1);
this.mc.thePlayer.resetCooldown();
}
}
示例12: MessageSettlerDigging
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public MessageSettlerDigging(EntitySettler settler, CPacketPlayerDigging.Action action, EnumFacing face, BlockPos pos) {
this();
this.settler = settler;
this.action = action;
this.face = face;
this.pos = pos;
}
示例13: leftClickBlock
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public boolean leftClickBlock(BlockPos pos, EnumFacing side, Vec3d hit) {
if (!this.getSettler().getWorld().getWorldBorder().contains(pos)
|| SettlerCraft.instance.getMinecraftServer().isBlockProtected(this.getWorld(), pos, this.getFakePlayer())) {
return true;
} else {
if (!this.isHittingBlock || !this.isHittingPosition(pos)) {
if (this.isHittingBlock) {
new MessageSettlerDigging(this.getSettler(), CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, side, this.currentBlock).sendToAll();
}
new MessageSettlerDigging(this.getSettler(), CPacketPlayerDigging.Action.START_DESTROY_BLOCK, side, pos).sendToAll();
PlayerInteractEvent.LeftClickBlock event = ForgeHooks.onLeftClickBlock(this.getFakePlayer(), pos, side, hit);
IBlockState state = this.getWorld().getBlockState(pos);
boolean flag = state.getMaterial() != Material.AIR;
if (flag && this.curBlockDamageMP == 0.0F) {
if (event.getUseBlock() != Event.Result.DENY)
state.getBlock().onBlockClicked(this.getWorld(), pos, this.getFakePlayer());
}
if (event.getUseItem() == Event.Result.DENY) return true;
if (flag && state.getPlayerRelativeBlockHardness(this.getFakePlayer(), this.getWorld(), pos) >= 1.0F) {
this.onPlayerDestroyBlock();
} else {
this.isHittingBlock = true;
this.currentBlock = pos;
this.currentItemHittingBlock = this.getSettler().getHeldItemMainhand();
this.curBlockDamageMP = 0.0F;
//this.stepSoundTickCounter = 0.0F;
this.getWorld().sendBlockBreakProgress(this.getSettler().getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
}
}
return true;
}
}
示例14: onStoppedUsingItem
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public void onStoppedUsingItem(EntityPlayer playerIn)
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
playerIn.stopActiveHand();
}
示例15: swapHands
import net.minecraft.network.play.client.CPacketPlayerDigging; //导入依赖的package包/类
public static void swapHands() {
Minecraft.getMinecraft().player.connection.sendPacket(new CPacketPlayerDigging(
CPacketPlayerDigging.Action.SWAP_HELD_ITEMS, BlockPos.ORIGIN, EnumFacing.DOWN));
}