use of net.minecraft.network.packet.s2c.play.ExplosionS2CPacket in project BleachHack by BleachDrinker420.
the class NoVelocity method readPacket.
@BleachSubscribe
public void readPacket(EventPacket.Read event) {
if (mc.player == null)
return;
if (event.getPacket() instanceof EntityVelocityUpdateS2CPacket && getSetting(0).asToggle().getState()) {
EntityVelocityUpdateS2CPacket packet = (EntityVelocityUpdateS2CPacket) event.getPacket();
if (packet.getId() == mc.player.getId()) {
double velXZ = getSetting(0).asToggle().getChild(0).asSlider().getValue() / 100;
double velY = getSetting(0).asToggle().getChild(1).asSlider().getValue() / 100;
double pvelX = (packet.getVelocityX() / 8000d - mc.player.getVelocity().x) * velXZ;
double pvelY = (packet.getVelocityY() / 8000d - mc.player.getVelocity().y) * velY;
double pvelZ = (packet.getVelocityZ() / 8000d - mc.player.getVelocity().z) * velXZ;
packet.velocityX = (int) (pvelX * 8000 + mc.player.getVelocity().x * 8000);
packet.velocityY = (int) (pvelY * 8000 + mc.player.getVelocity().y * 8000);
packet.velocityZ = (int) (pvelZ * 8000 + mc.player.getVelocity().z * 8000);
}
} else if (event.getPacket() instanceof ExplosionS2CPacket && getSetting(1).asToggle().getState()) {
ExplosionS2CPacket packet = (ExplosionS2CPacket) event.getPacket();
double velXZ = getSetting(1).asToggle().getChild(0).asSlider().getValue() / 100;
double velY = getSetting(1).asToggle().getChild(1).asSlider().getValue() / 100;
packet.playerVelocityX = (float) (packet.getPlayerVelocityX() * velXZ);
packet.playerVelocityY = (float) (packet.getPlayerVelocityY() * velY);
packet.playerVelocityZ = (float) (packet.getPlayerVelocityZ() * velXZ);
}
}
use of net.minecraft.network.packet.s2c.play.ExplosionS2CPacket in project BleachHack by BleachDrinker420.
the class ChunkProcessor method onReadPacket.
@BleachSubscribe
public void onReadPacket(EventPacket.Read event) {
if (MinecraftClient.getInstance().world == null)
return;
if (updateBlockConsumer != null && event.getPacket() instanceof BlockUpdateS2CPacket) {
BlockUpdateS2CPacket packet = (BlockUpdateS2CPacket) event.getPacket();
executor.execute(() -> updateBlockConsumer.accept(packet.getPos(), packet.getState()));
} else if (updateBlockConsumer != null && event.getPacket() instanceof ExplosionS2CPacket) {
ExplosionS2CPacket packet = (ExplosionS2CPacket) event.getPacket();
for (BlockPos pos : packet.getAffectedBlocks()) {
executor.execute(() -> updateBlockConsumer.accept(pos, Blocks.AIR.getDefaultState()));
}
} else if (updateBlockConsumer != null && event.getPacket() instanceof ChunkDeltaUpdateS2CPacket) {
ChunkDeltaUpdateS2CPacket packet = (ChunkDeltaUpdateS2CPacket) event.getPacket();
packet.visitUpdates((pos, state) -> {
BlockPos impos = /*ter*/
pos.toImmutable();
executor.execute(() -> updateBlockConsumer.accept(impos, state));
});
} else if (loadChunkConsumer != null && event.getPacket() instanceof ChunkDataS2CPacket) {
ChunkDataS2CPacket packet = (ChunkDataS2CPacket) event.getPacket();
ChunkPos cp = new ChunkPos(packet.getX(), packet.getZ());
WorldChunk chunk = new WorldChunk(MinecraftClient.getInstance().world, cp, null);
chunk.loadFromPacket(null, packet.getReadBuffer(), new NbtCompound(), packet.getVerticalStripBitmask());
executor.execute(() -> loadChunkConsumer.accept(cp, chunk));
} else if (unloadChunkConsumer != null && event.getPacket() instanceof UnloadChunkS2CPacket) {
UnloadChunkS2CPacket packet = (UnloadChunkS2CPacket) event.getPacket();
ChunkPos cp = new ChunkPos(packet.getX(), packet.getZ());
WorldChunk chunk = MinecraftClient.getInstance().world.getChunk(cp.x, cp.z);
executor.execute(() -> unloadChunkConsumer.accept(cp, chunk));
}
}
use of net.minecraft.network.packet.s2c.play.ExplosionS2CPacket in project Hypnotic-Client by Hypnotic-Development.
the class Velocity method onReceivePacket.
@EventTarget
public void onReceivePacket(EventReceivePacket event) {
if (mc.world == null || mc.player == null)
return;
this.setDisplayName("Velocity " + ColorUtils.gray + "H:" + horizontal.getValue() + " V:" + vertical.getValue());
if (event.getPacket() instanceof EntityVelocityUpdateS2CPacket) {
EntityVelocityUpdateS2CPacket velocity = (EntityVelocityUpdateS2CPacket) event.getPacket();
if (velocity.getId() == mc.player.getId() && !mc.player.isTouchingWater()) {
ReflectionHelper.setPrivateValue(EntityVelocityUpdateS2CPacket.class, velocity, (int) (velocity.getVelocityX() * (horizontal.getValue() * 0.01)), "velocityX", "field_12561");
ReflectionHelper.setPrivateValue(EntityVelocityUpdateS2CPacket.class, velocity, (int) (velocity.getVelocityY() * (vertical.getValue() * 0.01)), "velocityY", "field_12562");
ReflectionHelper.setPrivateValue(EntityVelocityUpdateS2CPacket.class, velocity, (int) (velocity.getVelocityZ() * (horizontal.getValue() * 0.01)), "velocityZ", "field_12563");
}
} else if (event.getPacket() instanceof ExplosionS2CPacket) {
ExplosionS2CPacket velocity = (ExplosionS2CPacket) event.getPacket();
ReflectionHelper.setPrivateValue(ExplosionS2CPacket.class, velocity, (int) (velocity.getPlayerVelocityX() * (horizontal.getValue() * 0.01)), "playerVelocityX", "field_12176");
ReflectionHelper.setPrivateValue(ExplosionS2CPacket.class, velocity, (int) (velocity.getPlayerVelocityY() * (vertical.getValue() * 0.01)), "playerVelocityY", "field_12183");
ReflectionHelper.setPrivateValue(ExplosionS2CPacket.class, velocity, (int) (velocity.getPlayerVelocityZ() * (horizontal.getValue() * 0.01)), "playerVelocityZ", "field_12182");
}
}
use of net.minecraft.network.packet.s2c.play.ExplosionS2CPacket in project Hypnotic-Client by Hypnotic-Development.
the class Search method receivePacket.
@EventTarget
public void receivePacket(EventReceivePacket event) {
if (event.getPacket() instanceof DisconnectS2CPacket || event.getPacket() instanceof GameJoinS2CPacket || event.getPacket() instanceof PlayerRespawnS2CPacket) {
reset();
} else if (event.getPacket() instanceof BlockUpdateS2CPacket) {
BlockUpdateS2CPacket packet = (BlockUpdateS2CPacket) event.getPacket();
queuedBlocks.add(Pair.of(packet.getPos(), packet.getState()));
} else if (event.getPacket() instanceof ExplosionS2CPacket) {
ExplosionS2CPacket packet = (ExplosionS2CPacket) event.getPacket();
for (BlockPos pos : packet.getAffectedBlocks()) {
queuedBlocks.add(Pair.of(pos, Blocks.AIR.getDefaultState()));
}
} else if (event.getPacket() instanceof ChunkDeltaUpdateS2CPacket) {
ChunkDeltaUpdateS2CPacket packet = (ChunkDeltaUpdateS2CPacket) event.getPacket();
packet.visitUpdates((pos, state) -> queuedBlocks.add(Pair.of(pos.toImmutable(), state)));
} else if (event.getPacket() instanceof ChunkDataS2CPacket) {
ChunkDataS2CPacket packet = (ChunkDataS2CPacket) event.getPacket();
ChunkPos cp = new ChunkPos(packet.getX(), packet.getZ());
queuedChunks.add(cp);
queuedUnloads.remove(cp);
} else if (event.getPacket() instanceof UnloadChunkS2CPacket) {
UnloadChunkS2CPacket packet = (UnloadChunkS2CPacket) event.getPacket();
queuedUnloads.add(new ChunkPos(packet.getX(), packet.getZ()));
}
}
Aggregations