Java Code Examples for net.minecraft.network.play.client.CPacketPlayer#getY()

The following examples show how to use net.minecraft.network.play.client.CPacketPlayer#getY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlinkHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onPacketOutput(WPacketOutputEvent event)
{
	if(!(event.getPacket() instanceof CPacketPlayer))
		return;
	
	event.setCanceled(true);
	
	CPacketPlayer packet = (CPacketPlayer)event.getPacket();
	CPacketPlayer prevPacket = packets.peekLast();
	
	if(prevPacket != null && packet.isOnGround() == prevPacket.isOnGround()
		&& packet.getYaw(-1) == prevPacket.getYaw(-1)
		&& packet.getPitch(-1) == prevPacket.getPitch(-1)
		&& packet.getX(-1) == prevPacket.getX(-1)
		&& packet.getY(-1) == prevPacket.getY(-1)
		&& packet.getZ(-1) == prevPacket.getZ(-1))
		return;
	
	packets.addLast(packet);
}
 
Example 2
Source File: StepMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onPacketSending(PacketEvent.Outgoing.Pre event) {
  if (event.getPacket() instanceof CPacketPlayer.Position
      || event.getPacket() instanceof CPacketPlayer.PositionRotation) {
    CPacketPlayer packetPlayer = event.getPacket();
    if (previousPositionPacket != null && !PacketHelper.isIgnored(event.getPacket())) {
      double diffY = packetPlayer.getY(0.f) - previousPositionPacket.getY(0.f);
      // y difference must be positive
      // greater than 1, but less than 1.5
      if (diffY > DEFAULT_STEP_HEIGHT && diffY <= 1.2491870787) {
        List<Packet> sendList = Lists.newArrayList();
        // if this is true, this must be a step
        // now to send additional packets to get around NCP
        double x = previousPositionPacket.getX(0.D);
        double y = previousPositionPacket.getY(0.D);
        double z = previousPositionPacket.getZ(0.D);
        sendList.add(new CPacketPlayer.Position(x, y + 0.4199999869D, z, true));
        sendList.add(new CPacketPlayer.Position(x, y + 0.7531999805D, z, true));
        sendList.add(
            new CPacketPlayer.Position(
                packetPlayer.getX(0.f),
                packetPlayer.getY(0.f),
                packetPlayer.getZ(0.f),
                packetPlayer.isOnGround()));
        for (Packet toSend : sendList) {
          PacketHelper.ignore(toSend);
          getNetworkManager().sendPacket(toSend);
        }
        event.setCanceled(true);
      }
    }
    previousPositionPacket = event.getPacket();
  }
}
 
Example 3
Source File: JesusHack.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onPacketOutput(WPacketOutputEvent event)
{
	// check packet type
	if(!(event.getPacket() instanceof CPacketPlayer))
		return;
	
	EntityPlayerSP player = WMinecraft.getPlayer();
	CPacketPlayer packet = (CPacketPlayer)event.getPacket();
	
	// check if packet contains a position
	if(!(packet instanceof CPacketPlayer.Position
		|| packet instanceof CPacketPlayer.PositionRotation))
		return;
	
	if(!isStandingOnLiquid(player))
		return;
	
	// if not actually moving, cancel packet
	if(player.movementInput == null)
	{
		event.setCanceled(true);
		return;
	}
	
	// get position
	double x = packet.getX(0);
	double y = packet.getY(0);
	double z = packet.getZ(0);
	
	// offset y
	if(player.ticksExisted % 2 == 0)
		y -= 0.05;
	else
		y += 0.05;
	
	// create new packet
	Packet<?> newPacket;
	if(packet instanceof CPacketPlayer.Position)
		newPacket = new CPacketPlayer.Position(x, y, z, true);
	else
		newPacket = new CPacketPlayer.PositionRotation(x, y, z,
			packet.getYaw(0), packet.getPitch(0), true);
	
	// send new packet
	event.setPacket(newPacket);
}