use of net.minecraft.client.network.ClientPlayerEntity in project BedrockIfy by juancarloscp52.
the class ReachAroundPlacement method checkReachAroundAndExecute.
public void checkReachAroundAndExecute(Hand hand, ItemStack itemStack) {
ClientPlayerEntity player = client.player;
if (player == null || client.interactionManager == null)
return;
int count = itemStack.getCount();
Vector3f facing = player.getHorizontalFacing().getUnitVector();
if (canReachAround()) {
BlockHitResult blockHitResult;
if (isNonFullBlock()) {
blockHitResult = new BlockHitResult(player.getPos().add(facing.getX(), facing.getY() - 1, facing.getZ()), Direction.fromVector((int) -facing.getX(), 0, (int) -facing.getZ()), player.getBlockPos().offset(player.getHorizontalFacing()), false);
} else {
blockHitResult = new BlockHitResult(player.getPos().add(facing.getX(), facing.getY(), facing.getZ()), Direction.fromVector((int) -facing.getX(), 0, (int) -facing.getZ()), player.getBlockPos().down().offset(player.getHorizontalFacing()), false);
}
ActionResult result = client.interactionManager.interactBlock(player, client.world, hand, blockHitResult);
if (result.isAccepted()) {
if (result.shouldSwingHand()) {
player.swingHand(hand);
if (!itemStack.isEmpty() && (itemStack.getCount() != count || client.interactionManager.hasCreativeInventory())) {
client.gameRenderer.firstPersonRenderer.resetEquipProgress(hand);
}
}
}
}
}
use of net.minecraft.client.network.ClientPlayerEntity in project ImmersivePortalsMod by qouteall.
the class MyCommandClient method listNearbyPortals.
private static int listNearbyPortals(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity playerServer = context.getSource().getPlayer();
ClientPlayerEntity playerClient = MinecraftClient.getInstance().player;
McHelper.serverLog(playerServer, "Server Portals");
McHelper.serverLog(playerServer, Helper.myToString(McHelper.getEntitiesNearby(playerServer, Portal.class, 64)));
McHelper.serverLog(playerServer, "Client Portals");
McHelper.serverLog(playerServer, Helper.myToString(McHelper.getEntitiesNearby(playerClient, Portal.class, 64)));
return 0;
}
use of net.minecraft.client.network.ClientPlayerEntity in project ImmersivePortalsMod by qouteall.
the class ClientTeleportationManager method teleportPlayer.
private void teleportPlayer(Portal portal) {
if (isTeleportingFrequently()) {
Helper.err("The Player is Teleporting Frequently");
}
lastTeleportGameTime = tickTimeForTeleportation;
ClientPlayerEntity player = mc.player;
DimensionType toDimension = portal.dimensionTo;
if (mc.player.hasPassengers() || mc.player.hasVehicle()) {
return;
}
Vec3d oldPos = player.getPos();
Vec3d newPos = portal.applyTransformationToPoint(oldPos);
Vec3d newLastTickPos = portal.applyTransformationToPoint(McHelper.lastTickPosOf(player));
ClientWorld fromWorld = mc.world;
DimensionType fromDimension = fromWorld.dimension.getType();
if (fromDimension != toDimension) {
ClientWorld toWorld = CGlobal.clientWorldLoader.getOrCreateFakedWorld(toDimension);
changePlayerDimension(player, fromWorld, toWorld, newPos);
}
player.setPosition(newPos.x, newPos.y, newPos.z);
Helper.setPosAndLastTickPos(player, newPos, newLastTickPos);
player.networkHandler.sendPacket(MyNetworkClient.createCtsTeleport(fromDimension, oldPos, portal.getUuid()));
amendChunkEntityStatus(player);
// slowDownIfTooFast(player, 0.5);
}
use of net.minecraft.client.network.ClientPlayerEntity in project Hypnotic-Client by Hypnotic-Development.
the class HeldItemRendererMixin method updateHeldItems1.
@Inject(method = "updateHeldItems", at = @At("HEAD"), cancellable = true)
public void updateHeldItems1(CallbackInfo ci) {
EventVisualCooldown event = new EventVisualCooldown();
event.call();
if (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled())
event.setCancelled(true);
if (event.isCancelled()) {
ci.cancel();
this.prevEquipProgressMainHand = this.equipProgressMainHand;
this.prevEquipProgressOffHand = this.equipProgressOffHand;
ClientPlayerEntity clientPlayerEntity = this.client.player;
ItemStack itemStack = clientPlayerEntity.getMainHandStack();
ItemStack itemStack2 = clientPlayerEntity.getOffHandStack();
if (ItemStack.areEqual(this.mainHand, itemStack)) {
this.mainHand = itemStack;
}
if (ItemStack.areEqual(this.offHand, itemStack2)) {
this.offHand = itemStack2;
}
if (clientPlayerEntity.isRiding()) {
this.equipProgressMainHand = MathHelper.clamp(this.equipProgressMainHand - 0.4F, 0.0F, 1.0F);
this.equipProgressOffHand = MathHelper.clamp(this.equipProgressOffHand - 0.4F, 0.0F, 1.0F);
} else {
// \/ This part here is what changed, it used to calculate with attack progress
this.equipProgressMainHand += MathHelper.clamp((this.mainHand == itemStack ? 1 : 0.0F) - this.equipProgressMainHand, -0.4F, 0.4F);
this.equipProgressOffHand += MathHelper.clamp((float) (this.offHand == itemStack2 ? 1 : 0) - this.equipProgressOffHand, -0.4F, 0.4F);
}
if (this.equipProgressMainHand < 0.1F) {
this.mainHand = itemStack;
}
if (this.equipProgressOffHand < 0.1F) {
this.offHand = itemStack2;
}
}
}
use of net.minecraft.client.network.ClientPlayerEntity in project JexClient by DustinRepo.
the class MixinHeldItemRenderer method updateHeldItems1.
@Inject(method = "updateHeldItems", at = @At("HEAD"), cancellable = true)
public void updateHeldItems1(CallbackInfo ci) {
if (((EventVisualCooldown) new EventVisualCooldown().run()).isCancelled()) {
ci.cancel();
this.prevEquipProgressMainHand = this.equipProgressMainHand;
this.prevEquipProgressOffHand = this.equipProgressOffHand;
ClientPlayerEntity clientPlayerEntity = this.client.player;
ItemStack itemStack = clientPlayerEntity.getMainHandStack();
ItemStack itemStack2 = clientPlayerEntity.getOffHandStack();
if (ItemStack.areEqual(this.mainHand, itemStack)) {
this.mainHand = itemStack;
}
if (ItemStack.areEqual(this.offHand, itemStack2)) {
this.offHand = itemStack2;
}
if (clientPlayerEntity.isRiding()) {
this.equipProgressMainHand = MathHelper.clamp(this.equipProgressMainHand - 0.4F, 0.0F, 1.0F);
this.equipProgressOffHand = MathHelper.clamp(this.equipProgressOffHand - 0.4F, 0.0F, 1.0F);
} else {
// \/ This part here is what changed, it used to calculate with attack progress
this.equipProgressMainHand += MathHelper.clamp((this.mainHand == itemStack ? 1 : 0.0F) - this.equipProgressMainHand, -0.4F, 0.4F);
this.equipProgressOffHand += MathHelper.clamp((float) (this.offHand == itemStack2 ? 1 : 0) - this.equipProgressOffHand, -0.4F, 0.4F);
}
if (this.equipProgressMainHand < 0.1F) {
this.mainHand = itemStack;
}
if (this.equipProgressOffHand < 0.1F) {
this.offHand = itemStack2;
}
}
}
Aggregations